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: Invert button group icons for better contrast #352

Merged
merged 13 commits into from
Oct 1, 2024

Conversation

abovedave
Copy link
Collaborator

@abovedave abovedave commented Sep 20, 2024

Closes internal ticket [STACKS-555].

Currently the button groups in Stacks make the text bold on selected state. However the editor uses icons in place of text, which we obiously can't easily 'bolden'.

existing

This PR adds some override CSS to button groups for the editor to invert the icon against a darker background, making it much more accessible.

proposed

@CGuindon
Copy link
Collaborator

@abovedave How to I test stuff in the editor repo? I noticed I can't add the "PR environment" label?

Copy link

netlify bot commented Sep 24, 2024

Deploy Preview for stacks-editor ready!

Name Link
🔨 Latest commit f1f0982
🔍 Latest deploy log https://app.netlify.com/sites/stacks-editor/deploys/66fbf23275dc4a000836fce0
😎 Deploy Preview https://deploy-preview-352--stacks-editor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@abovedave
Copy link
Collaborator Author

@CGuindon added the deploy preview, I think it didn't do automatically as the PR is from my personal account.

@CGuindon
Copy link
Collaborator

The focus state looks worse with the reverse colors. For HC mode and AAA we're supposed to have 2 px in between colors that need the contrast ratio. This would be a small, low severity issue since we still have at least 1 px line in there (and it's for AAA not AA, which we only support for HC mode) but if there's a better way to do the fill or we need to increase to py4

Focus on current
Screenshot 2024-09-24 at 8 03 58 AM
Screenshot 2024-09-24 at 8 03 54 AM

Focus with py4
Screenshot 2024-09-24 at 8 16 21 AM
Screenshot 2024-09-24 at 8 17 23 AM

@abovedave
Copy link
Collaborator Author

@CGuindon good catch. We could remove the inset on the focus?

Screenshot 2024-09-24 at 14 33 20

@CGuindon
Copy link
Collaborator

@abovedave I'd be ok with that for this type of icon only button group edge case. Would still love a gut check from @dancormier though.

@CGuindon
Copy link
Collaborator

@abovedave Can't see the changes in the PR — you might need to kick or something to regenerate a PR-env

@abovedave
Copy link
Collaborator Author

@CGuindon try now!

Copy link
Collaborator

@CGuindon CGuindon left a comment

Choose a reason for hiding this comment

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

Glorious! Would still wait for Dan before merging though

@giamir
Copy link
Contributor

giamir commented Sep 26, 2024

Before merging we should rollback the package-lock.json changes and run the formatter to get the lint step to pass. 🙂

Also are we ok to add these bespoke styles here? Should we solve this at Stacks Classic level? We try to keep bespoke editor styles to a minimum in general.

@abovedave
Copy link
Collaborator Author

@giamir reverted package changes. They were from some high vulnerability errors on install, but I assume they are the other PR's from dependabot.

12 vulnerabilities (7 moderate, 5 high)

If I can get access to this repo I can deal with them if you like?

@giamir
Copy link
Contributor

giamir commented Oct 1, 2024

@giamir reverted package changes. They were from some high vulnerability errors on install, but I assume they are the other PR's from dependabot.

@abovedave I gave you write access to the repo. Feel free to take care of the violations if you have time in a separate PR or commit. Thank you.

@giamir
Copy link
Contributor

giamir commented Oct 1, 2024

Also are we ok to add these bespoke styles here? Should we solve this at Stacks Classic level? We try to keep bespoke editor styles to a minimum in general.

I wanted to wait for Dan's opinion before merging. I personally do think it is something we should solve and document in Stacks Classic: https://github.com/StackExchange/Stacks/blob/develop/lib/components/button-group/button-group.less

@abovedave what are your thoughts? If there is urgency to fix this we can merge this PR and add a follow up ticket to move the styles back in Stacks classic if we agree. If there is no urgency maybe we should directly open a PR in Stacks Classic instead.

@abovedave
Copy link
Collaborator Author

The complication is this is a bit of a mash-up component. We're using the radio inputs with the + next sibling selector which could have been a switch component. So perhaps the 'right' way is to refactor this as a switch, but then add a variation for 'icons only' we've created here.

Another fix might be to refactor this to be more of a pure button group (no radio inputs) and use Stack's atomic classes to achieve the desired visuals. It looks like the outer :focus approach we're taking here has been applies to the single switch but not the multiple option.

I think on balance a few lines of CSS here for the high-is priority accessibility fix are probably worth the trade-off vs unpicking the above!

Copy link
Contributor

@giamir giamir left a comment

Choose a reason for hiding this comment

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

@abovedave I am ok to merge this then, thanks for the explanation. I only have a small ask to ensure the rules are scoped only to the editor. I have added a comment inline.
After that, we can merge. Thanks.

src/styles/custom-components.css Outdated Show resolved Hide resolved
@abovedave abovedave merged commit 5cea909 into StackExchange:main Oct 1, 2024
5 checks passed
@abovedave abovedave deleted the STACKS-555 branch October 1, 2024 13:03
@giamir
Copy link
Contributor

giamir commented Oct 1, 2024

@abovedave Let me know if you need assistance to cut a patch release:
https://github.com/StackExchange/Stacks-Editor?tab=readme-ov-file#creating-a-new-release

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

Successfully merging this pull request may close these issues.

3 participants