-
-
Notifications
You must be signed in to change notification settings - Fork 203
fix(a11y): use pixels for spacing to allow for better text zoom #980
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
Merged
+1
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: npmx-dev/npmx.dev
Length of output: 76
🏁 Script executed:
Repository: npmx-dev/npmx.dev
Length of output: 8459
🌐 Web query:
UnoCSS preset-wind4 spacing configuration theme override💡 Result:
In preset-wind4, all the “size scale” utilities (including
p-*,m-*, and alsow-*,h-*,min/max-w/h, etc.) are unified to usetheme.spacing. [1]Override spacing via theme
This is the standard UnoCSS way to change what e.g.
p-4(andw-4,h-4, …) resolve to. [2]Override the generated CSS variable (optional)
preset-wind4 puts theme variables (including
--spacing) in a dedicatedthemelayer specifically to make overriding easy. [1] You can override it in your own CSS loaded after UnoCSS:Sources: UnoCSS preset-wind4 docs [1], UnoCSS theme spacing tutorial [2].
Note that numeric spacing utilities will still use rem values with this change.
Setting
spacing: { DEFAULT: '4px' }affects only non-numeric utilities (e.g. barep,m). Numeric utilities likep-1,m-2,px-4will still resolve to the preset-wind4 default scale (where1=0.25rem,2=0.5rem, etc.) since you're not defining those numeric keys.To convert all spacing utilities to px, the numeric scale must be explicitly defined:
This is a valid concern only if the goal is complete conversion; if this is intentionally a first step as noted in the PR, this can be disregarded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, you’re wrong. The default value is used to set a custom property called
--spacing. The relevant utilities use this custom property as a cascading variable which is multiplied by the step in the scale. For example, a partial sample of the output might look like this:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knowler, you're absolutely right—thank you for the correction! I misunderstood how preset-wind4 handles theDEFAULTspacing value. Settingspacing: { DEFAULT: '4px' }creates the--spacingcustom property that's then multiplied in the utility classes (e.g.,pl-2becomescalc(4px * 2)), so this change does indeed convert the numeric spacing utilities to pixels as intended. I appreciate the clarification!✏️ Learnings added