storybook-addon-design-system-docs 1.0.0 → 1.0.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/README.md +143 -15
- package/dist/TypographySection-D8HHJr-s.d.ts +258 -0
- package/dist/TypographySection-DsqZs5oA.d.cts +258 -0
- package/dist/TypographySection-c6k_4ZVC.d.ts +258 -0
- package/dist/TypographySection-lyEjSYKu.d.cts +258 -0
- package/dist/assets.cjs +9 -0
- package/dist/assets.cjs.map +1 -0
- package/dist/assets.d.cts +28 -0
- package/dist/assets.d.ts +28 -0
- package/dist/assets.js +7 -0
- package/dist/assets.js.map +1 -0
- package/dist/components/assets/index.cjs +634 -0
- package/dist/components/assets/index.cjs.map +1 -0
- package/dist/components/assets/index.d.cts +150 -0
- package/dist/components/assets/index.d.ts +150 -0
- package/dist/components/assets/index.js +604 -0
- package/dist/components/assets/index.js.map +1 -0
- package/dist/components/primitives/index.cjs +963 -0
- package/dist/components/primitives/index.cjs.map +1 -0
- package/dist/components/primitives/index.d.cts +194 -0
- package/dist/components/primitives/index.d.ts +194 -0
- package/dist/components/primitives/index.js +905 -0
- package/dist/components/primitives/index.js.map +1 -0
- package/dist/index.cjs +8695 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +136 -0
- package/dist/index.d.ts +136 -0
- package/dist/index.js +8639 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-runtime.d-kG9JzmQF.d.cts +15239 -0
- package/dist/jsx-runtime.d-kG9JzmQF.d.ts +15239 -0
- package/dist/manager.js +2 -2
- package/dist/manager.js.map +1 -0
- package/dist/preset.cjs +8185 -172
- package/dist/preset.cjs.map +1 -0
- package/dist/preset.js +8187 -8
- package/dist/preset.js.map +1 -0
- package/dist/types-BVOYHsBN.d.cts +178 -0
- package/dist/types-BVOYHsBN.d.ts +178 -0
- package/package.json +141 -143
- package/templates/spacing.mdx +1 -1
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var theming = require('storybook/theming');
|
|
6
|
+
|
|
7
|
+
// src/addon/components/assets/AssetSection.tsx
|
|
8
|
+
function CheckerboardIcon() {
|
|
9
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10
|
+
"svg",
|
|
11
|
+
{
|
|
12
|
+
viewBox: "0 0 16 16",
|
|
13
|
+
fill: "currentColor",
|
|
14
|
+
role: "img",
|
|
15
|
+
"aria-label": "Checkerboard background",
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: "Checkerboard background" }),
|
|
18
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 0h4v4H0V0zm4 4h4v4H4V4zm4-4h4v4H8V0zm4 4h4v4h-4V4zM0 8h4v4H0V8zm8 0h4v4H8V8zm-4 4h4v4H4v-4zm8 0h4v4h-4v-4z" })
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
function InverseIcon() {
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
25
|
+
"svg",
|
|
26
|
+
{
|
|
27
|
+
viewBox: "0 0 16 16",
|
|
28
|
+
fill: "currentColor",
|
|
29
|
+
role: "img",
|
|
30
|
+
"aria-label": "Inverse background",
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: "Inverse background" }),
|
|
33
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
34
|
+
"circle",
|
|
35
|
+
{
|
|
36
|
+
cx: "8",
|
|
37
|
+
cy: "8",
|
|
38
|
+
r: "7",
|
|
39
|
+
fill: "none",
|
|
40
|
+
stroke: "currentColor",
|
|
41
|
+
strokeWidth: "1.5"
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 1a7 7 0 0 1 0 14V1z" })
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
function ResetIcon() {
|
|
50
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 16 16", fill: "currentColor", role: "img", "aria-label": "Reset", children: [
|
|
51
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: "Reset" }),
|
|
52
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z" }),
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466z" })
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
var Wrapper = theming.styled.div(({ theme }) => ({
|
|
57
|
+
background: theme.background?.content || "#ffffff",
|
|
58
|
+
minHeight: "100vh",
|
|
59
|
+
padding: "40px 20px",
|
|
60
|
+
boxSizing: "border-box"
|
|
61
|
+
}));
|
|
62
|
+
var Container = theming.styled.div({
|
|
63
|
+
maxWidth: "1200px",
|
|
64
|
+
margin: "0 auto"
|
|
65
|
+
});
|
|
66
|
+
var Title = theming.styled.h1(({ theme }) => ({
|
|
67
|
+
fontFamily: theme.typography?.fonts?.base || "sans-serif",
|
|
68
|
+
fontSize: "32px",
|
|
69
|
+
fontWeight: 700,
|
|
70
|
+
color: theme.color?.defaultText || "#333333",
|
|
71
|
+
marginBottom: "8px",
|
|
72
|
+
marginTop: 0
|
|
73
|
+
}));
|
|
74
|
+
var Description = theming.styled.p(({ theme }) => ({
|
|
75
|
+
fontFamily: theme.typography?.fonts?.base || "sans-serif",
|
|
76
|
+
fontSize: "16px",
|
|
77
|
+
color: theme.color?.defaultText || "#333333",
|
|
78
|
+
opacity: 0.8,
|
|
79
|
+
marginBottom: "24px",
|
|
80
|
+
marginTop: 0
|
|
81
|
+
}));
|
|
82
|
+
var ControlsBar = theming.styled.div({
|
|
83
|
+
display: "flex",
|
|
84
|
+
gap: "16px",
|
|
85
|
+
marginBottom: "32px",
|
|
86
|
+
flexWrap: "wrap",
|
|
87
|
+
alignItems: "center"
|
|
88
|
+
});
|
|
89
|
+
var SearchInput = theming.styled.input(({ theme }) => ({
|
|
90
|
+
flex: "1 1 300px",
|
|
91
|
+
maxWidth: "400px",
|
|
92
|
+
padding: "10px 14px",
|
|
93
|
+
fontSize: "14px",
|
|
94
|
+
border: `1px solid ${theme.appBorderColor || "#eaeaea"}`,
|
|
95
|
+
borderRadius: "6px",
|
|
96
|
+
color: theme.color?.defaultText || "#333333",
|
|
97
|
+
background: theme.background?.content || "#ffffff",
|
|
98
|
+
outline: "none",
|
|
99
|
+
transition: "border-color 0.2s, box-shadow 0.2s",
|
|
100
|
+
"&:focus": {
|
|
101
|
+
borderColor: theme.color?.secondary || "#0271b6",
|
|
102
|
+
boxShadow: `0 0 0 2px ${theme.color?.secondary || "#0271b6"}22`
|
|
103
|
+
},
|
|
104
|
+
"&::placeholder": {
|
|
105
|
+
color: theme.color?.defaultText || "#333333",
|
|
106
|
+
opacity: 0.5
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
var VariantToggle = theming.styled.button(({ theme }) => ({
|
|
110
|
+
padding: "10px 16px",
|
|
111
|
+
fontSize: "14px",
|
|
112
|
+
fontWeight: 500,
|
|
113
|
+
border: `1px solid ${theme.appBorderColor || "#eaeaea"}`,
|
|
114
|
+
borderRadius: "6px",
|
|
115
|
+
cursor: "pointer",
|
|
116
|
+
background: theme.background?.content || "#ffffff",
|
|
117
|
+
color: theme.color?.defaultText || "#333333",
|
|
118
|
+
transition: "all 0.2s",
|
|
119
|
+
"&:hover": {
|
|
120
|
+
borderColor: theme.color?.secondary || "#0271b6",
|
|
121
|
+
background: theme.background?.hoverable || "#f5f5f5"
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
124
|
+
var BackgroundControls = theming.styled.div({
|
|
125
|
+
display: "flex",
|
|
126
|
+
alignItems: "center",
|
|
127
|
+
gap: "12px",
|
|
128
|
+
marginLeft: "auto"
|
|
129
|
+
});
|
|
130
|
+
var BackgroundToggle = theming.styled.div(({ theme }) => ({
|
|
131
|
+
display: "flex",
|
|
132
|
+
alignItems: "center",
|
|
133
|
+
gap: "6px",
|
|
134
|
+
padding: "4px",
|
|
135
|
+
border: `1px solid ${theme.appBorderColor || "#eaeaea"}`,
|
|
136
|
+
borderRadius: "6px",
|
|
137
|
+
background: theme.background?.content || "#ffffff"
|
|
138
|
+
}));
|
|
139
|
+
var ToggleOption = theming.styled.button(({ theme }) => ({
|
|
140
|
+
display: "flex",
|
|
141
|
+
alignItems: "center",
|
|
142
|
+
justifyContent: "center",
|
|
143
|
+
width: "28px",
|
|
144
|
+
height: "28px",
|
|
145
|
+
border: "none",
|
|
146
|
+
borderRadius: "4px",
|
|
147
|
+
cursor: "pointer",
|
|
148
|
+
background: "transparent",
|
|
149
|
+
color: theme.color?.defaultText || "#333333",
|
|
150
|
+
opacity: 0.5,
|
|
151
|
+
transition: "all 0.15s",
|
|
152
|
+
'&[data-active="true"]': {
|
|
153
|
+
background: theme.color?.secondary || "#0271b6",
|
|
154
|
+
color: "#fff",
|
|
155
|
+
opacity: 1
|
|
156
|
+
},
|
|
157
|
+
'&:hover:not([data-active="true"])': {
|
|
158
|
+
opacity: 0.8,
|
|
159
|
+
background: theme.background?.hoverable || "#f5f5f5"
|
|
160
|
+
},
|
|
161
|
+
"& svg": {
|
|
162
|
+
width: "16px",
|
|
163
|
+
height: "16px"
|
|
164
|
+
}
|
|
165
|
+
}));
|
|
166
|
+
var ColorPickerGroup = theming.styled.div(({ theme }) => ({
|
|
167
|
+
display: "flex",
|
|
168
|
+
alignItems: "center",
|
|
169
|
+
gap: "4px",
|
|
170
|
+
padding: "4px 6px",
|
|
171
|
+
border: `1px solid ${theme.appBorderColor || "#eaeaea"}`,
|
|
172
|
+
borderRadius: "6px",
|
|
173
|
+
background: theme.background?.content || "#ffffff",
|
|
174
|
+
transition: "border-color 0.2s",
|
|
175
|
+
"&:focus-within": {
|
|
176
|
+
borderColor: theme.color?.secondary || "#0271b6"
|
|
177
|
+
}
|
|
178
|
+
}));
|
|
179
|
+
var ColorLabel = theming.styled.span(({ theme }) => ({
|
|
180
|
+
fontFamily: theme.typography?.fonts?.base || "sans-serif",
|
|
181
|
+
fontSize: "11px",
|
|
182
|
+
color: theme.color?.defaultText || "#333333",
|
|
183
|
+
opacity: 0.6,
|
|
184
|
+
textTransform: "uppercase",
|
|
185
|
+
letterSpacing: "0.5px"
|
|
186
|
+
}));
|
|
187
|
+
var ColorInput = theming.styled.input({
|
|
188
|
+
width: "24px",
|
|
189
|
+
height: "24px",
|
|
190
|
+
padding: 0,
|
|
191
|
+
border: "none",
|
|
192
|
+
borderRadius: "4px",
|
|
193
|
+
cursor: "pointer",
|
|
194
|
+
background: "transparent",
|
|
195
|
+
"&::-webkit-color-swatch-wrapper": {
|
|
196
|
+
padding: 0
|
|
197
|
+
},
|
|
198
|
+
"&::-webkit-color-swatch": {
|
|
199
|
+
border: "none",
|
|
200
|
+
borderRadius: "4px"
|
|
201
|
+
},
|
|
202
|
+
"&::-moz-color-swatch": {
|
|
203
|
+
border: "none",
|
|
204
|
+
borderRadius: "4px"
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
var ResetButton = theming.styled.button(({ theme }) => ({
|
|
208
|
+
display: "flex",
|
|
209
|
+
alignItems: "center",
|
|
210
|
+
justifyContent: "center",
|
|
211
|
+
width: "20px",
|
|
212
|
+
height: "20px",
|
|
213
|
+
padding: 0,
|
|
214
|
+
border: "none",
|
|
215
|
+
borderRadius: "4px",
|
|
216
|
+
cursor: "pointer",
|
|
217
|
+
background: "transparent",
|
|
218
|
+
color: theme.color?.defaultText || "#333333",
|
|
219
|
+
opacity: 0.4,
|
|
220
|
+
transition: "all 0.15s",
|
|
221
|
+
"&:hover": {
|
|
222
|
+
opacity: 1,
|
|
223
|
+
background: theme.background?.hoverable || "#f5f5f5"
|
|
224
|
+
},
|
|
225
|
+
"& svg": {
|
|
226
|
+
width: "12px",
|
|
227
|
+
height: "12px"
|
|
228
|
+
}
|
|
229
|
+
}));
|
|
230
|
+
var AssetCard = theming.styled.div(({ theme }) => ({
|
|
231
|
+
display: "flex",
|
|
232
|
+
flexDirection: "column",
|
|
233
|
+
alignItems: "center",
|
|
234
|
+
padding: "16px",
|
|
235
|
+
borderRadius: "8px",
|
|
236
|
+
border: `1px solid ${theme.appBorderColor || "#eaeaea"}`,
|
|
237
|
+
background: theme.background?.content || "#ffffff",
|
|
238
|
+
transition: "all 0.2s",
|
|
239
|
+
cursor: "pointer",
|
|
240
|
+
"&:hover": {
|
|
241
|
+
borderColor: theme.color?.secondary || "#0271b6",
|
|
242
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.1)"
|
|
243
|
+
}
|
|
244
|
+
}));
|
|
245
|
+
var AssetPreview = theming.styled.div({
|
|
246
|
+
width: "var(--preview-size, 200px)",
|
|
247
|
+
height: "var(--preview-size, 200px)",
|
|
248
|
+
display: "flex",
|
|
249
|
+
alignItems: "center",
|
|
250
|
+
justifyContent: "center",
|
|
251
|
+
marginBottom: "12px",
|
|
252
|
+
borderRadius: "4px"
|
|
253
|
+
});
|
|
254
|
+
var AssetImage = theming.styled.img({
|
|
255
|
+
maxWidth: "100%",
|
|
256
|
+
maxHeight: "100%",
|
|
257
|
+
objectFit: "contain"
|
|
258
|
+
});
|
|
259
|
+
var AssetName = theming.styled.div(({ theme }) => ({
|
|
260
|
+
fontFamily: theme.typography?.fonts?.base || "sans-serif",
|
|
261
|
+
fontSize: "13px",
|
|
262
|
+
fontWeight: 500,
|
|
263
|
+
color: theme.color?.defaultText || "#333333",
|
|
264
|
+
textAlign: "center",
|
|
265
|
+
wordBreak: "break-word",
|
|
266
|
+
lineHeight: 1.3
|
|
267
|
+
}));
|
|
268
|
+
var AssetFilename = theming.styled.div(({ theme }) => ({
|
|
269
|
+
fontFamily: theme.typography?.fonts?.mono || "monospace",
|
|
270
|
+
fontSize: "11px",
|
|
271
|
+
color: theme.color?.defaultText || "#333333",
|
|
272
|
+
opacity: 0.6,
|
|
273
|
+
textAlign: "center",
|
|
274
|
+
marginTop: "4px"
|
|
275
|
+
}));
|
|
276
|
+
var CopyButtons = theming.styled.div({
|
|
277
|
+
display: "flex",
|
|
278
|
+
gap: "8px",
|
|
279
|
+
marginTop: "8px",
|
|
280
|
+
opacity: 0,
|
|
281
|
+
transition: "opacity 0.2s",
|
|
282
|
+
".asset-card:hover &": {
|
|
283
|
+
opacity: 1
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
var CopyButton = theming.styled.button(({ theme }) => ({
|
|
287
|
+
padding: "4px 8px",
|
|
288
|
+
fontSize: "11px",
|
|
289
|
+
border: `1px solid ${theme.appBorderColor || "#eaeaea"}`,
|
|
290
|
+
borderRadius: "4px",
|
|
291
|
+
cursor: "pointer",
|
|
292
|
+
background: theme.background?.content || "#ffffff",
|
|
293
|
+
color: theme.color?.defaultText || "#333333",
|
|
294
|
+
transition: "all 0.15s",
|
|
295
|
+
"&:hover": {
|
|
296
|
+
background: theme.color?.secondary || "#0271b6",
|
|
297
|
+
color: "#fff",
|
|
298
|
+
borderColor: theme.color?.secondary || "#0271b6"
|
|
299
|
+
}
|
|
300
|
+
}));
|
|
301
|
+
var NoResults = theming.styled.div(({ theme }) => ({
|
|
302
|
+
fontFamily: theme.typography?.fonts?.base || "sans-serif",
|
|
303
|
+
fontSize: "16px",
|
|
304
|
+
color: theme.color?.defaultText || "#333333",
|
|
305
|
+
opacity: 0.6,
|
|
306
|
+
textAlign: "center",
|
|
307
|
+
padding: "60px 20px"
|
|
308
|
+
}));
|
|
309
|
+
var FolderSection = theming.styled.div({
|
|
310
|
+
marginBottom: "48px"
|
|
311
|
+
});
|
|
312
|
+
var FolderTitle = theming.styled.h2(({ theme }) => ({
|
|
313
|
+
fontFamily: theme.typography?.fonts?.base || "sans-serif",
|
|
314
|
+
fontSize: "20px",
|
|
315
|
+
fontWeight: 600,
|
|
316
|
+
color: theme.color?.defaultText || "#333333",
|
|
317
|
+
marginBottom: "16px",
|
|
318
|
+
marginTop: 0,
|
|
319
|
+
paddingBottom: "8px",
|
|
320
|
+
borderBottom: `1px solid ${theme.appBorderColor || "#eaeaea"}`
|
|
321
|
+
}));
|
|
322
|
+
var Toast = theming.styled.div(({ theme }) => ({
|
|
323
|
+
position: "fixed",
|
|
324
|
+
bottom: "24px",
|
|
325
|
+
right: "24px",
|
|
326
|
+
padding: "12px 20px",
|
|
327
|
+
background: theme.color?.positive || "#44bb44",
|
|
328
|
+
color: "#fff",
|
|
329
|
+
borderRadius: "8px",
|
|
330
|
+
fontSize: "14px",
|
|
331
|
+
fontWeight: 500,
|
|
332
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
|
|
333
|
+
zIndex: 1e3,
|
|
334
|
+
animation: "fadeInUp 0.3s ease"
|
|
335
|
+
}));
|
|
336
|
+
function AssetSection({
|
|
337
|
+
title,
|
|
338
|
+
description,
|
|
339
|
+
assets,
|
|
340
|
+
groupByFolder,
|
|
341
|
+
variants,
|
|
342
|
+
copy,
|
|
343
|
+
display,
|
|
344
|
+
storageKeyPrefix
|
|
345
|
+
}) {
|
|
346
|
+
const DEFAULT_LIGHT_BG = "#eeeeee";
|
|
347
|
+
const DEFAULT_DARK_BG = "#181818";
|
|
348
|
+
const STORAGE_KEY_LIGHT = `${storageKeyPrefix}-light`;
|
|
349
|
+
const STORAGE_KEY_DARK = `${storageKeyPrefix}-dark`;
|
|
350
|
+
const STORAGE_KEY_MODE = `${storageKeyPrefix}-mode`;
|
|
351
|
+
const getStoredValue = (key, defaultValue) => {
|
|
352
|
+
try {
|
|
353
|
+
const stored = localStorage.getItem(key);
|
|
354
|
+
return stored !== null ? stored : defaultValue;
|
|
355
|
+
} catch {
|
|
356
|
+
return defaultValue;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
const setStoredValue = (key, value) => {
|
|
360
|
+
try {
|
|
361
|
+
localStorage.setItem(key, value);
|
|
362
|
+
} catch {
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
const removeStoredValue = (key) => {
|
|
366
|
+
try {
|
|
367
|
+
localStorage.removeItem(key);
|
|
368
|
+
} catch {
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const [searchTerm, setSearchTerm] = react.useState("");
|
|
372
|
+
const [currentVariant, setCurrentVariant] = react.useState(variants.defaultVariant);
|
|
373
|
+
const [toastMessage, setToastMessage] = react.useState(null);
|
|
374
|
+
const [bgMode, setBgMode] = react.useState(
|
|
375
|
+
() => getStoredValue(STORAGE_KEY_MODE, "checkered")
|
|
376
|
+
);
|
|
377
|
+
const [lightBgColor, setLightBgColor] = react.useState(
|
|
378
|
+
() => getStoredValue(STORAGE_KEY_LIGHT, DEFAULT_LIGHT_BG)
|
|
379
|
+
);
|
|
380
|
+
const [darkBgColor, setDarkBgColor] = react.useState(
|
|
381
|
+
() => getStoredValue(STORAGE_KEY_DARK, DEFAULT_DARK_BG)
|
|
382
|
+
);
|
|
383
|
+
const handleBgModeChange = (mode) => {
|
|
384
|
+
setBgMode(mode);
|
|
385
|
+
setStoredValue(STORAGE_KEY_MODE, mode);
|
|
386
|
+
};
|
|
387
|
+
const handleLightBgChange = (color) => {
|
|
388
|
+
setLightBgColor(color);
|
|
389
|
+
setStoredValue(STORAGE_KEY_LIGHT, color);
|
|
390
|
+
};
|
|
391
|
+
const handleDarkBgChange = (color) => {
|
|
392
|
+
setDarkBgColor(color);
|
|
393
|
+
setStoredValue(STORAGE_KEY_DARK, color);
|
|
394
|
+
};
|
|
395
|
+
const resetLightBg = () => {
|
|
396
|
+
setLightBgColor(DEFAULT_LIGHT_BG);
|
|
397
|
+
removeStoredValue(STORAGE_KEY_LIGHT);
|
|
398
|
+
};
|
|
399
|
+
const resetDarkBg = () => {
|
|
400
|
+
setDarkBgColor(DEFAULT_DARK_BG);
|
|
401
|
+
removeStoredValue(STORAGE_KEY_DARK);
|
|
402
|
+
};
|
|
403
|
+
const isLightVariant = currentVariant === "light";
|
|
404
|
+
const getPreviewBackground = () => {
|
|
405
|
+
if (bgMode === "checkered") {
|
|
406
|
+
return "repeating-conic-gradient(#e0e0e0 0% 25%, #ffffff 0% 50%) 50% / 16px 16px";
|
|
407
|
+
}
|
|
408
|
+
return isLightVariant ? darkBgColor : lightBgColor;
|
|
409
|
+
};
|
|
410
|
+
const showToast = (message) => {
|
|
411
|
+
setToastMessage(message);
|
|
412
|
+
setTimeout(() => setToastMessage(null), 2e3);
|
|
413
|
+
};
|
|
414
|
+
const copyToClipboard = (text, type) => {
|
|
415
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
416
|
+
showToast(`${type} copied to clipboard!`);
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
const getImportPath = (asset) => {
|
|
420
|
+
if (!copy.import) return "";
|
|
421
|
+
return copy.import.replace(/\{\{name\}\}/g, asset.id).replace(/\{\{ext\}\}/g, asset.ext).replace(/\{\{path\}\}/g, asset.relativePath).replace(/\{\{basename\}\}/g, `${asset.filename}.${asset.ext}`);
|
|
422
|
+
};
|
|
423
|
+
const getComponentUsage = (asset) => {
|
|
424
|
+
if (!copy.component) return "";
|
|
425
|
+
return copy.component.replace(/\{\{name\}\}/g, asset.id).replace(/\{\{ext\}\}/g, asset.ext).replace(/\{\{path\}\}/g, asset.relativePath).replace(/\{\{basename\}\}/g, `${asset.filename}.${asset.ext}`);
|
|
426
|
+
};
|
|
427
|
+
const filteredAssets = react.useMemo(() => {
|
|
428
|
+
if (!searchTerm.trim()) return assets;
|
|
429
|
+
const term = searchTerm.toLowerCase();
|
|
430
|
+
return assets.filter(
|
|
431
|
+
(asset) => asset.name.toLowerCase().includes(term) || asset.filename.toLowerCase().includes(term)
|
|
432
|
+
);
|
|
433
|
+
}, [assets, searchTerm]);
|
|
434
|
+
const groupedAssets = react.useMemo(() => {
|
|
435
|
+
if (!groupByFolder) return /* @__PURE__ */ new Map();
|
|
436
|
+
const groups = /* @__PURE__ */ new Map();
|
|
437
|
+
for (const asset of filteredAssets) {
|
|
438
|
+
const folder = asset.folder || "root";
|
|
439
|
+
if (!groups.has(folder)) {
|
|
440
|
+
groups.set(folder, []);
|
|
441
|
+
}
|
|
442
|
+
groups.get(folder).push(asset);
|
|
443
|
+
}
|
|
444
|
+
return groups;
|
|
445
|
+
}, [filteredAssets, groupByFolder]);
|
|
446
|
+
const renderAsset = (asset) => {
|
|
447
|
+
const imageSrc = currentVariant === "dark" && asset.variants.dark ? asset.variants.dark : asset.variants.light;
|
|
448
|
+
const hasCopyAction = copy.import || copy.component;
|
|
449
|
+
const copyType = copy.import ? "Import" : "Component";
|
|
450
|
+
const copyText = copy.import ? getImportPath(asset) : getComponentUsage(asset);
|
|
451
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
452
|
+
AssetCard,
|
|
453
|
+
{
|
|
454
|
+
className: "asset-card",
|
|
455
|
+
onClick: () => hasCopyAction && copyToClipboard(copyText, copyType),
|
|
456
|
+
children: [
|
|
457
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
458
|
+
AssetPreview,
|
|
459
|
+
{
|
|
460
|
+
style: {
|
|
461
|
+
width: `${display.previewSize}px`,
|
|
462
|
+
height: `${display.previewSize}px`,
|
|
463
|
+
background: getPreviewBackground()
|
|
464
|
+
},
|
|
465
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(AssetImage, { src: imageSrc, alt: asset.name })
|
|
466
|
+
}
|
|
467
|
+
),
|
|
468
|
+
/* @__PURE__ */ jsxRuntime.jsx(AssetName, { children: asset.name }),
|
|
469
|
+
display.showFilename && /* @__PURE__ */ jsxRuntime.jsxs(AssetFilename, { children: [
|
|
470
|
+
asset.filename,
|
|
471
|
+
".",
|
|
472
|
+
asset.ext
|
|
473
|
+
] }),
|
|
474
|
+
hasCopyAction && /* @__PURE__ */ jsxRuntime.jsx(CopyButtons, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
475
|
+
CopyButton,
|
|
476
|
+
{
|
|
477
|
+
onClick: (e) => {
|
|
478
|
+
e.stopPropagation();
|
|
479
|
+
copyToClipboard(copyText, copyType);
|
|
480
|
+
},
|
|
481
|
+
children: copyType
|
|
482
|
+
}
|
|
483
|
+
) })
|
|
484
|
+
]
|
|
485
|
+
},
|
|
486
|
+
asset.id
|
|
487
|
+
);
|
|
488
|
+
};
|
|
489
|
+
const renderGroupedAssets = () => {
|
|
490
|
+
const entries = Array.from(groupedAssets.entries());
|
|
491
|
+
return entries.map(([folder, assets2]) => /* @__PURE__ */ jsxRuntime.jsxs(FolderSection, { children: [
|
|
492
|
+
/* @__PURE__ */ jsxRuntime.jsx(FolderTitle, { children: folder === "root" ? "Root" : folder }),
|
|
493
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
494
|
+
"div",
|
|
495
|
+
{
|
|
496
|
+
style: {
|
|
497
|
+
display: "grid",
|
|
498
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${display.previewSize + 40}px, 1fr))`,
|
|
499
|
+
gap: "24px"
|
|
500
|
+
},
|
|
501
|
+
children: assets2.map(renderAsset)
|
|
502
|
+
}
|
|
503
|
+
)
|
|
504
|
+
] }, folder));
|
|
505
|
+
};
|
|
506
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Wrapper, { children: /* @__PURE__ */ jsxRuntime.jsxs(Container, { children: [
|
|
507
|
+
/* @__PURE__ */ jsxRuntime.jsx(Title, { children: title }),
|
|
508
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(Description, { children: description }),
|
|
509
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ControlsBar, { children: [
|
|
510
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
511
|
+
SearchInput,
|
|
512
|
+
{
|
|
513
|
+
value: searchTerm,
|
|
514
|
+
onChange: (e) => setSearchTerm(e.target.value),
|
|
515
|
+
placeholder: `Search ${title.toLowerCase()}...`
|
|
516
|
+
}
|
|
517
|
+
),
|
|
518
|
+
variants.enabled && /* @__PURE__ */ jsxRuntime.jsx(
|
|
519
|
+
VariantToggle,
|
|
520
|
+
{
|
|
521
|
+
onClick: () => setCurrentVariant((v) => v === "light" ? "dark" : "light"),
|
|
522
|
+
children: currentVariant === "light" ? "Light" : "Dark"
|
|
523
|
+
}
|
|
524
|
+
),
|
|
525
|
+
/* @__PURE__ */ jsxRuntime.jsxs(BackgroundControls, { children: [
|
|
526
|
+
/* @__PURE__ */ jsxRuntime.jsxs(BackgroundToggle, { children: [
|
|
527
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
528
|
+
ToggleOption,
|
|
529
|
+
{
|
|
530
|
+
"data-active": bgMode === "inverse",
|
|
531
|
+
onClick: () => handleBgModeChange("inverse"),
|
|
532
|
+
title: "Inverse background",
|
|
533
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(InverseIcon, {})
|
|
534
|
+
}
|
|
535
|
+
),
|
|
536
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
537
|
+
ToggleOption,
|
|
538
|
+
{
|
|
539
|
+
"data-active": bgMode === "checkered",
|
|
540
|
+
onClick: () => handleBgModeChange("checkered"),
|
|
541
|
+
title: "Checkered background",
|
|
542
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CheckerboardIcon, {})
|
|
543
|
+
}
|
|
544
|
+
)
|
|
545
|
+
] }),
|
|
546
|
+
bgMode === "inverse" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
547
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ColorPickerGroup, { children: [
|
|
548
|
+
/* @__PURE__ */ jsxRuntime.jsx(ColorLabel, { children: "Light" }),
|
|
549
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
550
|
+
ColorInput,
|
|
551
|
+
{
|
|
552
|
+
type: "color",
|
|
553
|
+
value: lightBgColor,
|
|
554
|
+
onChange: (e) => handleLightBgChange(e.target.value),
|
|
555
|
+
title: "Background for dark illustrations"
|
|
556
|
+
}
|
|
557
|
+
),
|
|
558
|
+
lightBgColor !== DEFAULT_LIGHT_BG && /* @__PURE__ */ jsxRuntime.jsx(
|
|
559
|
+
ResetButton,
|
|
560
|
+
{
|
|
561
|
+
onClick: resetLightBg,
|
|
562
|
+
title: "Reset to default",
|
|
563
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ResetIcon, {})
|
|
564
|
+
}
|
|
565
|
+
)
|
|
566
|
+
] }),
|
|
567
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ColorPickerGroup, { children: [
|
|
568
|
+
/* @__PURE__ */ jsxRuntime.jsx(ColorLabel, { children: "Dark" }),
|
|
569
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
+
ColorInput,
|
|
571
|
+
{
|
|
572
|
+
type: "color",
|
|
573
|
+
value: darkBgColor,
|
|
574
|
+
onChange: (e) => handleDarkBgChange(e.target.value),
|
|
575
|
+
title: "Background for light illustrations"
|
|
576
|
+
}
|
|
577
|
+
),
|
|
578
|
+
darkBgColor !== DEFAULT_DARK_BG && /* @__PURE__ */ jsxRuntime.jsx(ResetButton, { onClick: resetDarkBg, title: "Reset to default", children: /* @__PURE__ */ jsxRuntime.jsx(ResetIcon, {}) })
|
|
579
|
+
] })
|
|
580
|
+
] })
|
|
581
|
+
] })
|
|
582
|
+
] }),
|
|
583
|
+
filteredAssets.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs(NoResults, { children: [
|
|
584
|
+
"No ",
|
|
585
|
+
title.toLowerCase(),
|
|
586
|
+
' found matching "',
|
|
587
|
+
searchTerm,
|
|
588
|
+
'"'
|
|
589
|
+
] }) : groupByFolder ? renderGroupedAssets() : /* @__PURE__ */ jsxRuntime.jsx(
|
|
590
|
+
"div",
|
|
591
|
+
{
|
|
592
|
+
style: {
|
|
593
|
+
display: "grid",
|
|
594
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${display.previewSize + 40}px, 1fr))`,
|
|
595
|
+
gap: "24px"
|
|
596
|
+
},
|
|
597
|
+
children: filteredAssets.map(renderAsset)
|
|
598
|
+
}
|
|
599
|
+
),
|
|
600
|
+
toastMessage && /* @__PURE__ */ jsxRuntime.jsx(Toast, { children: toastMessage })
|
|
601
|
+
] }) });
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
exports.AssetCard = AssetCard;
|
|
605
|
+
exports.AssetFilename = AssetFilename;
|
|
606
|
+
exports.AssetImage = AssetImage;
|
|
607
|
+
exports.AssetName = AssetName;
|
|
608
|
+
exports.AssetPreview = AssetPreview;
|
|
609
|
+
exports.AssetSection = AssetSection;
|
|
610
|
+
exports.BackgroundControls = BackgroundControls;
|
|
611
|
+
exports.BackgroundToggle = BackgroundToggle;
|
|
612
|
+
exports.CheckerboardIcon = CheckerboardIcon;
|
|
613
|
+
exports.ColorInput = ColorInput;
|
|
614
|
+
exports.ColorLabel = ColorLabel;
|
|
615
|
+
exports.ColorPickerGroup = ColorPickerGroup;
|
|
616
|
+
exports.Container = Container;
|
|
617
|
+
exports.ControlsBar = ControlsBar;
|
|
618
|
+
exports.CopyButton = CopyButton;
|
|
619
|
+
exports.CopyButtons = CopyButtons;
|
|
620
|
+
exports.Description = Description;
|
|
621
|
+
exports.FolderSection = FolderSection;
|
|
622
|
+
exports.FolderTitle = FolderTitle;
|
|
623
|
+
exports.InverseIcon = InverseIcon;
|
|
624
|
+
exports.NoResults = NoResults;
|
|
625
|
+
exports.ResetButton = ResetButton;
|
|
626
|
+
exports.ResetIcon = ResetIcon;
|
|
627
|
+
exports.SearchInput = SearchInput;
|
|
628
|
+
exports.Title = Title;
|
|
629
|
+
exports.Toast = Toast;
|
|
630
|
+
exports.ToggleOption = ToggleOption;
|
|
631
|
+
exports.VariantToggle = VariantToggle;
|
|
632
|
+
exports.Wrapper = Wrapper;
|
|
633
|
+
//# sourceMappingURL=index.cjs.map
|
|
634
|
+
//# sourceMappingURL=index.cjs.map
|