-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: added custom components initial content #1855
Conversation
docs/001_develop/03_client-capabilities/023_custom-components/01_quick-start
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/01_quick-start
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/01_quick-start
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/01_quick-start
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/01_quick-start
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/02_lifecycle
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/03_state-management
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/03_state-management
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/03_state-management
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/03_state-management
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really fantastic, you should be very proud of yourself. Please don't be put off by the amount of comments, this is a very substantial piece of work and therefore will always have generated many points of feedback.
docs/001_develop/03_client-capabilities/023_custom-components/01_quick-start
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/01_quick-start
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/01_quick-start
Outdated
Show resolved
Hide resolved
docs/001_develop/03_client-capabilities/023_custom-components/01_quick-start
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,75 @@ | |||
# Component Lifecycles | |||
|
|||
Web Components go through several lifecycle stages from creation to removal. Understanding these lifecycles is crucial for proper component initialization, cleanup, and state management. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to be careful and consistant with our terminology here. I think except the the intro in the previous page we should always refer to these as Genesis Elements. Not custom elements or web components.
|
||
``` | ||
|
||
- `ref("buttonElement")`: The ref directive assigns the `<button>` element to the `buttonElement` property on the `<my-button>` component instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `ref("buttonElement")`: The ref directive assigns the `<button>` element to the `buttonElement` property on the `<my-button>` component instance. | |
- `ref("buttonElement")`: The ref directive assigns a reference to the `<button>` element to the `buttonElement` property on the `<my-button>` component instance. |
``` | ||
- Property Name: The name of the property that will store the DOM reference in the component. The element with ref(propertyName) will be assigned to this property. | ||
|
||
## Slotted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all really good. It has me wondering if we should introduce the concept of slot
in the html earlier on though in addition to this, I am unsure just introducing it here makes it clear what the use case is.
<!-- Look into how to implement this --> | ||
|
||
### Usage in HTML | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template: html<MyButton>`
<div>
${whenElse(
x => !x.ready,
html<MyButton>`Loading...`,
html<MyButton>`<button>Data Loaded: ${x => x.data.message}</button>`
)}
</div>
`,
`, | ||
}) | ||
export class MyButtonList extends GenesisElement { | ||
@observable buttons: string[] = ["Click Me", "Submit", "Reset"]; // Static list of button labels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@observable buttons: string[] = ["Click Me", "Submit", "Reset"]; // Static list of button labels | |
buttons: string[] = ["Click Me", "Submit", "Reset"]; // Static list of button labels |
This doesn't need to be observable for your example, and the way observable works with array is a bit tricky so I wouldn't just use the keyword here without an explanation
- Expression: Specifies the data source for repeat. | ||
- Item Template: Defines the HTML structure for each item. | ||
- Options: Adds control over item positioning and view recycling (optional). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might want to elaborate on repeat a bit to explain some of the more advanced bits it can do. See here where it talks about opting into positioning. You probably don't need to go as in depth but we should mention it. Also the view recycling section
SyncThe @customElement({
name: 'my-element',
template: html<MyElement>`
<rapid-checkbox
?checked=${(x) => x.isSelected}
>Checkbox
</rapid-checkbox>
`,
})
export class MyElement extends GenesisElement {
@observable isSelected = true;
isSelectedChanged() {
console.log(this.isSelected);
}
} When Now we'll add the use the @customElement({
name: 'my-element',
template: html<MyElement>`
<rapid-checkbox
?checked=${sync((x) => x.isSelected, 'boolean')}
>Checkbox
</rapid-checkbox>
`,
})
export class MyElement extends GenesisElement {
@observable isSelected = true;
isSelectedChanged() {
console.log(this.isSelected);
}
} The property (and therefore checkbox state) is set as true by default as previously, but if you interact with the checkbox this time you should see that the console logs due to Usage in HTMLhtml`
<rapid-text-area :value=${sync((x) => x.textAreaValue)}><rapid-text-area>
<rapid-checkbox ?checked=${sync((x) => x.isSelected, 'boolean')}><rapid-checkbox>
<rapid-number-field :value=${sync((x) => x.numberInputValue, 'number')}><rapid-number-field>
` The above configuration example shows the subtle differences required when using
Syntax Breakdown
|
DRAFT - PLEASE DO NOT CLOSE THIS PR
ATENTION! YOU SHOULD NOW BRANCH FROM PREPROD WHEN YOU UPDATE
Thank you for contributing to the documentation.
Do the changes you have made apply to both Current and Previous versions?
Have you done a trial build to check all new or changed links?
Is there anything else you would like us to know?
This week's exciting advice from the style guide
Write your headings in sentence case:
This is a correct heading.
This is not a correct heading.