Skip to content

Commit f637cc1

Browse files
committed
refine docs around your first component and how controller works
1 parent 75f7ea6 commit f637cc1

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

docs/_guide/your-first-component.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,21 @@ The `@controller` decorator ties together the various other decorators within Ca
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.
4242
- Calls `window.customElements.define` with the newly derived tag name and your class.
43-
- Calls `defineObservedAttributes` with the class to add map any `@attr` decorators. See [attrs]({{ site.baseurl }}/guide/attrs) for more on this.
44-
- Injects the following code inside of the `connectedCallback()` function of your class:
45-
- `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.
46-
- `initializeAttrs(this)`; ensures that your element binds any `data-*` attributes to props. See [attrs]({{ site.baseurl }}/guide/attrs) for more on this.
43+
- Loads the `attrable` decorator, which provides the ability to define `@attr` decorators. See [attrs]({{ site.baseurl }}/guide/attrs) for more on this.
44+
- Loads the `actionable` decorator, which provides the ability to bind actions. See [actions]({{ site.baseurl }}/guide/actions) for more on this.
45+
- Loads the `targetable` decorator, which provides Target querying. See [targets]({{ site.baseurl }}/guide/targets) for more on this.
4746

4847
You can do all of this manually; for example here's the above `HelloWorldElement`, written without the `@controller` annotation:
4948

5049
```js
51-
import {bind, initializeAttrs, defineObservedAttributes} from '@github/catalyst'
50+
import {attrable, targetable, actionable} from '@github/catalyst'
51+
52+
@register
53+
@actionable
54+
@attrable
55+
@targetable
5256
class HelloWorldElement extends HTMLElement {
53-
connectedCallback() {
54-
initializeAttrs(this)
55-
this.innerHTML = 'Hello World!'
56-
bind(this)
57-
}
5857
}
59-
defineObservedAttributes(HelloWorldElement)
60-
window.customElements.define('hello-world', HelloWorldElement)
6158
```
6259

6360
The `@controller` decorator saves on having to write this boilerplate for each element.

0 commit comments

Comments
 (0)