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

Add validation check for type scale accessibility #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mbrowne
Copy link
Contributor

@mbrowne mbrowne commented Aug 14, 2024

Background: If you're not careful, when using fluid typography it's possible to end up violating the WCAG SC 1.4.4 accessibility rule (about zooming text).

Fortunately it's possible to do some math to ensure that the rule is not violated. More details here:
https://www.smashingmagazine.com/2023/11/addressing-accessibility-concerns-fluid-type/

I'm not a math whiz myself, but fortunately someone already implemented the validation discussed in the article, so I was able to adapt the code from this existing repo:
https://github.com/barvian/fluid-tailwind/blob/f85f1ae5a50ec1a37f99418d6d087a3a2e783e1b/packages/fluid-tailwind/src/util/expr.ts#L116

I decided to make it an error by default and also to still show it as a warning if you set typeScale.validateAccessibility to false, but I could of course change the PR if different behavior is desired.

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.

1 participant