-
Notifications
You must be signed in to change notification settings - Fork 26
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): add option to render as tag #674
Conversation
Preview branch generated at https://tag-as-button.d1gko6en628vir.amplifyapp.com |
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.
Should add an example of the Tag use on the button component page
LGTM |
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.
We should provide a visual indicator to sighted users on hover that the tag button is interactive. Right now, there is no indication that the tag button is interactive.
If the hover state is not already defined, it would be good to work with @awpearlm on it.
@@ -26,6 +26,8 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>( | |||
'Button--secondary': variant === 'secondary', | |||
'Button--error': variant === 'error', | |||
Link: variant === 'link', | |||
Tag: variant === 'tag', | |||
'Button--tag': variant === 'tag', |
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.
Rather than introduce a new class name, can we just leverage button.Tag
like we are doing for button.Link
?
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 could go either way on this, although we should be consistent on both. I think we can reutilize the styles for .Tag
but it would be nice to specifically target our buttons with .Button--variant
classname. If we want to use .Button--tag
, I think .Button--link
should exist as well.
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.
@scurker My personal preference would be .Button.Tag
, since it still targets our buttons without introducing another classname that needs to be included any time you want to do className="Button Tag"
. However, like you said, I wanted to be consistent with what we had w/o introducing a breaking change (button.Link
-> .Button.Link
) 🤷
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.
Thoughts?
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.
@thuey The problem is css specificity, and is counter to our guidelines:
For modifiers, such as variants or states, these values would be delimited by two dashes --
.Calendar--variant-large {
font-size: var(--text-size-large);
}
.Calendar--variant-small {
font-size: var(--text-size-small);
}
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'm suggesting something completely different that doesn't introduce a breaking change:
- Use both
button.Tag
andbutton.Button--tag
..Tag
inherits the styles from.Tag
and.Button--tag
keeps our conventions in place (and implementing the same pattern for.Link
).
This allows someone to target either all tags (with .Tag
) or just button tag variants (with .Button--tag
) while keeping specificity simple. Any styles that are specific to just .Button--tag
should exist on the variant class, not .Button.Tag
.
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.
Gotcha. That works for me 👍
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.
Actually, that still doesn't answer the question of what happens to the current button.Link
styles:
cauldron/packages/styles/button.css
Lines 44 to 46 in 62c9172
button.Link { | |
cursor: pointer; | |
} |
cauldron/packages/styles/button.css
Lines 231 to 237 in 62c9172
.cauldron--theme-dark button.Link { | |
color: var(--accent-light); | |
} | |
.cauldron--theme-dark button.Link:hover { | |
color: var(--white); | |
} |
If we change those to button.Button--link
, that is a breaking change. If we leave them as-is, that breaks consistency.
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.
Since this is an unrelated change to the proposed work, I don't have an issue with this being a breaking change as part of a separate ticket so here's my suggestion:
- Create a separate issue to change the
.Link
class to.Button--link
- Make the change here for
.Button--tag
as afeat
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.
@@ -26,6 +26,8 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>( | |||
'Button--secondary': variant === 'secondary', | |||
'Button--error': variant === 'error', | |||
Link: variant === 'link', | |||
Tag: variant === 'tag', | |||
'Button--tag': variant === 'tag', |
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 could go either way on this, although we should be consistent on both. I think we can reutilize the styles for .Tag
but it would be nice to specifically target our buttons with .Button--variant
classname. If we want to use .Button--tag
, I think .Button--link
should exist as well.
.Button--tag { | ||
position: relative; | ||
} |
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.
Why position: relative
?
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.
That is needed for hover to work. Since the :before
element has position: absolute
.
Preview branch generated at https://tag-as-button.d1gko6en628vir.amplifyapp.com |
Required for https://github.com/dequelabs/walnut/pull/3320