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): add option to render as tag #674

Merged
merged 3 commits into from
Jun 22, 2022
Merged

feat(button): add option to render as tag #674

merged 3 commits into from
Jun 22, 2022

Conversation

AdnoC
Copy link
Contributor

@AdnoC AdnoC commented Jun 10, 2022

@AdnoC AdnoC requested a review from a team as a code owner June 10, 2022 21:20
@AdnoC AdnoC marked this pull request as draft June 10, 2022 21:20
@AdnoC AdnoC marked this pull request as ready for review June 10, 2022 21:20
@github-actions
Copy link
Contributor

Preview branch generated at https://tag-as-button.d1gko6en628vir.amplifyapp.com

Copy link
Contributor

@straker straker left a 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

@straker
Copy link
Contributor

straker commented Jun 14, 2022

LGTM

thuey
thuey previously requested changes Jun 15, 2022
Copy link
Collaborator

@thuey thuey left a 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.

@AdnoC AdnoC dismissed thuey’s stale review June 15, 2022 16:46

added style

thuey
thuey previously requested changes Jun 15, 2022
@@ -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',
Copy link
Collaborator

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?

Copy link
Member

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.

Copy link
Collaborator

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) 🤷

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thoughts?

Copy link
Member

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);
}

Copy link
Member

@scurker scurker Jun 17, 2022

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 and button.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.

Copy link
Collaborator

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 👍

Copy link
Collaborator

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:

button.Link {
cursor: pointer;
}

.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.

Copy link
Member

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 a feat

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here's the ticket: #681

Sorry for the confusion @AdnoC. We will want to do Button--tag after all

@@ -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',
Copy link
Member

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.

Comment on lines +44 to +46
.Button--tag {
position: relative;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why position: relative?

Copy link
Contributor Author

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.

@AdnoC AdnoC dismissed thuey’s stale review June 16, 2022 08:09

Changed to use button.Tag selector

@AdnoC AdnoC merged commit 9a1593a into develop Jun 22, 2022
@AdnoC AdnoC deleted the tag-as-button branch June 22, 2022 15:36
@github-actions
Copy link
Contributor

Preview branch generated at https://tag-as-button.d1gko6en628vir.amplifyapp.com

@scurker scurker mentioned this pull request Jun 23, 2022
@scurker scurker mentioned this pull request Jul 12, 2022
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.

4 participants