FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix home page icons by fvsch · Pull Request #219 · stackblitz/docs · GitHub

Fix home page icons - #219

Merged
donmckenna merged 2 commits into
mainfrom
fvsch/vitepress-1-0-fix-icon-urls
Apr 2, 2024
Merged

Fix home page icons#219
donmckenna merged 2 commits into
mainfrom
fvsch/vitepress-1-0-fix-icon-urls

Conversation

fvsch commented Apr 2, 2024

Copy link
Copy Markdown
Contributor

Our icons on the home page are working correctly in development mode, but not in the final build.

The icons end up as data URLs in the HTML build, with the SVG attributes quoted with single quotes (instead of double quotes in the source files). And we render those URLs with:

const style = `--icon: url('${url}');`

Which breaks when the url is something like:

data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20512%20512'%3e…%3c/svg%3e

I added some logic to use double quotes when the URL contains single quotes.

fvsch requested a review from donmckenna April 2, 2024 17:26

Copy link
Copy Markdown

Run & review this pull request in StackBlitz Codeflow.

Copy link
Copy Markdown

Run & review this pull request in StackBlitz Codeflow.

fvsch requested a review from sulco April 2, 2024 17:26

netlify Bot commented Apr 2, 2024
edited
Loading

Copy link
Copy Markdown

Deploy Preview for stackblitz-docs ready!

Name Link
🔨 Latest commit e3dd82f
🔍 Latest deploy log https://app.netlify.com/sites/stackblitz-docs/deploys/660c3fb1f7aa9d0008ecd86b
😎 Deploy Preview https://deploy-preview-219--stackblitz-docs.netlify.app
📱 Preview on mobile Toggle QR Code...



Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

&:not(.has-bg)::before {
-webkit-mask-size: 32px;
mask-size: 32px;
mask-size: 32px;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Removing the -webkit-mask prefixes because:

  • the unprefixed version finally shipped in Chrome 120 (current is 123);
  • also we have some autoprefixing going on that will add those prefixes at build time anyway (unless we go out of our way to add a .browserslistrc to narrow down our target browsers to Chrome 120+, Safari 15.4+ and Firefox 53+).

Comment on lines -16 to +20
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})`;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🌟 This is the fix.

Comment thread package.json
"prettier": "^3.2.5",
"sass": "^1.72.0",
"vitepress": "~1.0.1"
"vitepress": "~1.0.2"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Tiny VitePress update, picks up a fix for the mobile nav that doesn't affect us but is safe to have.

donmckenna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🙏

donmckenna merged commit 75c0a1c into main Apr 2, 2024
donmckenna deleted the fvsch/vitepress-1-0-fix-icon-urls branch April 2, 2024 17:33
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL