@marianmeres/stuic 2.66.0 → 3.0.0
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 +292 -4
- package/dist/README.md +41 -18
- package/dist/actions/popover/README.md +19 -0
- package/dist/actions/popover/index.css +6 -9
- package/dist/actions/popover/popover.svelte.js +2 -2
- package/dist/actions/tooltip/README.md +18 -0
- package/dist/actions/tooltip/index.css +5 -8
- package/dist/actions/tooltip/tooltip.svelte.js +1 -1
- package/dist/components/AlertConfirmPrompt/AlertConfirmPrompt.svelte +9 -10
- package/dist/components/AlertConfirmPrompt/AlertConfirmPrompt.svelte.d.ts +3 -3
- package/dist/components/AlertConfirmPrompt/Current.svelte +15 -17
- package/dist/components/AlertConfirmPrompt/Current.svelte.d.ts +5 -3
- package/dist/components/AlertConfirmPrompt/acp-icons.js +5 -4
- package/dist/components/AlertConfirmPrompt/index.css +62 -0
- package/dist/components/AssetsPreview/AssetsPreview.svelte +92 -73
- package/dist/components/AssetsPreview/AssetsPreview.svelte.d.ts +1 -0
- package/dist/components/AssetsPreview/index.css +59 -0
- package/dist/components/Avatar/Avatar.svelte +32 -18
- package/dist/components/Avatar/Avatar.svelte.d.ts +1 -0
- package/dist/components/Avatar/README.md +166 -0
- package/dist/components/Avatar/index.css +128 -0
- package/dist/components/Backdrop/Backdrop.svelte +8 -2
- package/dist/components/Backdrop/Backdrop.svelte.d.ts +1 -0
- package/dist/components/Backdrop/README.md +71 -6
- package/dist/components/Backdrop/index.css +29 -0
- package/dist/components/Button/Button.svelte +117 -124
- package/dist/components/Button/Button.svelte.d.ts +35 -23
- package/dist/components/Button/README.md +87 -21
- package/dist/components/Button/index.css +473 -9
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/ButtonGroupRadio/ButtonGroupRadio.svelte +7 -38
- package/dist/components/ButtonGroupRadio/README.md +82 -4
- package/dist/components/ButtonGroupRadio/index.css +152 -14
- package/dist/components/Collapsible/Collapsible.svelte +7 -7
- package/dist/components/Collapsible/Collapsible.svelte.d.ts +2 -2
- package/dist/components/Collapsible/README.md +34 -2
- package/dist/components/Collapsible/index.css +38 -0
- package/dist/components/CommandMenu/CommandMenu.svelte +13 -24
- package/dist/components/CommandMenu/README.md +39 -0
- package/dist/components/CommandMenu/index.css +45 -2
- package/dist/components/DismissibleMessage/DismissibleMessage.svelte +53 -50
- package/dist/components/DismissibleMessage/DismissibleMessage.svelte.d.ts +6 -5
- package/dist/components/DismissibleMessage/README.md +93 -11
- package/dist/components/DismissibleMessage/index.css +122 -8
- package/dist/components/DismissibleMessage/index.d.ts +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.svelte +14 -50
- package/dist/components/DropdownMenu/DropdownMenu.svelte.d.ts +6 -6
- package/dist/components/DropdownMenu/README.md +132 -0
- package/dist/components/DropdownMenu/index.css +231 -27
- package/dist/components/Input/FieldAssets.svelte +8 -5
- package/dist/components/Input/FieldCheckbox.svelte +7 -44
- package/dist/components/Input/FieldFile.svelte +1 -6
- package/dist/components/Input/FieldInput.svelte +1 -1
- package/dist/components/Input/FieldOptions.svelte +41 -38
- package/dist/components/Input/FieldRadios.svelte +7 -16
- package/dist/components/Input/FieldSelect.svelte +1 -1
- package/dist/components/Input/FieldSwitch.svelte +1 -5
- package/dist/components/Input/FieldTextarea.svelte +1 -1
- package/dist/components/Input/README.md +194 -0
- package/dist/components/Input/_internal/FieldRadioInternal.svelte +2 -40
- package/dist/components/Input/_internal/InputWrap.svelte +8 -48
- package/dist/components/Input/index.css +522 -127
- package/dist/components/ListItemButton/ListItemButton.svelte +37 -73
- package/dist/components/ListItemButton/ListItemButton.svelte.d.ts +1 -9
- package/dist/components/ListItemButton/README.md +100 -45
- package/dist/components/ListItemButton/index.css +175 -56
- package/dist/components/ListItemButton/index.d.ts +1 -1
- package/dist/components/ListItemButton/index.js +1 -1
- package/dist/components/Modal/Modal.svelte +2 -8
- package/dist/components/Modal/Modal.svelte.d.ts +1 -0
- package/dist/components/Modal/README.md +29 -0
- package/dist/components/Modal/index.css +36 -0
- package/dist/components/ModalDialog/ModalDialog.svelte +2 -21
- package/dist/components/ModalDialog/README.md +35 -0
- package/dist/components/ModalDialog/index.css +57 -0
- package/dist/components/Notifications/Notifications.svelte +44 -128
- package/dist/components/Notifications/Notifications.svelte.d.ts +9 -17
- package/dist/components/Notifications/README.md +186 -70
- package/dist/components/Notifications/index.css +212 -15
- package/dist/components/Progress/README.md +15 -0
- package/dist/components/Progress/_internal/Bar.svelte +2 -2
- package/dist/components/Progress/index.css +4 -4
- package/dist/components/Skeleton/Skeleton.svelte +3 -2
- package/dist/components/Skeleton/index.css +11 -14
- package/dist/components/Spinner/Spinner.svelte +2 -2
- package/dist/components/Spinner/SpinnerCircle.svelte +1 -1
- package/dist/components/Switch/README.md +15 -0
- package/dist/components/Switch/Switch.svelte +4 -7
- package/dist/components/Switch/Switch.svelte.d.ts +1 -1
- package/dist/components/Switch/SwitchButton.svelte +4 -5
- package/dist/components/Switch/index.css +3 -4
- package/dist/components/TabbedMenu/README.md +26 -21
- package/dist/components/TabbedMenu/TabbedMenu.svelte +5 -5
- package/dist/components/TabbedMenu/index.css +7 -22
- package/dist/components/ThemePreview/README.md +289 -0
- package/dist/components/ThemePreview/ThemePreview.svelte +341 -0
- package/dist/components/ThemePreview/ThemePreview.svelte.d.ts +33 -0
- package/dist/components/ThemePreview/index.css +493 -0
- package/dist/components/ThemePreview/index.d.ts +1 -0
- package/dist/components/ThemePreview/index.js +1 -0
- package/dist/components/TwCheck/TwCheck.svelte +4 -4
- package/dist/components/TwCheck/index.css +3 -2
- package/dist/components/TypeaheadInput/TypeaheadInput.svelte +1 -1
- package/dist/components/X/X.svelte +12 -5
- package/dist/components/X/X.svelte.d.ts +1 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +1 -0
- package/dist/index.css +31 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/themes/blue-orange.css +163 -0
- package/dist/themes/blue-orange.d.ts +6 -0
- package/dist/themes/blue-orange.js +151 -0
- package/dist/themes/cyan-red.css +163 -0
- package/dist/themes/cyan-red.d.ts +6 -0
- package/dist/themes/cyan-red.js +151 -0
- package/dist/themes/cyan-slate.css +163 -0
- package/dist/themes/cyan-slate.d.ts +6 -0
- package/dist/themes/cyan-slate.js +151 -0
- package/dist/themes/emerald-pink.css +163 -0
- package/dist/themes/emerald-pink.d.ts +6 -0
- package/dist/themes/emerald-pink.js +151 -0
- package/dist/themes/fuchsia-emerald.css +163 -0
- package/dist/themes/fuchsia-emerald.d.ts +6 -0
- package/dist/themes/fuchsia-emerald.js +151 -0
- package/dist/themes/gray.css +163 -0
- package/dist/themes/gray.d.ts +6 -0
- package/dist/themes/gray.js +151 -0
- package/dist/themes/indigo-amber.css +163 -0
- package/dist/themes/indigo-amber.d.ts +6 -0
- package/dist/themes/indigo-amber.js +151 -0
- package/dist/themes/neutral.css +163 -0
- package/dist/themes/neutral.d.ts +6 -0
- package/dist/themes/neutral.js +151 -0
- package/dist/themes/pink-emerald.css +163 -0
- package/dist/themes/pink-emerald.d.ts +6 -0
- package/dist/themes/pink-emerald.js +151 -0
- package/dist/themes/purple-yellow.css +163 -0
- package/dist/themes/purple-yellow.d.ts +6 -0
- package/dist/themes/purple-yellow.js +151 -0
- package/dist/themes/rainbow.css +163 -0
- package/dist/themes/rainbow.d.ts +6 -0
- package/dist/themes/rainbow.js +156 -0
- package/dist/themes/red-blue.css +163 -0
- package/dist/themes/red-blue.d.ts +6 -0
- package/dist/themes/red-blue.js +151 -0
- package/dist/themes/red-cyan.css +163 -0
- package/dist/themes/red-cyan.d.ts +6 -0
- package/dist/themes/red-cyan.js +151 -0
- package/dist/themes/rose-teal.css +163 -0
- package/dist/themes/rose-teal.d.ts +6 -0
- package/dist/themes/rose-teal.js +151 -0
- package/dist/themes/sky-amber.css +163 -0
- package/dist/themes/sky-amber.d.ts +6 -0
- package/dist/themes/sky-amber.js +151 -0
- package/dist/themes/slate-cyan.css +163 -0
- package/dist/themes/slate-cyan.d.ts +6 -0
- package/dist/themes/slate-cyan.js +151 -0
- package/dist/themes/tailwind-color-pairs.md +31 -0
- package/dist/themes/teal-rose.css +163 -0
- package/dist/themes/teal-rose.d.ts +6 -0
- package/dist/themes/teal-rose.js +151 -0
- package/dist/themes/violet-lime.css +163 -0
- package/dist/themes/violet-lime.d.ts +6 -0
- package/dist/themes/violet-lime.js +151 -0
- package/dist/utils/design-tokens.d.ts +43 -0
- package/dist/utils/design-tokens.js +100 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +22 -2
|
@@ -1,40 +1,52 @@
|
|
|
1
|
-
import type { Snippet } from "svelte";
|
|
2
1
|
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { IntentColorKey } from "../../utils/design-tokens.js";
|
|
4
|
+
export type ButtonVariant = "solid" | "outline" | "ghost" | "soft" | "link";
|
|
5
|
+
export type ButtonSize = "sm" | "md" | "lg" | "xl";
|
|
3
6
|
export interface Props extends Omit<HTMLButtonAttributes, "children"> {
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
/** Color intent (semantic meaning) */
|
|
8
|
+
intent?: IntentColorKey;
|
|
9
|
+
/** Visual variant (how colors are applied) */
|
|
10
|
+
variant?: ButtonVariant | string;
|
|
11
|
+
/** Size preset */
|
|
12
|
+
size?: ButtonSize | string;
|
|
13
|
+
/** Reduce emphasis */
|
|
8
14
|
muted?: boolean;
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
/** 3D push effect */
|
|
16
|
+
raised?: boolean;
|
|
11
17
|
/** Skip all default styling, use only custom classes */
|
|
12
18
|
unstyled?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
|
|
19
|
+
/** Render as rounded-full */
|
|
20
|
+
roundedFull?: boolean;
|
|
21
|
+
/** Render as aspect ratio 1 */
|
|
22
|
+
aspect1?: boolean;
|
|
23
|
+
/** Additional CSS classes */
|
|
15
24
|
class?: string;
|
|
16
25
|
/** Render as anchor tag instead of button */
|
|
17
26
|
href?: string;
|
|
27
|
+
/** Content snippet */
|
|
18
28
|
children?: Snippet<[{
|
|
19
29
|
checked?: boolean;
|
|
20
30
|
}]>;
|
|
21
|
-
/**
|
|
22
|
-
roleSwitch?: boolean;
|
|
31
|
+
/** Toggle state for switch behavior */
|
|
23
32
|
checked?: boolean;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
/** Enable switch/toggle behavior */
|
|
34
|
+
roleSwitch?: boolean;
|
|
35
|
+
/** Bindable element reference */
|
|
36
|
+
el?: HTMLElement;
|
|
37
|
+
/** Optional tooltip configuration or direct content */
|
|
38
|
+
tooltip?: string | TooltipConfig;
|
|
39
|
+
/** Is this button a "X" button (this is a pragmatic convenience) */
|
|
40
|
+
x?: boolean | XProps;
|
|
41
|
+
/** Optional out-of-the-box spinner support */
|
|
42
|
+
spinner?: boolean | THC;
|
|
43
|
+
/** Show only spinner when spinner? */
|
|
44
|
+
spinnerOnly?: boolean;
|
|
33
45
|
}
|
|
34
|
-
export declare const BUTTON_STUIC_BASE_CLASSES = "\n\t\tbg-button-bg text-button-text\n\t\tdark:bg-button-bg-dark dark:text-button-text-dark\n\t\ttext-base text-center\n\t\tleading-none\n\t\tborder-1\n\t\tborder-button-border dark:border-button-border-dark\n\t\trounded-lg\n\t\tinline-flex items-center justify-center gap-x-2\n\t\tpx-4 py-3\n\t\tselect-none\n\t\tmin-h-[44px] min-w-[44px]\n\n\t\thover:brightness-105\n\t\tactive:brightness-95\n\t\tdisabled:hover:brightness-100 disabled:opacity-50\n\n\t\tfocus:brightness-105\n\t\tfocus:border-button-border-focus focus:dark:border-button-border-focus-dark\n\n\t\t focus:outline-4 focus:outline-black/10 focus:dark:outline-white/20\n\t\tfocus-visible:outline-4 focus-visible:outline-black/10 focus-visible:dark:outline-white/20\n\t";
|
|
35
|
-
export declare const BUTTON_STUIC_PRESET_CLASSES: ButtonPresetClasses;
|
|
36
46
|
import "./index.css";
|
|
37
|
-
import { type TooltipConfig } from "../../actions/
|
|
47
|
+
import { type TooltipConfig } from "../../actions/tooltip/tooltip.svelte.js";
|
|
48
|
+
import { type XProps } from "../X/index.js";
|
|
49
|
+
import { type THC } from "../Thc/Thc.svelte";
|
|
38
50
|
declare const Button: import("svelte").Component<Props, {}, "checked" | "el">;
|
|
39
51
|
type Button = ReturnType<typeof Button>;
|
|
40
52
|
export default Button;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
# Button
|
|
2
2
|
|
|
3
|
-
A flexible button component with
|
|
3
|
+
A flexible button component with semantic intents, visual variants, sizes, and optional toggle/switch behavior. Can render as a button or anchor tag.
|
|
4
4
|
|
|
5
5
|
## Props
|
|
6
6
|
|
|
7
7
|
| Prop | Type | Default | Description |
|
|
8
8
|
|------|------|---------|-------------|
|
|
9
|
-
| `
|
|
10
|
-
| `
|
|
11
|
-
| `
|
|
12
|
-
| `
|
|
13
|
-
| `
|
|
9
|
+
| `intent` | `"primary" \| "accent" \| "destructive" \| "warning" \| "success" \| "info"` | - | Semantic color intent |
|
|
10
|
+
| `variant` | `"solid" \| "outline" \| "ghost" \| "soft" \| "link"` | `"solid"` | Visual variant (how colors are applied) |
|
|
11
|
+
| `size` | `"sm" \| "md" \| "lg" \| "xl"` | `"md"` | Button size |
|
|
12
|
+
| `muted` | `boolean` | `false` | Reduce emphasis (lower opacity) |
|
|
13
|
+
| `raised` | `boolean` | `false` | 3D push effect |
|
|
14
14
|
| `unstyled` | `boolean` | `false` | Skip all default styling |
|
|
15
|
-
| `inverse` | `boolean` | `false` | Transparent bg, styled on hover |
|
|
16
15
|
| `href` | `string` | - | Render as anchor tag with this URL |
|
|
17
16
|
| `roleSwitch` | `boolean` | `false` | Enable toggle/switch behavior |
|
|
18
17
|
| `checked` | `boolean` | `false` | Toggle state when `roleSwitch` is true (bindable) |
|
|
19
|
-
| `el` | `
|
|
18
|
+
| `el` | `HTMLElement` | - | Element reference (bindable) |
|
|
20
19
|
| `class` | `string` | - | Additional CSS classes |
|
|
21
20
|
|
|
22
21
|
## Snippet Props
|
|
@@ -25,32 +24,45 @@ The `children` snippet receives `{ checked }` when `roleSwitch` is enabled.
|
|
|
25
24
|
|
|
26
25
|
## Usage
|
|
27
26
|
|
|
28
|
-
###
|
|
27
|
+
### Intent x Variant
|
|
29
28
|
|
|
30
29
|
```svelte
|
|
31
30
|
<script lang="ts">
|
|
32
|
-
import { Button } from 'stuic';
|
|
31
|
+
import { Button } from '@marianmeres/stuic';
|
|
33
32
|
</script>
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
<Button
|
|
37
|
-
<Button
|
|
34
|
+
<!-- Intent determines the color palette -->
|
|
35
|
+
<Button intent="primary">Primary</Button>
|
|
36
|
+
<Button intent="destructive">Destructive</Button>
|
|
37
|
+
<Button intent="success">Success</Button>
|
|
38
|
+
|
|
39
|
+
<!-- Variant determines how colors are applied -->
|
|
40
|
+
<Button intent="primary" variant="solid">Solid</Button>
|
|
41
|
+
<Button intent="primary" variant="outline">Outline</Button>
|
|
42
|
+
<Button intent="primary" variant="ghost">Ghost</Button>
|
|
43
|
+
<Button intent="primary" variant="soft">Soft</Button>
|
|
44
|
+
<Button intent="primary" variant="link">Link</Button>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Sizes
|
|
48
|
+
|
|
49
|
+
```svelte
|
|
38
50
|
<Button size="sm">Small</Button>
|
|
51
|
+
<Button size="md">Medium</Button>
|
|
39
52
|
<Button size="lg">Large</Button>
|
|
53
|
+
<Button size="xl">Extra Large</Button>
|
|
40
54
|
```
|
|
41
55
|
|
|
42
|
-
###
|
|
56
|
+
### 3D Push Effect
|
|
43
57
|
|
|
44
58
|
```svelte
|
|
45
|
-
<Button
|
|
46
|
-
Hover to see background
|
|
47
|
-
</Button>
|
|
59
|
+
<Button intent="primary" raised>Push Me</Button>
|
|
48
60
|
```
|
|
49
61
|
|
|
50
62
|
### As Link
|
|
51
63
|
|
|
52
64
|
```svelte
|
|
53
|
-
<Button href="/dashboard">
|
|
65
|
+
<Button href="/dashboard" intent="primary">
|
|
54
66
|
Go to Dashboard
|
|
55
67
|
</Button>
|
|
56
68
|
```
|
|
@@ -59,7 +71,7 @@ The `children` snippet receives `{ checked }` when `roleSwitch` is enabled.
|
|
|
59
71
|
|
|
60
72
|
```svelte
|
|
61
73
|
<script lang="ts">
|
|
62
|
-
import { Button } from 'stuic';
|
|
74
|
+
import { Button } from '@marianmeres/stuic';
|
|
63
75
|
|
|
64
76
|
let isActive = $state(false);
|
|
65
77
|
</script>
|
|
@@ -74,10 +86,64 @@ The `children` snippet receives `{ checked }` when `roleSwitch` is enabled.
|
|
|
74
86
|
### Custom Styling
|
|
75
87
|
|
|
76
88
|
```svelte
|
|
89
|
+
<!-- Using unstyled for full control -->
|
|
77
90
|
<Button
|
|
78
91
|
unstyled
|
|
79
|
-
class="bg-
|
|
92
|
+
class="bg-gradient-to-red from-purple-500 to-pink-500 text-white px-4 py-2 rounded-lg"
|
|
80
93
|
>
|
|
81
|
-
|
|
94
|
+
Gradient Button
|
|
95
|
+
</Button>
|
|
96
|
+
|
|
97
|
+
<!-- Override component tokens inline -->
|
|
98
|
+
<Button intent="primary" style="--stuic-button-radius: 9999px;">
|
|
99
|
+
Pill Shape
|
|
82
100
|
</Button>
|
|
83
101
|
```
|
|
102
|
+
|
|
103
|
+
## CSS Variables
|
|
104
|
+
|
|
105
|
+
### Component Tokens
|
|
106
|
+
|
|
107
|
+
| Variable | Default | Description |
|
|
108
|
+
|----------|---------|-------------|
|
|
109
|
+
| `--stuic-button-radius` | `--radius-md` | Border radius |
|
|
110
|
+
| `--stuic-button-font-family` | `--font-sans` | Font family |
|
|
111
|
+
| `--stuic-button-font-weight` | `--font-weight-medium` | Font weight |
|
|
112
|
+
| `--stuic-button-transition` | `100ms` | Transition duration |
|
|
113
|
+
| `--stuic-button-ring-width` | `3px` | Focus ring width |
|
|
114
|
+
| `--stuic-button-ring-color` | `--stuic-color-ring` | Focus ring color |
|
|
115
|
+
| `--stuic-button-raised-offset` | `2px` | 3D effect offset |
|
|
116
|
+
| `--stuic-button-raised-color` | `rgb(0 0 0 / 0.8)` | 3D shadow color |
|
|
117
|
+
|
|
118
|
+
### Size Tokens
|
|
119
|
+
|
|
120
|
+
Each size (sm, md, lg, xl) has corresponding tokens:
|
|
121
|
+
- `--stuic-button-padding-x-{size}`
|
|
122
|
+
- `--stuic-button-padding-y-{size}`
|
|
123
|
+
- `--stuic-button-font-size-{size}`
|
|
124
|
+
- `--stuic-button-min-height-{size}`
|
|
125
|
+
|
|
126
|
+
### Intent Color Tokens
|
|
127
|
+
|
|
128
|
+
Override these to customize intent colors globally:
|
|
129
|
+
|
|
130
|
+
```css
|
|
131
|
+
:root {
|
|
132
|
+
--stuic-color-primary: var(--color-blue-600);
|
|
133
|
+
--stuic-color-primary-hover: var(--color-blue-700);
|
|
134
|
+
--stuic-color-primary-active: var(--color-blue-800);
|
|
135
|
+
--stuic-color-primary-foreground: var(--color-white);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Available intents: `primary`, `accent`, `destructive`, `warning`, `success`, `info`
|
|
140
|
+
|
|
141
|
+
## Data Attributes
|
|
142
|
+
|
|
143
|
+
The component uses data attributes for styling:
|
|
144
|
+
- `data-intent` - The intent value
|
|
145
|
+
- `data-variant` - The variant value
|
|
146
|
+
- `data-size` - The size value
|
|
147
|
+
- `data-muted` - Present when muted
|
|
148
|
+
- `data-raised` - Present when raised
|
|
149
|
+
- `data-checked` - Present when roleSwitch is enabled and checked
|