Skip to content

Commit 4f9b827

Browse files
authored
Merge branch 'main' into patch-1
2 parents 0060a38 + 7078630 commit 4f9b827

14 files changed

Lines changed: 79 additions & 33 deletions

.github/workflows/lighthouse.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5252

5353
- name: Run Lighthouse CI
54-
run: npx lhci autorun
54+
run: npx @lhci/cli@0.7.x autorun
5555
env:
5656
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757
LHCI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docs/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
addressable (2.7.0)
4+
addressable (2.8.0)
55
public_suffix (>= 2.0.2, < 5.0)
66
colorator (1.1.0)
77
commonmarker (0.17.13)

docs/_guide/actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ data-action: Fires all of these methods depending on the event
9494
data-action="
9595
click:hello-world#greetSomeone
9696
click:analytics-tracking#click
97-
hover:analytics-tracking#hover
97+
mouseover:analytics-tracking#hover
9898
"
9999
>
100100
Greet Someone

docs/_guide/anti-patterns.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,18 @@ class UserFilter {
305305
```
306306

307307
```html
308-
<user-list>
308+
<user-filter>
309309
<label><input type="checkbox"
310-
data-action="change:user-list.filter"
311-
data-targets="user-list.filters"
310+
data-action="change:user-filter#filter"
311+
data-targets="user-filter.filters"
312312
data-filter="all">Show all</label>
313313
<label><input type="checkbox"
314-
data-action="change:user-list.filter"
315-
data-targets="user-list.filters"
314+
data-action="change:user-filter#filter"
315+
data-targets="user-filter.filters"
316316
data-filter="new">New Users</label>
317317
<label><input type="checkbox"
318-
data-action="change:user-list.filter"
319-
data-targets="user-list.filters"
318+
data-action="change:user-filter#filter"
319+
data-targets="user-filter.filters"
320320
data-filter="admin">Admins</label>
321321
<!-- ... --->
322322
</user-filter>
@@ -347,17 +347,17 @@ class UserFilter {
347347
```html
348348
<user-filter>
349349
<label><input type="checkbox"
350-
data-action="change:user-list.filter"
351-
data-target="user-list.allFilter"
352-
data-targets="user-list.filters"
350+
data-action="change:user-filter#filter"
351+
data-target="user-filter.allFilter"
352+
data-targets="user-filter.filters"
353353
data-filter="all">Show all</label>
354354
<label><input type="checkbox"
355-
data-action="change:user-list.filter"
356-
data-targets="user-list.filters"
355+
data-action="change:user-filter#filter"
356+
data-targets="user-filter.filters"
357357
data-filter="new">New Users</label>
358358
<label><input type="checkbox"
359-
data-action="change:user-list.filter"
360-
data-targets="user-list.filters"
359+
data-action="change:user-filter#filter"
360+
data-targets="user-filter.filters"
361361
data-filter="admin">Admins</label>
362362
<!-- ... --->
363363
</user-filter>

docs/_guide/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ GitHub's first page interactions were written using jQuery, which was widely use
1111

1212
Rather than moving to entirely new paradigms, GitHub continued to use the same concepts within jQuery. Event Delegation was still heavily used, as well as querySelector. The event delegation concept was also extended to "element delegation" - discovering when Elements were added to the DOM, using the [Selector Observer](https://github.com/josh/selector-observer) library.
1313

14-
From this emerged a set of patterns which were reduced down to their first principles. _Observing_ elements on the page, _listening_ to the events these elements or their children emit, and _querying_ the children of an element to mutate or extend them.
14+
These patterns were reduced to first principles: _Observing_ elements on the page, _listening_ to the events these elements or their children emit, and _querying_ the children of an element to mutate or extend them.
1515

1616
The Web Systems team at GitHub explored other tools that adopt these set of patterns and principles. The closest match to those goals was [Stimulus](https://stimulusjs.org/) (from which Catalyst is heavily inspired), but ultimately the desire to leverage technology that engineers at GitHub were already familiar with was the motivation to create Catalyst.
1717

1818
## Three core concepts: Observe, Listen, Query
1919

2020
Catalyst takes these three core concepts and delivers them in the lightest possible way they can be delivered.
2121

22-
- **Observability** Catalyst solves observability by leveraging [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements). Custom Elements are given unique names within a system, and the browser will automatically use the Custom Element registry to observe these Elements entering and leaving the DOM. Read more about this in the Guide Section entitled [Custom Elements]({{ site.baseurl }}/guide/your-first-component).
22+
- **Observability** Catalyst solves observability by leveraging [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements). Custom Elements are given unique names within a system, and the browser will automatically use the Custom Element registry to observe these Elements entering and leaving the DOM. Read more about this in the Guide Section entitled [Your First Component]({{ site.baseurl }}/guide/your-first-component).
2323

2424
- **Listening** Event Delegation makes a great deal of sense when observing events "high up the tree" - registering global event listeners on the Window element - but Custom Elements sit much closer to their children within the tree, and so Direct Event binding is preferred. Catalyst solves this by binding event listeners to any descendants with `data-action` attributes. Read more about this in the Guide Section entitled [Actions]({{ site.baseurl }}/guide/actions).
2525

docs/_guide/you-will-need.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ Catalyst uses modern browser standards, and so requires evergreen browsers or ma
1818
- [`MutationObserver`](https://caniuse.com/#search=MutationObserver). [`mutation-observer`](https://github.com/webmodules/mutation-observer) can polyfill this.
1919

2020
Please note this list may increase over time. Catalyst will never ship with polyfills that add missing browser functionality, but will continue to use the latest Web Standards, and so may require more polyfills as new releases come out.
21+
22+
### Build considerations
23+
24+
When using build tools, some JavaScript minifiers modify the class name that Catalyst relies on. You know you have an issue if you encounter the error `"c" is not a valid custom element name`.
25+
26+
A best practice is to allow class names that end with `Element`. For instance, for Terser, you can use the following config: `{ keep_classnames: /Element$/ }`

docs/_guide/your-first-component.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Remember! A class name _must_ include at least two CamelCased words (not includi
3939
The `@controller` decorator ties together the various other decorators within Catalyst, plus a few extra conveniences such as automatically registering the element, which saves you writing some boilerplate that you'd otherwise have to write by hand. Specifically the `@controller` decorator:
4040

4141
- Derives a tag name based on your class name, removing the trailing `Element` suffix and lowercasing all capital letters, separating them with a dash.
42-
- Calls `window.customElements.register` with the newly derived tag name and your class.
42+
- Calls `window.customElements.define` with the newly derived tag name and your class.
4343
- Calls `defineObservedAttributes` with the class to add map any `@attr` decorators. See [attrs]({{ site.baseurl }}/guide/attrs) for more on this.
4444
- Injects the following code inside of the `connectedCallback()` function of your class:
4545
- `bind(this)`; ensures that as your element connects it picks up any `data-action` handlers. See [actions]({{ site.baseurl }}/guide/actions) for more on this.
@@ -59,7 +59,7 @@ class HelloWorldElement extends HTMLElement {
5959
}
6060
}
6161
defineObservedAttributes(HelloWorldElement)
62-
window.customElements.register('hello-world', HelloWorldElement)
62+
window.customElements.define('hello-world', HelloWorldElement)
6363
```
6464

6565
Using the `@controller` decorator saves on having to write this boilerplate for each element.

docs/custom.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ body {
4545
/* Code Blocks & Syntax */
4646
.markdown-body .highlight pre, .markdown-body pre {
4747
background-color: var(--color-bg-canvas-tertiary);
48-
overflow: inherit
48+
overflow: auto;
4949
}
5050

5151
/* Inline Code */

lighthouserc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"ci": {
33
"collect": {
44
"url": ["http://localhost:4000/?prefers-color-scheme=light", "http://localhost:4000/?prefers-color-scheme=dark"],
5-
"startServerCommand": "cd docs && bundle exec jekyll serve"
5+
"startServerCommand": "cd docs && bundle exec jekyll serve",
6+
"startServerReadyPattern": "Server running..."
67
},
78
"assert": {
89
"preset": "lighthouse:no-pwa",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)