Sfoglia il codice sorgente

fix: correct viewbox for svg spritesheet

Sv443 2 mesi fa
parent
commit
e7a6974858

File diff suppressed because it is too large
+ 10 - 10
assets/spritesheet.svg


+ 30 - 0
src/dev/snippets/svg_spritesheet_test.html

@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>SVG Spritesheet test</title>
+    <style>
+      body {
+        color: #f1f1f1;
+        background-color: #333;
+      }
+    </style>
+  </head>
+  <body>
+    <div>
+      SVG:
+      <svg height="24" width="24">
+        <use xlink:href="#bytm-svg-icon-advanced_mode"></use>
+      </svg>
+    </div>
+
+    <div id="bytm-svg-spritesheet-container" style="display: none;">
+      <svg xmlns="http://www.w3.org/2000/svg" id="bytm-svg-spritesheet">
+        <symbol id="bytm-svg-icon-advanced_mode">
+          <svg viewBox="0 -960 960 960" height="24" width="24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
+            <path fill="#ffffff" d="m 456.54655,-331.45728 h 46.9069 v -125.08927 h 125.08927 v -46.9069 H 503.45345 v -125.08927 h -46.9069 v 125.08927 H 331.45728 v 46.9069 h 125.08927 z m 23.50583,148.54349 q -61.63461,0 -115.86705,-23.39169 -54.23324,-23.39169 -94.35014,-63.49062 -40.11769,-40.0997 -63.51955,-94.3087 -23.40185,-54.20821 -23.40185,-115.84282 0,-61.63461 23.39169,-115.86705 23.39169,-54.23324 63.49062,-94.35014 40.0997,-40.11769 94.3087,-63.51955 54.20821,-23.40185 115.84282,-23.40185 61.63461,0 115.86705,23.39169 54.23324,23.39169 94.35014,63.49062 40.11769,40.0997 63.51955,94.3087 23.40185,54.20821 23.40185,115.84282 0,61.63461 -23.39169,115.86705 -23.39169,54.23324 -63.49062,94.35014 -40.0997,40.11769 -94.3087,63.51955 -54.20821,23.40185 -115.84282,23.40185 z M 480,-229.82148 q 104.76226,0 177.47039,-72.70813 72.70813,-72.70813 72.70813,-177.47039 0,-104.76226 -72.70813,-177.47039 Q 584.76226,-730.17852 480,-730.17852 q -104.76226,0 -177.47039,72.70813 -72.70813,72.70813 -72.70813,177.47039 0,104.76226 72.70813,177.47039 72.70813,72.70813 177.47039,72.70813 z M 480,-480 Z" style="stroke-width:0.781808" />
+          </svg>
+        </symbol>
+      </svg>
+    </div>
+  </body>
+</html>

+ 1 - 2
src/tools/post-build.ts

@@ -515,9 +515,8 @@ async function createSvgSpritesheet() {
 
       const iconPath = resolveResourcePath(typeof val === "string" ? val : val.path);
       const iconSvg = String(await readFile(iconPath)).replace(/\n/g, "");
-      const viewBox = iconSvg.match(/viewBox="([^"]+)"/)?.[1] ?? "0 0 24 24";
 
-      sprites.push(`<symbol id="bytm-svg-${name}" viewBox="${viewBox}">\n    ${iconSvg}\n  </symbol>`);
+      sprites.push(`<symbol id="bytm-svg-${name}">\n    ${iconSvg}\n  </symbol>`);
     }
 
     await writeFile(resolveResourcePath("spritesheet.svg"), `\

Some files were not shown because too many files changed in this diff