Skip to content
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

feat!: button v11 #1895

Open
wants to merge 6 commits into
base: next/v11-styles
Choose a base branch
from
Open

feat!: button v11 #1895

wants to merge 6 commits into from

Conversation

theetrain
Copy link
Collaborator

@theetrain theetrain commented Jan 16, 2024

Relates: #1641
For #1629

Meta

Todo

  • Implement ButtonSet
  • Implement ButtonSkeleton

Out of scope

Button changes

BREAKING CHANGES

  • size prop has new values: sm, md, lg, xl, and 2xl. xl is the default.
  • kind prop has new values: danger-tertiary is now danger--tertiary (two hyphens), and danger-ghost is now danger--ghost (two hyphens)

Features

  • New 2xl size
  • expressive styles now apply to all button sizes

Fixes

  • Exports all SCSS styles using official conventions
  • All theme tokens are included in built CSS files

- Using all component tokens and styles that were previously-missing
Button changes

##BREAKING CHANGES

- `skeleton` prop has been removed. Use `ButtonSkeleton` component instead
- `size` prop has new values
- `kind` prop has new values
- `isSelected` is now `selected
- `on:mouseover`, `on:mouseenter`, and `on:mouseleave` forwarded events were replaced with `on:pointerover`, `on:pointerenter`, and `on:pointerleave`
- `as` no longer accepts boolean types

## Features

- New `2xl` size
- `expressive` styles now apply to all button sizes
- `as` accepts a string to specify a desired HTML element
@theetrain
Copy link
Collaborator Author

theetrain commented Jan 16, 2024

I'm accepting preliminary reviews until the tasks above are complete.

Copy link
Contributor

@gregorw gregorw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very hard to review due to the many changes.

Changes to Button using v11 can be much smaller and they still look good.

My 2 cents would be to separate v11 styles from feature parity. Otherwise it will be very hard to review the changes in next/v11-styles compared to master. We’re taking two steps at the same time and it will make reviewing, writing release notes and upgrading existing apps very very hard.

See also #1889 (comment).

If we really want to move the needle with v11 styles we should work on components such as Theme, Layer, CodeSnippet, maybe Stack, etc.

src/Button/Button.svelte Outdated Show resolved Hide resolved
* @type {import('svelte/elements').HTMLAnchorAttributes |
* import('svelte/elements').HTMLButtonAttributes | import('svelte/elements').HTMLAttributes}
*/
export let buttonAttributes = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of this, at least not in this form/for this component.

  • It's unwieldy, you repeat "button" which is already part of the element, maybe it could just be attributes if it refers to the root element
  • Button primarily is just a wrapper around a single element, I would prefer to pass any unknown properties automatically via $$restProps
  • If an attributes property is used, there should at least also be iconAttributes.
  • It is inconsistent, some attributes, like disabled, have their own property.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all good points. I think it's fair to revise #1621 accordingly.

maybe it could just be attributes if it refers to the root element

I think attributes works. The main benefit of a dedicated prop over $$restProps is for more ergonomic autocomplete. Only component props would appear in the IDE, and element attributes would be contained within a dedicated prop such as attributes.

I would prefer to pass any unknown properties automatically via $$restProps

Given the autocomplete trade-off above, I'm leaning towards attributes, but I'm also torn because this:

<Button kind="secondary" type="submit" data-test-id="abc123">Save</button>

Looks nicer than this:

<Button kind="secondary" type="submit" attributes={{ 'data-test-id': "abc123" }}>
  Save
</button>

there should at least also be iconAttributes.

Agreed.

We have this note in our standardization ticket:

HTML attributes are provided via Type declarations and should not be included as explicit props unless it has special treatment as part of a component.

Appropriate: disabled for <Button>
Inappropriate: aria-label for <TextInput>

I suppose disabled has special treatment depending on usage of as or href. For that reason, I think it deserves to be a prop.

src/Button/Button.svelte Outdated Show resolved Hide resolved
@theetrain theetrain marked this pull request as ready for review January 19, 2024 21:33
@theetrain theetrain requested a review from metonym January 19, 2024 21:33
@theetrain theetrain mentioned this pull request Jan 20, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants