Skip to content

Add validation check for type scale accessibility#2

Open
mbrowne wants to merge 5 commits intoparamours:mainfrom
mbrowne:accessibility-warning
Open

Add validation check for type scale accessibility#2
mbrowne wants to merge 5 commits intoparamours:mainfrom
mbrowne:accessibility-warning

Conversation

@mbrowne
Copy link
Copy Markdown
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.

@mbrowne mbrowne force-pushed the accessibility-warning branch from 7b34bd3 to 9d6aab4 Compare August 14, 2024 12:00
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