@phcdevworks/spectre-ui 0.1.0 → 0.2.1
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 +74 -1
- package/dist/components.css +165 -0
- package/dist/index.cjs +214 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -24
- package/dist/index.d.ts +31 -24
- package/dist/index.js +213 -56
- package/dist/index.js.map +1 -1
- package/dist/tailwind/index.cjs +84 -0
- package/dist/tailwind/index.cjs.map +1 -0
- package/dist/tailwind/index.d.cts +26 -0
- package/dist/tailwind/index.d.ts +26 -0
- package/dist/tailwind/index.js +81 -0
- package/dist/tailwind/index.js.map +1 -0
- package/dist/utilities.css +7 -8
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -57,7 +57,33 @@ export default {
|
|
|
57
57
|
|
|
58
58
|
Works with Tailwind 3.x and 4.x through the classic config API.
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
**Custom preset:** Need to customize the preset or provide your own tokens?
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
// tailwind.config.ts
|
|
64
|
+
import {
|
|
65
|
+
createSpectreTailwindPreset,
|
|
66
|
+
spectreTokens,
|
|
67
|
+
} from "@phcdevworks/spectre-ui";
|
|
68
|
+
|
|
69
|
+
const customPreset = createSpectreTailwindPreset({
|
|
70
|
+
tokens: spectreTokens,
|
|
71
|
+
themeOverrides: {
|
|
72
|
+
colors: {
|
|
73
|
+
brand: {
|
|
74
|
+
500: "#ff6b6b",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
content: ["./src/**/*.{js,ts,jsx,tsx,astro}"],
|
|
82
|
+
presets: [customPreset],
|
|
83
|
+
};
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Plain theme object:** Need a plain theme object without presets? Generate it from the first-party tokens.
|
|
61
87
|
|
|
62
88
|
```ts
|
|
63
89
|
// tailwind.config.ts
|
|
@@ -91,6 +117,8 @@ import {
|
|
|
91
117
|
getButtonClasses,
|
|
92
118
|
getCardClasses,
|
|
93
119
|
getInputClasses,
|
|
120
|
+
getBadgeClasses,
|
|
121
|
+
getIconBoxClasses,
|
|
94
122
|
} from "@phcdevworks/spectre-ui";
|
|
95
123
|
|
|
96
124
|
const buttonClasses = getButtonClasses({
|
|
@@ -109,6 +137,12 @@ const inputClasses = getInputClasses({
|
|
|
109
137
|
fullWidth: true,
|
|
110
138
|
});
|
|
111
139
|
// "sp-input sp-input--error sp-input--sm sp-input--full"
|
|
140
|
+
|
|
141
|
+
const badgeClasses = getBadgeClasses({ variant: "success", size: "sm" });
|
|
142
|
+
// "sp-badge sp-badge--success sp-badge--sm"
|
|
143
|
+
|
|
144
|
+
const iconBoxClasses = getIconBoxClasses({ variant: "info", size: "lg" });
|
|
145
|
+
// "sp-iconbox sp-iconbox--info sp-iconbox--lg"
|
|
112
146
|
```
|
|
113
147
|
|
|
114
148
|
## Component Surfaces
|
|
@@ -162,6 +196,39 @@ getCardClasses({ variant: "outline" }); // Bordered
|
|
|
162
196
|
getCardClasses({ variant: "ghost" }); // Transparent
|
|
163
197
|
```
|
|
164
198
|
|
|
199
|
+
### Badge variants
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
getBadgeClasses({ variant: "primary" }); // Primary/default
|
|
203
|
+
getBadgeClasses({ variant: "success" }); // Success state
|
|
204
|
+
getBadgeClasses({ variant: "warning" }); // Warning state
|
|
205
|
+
getBadgeClasses({ variant: "danger" }); // Danger/error state
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Available sizes: `sm`, `md`, `lg`
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
getBadgeClasses({ variant: "success", size: "sm" });
|
|
212
|
+
// "sp-badge sp-badge--success sp-badge--sm"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Icon Box variants
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
getIconBoxClasses({ variant: "primary" }); // Primary/default
|
|
219
|
+
getIconBoxClasses({ variant: "success" }); // Success state
|
|
220
|
+
getIconBoxClasses({ variant: "warning" }); // Warning state
|
|
221
|
+
getIconBoxClasses({ variant: "danger" }); // Danger/error state
|
|
222
|
+
getIconBoxClasses({ variant: "info" }); // Info state
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Available sizes: `sm`, `md`, `lg`
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
getIconBoxClasses({ variant: "info", size: "lg" });
|
|
229
|
+
// "sp-iconbox sp-iconbox--info sp-iconbox--lg"
|
|
230
|
+
```
|
|
231
|
+
|
|
165
232
|
## Surface & Typography Roles
|
|
166
233
|
|
|
167
234
|
Spectre exposes semantic layers that decouple structural styles from raw palette values. Override these roles at any scope (root, layout, or component wrapper) to restyle whole experiences without editing CSS.
|
|
@@ -281,9 +348,15 @@ import type {
|
|
|
281
348
|
InputState,
|
|
282
349
|
InputSize,
|
|
283
350
|
CardVariant,
|
|
351
|
+
BadgeVariant,
|
|
352
|
+
BadgeSize,
|
|
353
|
+
IconBoxVariant,
|
|
354
|
+
IconBoxSize,
|
|
284
355
|
ButtonRecipeOptions,
|
|
285
356
|
CardRecipeOptions,
|
|
286
357
|
InputRecipeOptions,
|
|
358
|
+
BadgeRecipeOptions,
|
|
359
|
+
IconBoxRecipeOptions,
|
|
287
360
|
} from "@phcdevworks/spectre-ui";
|
|
288
361
|
```
|
|
289
362
|
|
package/dist/components.css
CHANGED
|
@@ -84,6 +84,50 @@
|
|
|
84
84
|
var(--sp-text-on-surface-muted, var(--sp-color-neutral-400, #94a3b8)));
|
|
85
85
|
--sp-component-input-role-border-disabled: var(--sp-component-input-border-disabled,
|
|
86
86
|
var(--sp-surface-input, var(--sp-color-neutral-200, #e2e8f0)));
|
|
87
|
+
|
|
88
|
+
/* badge roles */
|
|
89
|
+
--sp-component-badge-font: var(--sp-font-family-sans, system-ui);
|
|
90
|
+
--sp-component-badge-weight: var(--sp-font-sm-weight, 500);
|
|
91
|
+
--sp-component-badge-gap: var(--sp-space-4xs, 0.125rem);
|
|
92
|
+
--sp-component-badge-radius: var(--sp-radius-pill, 999px);
|
|
93
|
+
--sp-component-badge-primary-bg: var(--sp-badge-primary-bg,
|
|
94
|
+
var(--sp-color-brand-500, #8652ff));
|
|
95
|
+
--sp-component-badge-primary-text: var(--sp-badge-primary-text,
|
|
96
|
+
var(--sp-text-on-surface-default, var(--sp-color-neutral-900, #0f172a)));
|
|
97
|
+
--sp-component-badge-success-bg: var(--sp-badge-success-bg,
|
|
98
|
+
var(--sp-color-success-500, #22c55e));
|
|
99
|
+
--sp-component-badge-success-text: var(--sp-badge-success-text,
|
|
100
|
+
var(--sp-text-on-surface-default, var(--sp-color-neutral-900, #0f172a)));
|
|
101
|
+
--sp-component-badge-warning-bg: var(--sp-badge-warning-bg,
|
|
102
|
+
var(--sp-color-warning-500, #f59e0b));
|
|
103
|
+
--sp-component-badge-warning-text: var(--sp-badge-warning-text,
|
|
104
|
+
var(--sp-text-on-surface-default, var(--sp-color-neutral-900, #0f172a)));
|
|
105
|
+
--sp-component-badge-danger-bg: var(--sp-badge-danger-bg,
|
|
106
|
+
var(--sp-color-error-500, #ef4444));
|
|
107
|
+
--sp-component-badge-danger-text: var(--sp-badge-danger-text,
|
|
108
|
+
var(--sp-text-on-surface-default, var(--sp-color-neutral-900, #0f172a)));
|
|
109
|
+
--sp-component-badge-padding-x-sm: var(--sp-space-xs, 0.5rem);
|
|
110
|
+
--sp-component-badge-padding-x-md: var(--sp-space-sm, 0.75rem);
|
|
111
|
+
--sp-component-badge-padding-x-lg: var(--sp-space-md, 1rem);
|
|
112
|
+
--sp-component-badge-padding-y-sm: var(--sp-space-4xs, 0.125rem);
|
|
113
|
+
--sp-component-badge-padding-y-md: var(--sp-space-3xs, 0.1875rem);
|
|
114
|
+
--sp-component-badge-padding-y-lg: var(--sp-space-2xs, 0.25rem);
|
|
115
|
+
|
|
116
|
+
/* icon box roles */
|
|
117
|
+
--sp-component-iconbox-radius: var(--sp-radius-lg, 8px);
|
|
118
|
+
--sp-component-iconbox-size-sm: var(--sp-space-xl, 2rem);
|
|
119
|
+
--sp-component-iconbox-size-md: var(--sp-space-2xl, 3rem);
|
|
120
|
+
--sp-component-iconbox-size-lg: var(--sp-space-3xl, 4rem);
|
|
121
|
+
--sp-component-iconbox-primary-bg: var(--sp-color-brand-50, #f5f0ff);
|
|
122
|
+
--sp-component-iconbox-primary-text: var(--sp-color-brand-700, #5626b4);
|
|
123
|
+
--sp-component-iconbox-success-bg: var(--sp-color-success-50, #f0fdf4);
|
|
124
|
+
--sp-component-iconbox-success-text: var(--sp-color-success-700, #15803d);
|
|
125
|
+
--sp-component-iconbox-warning-bg: var(--sp-color-warning-50, #fffbeb);
|
|
126
|
+
--sp-component-iconbox-warning-text: var(--sp-color-warning-700, #b45309);
|
|
127
|
+
--sp-component-iconbox-danger-bg: var(--sp-color-error-50, #fef2f2);
|
|
128
|
+
--sp-component-iconbox-danger-text: var(--sp-color-error-700, #b91c1c);
|
|
129
|
+
--sp-component-iconbox-info-bg: var(--sp-color-info-50, #eff6ff);
|
|
130
|
+
--sp-component-iconbox-info-text: var(--sp-color-info-700, #1d4ed8);
|
|
87
131
|
}
|
|
88
132
|
|
|
89
133
|
/* BUTTONS -------------------------------------------------------------- */
|
|
@@ -433,4 +477,125 @@
|
|
|
433
477
|
transform: translateY(-1px);
|
|
434
478
|
box-shadow: var(--sp-component-card-shadow-elevated, var(--sp-shadow-lg));
|
|
435
479
|
}
|
|
480
|
+
|
|
481
|
+
/* BADGES --------------------------------------------------------------- */
|
|
482
|
+
|
|
483
|
+
.sp-badge {
|
|
484
|
+
display: inline-flex;
|
|
485
|
+
align-items: center;
|
|
486
|
+
justify-content: center;
|
|
487
|
+
gap: var(--sp-component-badge-gap, var(--sp-space-4xs, 0.125rem));
|
|
488
|
+
border-radius: var(--sp-component-badge-radius, var(--sp-radius-pill, 999px));
|
|
489
|
+
font-family: var(--sp-component-badge-font, var(--sp-font-family-sans, system-ui));
|
|
490
|
+
font-weight: var(--sp-component-badge-weight, var(--sp-font-sm-weight, 500));
|
|
491
|
+
padding: var(--sp-component-badge-padding-y-md, var(--sp-space-3xs, 0.1875rem))
|
|
492
|
+
var(--sp-component-badge-padding-x-md, var(--sp-space-sm, 0.75rem));
|
|
493
|
+
font-size: var(--sp-font-sm-size, 0.875rem);
|
|
494
|
+
line-height: var(--sp-font-sm-line-height, 1.5rem);
|
|
495
|
+
border: 1px solid transparent;
|
|
496
|
+
white-space: nowrap;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
.sp-badge--sm {
|
|
500
|
+
padding: var(--sp-component-badge-padding-y-sm, var(--sp-space-4xs, 0.125rem))
|
|
501
|
+
var(--sp-component-badge-padding-x-sm, var(--sp-space-xs, 0.5rem));
|
|
502
|
+
font-size: var(--sp-font-xs-size, 0.75rem);
|
|
503
|
+
line-height: var(--sp-font-xs-line-height, 1.25rem);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.sp-badge--md {
|
|
507
|
+
padding: var(--sp-component-badge-padding-y-md, var(--sp-space-3xs, 0.1875rem))
|
|
508
|
+
var(--sp-component-badge-padding-x-md, var(--sp-space-sm, 0.75rem));
|
|
509
|
+
font-size: var(--sp-font-sm-size, 0.875rem);
|
|
510
|
+
line-height: var(--sp-font-sm-line-height, 1.5rem);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.sp-badge--lg {
|
|
514
|
+
padding: var(--sp-component-badge-padding-y-lg, var(--sp-space-2xs, 0.25rem))
|
|
515
|
+
var(--sp-component-badge-padding-x-lg, var(--sp-space-md, 1rem));
|
|
516
|
+
font-size: var(--sp-font-md-size, 1rem);
|
|
517
|
+
line-height: var(--sp-font-md-line-height, 1.75rem);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.sp-badge--primary {
|
|
521
|
+
background-color: var(--sp-component-badge-primary-bg);
|
|
522
|
+
color: var(--sp-component-badge-primary-text);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.sp-badge--success {
|
|
526
|
+
background-color: var(--sp-component-badge-success-bg);
|
|
527
|
+
color: var(--sp-component-badge-success-text);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.sp-badge--warning {
|
|
531
|
+
background-color: var(--sp-component-badge-warning-bg);
|
|
532
|
+
color: var(--sp-component-badge-warning-text);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.sp-badge--danger {
|
|
536
|
+
background-color: var(--sp-component-badge-danger-bg);
|
|
537
|
+
color: var(--sp-component-badge-danger-text);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/* ICON BOXES ----------------------------------------------------------- */
|
|
541
|
+
|
|
542
|
+
.sp-iconbox {
|
|
543
|
+
display: inline-flex;
|
|
544
|
+
align-items: center;
|
|
545
|
+
justify-content: center;
|
|
546
|
+
border-radius: var(--sp-component-iconbox-radius, var(--sp-radius-lg, 8px));
|
|
547
|
+
color: var(--sp-component-iconbox-primary-text);
|
|
548
|
+
background-color: var(--sp-component-iconbox-primary-bg);
|
|
549
|
+
font-family: var(--sp-font-family-sans, system-ui);
|
|
550
|
+
font-weight: var(--sp-font-md-weight, 500);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.sp-iconbox--sm {
|
|
554
|
+
width: var(--sp-component-iconbox-size-sm, var(--sp-space-xl, 2rem));
|
|
555
|
+
height: var(--sp-component-iconbox-size-sm, var(--sp-space-xl, 2rem));
|
|
556
|
+
font-size: var(--sp-font-sm-size, 0.875rem);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
.sp-iconbox--md {
|
|
560
|
+
width: var(--sp-component-iconbox-size-md, var(--sp-space-2xl, 3rem));
|
|
561
|
+
height: var(--sp-component-iconbox-size-md, var(--sp-space-2xl, 3rem));
|
|
562
|
+
font-size: var(--sp-font-md-size, 1rem);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.sp-iconbox--lg {
|
|
566
|
+
width: var(--sp-component-iconbox-size-lg, var(--sp-space-3xl, 4rem));
|
|
567
|
+
height: var(--sp-component-iconbox-size-lg, var(--sp-space-3xl, 4rem));
|
|
568
|
+
font-size: var(--sp-font-lg-size, 1.125rem);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
.sp-iconbox > svg,
|
|
572
|
+
.sp-iconbox > i {
|
|
573
|
+
width: 1em;
|
|
574
|
+
height: 1em;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.sp-iconbox--primary {
|
|
578
|
+
background-color: var(--sp-component-iconbox-primary-bg);
|
|
579
|
+
color: var(--sp-component-iconbox-primary-text);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.sp-iconbox--success {
|
|
583
|
+
background-color: var(--sp-component-iconbox-success-bg);
|
|
584
|
+
color: var(--sp-component-iconbox-success-text);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.sp-iconbox--warning {
|
|
588
|
+
background-color: var(--sp-component-iconbox-warning-bg);
|
|
589
|
+
color: var(--sp-component-iconbox-warning-text);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
.sp-iconbox--danger {
|
|
593
|
+
background-color: var(--sp-component-iconbox-danger-bg);
|
|
594
|
+
color: var(--sp-component-iconbox-danger-text);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
.sp-iconbox--info {
|
|
598
|
+
background-color: var(--sp-component-iconbox-info-bg);
|
|
599
|
+
color: var(--sp-component-iconbox-info-text);
|
|
600
|
+
}
|
|
436
601
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -18,49 +18,77 @@ var spectreStyles = {
|
|
|
18
18
|
utilities: spectreUtilitiesStylesPath
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
// src/
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
return
|
|
21
|
+
// src/internal/cx.ts
|
|
22
|
+
function cx(...parts) {
|
|
23
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24
|
+
const classes = [];
|
|
25
|
+
for (const part of parts) {
|
|
26
|
+
if (!part) continue;
|
|
27
|
+
const trimmed = part.trim();
|
|
28
|
+
if (!trimmed) continue;
|
|
29
|
+
if (!/\s/.test(trimmed)) {
|
|
30
|
+
if (!seen.has(trimmed)) {
|
|
31
|
+
seen.add(trimmed);
|
|
32
|
+
classes.push(trimmed);
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
for (const token of trimmed.split(/\s+/)) {
|
|
37
|
+
if (!token || seen.has(token)) continue;
|
|
38
|
+
seen.add(token);
|
|
39
|
+
classes.push(token);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return classes.join(" ");
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// src/
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
// src/internal/resolve-option.ts
|
|
46
|
+
var hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
47
|
+
var isAllowedValue = (value, allowed) => Array.isArray(allowed) ? allowed.includes(value) : hasOwn(allowed, value);
|
|
48
|
+
function resolveOption(config) {
|
|
49
|
+
const { name, value, allowed, fallback } = config;
|
|
50
|
+
if (value === void 0) return fallback;
|
|
51
|
+
if (isAllowedValue(value, allowed)) return value;
|
|
52
|
+
if (process.env.NODE_ENV !== "production") {
|
|
53
|
+
throw new Error(`[spectre-ui] Unknown ${name}: ${value}`);
|
|
54
|
+
}
|
|
55
|
+
return fallback;
|
|
56
|
+
}
|
|
52
57
|
|
|
53
58
|
// src/recipes/button.ts
|
|
59
|
+
var BUTTON_VARIANTS = {
|
|
60
|
+
primary: true,
|
|
61
|
+
secondary: true,
|
|
62
|
+
ghost: true,
|
|
63
|
+
danger: true,
|
|
64
|
+
success: true
|
|
65
|
+
};
|
|
66
|
+
var BUTTON_SIZES = {
|
|
67
|
+
sm: true,
|
|
68
|
+
md: true,
|
|
69
|
+
lg: true
|
|
70
|
+
};
|
|
54
71
|
function getButtonClasses(opts = {}) {
|
|
55
72
|
const {
|
|
56
|
-
variant
|
|
57
|
-
size
|
|
73
|
+
variant: variantInput,
|
|
74
|
+
size: sizeInput,
|
|
58
75
|
fullWidth = false,
|
|
59
76
|
loading = false,
|
|
60
77
|
disabled = false,
|
|
61
78
|
iconOnly = false
|
|
62
79
|
} = opts;
|
|
63
|
-
const
|
|
80
|
+
const variant = resolveOption({
|
|
81
|
+
name: "button variant",
|
|
82
|
+
value: variantInput,
|
|
83
|
+
allowed: BUTTON_VARIANTS,
|
|
84
|
+
fallback: "primary"
|
|
85
|
+
});
|
|
86
|
+
const size = resolveOption({
|
|
87
|
+
name: "button size",
|
|
88
|
+
value: sizeInput,
|
|
89
|
+
allowed: BUTTON_SIZES,
|
|
90
|
+
fallback: "md"
|
|
91
|
+
});
|
|
64
92
|
const variantMap = {
|
|
65
93
|
primary: "sp-btn--primary",
|
|
66
94
|
secondary: "sp-btn--secondary",
|
|
@@ -68,70 +96,200 @@ function getButtonClasses(opts = {}) {
|
|
|
68
96
|
danger: "sp-btn--danger",
|
|
69
97
|
success: "sp-btn--success"
|
|
70
98
|
};
|
|
71
|
-
|
|
99
|
+
const variantClass = variantMap[variant];
|
|
72
100
|
const sizeMap = {
|
|
73
101
|
sm: "sp-btn--sm",
|
|
74
102
|
md: "sp-btn--md",
|
|
75
103
|
lg: "sp-btn--lg"
|
|
76
104
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
105
|
+
const sizeClass = sizeMap[size];
|
|
106
|
+
return cx(
|
|
107
|
+
"sp-btn",
|
|
108
|
+
variantClass,
|
|
109
|
+
sizeClass,
|
|
110
|
+
fullWidth && "sp-btn--full",
|
|
111
|
+
loading && "sp-btn--loading",
|
|
112
|
+
disabled && "sp-btn--disabled",
|
|
113
|
+
iconOnly && "sp-btn--icon"
|
|
114
|
+
);
|
|
83
115
|
}
|
|
84
116
|
|
|
85
117
|
// src/recipes/card.ts
|
|
118
|
+
var CARD_VARIANTS = {
|
|
119
|
+
elevated: true,
|
|
120
|
+
flat: true,
|
|
121
|
+
outline: true,
|
|
122
|
+
ghost: true
|
|
123
|
+
};
|
|
86
124
|
function getCardClasses(opts = {}) {
|
|
87
125
|
const {
|
|
88
|
-
variant
|
|
126
|
+
variant: variantInput,
|
|
89
127
|
interactive = false,
|
|
90
128
|
padded = false,
|
|
91
129
|
fullHeight = false
|
|
92
130
|
} = opts;
|
|
93
|
-
const
|
|
131
|
+
const variant = resolveOption({
|
|
132
|
+
name: "card variant",
|
|
133
|
+
value: variantInput,
|
|
134
|
+
allowed: CARD_VARIANTS,
|
|
135
|
+
fallback: "elevated"
|
|
136
|
+
});
|
|
94
137
|
const variantMap = {
|
|
95
138
|
elevated: "sp-card--elevated",
|
|
96
139
|
flat: "sp-card--flat",
|
|
97
140
|
outline: "sp-card--outline",
|
|
98
141
|
ghost: "sp-card--ghost"
|
|
99
142
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
143
|
+
const variantClass = variantMap[variant];
|
|
144
|
+
return cx(
|
|
145
|
+
"sp-card",
|
|
146
|
+
variantClass,
|
|
147
|
+
interactive && "sp-card--interactive",
|
|
148
|
+
padded && "sp-card--padded",
|
|
149
|
+
fullHeight && "sp-card--full"
|
|
150
|
+
);
|
|
105
151
|
}
|
|
106
152
|
|
|
107
153
|
// src/recipes/input.ts
|
|
154
|
+
var INPUT_STATES = {
|
|
155
|
+
default: true,
|
|
156
|
+
error: true,
|
|
157
|
+
success: true,
|
|
158
|
+
disabled: true
|
|
159
|
+
};
|
|
160
|
+
var INPUT_SIZES = {
|
|
161
|
+
sm: true,
|
|
162
|
+
md: true,
|
|
163
|
+
lg: true
|
|
164
|
+
};
|
|
108
165
|
function getInputClasses(opts = {}) {
|
|
109
|
-
const { state
|
|
110
|
-
const
|
|
166
|
+
const { state: stateInput, size: sizeInput, fullWidth = false } = opts;
|
|
167
|
+
const state = resolveOption({
|
|
168
|
+
name: "input state",
|
|
169
|
+
value: stateInput,
|
|
170
|
+
allowed: INPUT_STATES,
|
|
171
|
+
fallback: "default"
|
|
172
|
+
});
|
|
173
|
+
const size = resolveOption({
|
|
174
|
+
name: "input size",
|
|
175
|
+
value: sizeInput,
|
|
176
|
+
allowed: INPUT_SIZES,
|
|
177
|
+
fallback: "md"
|
|
178
|
+
});
|
|
111
179
|
const sizeMap = {
|
|
112
180
|
sm: "sp-input--sm",
|
|
113
181
|
md: "sp-input--md",
|
|
114
182
|
lg: "sp-input--lg"
|
|
115
183
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
184
|
+
const sizeClass = sizeMap[size];
|
|
185
|
+
return cx(
|
|
186
|
+
"sp-input",
|
|
187
|
+
sizeClass,
|
|
188
|
+
state === "error" && "sp-input--error",
|
|
189
|
+
state === "success" && "sp-input--success",
|
|
190
|
+
// Visual state only; actual disabled attribute is handled by adapters.
|
|
191
|
+
state === "disabled" && "sp-input--disabled",
|
|
192
|
+
fullWidth && "sp-input--full"
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// src/recipes/badge.ts
|
|
197
|
+
var BADGE_VARIANTS = {
|
|
198
|
+
primary: true,
|
|
199
|
+
success: true,
|
|
200
|
+
warning: true,
|
|
201
|
+
danger: true
|
|
202
|
+
};
|
|
203
|
+
var BADGE_SIZES = {
|
|
204
|
+
sm: true,
|
|
205
|
+
md: true,
|
|
206
|
+
lg: true
|
|
207
|
+
};
|
|
208
|
+
function getBadgeClasses(opts = {}) {
|
|
209
|
+
const { variant: variantInput, size: sizeInput } = opts;
|
|
210
|
+
const variant = resolveOption({
|
|
211
|
+
name: "badge variant",
|
|
212
|
+
value: variantInput,
|
|
213
|
+
allowed: BADGE_VARIANTS,
|
|
214
|
+
fallback: "primary"
|
|
215
|
+
});
|
|
216
|
+
const size = resolveOption({
|
|
217
|
+
name: "badge size",
|
|
218
|
+
value: sizeInput,
|
|
219
|
+
allowed: BADGE_SIZES,
|
|
220
|
+
fallback: "md"
|
|
221
|
+
});
|
|
222
|
+
const variantMap = {
|
|
223
|
+
primary: "sp-badge--primary",
|
|
224
|
+
success: "sp-badge--success",
|
|
225
|
+
warning: "sp-badge--warning",
|
|
226
|
+
danger: "sp-badge--danger"
|
|
227
|
+
};
|
|
228
|
+
const variantClass = variantMap[variant];
|
|
229
|
+
const sizeMap = {
|
|
230
|
+
sm: "sp-badge--sm",
|
|
231
|
+
md: "sp-badge--md",
|
|
232
|
+
lg: "sp-badge--lg"
|
|
233
|
+
};
|
|
234
|
+
const sizeClass = sizeMap[size];
|
|
235
|
+
return cx("sp-badge", variantClass, sizeClass);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/recipes/iconbox.ts
|
|
239
|
+
var ICONBOX_VARIANTS = {
|
|
240
|
+
primary: true,
|
|
241
|
+
success: true,
|
|
242
|
+
warning: true,
|
|
243
|
+
danger: true,
|
|
244
|
+
info: true
|
|
245
|
+
};
|
|
246
|
+
var ICONBOX_SIZES = {
|
|
247
|
+
sm: true,
|
|
248
|
+
md: true,
|
|
249
|
+
lg: true
|
|
250
|
+
};
|
|
251
|
+
function getIconBoxClasses(opts = {}) {
|
|
252
|
+
const { variant: variantInput, size: sizeInput } = opts;
|
|
253
|
+
const variant = resolveOption({
|
|
254
|
+
name: "icon box variant",
|
|
255
|
+
value: variantInput,
|
|
256
|
+
allowed: ICONBOX_VARIANTS,
|
|
257
|
+
fallback: "primary"
|
|
258
|
+
});
|
|
259
|
+
const size = resolveOption({
|
|
260
|
+
name: "icon box size",
|
|
261
|
+
value: sizeInput,
|
|
262
|
+
allowed: ICONBOX_SIZES,
|
|
263
|
+
fallback: "md"
|
|
264
|
+
});
|
|
265
|
+
const variantMap = {
|
|
266
|
+
primary: "sp-iconbox--primary",
|
|
267
|
+
success: "sp-iconbox--success",
|
|
268
|
+
warning: "sp-iconbox--warning",
|
|
269
|
+
danger: "sp-iconbox--danger",
|
|
270
|
+
info: "sp-iconbox--info"
|
|
271
|
+
};
|
|
272
|
+
const variantClass = variantMap[variant];
|
|
273
|
+
const sizeMap = {
|
|
274
|
+
sm: "sp-iconbox--sm",
|
|
275
|
+
md: "sp-iconbox--md",
|
|
276
|
+
lg: "sp-iconbox--lg"
|
|
277
|
+
};
|
|
278
|
+
const sizeClass = sizeMap[size];
|
|
279
|
+
return cx("sp-iconbox", variantClass, sizeClass);
|
|
122
280
|
}
|
|
123
281
|
|
|
124
282
|
Object.defineProperty(exports, "spectreTokens", {
|
|
125
283
|
enumerable: true,
|
|
126
284
|
get: function () { return spectreTokens__default.default; }
|
|
127
285
|
});
|
|
128
|
-
exports.
|
|
286
|
+
exports.getBadgeClasses = getBadgeClasses;
|
|
129
287
|
exports.getButtonClasses = getButtonClasses;
|
|
130
288
|
exports.getCardClasses = getCardClasses;
|
|
289
|
+
exports.getIconBoxClasses = getIconBoxClasses;
|
|
131
290
|
exports.getInputClasses = getInputClasses;
|
|
132
291
|
exports.spectreBaseStylesPath = spectreBaseStylesPath;
|
|
133
292
|
exports.spectreComponentsStylesPath = spectreComponentsStylesPath;
|
|
134
|
-
exports.spectrePreset = spectrePreset;
|
|
135
293
|
exports.spectreStyles = spectreStyles;
|
|
136
294
|
exports.spectreUtilitiesStylesPath = spectreUtilitiesStylesPath;
|
|
137
295
|
//# sourceMappingURL=index.cjs.map
|