-
Notifications
You must be signed in to change notification settings - Fork 98
Fix home page icons #219
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
Fix home page icons #219
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,14 @@ const props = defineProps<{ | |
|
||
const styleObj = computed(() => { | ||
const style: Record<string, string> = {}; | ||
|
||
const url = iconsUrls[props.icon]; | ||
|
||
if (url) { | ||
style['--icon'] = `url('${url}')`; | ||
// Vite may transform SVG assets to data URLs, using single quotes for XML | ||
// attribute values for some reason. This means we can't always quote URLs | ||
// with single quotes, or the CSS value might be invalid. | ||
const quote = url.includes(`"`) ? `'` : `"`; | ||
style['--icon'] = `url(${quote}${url}${quote})`; | ||
Comment on lines
-16
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🌟 This is the fix. |
||
} else { | ||
style['visibility'] = 'hidden'; | ||
style['--error'] = `'${props.icon} not found'`; | ||
|
@@ -39,10 +43,12 @@ const styleObj = computed(() => { | |
flex: none; | ||
width: var(--size, 1em); | ||
height: var(--size, 1em); | ||
color: inherit; | ||
// Use SVG icon as mask for background | ||
-webkit-mask: var(--icon) center/contain no-repeat; | ||
mask: var(--icon) center/contain no-repeat; | ||
// Use inherited text color to paint a square | ||
background-color: currentColor; | ||
// Then use the SVG icon as mask | ||
mask-image: var(--icon); | ||
mask-position: center; | ||
mask-repeat: no-repeat; | ||
mask-size: contain; | ||
} | ||
</style> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
"markdown-it-footnote": "^3.0.3", | ||
"prettier": "^3.2.5", | ||
"sass": "^1.72.0", | ||
"vitepress": "~1.0.1" | ||
"vitepress": "~1.0.2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny VitePress update, picks up a fix for the mobile nav that doesn't affect us but is safe to have. |
||
}, | ||
"prettier": { | ||
"printWidth": 100, | ||
|
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.
Removing the
-webkit-mask
prefixes because:.browserslistrc
to narrow down our target browsers to Chrome 120+, Safari 15.4+ and Firefox 53+).