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: Add consistent variant prop for design variant of buttons / chips #6472

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Jan 29, 2025

☑️ Resolves

Currently we need to wrap the native type prop of a button into nativeType of NcButton.
This is confusing and we should never use names for props that are already attributes of the native HTML element.

The solution is to rename type to variant.
To not make it breaking following is applied:

  1. variant prop is added replacing type
  2. nativeType is deprecated in favor of type
  3. type allows both, the native button type and the color variant
  • If a color variant is passed then the legacy behavior is applied
  • Otherwise it behaves like nativeType

The same is also applied for NcDialogButton and NcActions.
NcChip also referred to the NcButton for the type so this is also migrated the same way to make the wording variant consistent.

In a last step all components are refactored to use the new props instead.

🖼️ Screenshots

Nothing visually changed - if it does that's a regression 😨

🏁 Checklist

  • ⛑️ Tests are included or are not applicable
  • 📘 Component documentation has been extended, updated or is not applicable
  • 3️⃣ Backport to next requested with a Vue 3 upgrade

@susnux susnux added enhancement New feature or request 3. to review Waiting for reviews feature: button labels Jan 29, 2025
@susnux susnux added this to the 8.23.0 milestone Jan 29, 2025
Deprecate `type` for usage with the color variant.
Also deprecate `nativeType` in favor of `type` and `variant`.

Signed-off-by: Ferdinand Thiessen <[email protected]>
This is done to align with `NcButton`.

Signed-off-by: Ferdinand Thiessen <[email protected]>
To align with `NcButton`.

Signed-off-by: Ferdinand Thiessen <[email protected]>
…`type` prop

To align with `NcButton`.

Signed-off-by: Ferdinand Thiessen <[email protected]>
…e` prop

To align with `NcButton`.

Signed-off-by: Ferdinand Thiessen <[email protected]>
variant: {
type: String,
validator(value) {
return ['primary', 'secondary', 'tertiary', 'tertiary-no-background', 'tertiary-on-primary', 'error', 'warning', 'success'].indexOf(value) !== -1
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer using .includes(value) here.
Can we also keep available variants in one place (as const, or util like ValidateSlot) to not duplicate it everywhere? In case it's not a limited list of only primary, secondary, tertiary

/**
* The button variant, see NcButton.
*
* @type {'primary'|'secondary'|'error'|'warning'|'success'}
Copy link
Contributor

Choose a reason for hiding this comment

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

'tertiary' is skipped here and above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fun fact: It is even in current version (and next) causing me in my apps having "invalid attribute 'tertiary'" 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement New feature or request feature: button
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants