@marianmeres/stuic 3.72.2 → 3.74.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/AGENTS.md +2 -2
- package/API.md +30 -0
- package/README.md +1 -1
- package/dist/components/Book/BookResponsive.svelte +2 -1
- package/dist/components/Input/FieldPhoneNumber.svelte +2 -3
- package/dist/components/LoginForm/LoginForm.svelte +26 -64
- package/dist/components/LoginForm/LoginForm.svelte.d.ts +0 -1
- package/dist/components/LoginForm/LoginFormModal.svelte +1 -2
- package/dist/components/LoginForm/index.css +12 -29
- package/dist/components/LoginOrRegisterForm/LoginOrRegisterForm.svelte +9 -1
- package/dist/components/LoginOrRegisterForm/LoginOrRegisterForm.svelte.d.ts +6 -1
- package/dist/components/LoginOrRegisterForm/LoginOrRegisterFormModal.svelte +8 -0
- package/dist/components/LoginOrRegisterForm/LoginOrRegisterFormModal.svelte.d.ts +5 -0
- package/dist/components/LoginOrRegisterForm/index.css +3 -3
- package/dist/components/Pill/Pill.svelte +205 -0
- package/dist/components/Pill/Pill.svelte.d.ts +51 -0
- package/dist/components/Pill/README.md +211 -0
- package/dist/components/Pill/index.css +488 -0
- package/dist/components/Pill/index.d.ts +1 -0
- package/dist/components/Pill/index.js +1 -0
- package/dist/components/PricingTable/PricingTable.svelte +0 -2
- package/dist/components/RegisterForm/RegisterForm.svelte +1 -23
- package/dist/components/RegisterForm/RegisterForm.svelte.d.ts +0 -1
- package/dist/components/RegisterForm/RegisterFormModal.svelte +0 -1
- package/dist/components/RegisterForm/index.css +6 -16
- package/dist/index.css +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mcp.js +1 -0
- package/docs/domains/components.md +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { IntentColorKey } from "../../utils/design-tokens.js";
|
|
4
|
+
import type { THC } from "../Thc/Thc.svelte";
|
|
5
|
+
export type PillVariant = "solid" | "outline" | "ghost" | "soft" | "link";
|
|
6
|
+
export type PillSize = "sm" | "md" | "lg";
|
|
7
|
+
export interface Props extends Omit<HTMLAttributes<HTMLElement>, "children"> {
|
|
8
|
+
/** Color intent (semantic meaning) */
|
|
9
|
+
intent?: IntentColorKey;
|
|
10
|
+
/** Visual variant (how colors are applied) */
|
|
11
|
+
variant?: PillVariant | string;
|
|
12
|
+
/** Size preset */
|
|
13
|
+
size?: PillSize | string;
|
|
14
|
+
/** Reduce emphasis (lower opacity) */
|
|
15
|
+
muted?: boolean;
|
|
16
|
+
/** Selected/active state — useful for filter-chip behavior */
|
|
17
|
+
active?: boolean;
|
|
18
|
+
/** Pill is fully rounded by default; set false to use element radius */
|
|
19
|
+
roundedFull?: boolean;
|
|
20
|
+
/** Render as block-level flex (full width). Inline-flex by default. */
|
|
21
|
+
block?: boolean;
|
|
22
|
+
/** Skip all default styling, use only custom classes */
|
|
23
|
+
unstyled?: boolean;
|
|
24
|
+
/** Additional CSS classes */
|
|
25
|
+
class?: string;
|
|
26
|
+
/** Render as anchor tag */
|
|
27
|
+
href?: string;
|
|
28
|
+
/** Link target (e.g. "_blank") — only relevant when href is set */
|
|
29
|
+
target?: string;
|
|
30
|
+
/** Render as button (when href not set) */
|
|
31
|
+
onclick?: (e: MouseEvent) => void;
|
|
32
|
+
/** Disabled (interactive variants only) */
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/** Show built-in X dismiss control */
|
|
35
|
+
dismissible?: boolean;
|
|
36
|
+
/** Called when X is clicked. Stops propagation so parent onclick is unaffected. */
|
|
37
|
+
ondismiss?: (e: MouseEvent) => void;
|
|
38
|
+
/** Status dot rendered before content (uses current intent color) */
|
|
39
|
+
dot?: boolean;
|
|
40
|
+
/** Content rendered before children */
|
|
41
|
+
contentBefore?: THC;
|
|
42
|
+
/** Content rendered after children */
|
|
43
|
+
contentAfter?: THC;
|
|
44
|
+
/** Bindable element reference */
|
|
45
|
+
el?: HTMLElement;
|
|
46
|
+
/** Content snippet */
|
|
47
|
+
children?: Snippet;
|
|
48
|
+
}
|
|
49
|
+
declare const Pill: import("svelte").Component<Props, {}, "el">;
|
|
50
|
+
type Pill = ReturnType<typeof Pill>;
|
|
51
|
+
export default Pill;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Pill
|
|
2
|
+
|
|
3
|
+
A small rounded inline element for tags, badges, status indicators, and filter chips. Polymorphic (renders as `<span>`, `<a>`, or `<button>` depending on props), with optional dismiss button, status dot, and content slots.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Default | Description |
|
|
8
|
+
| --------------- | ------------------------------------------------------------------ | -------- | -------------------------------------------------------------------- |
|
|
9
|
+
| `intent` | `"primary" \| "accent" \| "destructive" \| "warning" \| "success"` | - | Semantic color intent |
|
|
10
|
+
| `variant` | `"solid" \| "outline" \| "ghost" \| "soft" \| "link"` | `"soft"` | Visual variant (how colors are applied) |
|
|
11
|
+
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | Pill size |
|
|
12
|
+
| `muted` | `boolean` | `false` | Reduce emphasis (lower opacity) |
|
|
13
|
+
| `active` | `boolean` | `false` | Selected/active state (filter-chip behavior) |
|
|
14
|
+
| `roundedFull` | `boolean` | `true` | Fully rounded corners (9999px). Set `false` to use the element radius |
|
|
15
|
+
| `block` | `boolean` | `false` | Render as block-level flex (full width). `inline-flex` by default |
|
|
16
|
+
| `unstyled` | `boolean` | `false` | Skip all default styling |
|
|
17
|
+
| `href` | `string` | - | Render as `<a>` with this URL |
|
|
18
|
+
| `target` | `string` | - | Link target (only when `href` is set) |
|
|
19
|
+
| `onclick` | `(e: MouseEvent) => void` | - | Render as `<button>` with this handler (when no `href`) |
|
|
20
|
+
| `disabled` | `boolean` | - | Disabled state (interactive variants only) |
|
|
21
|
+
| `dismissible` | `boolean` | `false` | Show built-in X dismiss button |
|
|
22
|
+
| `ondismiss` | `(e: MouseEvent) => void` | - | Called when X is clicked. Stops propagation |
|
|
23
|
+
| `dot` | `boolean` | `false` | Status dot rendered before content |
|
|
24
|
+
| `contentBefore` | `THC` | - | Content rendered before children |
|
|
25
|
+
| `contentAfter` | `THC` | - | Content rendered after children |
|
|
26
|
+
| `el` | `HTMLElement` | - | Element reference (bindable) |
|
|
27
|
+
| `class` | `string` | - | Additional CSS classes |
|
|
28
|
+
|
|
29
|
+
## Element Resolution
|
|
30
|
+
|
|
31
|
+
| Condition | Element |
|
|
32
|
+
| --------------------------------- | ------------------------------------------------------ |
|
|
33
|
+
| Default | `<span>` |
|
|
34
|
+
| `href` set | `<a>` |
|
|
35
|
+
| `onclick` set (no `href`) | `<button>` |
|
|
36
|
+
| `dismissible` set | `<span>` wrapper containing main element + X sibling |
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
### Intent x Variant
|
|
41
|
+
|
|
42
|
+
```svelte
|
|
43
|
+
<script lang="ts">
|
|
44
|
+
import { Pill } from "@marianmeres/stuic";
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<Pill intent="primary">primary</Pill>
|
|
48
|
+
<Pill intent="success" variant="solid">success</Pill>
|
|
49
|
+
<Pill intent="destructive" variant="outline">destructive</Pill>
|
|
50
|
+
<Pill intent="warning" variant="ghost">warning</Pill>
|
|
51
|
+
<Pill intent="accent" variant="link">accent</Pill>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Sizes
|
|
55
|
+
|
|
56
|
+
```svelte
|
|
57
|
+
<Pill size="sm">Small</Pill>
|
|
58
|
+
<Pill size="md">Medium</Pill>
|
|
59
|
+
<Pill size="lg">Large</Pill>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Polymorphic
|
|
63
|
+
|
|
64
|
+
```svelte
|
|
65
|
+
<!-- Plain inline marker (span) -->
|
|
66
|
+
<Pill intent="primary">tag</Pill>
|
|
67
|
+
|
|
68
|
+
<!-- Anchor link -->
|
|
69
|
+
<Pill intent="accent" href="/profile">Profile</Pill>
|
|
70
|
+
|
|
71
|
+
<!-- Button -->
|
|
72
|
+
<Pill intent="success" onclick={() => console.log("clicked")}>
|
|
73
|
+
Click me
|
|
74
|
+
</Pill>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Status Dot
|
|
78
|
+
|
|
79
|
+
```svelte
|
|
80
|
+
<Pill intent="success" dot>Online</Pill>
|
|
81
|
+
<Pill intent="warning" dot>Idle</Pill>
|
|
82
|
+
<Pill intent="destructive" dot>Offline</Pill>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Dismissible
|
|
86
|
+
|
|
87
|
+
```svelte
|
|
88
|
+
<script lang="ts">
|
|
89
|
+
let tags = $state(["svelte", "tailwind", "stuic"]);
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
{#each tags as tag (tag)}
|
|
93
|
+
<Pill
|
|
94
|
+
intent="primary"
|
|
95
|
+
dismissible
|
|
96
|
+
ondismiss={() => (tags = tags.filter((x) => x !== tag))}
|
|
97
|
+
>
|
|
98
|
+
{tag}
|
|
99
|
+
</Pill>
|
|
100
|
+
{/each}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`dismissible` works alongside `onclick` and `href` — the X button stops propagation so the parent click/navigation only fires for clicks outside the X.
|
|
104
|
+
|
|
105
|
+
### Filter Chips (active state)
|
|
106
|
+
|
|
107
|
+
```svelte
|
|
108
|
+
<script lang="ts">
|
|
109
|
+
let filters = $state(new Set<string>());
|
|
110
|
+
function toggle(f: string) {
|
|
111
|
+
filters.has(f) ? filters.delete(f) : filters.add(f);
|
|
112
|
+
filters = new Set(filters);
|
|
113
|
+
}
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
{#each ["new", "popular", "in-stock"] as opt}
|
|
117
|
+
<Pill
|
|
118
|
+
intent="primary"
|
|
119
|
+
variant="outline"
|
|
120
|
+
active={filters.has(opt)}
|
|
121
|
+
onclick={() => toggle(opt)}
|
|
122
|
+
>
|
|
123
|
+
{opt}
|
|
124
|
+
</Pill>
|
|
125
|
+
{/each}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Icons via contentBefore / contentAfter
|
|
129
|
+
|
|
130
|
+
```svelte
|
|
131
|
+
<Pill intent="success" contentBefore={{ html: iconCheck() }}>Verified</Pill>
|
|
132
|
+
<Pill intent="primary" contentAfter={{ html: iconArrowRight() }}>Next</Pill>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`contentBefore` and `contentAfter` accept any `THC` value (string, `{ html }`, `{ text }`, component, snippet).
|
|
136
|
+
|
|
137
|
+
### Block (full width)
|
|
138
|
+
|
|
139
|
+
```svelte
|
|
140
|
+
<Pill intent="primary" block>Block-level pill</Pill>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Custom Styling
|
|
144
|
+
|
|
145
|
+
```svelte
|
|
146
|
+
<!-- Override radius inline -->
|
|
147
|
+
<Pill intent="primary" style="--stuic-pill-radius: 4px;">Squared</Pill>
|
|
148
|
+
|
|
149
|
+
<!-- Disable rounded-full default for element-radius -->
|
|
150
|
+
<Pill intent="primary" roundedFull={false}>Element radius</Pill>
|
|
151
|
+
|
|
152
|
+
<!-- Unstyled for full control -->
|
|
153
|
+
<Pill unstyled class="bg-gradient-to-r from-purple-500 to-pink-500 text-white px-3 py-1 rounded-full">
|
|
154
|
+
Custom
|
|
155
|
+
</Pill>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## CSS Variables
|
|
159
|
+
|
|
160
|
+
### Component Tokens
|
|
161
|
+
|
|
162
|
+
| Variable | Default | Description |
|
|
163
|
+
| ----------------------------- | ---------------------- | --------------------- |
|
|
164
|
+
| `--stuic-pill-radius` | `--stuic-radius` | Border radius (overridden to `9999px` by `roundedFull`) |
|
|
165
|
+
| `--stuic-pill-font-family` | `--font-sans` | Font family |
|
|
166
|
+
| `--stuic-pill-font-weight` | `--font-weight-medium` | Font weight |
|
|
167
|
+
| `--stuic-pill-transition` | `--stuic-transition` | Transition duration |
|
|
168
|
+
| `--stuic-pill-border-width` | `--stuic-border-width` | Border width |
|
|
169
|
+
| `--stuic-pill-ring-width` | `2px` | Focus ring width |
|
|
170
|
+
| `--stuic-pill-ring-color` | `--stuic-color-ring` | Focus ring color |
|
|
171
|
+
| `--stuic-pill-gap` | `0.375rem` | Gap between dot/before/children/after/dismiss |
|
|
172
|
+
| `--stuic-pill-dot-size` | `0.5rem` | Status dot diameter |
|
|
173
|
+
|
|
174
|
+
### Size Tokens
|
|
175
|
+
|
|
176
|
+
Each size (sm, md, lg) has corresponding tokens:
|
|
177
|
+
|
|
178
|
+
- `--stuic-pill-padding-x-{size}`
|
|
179
|
+
- `--stuic-pill-padding-y-{size}`
|
|
180
|
+
- `--stuic-pill-font-size-{size}`
|
|
181
|
+
- `--stuic-pill-min-height-{size}`
|
|
182
|
+
|
|
183
|
+
Dismissible pills override `padding-y` to `0` (the X button defines the height).
|
|
184
|
+
|
|
185
|
+
### Intent Color Tokens
|
|
186
|
+
|
|
187
|
+
Pill reuses the global intent palette:
|
|
188
|
+
|
|
189
|
+
```css
|
|
190
|
+
:root {
|
|
191
|
+
--stuic-color-primary: ...;
|
|
192
|
+
--stuic-color-primary-hover: ...;
|
|
193
|
+
--stuic-color-primary-foreground: ...;
|
|
194
|
+
/* + accent, destructive, warning, success */
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Data Attributes
|
|
199
|
+
|
|
200
|
+
The component uses data attributes for styling:
|
|
201
|
+
|
|
202
|
+
- `data-intent` - intent value
|
|
203
|
+
- `data-variant` - variant value
|
|
204
|
+
- `data-size` - size value
|
|
205
|
+
- `data-muted` - present when `muted`
|
|
206
|
+
- `data-active` - present when `active`
|
|
207
|
+
- `data-rounded-full` - present when `roundedFull`
|
|
208
|
+
- `data-block` - present when `block`
|
|
209
|
+
- `data-with-dot` - present when `dot`
|
|
210
|
+
- `data-dismissible` - present when `dismissible`
|
|
211
|
+
- `data-interactive` - present on `<a>` / `<button>` non-dismissible variants
|