-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #442 from ably/add-pubsub-icons
[WEB-3878] Add icons for pubsub, bump to Storybook 8.2.9
- Loading branch information
Showing
68 changed files
with
1,444 additions
and
1,839 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const svgSprite = require("svg-sprite"); | ||
|
||
// Configuration for svg-sprite | ||
const config = { | ||
dest: "dist/core", | ||
mode: { | ||
symbol: { | ||
inline: true, | ||
sprite: "../sprites", | ||
}, | ||
}, | ||
shape: { | ||
id: { | ||
generator: "sprite-%s", | ||
}, | ||
}, | ||
svg: { | ||
transform: [ | ||
function (svg) { | ||
let globalDefs = ""; | ||
|
||
return svg | ||
.replace(/<defs>(.+?)<\/defs>/g, (_match, def) => { | ||
globalDefs += def; | ||
}) | ||
.replace("<symbol", `<defs>${globalDefs}</defs><symbol`); | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
// Create a new SVG sprite instance | ||
const sprite = new svgSprite(config); | ||
|
||
// Directory where your individual SVG files are located | ||
const svgDir = path.resolve(__dirname, "src/core/icons"); | ||
|
||
// Read all SVG files from the directory and add them to the sprite | ||
fs.readdirSync(svgDir).forEach((file) => { | ||
if (file.endsWith(".svg")) { | ||
sprite.add( | ||
path.resolve(svgDir, file), | ||
null, | ||
fs.readFileSync(path.resolve(svgDir, file), "utf-8"), | ||
); | ||
} | ||
}); | ||
|
||
// Compile the sprite | ||
sprite.compile((err, result) => { | ||
if (err) { | ||
console.error("Error generating SVG sprite:", err); | ||
} else { | ||
// Write the compiled sprite to the destination directory | ||
fs.mkdirSync(path.resolve(__dirname, "dist/core"), { recursive: true }); | ||
fs.writeFileSync( | ||
path.resolve(__dirname, "dist", result.symbol.sprite.path), | ||
result.symbol.sprite.contents, | ||
); | ||
console.log("SVG sprite generated successfully!"); | ||
} | ||
}); |
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.