@300codes/design-system 1.2.5 → 1.2.7
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/README.md
CHANGED
|
@@ -138,12 +138,29 @@ cp -r node_modules/@300codes/design-system/public/icons public/
|
|
|
138
138
|
|
|
139
139
|
Available sizes: `2xs` · `xs` · `sm` · `md` · `lg` · `xl` · `2xl` · `3xl` · `auto`
|
|
140
140
|
|
|
141
|
-
By default icons are loaded from `/icons/{name}.svg`. If your icons live elsewhere, pass a custom `
|
|
141
|
+
By default icons are loaded from `/icons/{name}.svg`. If your icons live elsewhere, pass a custom `iconPath` prop:
|
|
142
142
|
|
|
143
143
|
```vue
|
|
144
|
-
<BaseIcon name="star"
|
|
144
|
+
<BaseIcon name="star" icon-path="/assets/icons" size="md" />
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
+
### SSR — server-side base directory
|
|
148
|
+
|
|
149
|
+
During SSR, `BaseIcon` reads SVG files directly from the filesystem. It looks in `public/` in dev and `_client/` in production builds (Astro default). If your framework uses a different output directory, set `DS_PUBLIC_PATH`:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Nuxt (files end up in .output/public/)
|
|
153
|
+
DS_PUBLIC_PATH=.output/public nuxt build
|
|
154
|
+
|
|
155
|
+
# Astro (default — _client/ is already the built-in default, no override needed)
|
|
156
|
+
# DS_PUBLIC_PATH=_client
|
|
157
|
+
|
|
158
|
+
# Custom deployment
|
|
159
|
+
DS_PUBLIC_PATH=dist/static astro build
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The variable is resolved by Vite at build time via `import.meta.env.DS_PUBLIC_PATH`.
|
|
163
|
+
|
|
147
164
|
---
|
|
148
165
|
|
|
149
166
|
## Storybook
|
package/package.json
CHANGED
|
@@ -15,11 +15,11 @@ const props = withDefaults(defineProps<BaseIconProps>(), {
|
|
|
15
15
|
|
|
16
16
|
const sizeClasses: Record<IconSize, string> = {
|
|
17
17
|
'2xs': 'w-3 min-w-3 h-3',
|
|
18
|
-
'xs':
|
|
19
|
-
'sm':
|
|
20
|
-
'md':
|
|
21
|
-
'lg':
|
|
22
|
-
'xl':
|
|
18
|
+
'xs': 'w-4 min-w-4 h-4',
|
|
19
|
+
'sm': 'w-5 min-w-5 h-5',
|
|
20
|
+
'md': 'w-6 min-w-6 h-6',
|
|
21
|
+
'lg': 'w-8 min-w-8 h-8',
|
|
22
|
+
'xl': 'w-10 min-w-10 h-10',
|
|
23
23
|
'2xl': 'w-12 min-w-12 h-12',
|
|
24
24
|
'3xl': 'w-16 min-w-16 h-16',
|
|
25
25
|
'auto': '',
|
|
@@ -30,7 +30,11 @@ const iconClasses = computed(() => sizeClasses[props.size]);
|
|
|
30
30
|
const svgHtml = ref('');
|
|
31
31
|
const spanRef = ref<HTMLElement | null>(null);
|
|
32
32
|
const isServer = typeof window === 'undefined';
|
|
33
|
-
const notFound =
|
|
33
|
+
const notFound =
|
|
34
|
+
'<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 256 256"><path d="M48,48V208H80a8,8,0,0,1,0,16H40a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8H80a8,8,0,0,1,0,16ZM216,32H176a8,8,0,0,0,0,16h32V208H176a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32Z"></path></svg>';
|
|
35
|
+
|
|
36
|
+
// DS_PUBLIC_PATH overrides the server-side base directory (e.g. _client for Astro, .output/public for Nuxt).
|
|
37
|
+
const serverBase = import.meta.env.PROD ? (import.meta.env.DS_PUBLIC_PATH || '_client') : 'public';
|
|
34
38
|
|
|
35
39
|
async function getSvgContent(name: string): Promise<string> {
|
|
36
40
|
const warnNotFound = () =>
|
|
@@ -41,7 +45,7 @@ async function getSvgContent(name: string): Promise<string> {
|
|
|
41
45
|
const fs = await import('fs/promises');
|
|
42
46
|
|
|
43
47
|
try {
|
|
44
|
-
const filePath = path.join(process.cwd(),
|
|
48
|
+
const filePath = path.join(process.cwd(), serverBase, props.iconPath, `${name}.svg`);
|
|
45
49
|
return await fs.readFile(filePath, 'utf8');
|
|
46
50
|
} catch {
|
|
47
51
|
warnNotFound();
|
|
@@ -69,7 +73,7 @@ watch(
|
|
|
69
73
|
() => props.name,
|
|
70
74
|
async (newName) => {
|
|
71
75
|
svgHtml.value = await getSvgContent(newName);
|
|
72
|
-
}
|
|
76
|
+
}
|
|
73
77
|
);
|
|
74
78
|
|
|
75
79
|
onMounted(async () => {
|
|
@@ -69,6 +69,7 @@ const emit = defineEmits<{
|
|
|
69
69
|
color: var(--baseTooltip-fg, #ffffff);
|
|
70
70
|
border-radius: var(--baseTooltip-radius, 0.5rem);
|
|
71
71
|
max-width: var(--baseTooltip-max-w, 12.25rem);
|
|
72
|
+
width: var(--baseTooltip-max-w, 12.25rem);
|
|
72
73
|
padding: var(--baseTooltip-py, 0.75rem) var(--baseTooltip-px, 0.75rem);
|
|
73
74
|
font-size: var(--baseTooltip-font-size, 0.75rem);
|
|
74
75
|
}
|