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

Updates Button and ButtonMarketing Lookbook previews with accessible examples #2802

Merged
merged 13 commits into from
Apr 25, 2024

Conversation

lindseywild
Copy link
Contributor

@lindseywild lindseywild commented Apr 24, 2024

Authors: Please fill out this form carefully and completely.

Reviewers: By approving this Pull Request you are approving the code change, as well as its deployment and mitigation plans.
Please read this description carefully. If you feel there is anything unclear or missing, please ask for updates.

What are you trying to accomplish?

These changes make the Lookbook previews accessible and have proper markup. Specifically:

  • Removed the ability to change the tag argument in the playground
  • Added a preview for "Summary as button" to show the proper markup with a wrapping <details> element
  • Added missing href attributes when a button tag is rendered as an <a>.

I've also added documentation with the markup requirements if changing a Button tag to either summary or a. This does not change any component API or functionality, they are strictly preview changes.

One question I had is: should we consider requiring an href to be passed in if the user passes an a to the tag argument in the component itself? I didn't want to get too deep into changing component functionality, but I can file a follow-up issue if this is something that's desired.

Integration

No

List the issues that this change affects.

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

Originally, I tried to render the required attributes (<details> wrapping a summary and an href attribute for <a> elements) in a conditional way, but it felt messy; while I could get the href to render conditionally, we needed to add it to every preview example which was not ideal. I also couldn't figure out how to conditionally wrap the button previews with a <details> element, which I don't think is possible in Ruby (but I could be wrong, open to other ideas here!)

I felt the best option was to remove the option to change the tag entirely. It doesn't affect anything visually, and we don't want to give people the wrong impression about how to use the component so I broke things out into their own stories (i.e. Summary as button and Link as button, the latter already existed). I also added an href param in the previews where the buttons are rendered as link tags.

Anything you want to highlight for special attention from reviewers?

Are there other approaches you'd suggest here? I am a newer Primer contributor so all feedback is welcomed ✨

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

Copy link

changeset-bot bot commented Apr 24, 2024

🦋 Changeset detected

Latest commit: 017fd24

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Apr 24, 2024

⚠️ Visual differences found

Our visual comparison tests found UI differences. Please review the differences by viewing the files changed tab to ensure that the changes were intentional.

Review visual differences

@@ -63,22 +63,18 @@ def icon_buttons(size: :medium)
end
end

# @label Button group with all tags
# @label Button group with multiple tags
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if we'd ever want a summary tag in a button group, so I've removed this example.

@lindseywild lindseywild marked this pull request as ready for review April 24, 2024 16:30
@lindseywild lindseywild requested review from a team as code owners April 24, 2024 16:30
Copy link
Contributor

@khiga8 khiga8 left a comment

Choose a reason for hiding this comment

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

This makes a lot of sense to me! 🚀

app/components/primer/alpha/button_marketing.rb Outdated Show resolved Hide resolved
app/components/primer/beta/button.rb Outdated Show resolved Hide resolved
Co-authored-by: Kate Higa <16447748+khiga8@users.noreply.github.com>
@@ -20,7 +20,6 @@ class ButtonPreview < ViewComponent::Preview
# @param disabled toggle
# @param inactive toggle
# @param align_content select [center, start]
# @param tag select [a, summary, button]
Copy link
Contributor

Choose a reason for hiding this comment

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

Since tag is still an option for the component, I think we should at least keep it in the Playground story. This is what we use to test different cases and make sure we haven't broken anything.. I would at least keep it to button, a and maybe there's a way to pass in href if a is selected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can definitely keep it to button and a! There is a way I can dynamically add a # if it is an <a> so I will do that :) Thank you!

Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Generally LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants