Replies: 11 comments
-
|
Linking this: #1420 |
Beta Was this translation helpful? Give feedback.
-
|
Also related: |
Beta Was this translation helpful? Give feedback.
-
|
I agree that we should only forward useful events. A lot of components have a wrapping Furthermore, it can be confusing if we forward events to different elements. Example: <!-- events forwarded to the div are not useful and can be done by the consumer -->
<div
on:click
on:mouseover
on:mouseenter
on:mouseleave
>
<input on:input />
</div> |
Beta Was this translation helpful? Give feedback.
-
|
@metonym I added "Prop ordering" above. On another note, I noticed As props: <form method="POST" action="?/deleteProfile" use:enhance>
<Button
type="submit"
kind="tertiary"
size="lg"
id="abc123"
skeleton={!ready}
/>
Delete Profile
</Button>
</form>As components: {#if ready}
<form method="POST" action="?/deleteProfile" use:enhance>
<Button
type="submit"
kind="tertiary"
size="lg"
id="abc123"
/>
Delete Profile
</Button>
</form>
{:else}
<ButtonSkeleton size="lg" />
{/if} |
Beta Was this translation helpful? Give feedback.
-
|
@theetrain agree - skeleton variants should live as standalone components. We should remove the skeleton prop. |
Beta Was this translation helpful? Give feedback.
-
|
Do we want to allow Example with <Button
kind="secondary"
type="submit"
data-test-id="abc123"
>
Save
</button>Example without <Button
kind="secondary"
type="submit"
attributes={{ 'data-test-id': "abc123" }}
>
Save
</button>One other trade-off when using Related comments: #1895 (comment), #1932 (comment) |
Beta Was this translation helpful? Give feedback.
-
|
My personal preference is for a uniform API. I like the idea of being able to use CDS Svelte and know I should never use |
Beta Was this translation helpful? Give feedback.
-
It just shifts things, instead you now need to know which attribute object is the relevant one if any (because the delineation of special properties and plain attributes is not entirely clear - see #1895 (comment)). These properties are meant to standardize, but this is just not possible to the degree envisioned. The syntax is also just plain worse, it is more verbose, noisy and forces a switch away from HTML to JS in the markup, even for static attributes. This goes against Svelte's core HTML-first approach. I would argue for the continued use of In Svelte 5 rest props will further be strengthened with the ability to forward all event handlers. The feature was always meant to support the wrapping of elements in generic components, it does not make sense to me to ditch it. |
Beta Was this translation helpful? Give feedback.
-
|
@brunnerh if I were to formalize your note into a protocol, it could be:
Mind you, some extra considerations may need to be made for #1622 (thinking about Note: "attribute props" == "pass-through props" |
Beta Was this translation helpful? Give feedback.
-
|
Personally, I echo @SimpleProgrammingAU's sentiment.
|
Beta Was this translation helpful? Give feedback.
-
The same should be true for spreading any object as props. For component libraries there is no way around this.
It's not predictable because some props (e.g.
True, but ideally the secondary elements would not need as much customization. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Status: 🟡 Proposal
We have several props and dispatched event names that are reused across components. Let's improve their consistency in naming and intent.
Todo
titleTexttolabelTextProp ordering
Rather than alphabetical order, props SHOULD be ordered in a manner that is intuitive and useful to users. Sveld will generate documentation in the order props are defined within components.
Proposed ordering:
refor[elementName]RefpropskindsizelabelTextandhideLabel$$restPropsbelow)Prop names
Props that have different intent follow different aspirational rules.
The following MUST be followed:
kindto represent a set of other named options for visual or interactive component representationsskeletonvariants should be separate components; and not a prop toggleThe following SHOULD be followed:
trueorfalsevalues are represented as plain adjectives without anisprefix. Examples:expandable,selectable,selected. Prefer to have them default tofalsefor easy truthy flagging. i.e. absense ofselectableimpliesselectable == false, but the presence ofselectedtoggles totrue.disabledfor<Button>aria-labelfor<TextInput>refprop with 2-way binding should be provided to allow focusing via JS. Appropriate elements include, but aren't limited to:sizeshould have all possible values explicitly typed, including defaults, such as'sm' | 'md' | 'lg'instead of'sm' | 'lg'. Components impacted:Form components
Components that render form inputs MUST have the following props:
labelTextfor the labelhelperTextfor any helpful or hint text placementname,id,value,checkedreadonlyshould bereadOnlyProp behaviours SHOULD include:
valueis bindable, and can be instantiated (currently not the case for Combobox)Events
Demo: https://svelte.dev/repl/9b1e3a7822bb4aac9418c95f518523e7?version=3.55.1
In general:
pointerevents overmouseevents to ensure cross-compatibility with touch and desktop devices. Usemouseortouchonly when necessaryDispatched events
Forwarded events
on:input,on:submit, andon:change; this includes TextInput, ComboBox, and others$$restPropsSee #1064 (comment)
$$restPropssince it's a discouraged feature of SveltebuttonAttributesfor<Button>; andlabelAttributesandinputAttributesfor<TextInput>Slots
Beta Was this translation helpful? Give feedback.
All reactions