Skip to content

Commit bdb1240

Browse files
committed
refine docs around your first component and how controller works
1 parent ab99a16 commit bdb1240

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
@@ -42,24 +42,21 @@ The `@controller` decorator ties together the various other decorators within Ca
4242

4343
- Derives a tag name based on your class name, removing the trailing `Element` suffix and lowercasing all capital letters, separating them with a dash.
4444
- Calls `window.customElements.define` with the newly derived tag name and your class.
45-
- Calls `defineObservedAttributes` with the class to add map any `@attr` decorators. See [attrs]({{ site.baseurl }}/guide/attrs) for more on this.
46-
- Injects the following code inside of the `connectedCallback()` function of your class:
47-
- `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.
48-
- `initializeAttrs(this)`; ensures that your element binds any `data-*` attributes to props. See [attrs]({{ site.baseurl }}/guide/attrs) for more on this.
45+
- Loads the `attrable` decorator, which provides the ability to define `@attr` decorators. See [attrs]({{ site.baseurl }}/guide/attrs) for more on this.
46+
- Loads the `actionable` decorator, which provides the ability to bind actions. See [actions]({{ site.baseurl }}/guide/actions) for more on this.
47+
- Loads the `targetable` decorator, which provides Target querying. See [targets]({{ site.baseurl }}/guide/targets) for more on this.
4948

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

5251
```js
53-
import {bind, initializeAttrs, defineObservedAttributes} from '@github/catalyst'
52+
import {attrable, targetable, actionable} from '@github/catalyst'
53+
54+
@register
55+
@actionable
56+
@attrable
57+
@targetable
5458
class HelloWorldElement extends HTMLElement {
55-
connectedCallback() {
56-
initializeAttrs(this)
57-
this.innerHTML = 'Hello World!'
58-
bind(this)
59-
}
6059
}
61-
defineObservedAttributes(HelloWorldElement)
62-
window.customElements.define('hello-world', HelloWorldElement)
6360
```
6461

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

0 commit comments

Comments
 (0)