Skip to content
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

add static svg sprite sheet file #1763

Merged
merged 4 commits into from Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mighty-singers-prove.md
@@ -0,0 +1,5 @@
---
"@hashicorp/flight-icons": minor
---

Add static SVG sprite sheet file
dstaley marked this conversation as resolved.
Show resolved Hide resolved
Expand Up @@ -26,7 +26,16 @@ export async function generateBundleSVGSprite({ config, catalog } : { config: Co
const sprites = svgstore({
// see https://github.com/svgstore/svgstore#options for details
renameDefs: false, // we already create unique IDs (using the icon name) in the SVGO step
svgAttrs: { width: '0', height: '0', class: 'flight-sprite-container', 'aria-hidden': 'true' },
svgAttrs: {
width: '0',
height: '0',
// some browsers will not correctly render remote <use> references unless the remote document has the correct namespace
xmlns: "http://www.w3.org/2000/svg",
dstaley marked this conversation as resolved.
Show resolved Hide resolved
// Next.js expects there to be a viewBox attribute to calculate dimensions; while this isn't actually useful in the case of an SVG sprite, it does prevent Next.js from throwing an error about being unable to parse the file
viewBox: "0 0 0 0",
dstaley marked this conversation as resolved.
Show resolved Hide resolved
class: 'flight-sprite-container',
'aria-hidden': 'true'
},
});

// add the SVGs to the sprite
Expand All @@ -51,4 +60,11 @@ export async function generateBundleSVGSprite({ config, catalog } : { config: Co

// update the SVG "module"
await fs.writeFile(`${config.mainFolder}/svg-sprite/svg-sprite-module.js`, svgModuleContent);

let svgFileContent = '<!--\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n-->\n\n';
svgFileContent += '<!-- THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -->\n';
svgFileContent += `${svgSpriteContent}\n`;

// update the SVG file
await fs.writeFile(`${config.mainFolder}/svg-sprite/svg-sprite.svg`, svgFileContent);
}
2 changes: 1 addition & 1 deletion packages/flight-icons/svg-sprite/svg-sprite-module.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions packages/flight-icons/svg-sprite/svg-sprite.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.