@stnd/icon 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/Icon.svelte +16 -5
- package/package.json +1 -1
- package/tokens.js +8 -0
package/CHANGELOG.md
CHANGED
package/Icon.svelte
CHANGED
|
@@ -25,6 +25,18 @@
|
|
|
25
25
|
return `/icons/${prefix}/${name}.svg`;
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
function formatDimension(dim) {
|
|
29
|
+
if (dim == null) return "1em";
|
|
30
|
+
const s = String(dim).trim();
|
|
31
|
+
if (/^\d+(\.\d+)?$/.test(s)) {
|
|
32
|
+
return `${s}px`;
|
|
33
|
+
}
|
|
34
|
+
return s;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let formattedWidth = $derived(formatDimension(width));
|
|
38
|
+
let formattedHeight = $derived(formatDimension(height));
|
|
39
|
+
|
|
28
40
|
let svgContent = $state(null);
|
|
29
41
|
|
|
30
42
|
$effect(() => {
|
|
@@ -74,7 +86,7 @@
|
|
|
74
86
|
{#if svgContent}
|
|
75
87
|
<span
|
|
76
88
|
class="stnd-icon {className}"
|
|
77
|
-
style="display: inline-flex; width:{
|
|
89
|
+
style="display: inline-flex; width:{formattedWidth}; height:{formattedHeight}; align-items: center; justify-content: center;"
|
|
78
90
|
role="img"
|
|
79
91
|
aria-hidden="true"
|
|
80
92
|
{...props}
|
|
@@ -84,7 +96,7 @@
|
|
|
84
96
|
{:else if src}
|
|
85
97
|
<img
|
|
86
98
|
{src}
|
|
87
|
-
style="width:{
|
|
99
|
+
style="width:{formattedWidth};height:{formattedHeight};"
|
|
88
100
|
class="stnd-icon {className}"
|
|
89
101
|
aria-hidden="true"
|
|
90
102
|
alt=""
|
|
@@ -92,13 +104,12 @@
|
|
|
92
104
|
/>
|
|
93
105
|
{/if}
|
|
94
106
|
|
|
95
|
-
|
|
107
|
+
<style>
|
|
96
108
|
span.stnd-icon :global(svg) {
|
|
97
109
|
width: 100%;
|
|
98
110
|
height: 100%;
|
|
99
111
|
max-width: 100%;
|
|
100
112
|
max-height: 100%;
|
|
101
|
-
fill: currentColor;
|
|
102
113
|
display: block;
|
|
103
114
|
}
|
|
104
|
-
</style
|
|
115
|
+
</style>
|
package/package.json
CHANGED
package/tokens.js
CHANGED
|
@@ -26,6 +26,14 @@ export const tokens = {
|
|
|
26
26
|
|
|
27
27
|
users: "ph:users",
|
|
28
28
|
|
|
29
|
+
// ── Garden & Launcher ───────────────────────────────────────
|
|
30
|
+
mycelium: "ph:graph",
|
|
31
|
+
daily: "ph:calendar",
|
|
32
|
+
random: "ph:shuffle",
|
|
33
|
+
standard: "ph:scroll",
|
|
34
|
+
documentations: "ph:books",
|
|
35
|
+
highlight: "ph:highlighter",
|
|
36
|
+
|
|
29
37
|
// ── Items ─────────────────────────────────────────────────
|
|
30
38
|
book: "ph:book",
|
|
31
39
|
"book-open": "ph:book-open",
|