Conversation
Initial draft
|
Couple things to think about that come to mind.
Eg. class FancyButton extends HTMLButtonElement {
constructor() {
super();
this.addEventListener('click', e => this.innerHTML = "I was clicked");
}
}
customElements.define('fancy-button', FancyButton, { extends: 'button' }); |
|
Scratch that last point. Safari does not support customising built in elements in this way. |
|
I believe it's helpful to maintain consistency by naming attributes the same as we do in the other libraries. I believe we used naming standards in those that are comparable to those in HTML. I also think this consistency goes for the components as a whole. I think the components in |
| To what degree should web components be customized with respective attributes if they return just one main HTML element, | ||
| e.g. when `<f-textarea>` returns `<textarea>`, `<f-button>` returns `<button>` or `<f-textfield>` returns `<input>`? |
There was a problem hiding this comment.
This is a bit on the side of your question, but I wonder if there's a minimal requirement for components we implement in Fabric. If a f-button web component only wraps a button element with a class attribute, does it add enough value to justify the added complexity?
The DOM is already capable of rendering <button class="button button--primary">, if that is all <f-button type="primary"> would do. Adding a layer of JS around this will complicate SSR or force client-side rendering for behaviour that already exist.
Many web components will probably implements some extra behaviour, like form validation for input fields, and custom styling for checkboxes. And I clearly see the usefulness of having web components for that.
I'm sorry if this is off topic, but I would like to hear your thoughts on this. My main concern is that we use web components (and components in general) where it makes sense to encapsulate specific behaviour, and I believe there is a lower and upper bounds on the complexity it makes sense to implement with web components.
WDYT?
|
|
||
| ### Naming of component attributes | ||
|
|
||
| In most web component libraries the component attributes are called the same as native element attributes, e.g. `disabled`, `target`, `aria-label`. |
There was a problem hiding this comment.
From my limited experience with web components, I can only say that it looks like WC libs try to be as transparent as possible, mimicing the behaviour and attributes of native HTML elements. That could also be a good strategy for components in other frameworks, to expose eg. an onChange prop in a Combobox component where an change event would be expected in a conceptually related select element.
Rendered markdown: https://github.com/fabric-ds/issues/blob/rfc/fabric-elements-api/rfcs/0005-fabric-elements-api.md