Apply dynamic sizing for octicons#3109
Closed
iansan5653 wants to merge 2 commits into
Closed
Conversation
🦋 Changeset detectedLatest commit: 05a44fb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make Octicon sizing respond to base font-size changes by overriding their inline width/height attributes with rem-based Primer --base-size-* tokens, improving consistency when root font size is customized.
Changes:
- Adds CSS sizing rules for
.octiconto use--base-size-16instead of relying on hardcoded SVG attributes. - Documents the rationale for overriding inline SVG dimensions.
Show a summary per file
| File | Description |
|---|---|
src/base/octicons.scss |
Overrides Octicon SVG sizing via CSS variables to support dynamic scaling with base font-size changes. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Low
Comment on lines
+6
to
+11
| /* Icon svg elements have `height="16" width="16"` set, hardcoding their dimensions to 16px. | ||
| This is useful for sizing in case CSS is missing/not yet loaded, but prevents icons from | ||
| responding to changes in font size/zoom. Using base-size applies the same size by default | ||
| but allows for dynamic sizing when base font size changes. */ | ||
| height: var(--base-size-16); | ||
| width: var(--base-size-16); |
Author
|
Hmm on second thought this is probably the wrong fix; it would work for most icons but would break custom icon |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What are you trying to accomplish?
Octicons are currently hardcoded to
16pxdimensions due tosvgelementheightandwidthattributes. This prevents them from changing in response to changes in base font size, even when everything else on the page does change, making them look disproportionately small or large if the base font size is overidden to anything other than the default.What approach did you choose and why?
The simple fix is to apply
base-sizePrimer tokens here, which arerembased and will adjust in response to base font size changes.What should reviewers focus on?
Not much to see here really, it's pretty straightforward.
Can these changes ship as is?