plasma-svelte 0.0.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 +65 -0
- package/dist/accordion/Accordion.svelte +28 -0
- package/dist/accordion/Accordion.svelte.d.ts +8 -0
- package/dist/accordion/AccordionItem.svelte +193 -0
- package/dist/accordion/AccordionItem.svelte.d.ts +14 -0
- package/dist/avatar/Avatar.svelte +178 -0
- package/dist/avatar/Avatar.svelte.d.ts +16 -0
- package/dist/badge/Badge.svelte +162 -0
- package/dist/badge/Badge.svelte.d.ts +16 -0
- package/dist/breadcrumb/Breadcrumb.svelte +59 -0
- package/dist/breadcrumb/Breadcrumb.svelte.d.ts +9 -0
- package/dist/breadcrumb/BreadcrumbItem.svelte +151 -0
- package/dist/breadcrumb/BreadcrumbItem.svelte.d.ts +14 -0
- package/dist/button/Button.svelte +274 -0
- package/dist/button/Button.svelte.d.ts +22 -0
- package/dist/button/ButtonGroup.svelte +98 -0
- package/dist/button/ButtonGroup.svelte.d.ts +12 -0
- package/dist/card/Card.svelte +191 -0
- package/dist/card/Card.svelte.d.ts +18 -0
- package/dist/checkbox/Checkbox.svelte +199 -0
- package/dist/checkbox/Checkbox.svelte.d.ts +12 -0
- package/dist/datepicker/DatePicker.svelte +509 -0
- package/dist/datepicker/DatePicker.svelte.d.ts +14 -0
- package/dist/divider/Divider.svelte +112 -0
- package/dist/divider/Divider.svelte.d.ts +13 -0
- package/dist/drawer/Drawer.svelte +330 -0
- package/dist/drawer/Drawer.svelte.d.ts +21 -0
- package/dist/dropzone/DropZone.svelte +282 -0
- package/dist/dropzone/DropZone.svelte.d.ts +17 -0
- package/dist/emptystate/EmptyState.svelte +169 -0
- package/dist/emptystate/EmptyState.svelte.d.ts +15 -0
- package/dist/headerbar/HeaderBar.svelte +210 -0
- package/dist/headerbar/HeaderBar.svelte.d.ts +17 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +44 -0
- package/dist/input/Input.svelte +227 -0
- package/dist/input/Input.svelte.d.ts +14 -0
- package/dist/layout/Flex.svelte +110 -0
- package/dist/layout/Flex.svelte.d.ts +20 -0
- package/dist/layout/Grid.svelte +78 -0
- package/dist/layout/Grid.svelte.d.ts +19 -0
- package/dist/layout/Space.svelte +64 -0
- package/dist/layout/Space.svelte.d.ts +16 -0
- package/dist/layout/utils.d.ts +2 -0
- package/dist/layout/utils.js +19 -0
- package/dist/menu/Menu.svelte +156 -0
- package/dist/menu/Menu.svelte.d.ts +14 -0
- package/dist/menu/MenuDivider.svelte +19 -0
- package/dist/menu/MenuDivider.svelte.d.ts +6 -0
- package/dist/menu/MenuItem.svelte +126 -0
- package/dist/menu/MenuItem.svelte.d.ts +13 -0
- package/dist/message/InlineMessage.svelte +226 -0
- package/dist/message/InlineMessage.svelte.d.ts +15 -0
- package/dist/modal/ConfirmDialog.svelte +151 -0
- package/dist/modal/ConfirmDialog.svelte.d.ts +19 -0
- package/dist/modal/Modal.svelte +279 -0
- package/dist/modal/Modal.svelte.d.ts +18 -0
- package/dist/pagination/Pagination.svelte +258 -0
- package/dist/pagination/Pagination.svelte.d.ts +16 -0
- package/dist/progress/ProgressBar.svelte +179 -0
- package/dist/progress/ProgressBar.svelte.d.ts +15 -0
- package/dist/radio/Radio.svelte +161 -0
- package/dist/radio/Radio.svelte.d.ts +13 -0
- package/dist/searchfield/SearchField.svelte +246 -0
- package/dist/searchfield/SearchField.svelte.d.ts +15 -0
- package/dist/select/Select.svelte +392 -0
- package/dist/select/Select.svelte.d.ts +20 -0
- package/dist/sidebar/Sidebar.svelte +78 -0
- package/dist/sidebar/Sidebar.svelte.d.ts +11 -0
- package/dist/sidebar/SidebarGroup.svelte +51 -0
- package/dist/sidebar/SidebarGroup.svelte.d.ts +9 -0
- package/dist/sidebar/SidebarItem.svelte +185 -0
- package/dist/sidebar/SidebarItem.svelte.d.ts +16 -0
- package/dist/slider/Slider.svelte +204 -0
- package/dist/slider/Slider.svelte.d.ts +16 -0
- package/dist/spinbox/SpinBox.svelte +299 -0
- package/dist/spinbox/SpinBox.svelte.d.ts +20 -0
- package/dist/spinner/Spinner.svelte +130 -0
- package/dist/spinner/Spinner.svelte.d.ts +11 -0
- package/dist/style/base.css +178 -0
- package/dist/style/index.css +2 -0
- package/dist/style/token.css +230 -0
- package/dist/switch/Switch.svelte +199 -0
- package/dist/switch/Switch.svelte.d.ts +13 -0
- package/dist/table/Table.svelte +305 -0
- package/dist/table/Table.svelte.d.ts +32 -0
- package/dist/tabs/Tabs.svelte +216 -0
- package/dist/tabs/Tabs.svelte.d.ts +21 -0
- package/dist/textarea/TextArea.svelte +114 -0
- package/dist/textarea/TextArea.svelte.d.ts +14 -0
- package/dist/timepicker/TimePicker.svelte +452 -0
- package/dist/timepicker/TimePicker.svelte.d.ts +16 -0
- package/dist/tooltip/Tooltip.svelte +122 -0
- package/dist/tooltip/Tooltip.svelte.d.ts +12 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Svelte library
|
|
2
|
+
|
|
3
|
+
Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
|
|
4
|
+
|
|
5
|
+
Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
|
|
6
|
+
|
|
7
|
+
## Creating a project
|
|
8
|
+
|
|
9
|
+
If you're seeing this, you've probably already done this step. Congrats!
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
# create a new project in the current directory
|
|
13
|
+
npx sv create
|
|
14
|
+
|
|
15
|
+
# create a new project in my-app
|
|
16
|
+
npx sv create my-app
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
To recreate this project with the same configuration:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
# recreate this project
|
|
23
|
+
pnpm dlx sv@0.17.0 create --template library --types ts --add storybook --install pnpm plasma-svelte
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Developing
|
|
27
|
+
|
|
28
|
+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm run dev
|
|
32
|
+
|
|
33
|
+
# or start the server and open the app in a new browser tab
|
|
34
|
+
npm run dev -- --open
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
|
|
38
|
+
|
|
39
|
+
## Building
|
|
40
|
+
|
|
41
|
+
To build your library:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm pack
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
To create a production version of your showcase app:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm run build
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You can preview the production build with `npm run preview`.
|
|
54
|
+
|
|
55
|
+
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
|
56
|
+
|
|
57
|
+
## Publishing
|
|
58
|
+
|
|
59
|
+
Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
|
|
60
|
+
|
|
61
|
+
To publish your library to [npm](https://www.npmjs.com):
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npm publish
|
|
65
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
children,
|
|
11
|
+
class: customClass = "",
|
|
12
|
+
...restProps
|
|
13
|
+
}: Props = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<div class="plasma-accordion-group {customClass}" {...restProps}>
|
|
17
|
+
{@render children?.()}
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<style>
|
|
21
|
+
.plasma-accordion-group {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
gap: var(--plasma-space-sm);
|
|
25
|
+
width: 100%;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
}
|
|
6
|
+
declare const Accordion: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type Accordion = ReturnType<typeof Accordion>;
|
|
8
|
+
export default Accordion;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, "ontoggle"> {
|
|
6
|
+
title?: string;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
icon?: Snippet;
|
|
10
|
+
header?: Snippet;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
ontoggle?: (isOpen: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
title = "",
|
|
18
|
+
open = $bindable(false),
|
|
19
|
+
disabled = false,
|
|
20
|
+
icon,
|
|
21
|
+
header,
|
|
22
|
+
children,
|
|
23
|
+
ontoggle,
|
|
24
|
+
class: customClass = "",
|
|
25
|
+
id,
|
|
26
|
+
...restProps
|
|
27
|
+
}: Props = $props();
|
|
28
|
+
|
|
29
|
+
function toggle() {
|
|
30
|
+
if (disabled) return;
|
|
31
|
+
open = !open;
|
|
32
|
+
ontoggle?.(open);
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<div
|
|
37
|
+
class="plasma-accordion-item {customClass}"
|
|
38
|
+
class:plasma-accordion-item--open={open}
|
|
39
|
+
class:plasma-accordion-item--disabled={disabled}
|
|
40
|
+
{...restProps}
|
|
41
|
+
>
|
|
42
|
+
<button
|
|
43
|
+
{id}
|
|
44
|
+
type="button"
|
|
45
|
+
aria-expanded={open}
|
|
46
|
+
{disabled}
|
|
47
|
+
onclick={toggle}
|
|
48
|
+
class="plasma-accordion-header"
|
|
49
|
+
>
|
|
50
|
+
{#if icon}
|
|
51
|
+
<span class="plasma-accordion-icon">
|
|
52
|
+
{@render icon()}
|
|
53
|
+
</span>
|
|
54
|
+
{/if}
|
|
55
|
+
|
|
56
|
+
<span class="plasma-accordion-title">
|
|
57
|
+
{#if header}
|
|
58
|
+
{@render header()}
|
|
59
|
+
{:else}
|
|
60
|
+
{title}
|
|
61
|
+
{/if}
|
|
62
|
+
</span>
|
|
63
|
+
|
|
64
|
+
<span class="plasma-accordion-chevron">
|
|
65
|
+
<svg
|
|
66
|
+
aria-hidden="true"
|
|
67
|
+
viewBox="0 0 16 16"
|
|
68
|
+
width="12"
|
|
69
|
+
height="12"
|
|
70
|
+
fill="currentColor"
|
|
71
|
+
>
|
|
72
|
+
<path
|
|
73
|
+
fill-rule="evenodd"
|
|
74
|
+
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"
|
|
75
|
+
/>
|
|
76
|
+
</svg>
|
|
77
|
+
</span>
|
|
78
|
+
</button>
|
|
79
|
+
|
|
80
|
+
<div class="plasma-accordion-collapse" class:plasma-accordion-collapse--open={open}>
|
|
81
|
+
<div class="plasma-accordion-content">
|
|
82
|
+
{#if children}
|
|
83
|
+
{@render children()}
|
|
84
|
+
{/if}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<style>
|
|
90
|
+
.plasma-accordion-item {
|
|
91
|
+
border: 1px solid var(--plasma-color-border);
|
|
92
|
+
border-radius: var(--plasma-radius-lg);
|
|
93
|
+
background-color: var(--plasma-color-surface);
|
|
94
|
+
overflow: hidden;
|
|
95
|
+
transition: var(--plasma-transition-fast);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.plasma-accordion-item:hover:not(.plasma-accordion-item--disabled) {
|
|
99
|
+
border-color: var(--plasma-color-border-hover);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.plasma-accordion-item--open {
|
|
103
|
+
border-color: var(--plasma-color-border-hover);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.plasma-accordion-item--disabled {
|
|
107
|
+
opacity: 0.5;
|
|
108
|
+
cursor: not-allowed;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* --------------------------------------------------------------------------
|
|
112
|
+
Header Trigger Button
|
|
113
|
+
-------------------------------------------------------------------------- */
|
|
114
|
+
.plasma-accordion-header {
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
width: 100%;
|
|
118
|
+
padding: var(--plasma-space-md) var(--plasma-space-lg);
|
|
119
|
+
background: transparent;
|
|
120
|
+
border: none;
|
|
121
|
+
outline: none;
|
|
122
|
+
font-family: var(--plasma-font-sans);
|
|
123
|
+
font-size: var(--plasma-font-size-base);
|
|
124
|
+
color: var(--plasma-color-text);
|
|
125
|
+
cursor: pointer;
|
|
126
|
+
user-select: none;
|
|
127
|
+
text-align: left;
|
|
128
|
+
gap: var(--plasma-space-sm);
|
|
129
|
+
transition: var(--plasma-transition-fast);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.plasma-accordion-header:hover:not(:disabled) {
|
|
133
|
+
background-color: var(--plasma-color-surface-hover);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.plasma-accordion-header:focus-visible {
|
|
137
|
+
outline: 2px solid var(--plasma-color-highlight);
|
|
138
|
+
outline-offset: -2px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.plasma-accordion-icon {
|
|
142
|
+
display: inline-flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
justify-content: center;
|
|
145
|
+
color: var(--plasma-color-highlight);
|
|
146
|
+
flex-shrink: 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.plasma-accordion-title {
|
|
150
|
+
flex: 1;
|
|
151
|
+
font-weight: var(--plasma-font-weight-medium);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.plasma-accordion-chevron {
|
|
155
|
+
display: inline-flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
color: var(--plasma-color-text-muted);
|
|
158
|
+
transition: transform var(--plasma-duration-base) var(--plasma-ease-default);
|
|
159
|
+
flex-shrink: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.plasma-accordion-item--open .plasma-accordion-chevron {
|
|
163
|
+
transform: rotate(90deg);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* --------------------------------------------------------------------------
|
|
167
|
+
Collapsible Content Area (CSS Grid Height Transition)
|
|
168
|
+
-------------------------------------------------------------------------- */
|
|
169
|
+
.plasma-accordion-collapse {
|
|
170
|
+
display: grid;
|
|
171
|
+
grid-template-rows: 0fr;
|
|
172
|
+
transition: grid-template-rows var(--plasma-duration-base) var(--plasma-ease-default);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.plasma-accordion-collapse--open {
|
|
176
|
+
grid-template-rows: 1fr;
|
|
177
|
+
border-top: 1px solid var(--plasma-color-border-subtle);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.plasma-accordion-content {
|
|
181
|
+
overflow: hidden;
|
|
182
|
+
padding: 0 var(--plasma-space-lg);
|
|
183
|
+
font-size: var(--plasma-font-size-sm);
|
|
184
|
+
color: var(--plasma-color-text-muted);
|
|
185
|
+
line-height: var(--plasma-line-height-base);
|
|
186
|
+
background-color: var(--plasma-color-surface-sunken);
|
|
187
|
+
transition: padding var(--plasma-duration-base) var(--plasma-ease-default);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.plasma-accordion-collapse--open .plasma-accordion-content {
|
|
191
|
+
padding: var(--plasma-space-md) var(--plasma-space-lg);
|
|
192
|
+
}
|
|
193
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, "ontoggle"> {
|
|
4
|
+
title?: string;
|
|
5
|
+
open?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
icon?: Snippet;
|
|
8
|
+
header?: Snippet;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
ontoggle?: (isOpen: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const AccordionItem: import("svelte").Component<Props, {}, "open">;
|
|
13
|
+
type AccordionItem = ReturnType<typeof AccordionItem>;
|
|
14
|
+
export default AccordionItem;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
|
|
4
|
+
type AvatarSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
5
|
+
type AvatarShape = "circle" | "rounded";
|
|
6
|
+
type AvatarStatus = "online" | "away" | "busy" | "offline";
|
|
7
|
+
|
|
8
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
src?: string;
|
|
10
|
+
alt?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
initials?: string;
|
|
13
|
+
size?: AvatarSize;
|
|
14
|
+
shape?: AvatarShape;
|
|
15
|
+
status?: AvatarStatus;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
src,
|
|
20
|
+
alt = "Avatar",
|
|
21
|
+
name = "",
|
|
22
|
+
initials = "",
|
|
23
|
+
size = "md",
|
|
24
|
+
shape = "circle",
|
|
25
|
+
status,
|
|
26
|
+
class: customClass = "",
|
|
27
|
+
...restProps
|
|
28
|
+
}: Props = $props();
|
|
29
|
+
|
|
30
|
+
let hasImageError = $state(false);
|
|
31
|
+
|
|
32
|
+
const displayInitials = $derived(
|
|
33
|
+
initials
|
|
34
|
+
? initials
|
|
35
|
+
: name
|
|
36
|
+
? name
|
|
37
|
+
.split(" ")
|
|
38
|
+
.map((part) => part[0])
|
|
39
|
+
.slice(0, 2)
|
|
40
|
+
.join("")
|
|
41
|
+
.toUpperCase()
|
|
42
|
+
: "",
|
|
43
|
+
);
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<div
|
|
47
|
+
class="plasma-avatar plasma-avatar--{size} plasma-avatar--{shape} {customClass}"
|
|
48
|
+
{...restProps}
|
|
49
|
+
>
|
|
50
|
+
{#if src && !hasImageError}
|
|
51
|
+
<img
|
|
52
|
+
{src}
|
|
53
|
+
{alt}
|
|
54
|
+
onerror={() => (hasImageError = true)}
|
|
55
|
+
class="plasma-avatar-img"
|
|
56
|
+
/>
|
|
57
|
+
{:else if displayInitials}
|
|
58
|
+
<span class="plasma-avatar-initials">{displayInitials}</span>
|
|
59
|
+
{:else}
|
|
60
|
+
<svg
|
|
61
|
+
aria-hidden="true"
|
|
62
|
+
viewBox="0 0 16 16"
|
|
63
|
+
width="60%"
|
|
64
|
+
height="60%"
|
|
65
|
+
fill="currentColor"
|
|
66
|
+
class="plasma-avatar-fallback-icon"
|
|
67
|
+
>
|
|
68
|
+
<path
|
|
69
|
+
d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832 1.664h10z"
|
|
70
|
+
/>
|
|
71
|
+
</svg>
|
|
72
|
+
{/if}
|
|
73
|
+
|
|
74
|
+
{#if status}
|
|
75
|
+
<span class="plasma-avatar-status plasma-avatar-status--{status}"></span>
|
|
76
|
+
{/if}
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<style>
|
|
80
|
+
.plasma-avatar {
|
|
81
|
+
position: relative;
|
|
82
|
+
display: inline-flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
background-color: var(--plasma-color-highlight-soft);
|
|
86
|
+
color: var(--plasma-color-highlight);
|
|
87
|
+
border: 1px solid var(--plasma-color-border-subtle);
|
|
88
|
+
font-family: var(--plasma-font-sans);
|
|
89
|
+
font-weight: var(--plasma-font-weight-bold);
|
|
90
|
+
user-select: none;
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
box-sizing: border-box;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.plasma-avatar--circle {
|
|
96
|
+
border-radius: var(--plasma-radius-full);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.plasma-avatar--rounded {
|
|
100
|
+
border-radius: var(--plasma-radius-md);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.plasma-avatar-img {
|
|
104
|
+
width: 100%;
|
|
105
|
+
height: 100%;
|
|
106
|
+
object-fit: cover;
|
|
107
|
+
border-radius: inherit;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.plasma-avatar-initials {
|
|
111
|
+
line-height: 1;
|
|
112
|
+
text-transform: uppercase;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.plasma-avatar-fallback-icon {
|
|
116
|
+
opacity: 0.8;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* --------------------------------------------------------------------------
|
|
120
|
+
Sizing
|
|
121
|
+
-------------------------------------------------------------------------- */
|
|
122
|
+
.plasma-avatar--xs {
|
|
123
|
+
width: 24px;
|
|
124
|
+
height: 24px;
|
|
125
|
+
font-size: 10px;
|
|
126
|
+
}
|
|
127
|
+
.plasma-avatar--sm {
|
|
128
|
+
width: 32px;
|
|
129
|
+
height: 32px;
|
|
130
|
+
font-size: var(--plasma-font-size-xs);
|
|
131
|
+
}
|
|
132
|
+
.plasma-avatar--md {
|
|
133
|
+
width: 40px;
|
|
134
|
+
height: 40px;
|
|
135
|
+
font-size: var(--plasma-font-size-sm);
|
|
136
|
+
}
|
|
137
|
+
.plasma-avatar--lg {
|
|
138
|
+
width: 48px;
|
|
139
|
+
height: 48px;
|
|
140
|
+
font-size: var(--plasma-font-size-base);
|
|
141
|
+
}
|
|
142
|
+
.plasma-avatar--xl {
|
|
143
|
+
width: 64px;
|
|
144
|
+
height: 64px;
|
|
145
|
+
font-size: var(--plasma-font-size-lg);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* --------------------------------------------------------------------------
|
|
149
|
+
Status Dot Badge
|
|
150
|
+
-------------------------------------------------------------------------- */
|
|
151
|
+
.plasma-avatar-status {
|
|
152
|
+
position: absolute;
|
|
153
|
+
bottom: 0;
|
|
154
|
+
right: 0;
|
|
155
|
+
width: 26%;
|
|
156
|
+
height: 26%;
|
|
157
|
+
min-width: 8px;
|
|
158
|
+
min-height: 8px;
|
|
159
|
+
max-width: 14px;
|
|
160
|
+
max-height: 14px;
|
|
161
|
+
border-radius: var(--plasma-radius-full);
|
|
162
|
+
border: 2px solid var(--plasma-color-surface);
|
|
163
|
+
box-sizing: content-box;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.plasma-avatar-status--online {
|
|
167
|
+
background-color: var(--plasma-color-positive);
|
|
168
|
+
}
|
|
169
|
+
.plasma-avatar-status--away {
|
|
170
|
+
background-color: var(--plasma-color-neutral);
|
|
171
|
+
}
|
|
172
|
+
.plasma-avatar-status--busy {
|
|
173
|
+
background-color: var(--plasma-color-negative);
|
|
174
|
+
}
|
|
175
|
+
.plasma-avatar-status--offline {
|
|
176
|
+
background-color: var(--plasma-color-text-muted);
|
|
177
|
+
}
|
|
178
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
type AvatarSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
3
|
+
type AvatarShape = "circle" | "rounded";
|
|
4
|
+
type AvatarStatus = "online" | "away" | "busy" | "offline";
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
src?: string;
|
|
7
|
+
alt?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
initials?: string;
|
|
10
|
+
size?: AvatarSize;
|
|
11
|
+
shape?: AvatarShape;
|
|
12
|
+
status?: AvatarStatus;
|
|
13
|
+
}
|
|
14
|
+
declare const Avatar: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type Avatar = ReturnType<typeof Avatar>;
|
|
16
|
+
export default Avatar;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
type BadgeVariant =
|
|
6
|
+
| "default"
|
|
7
|
+
| "primary"
|
|
8
|
+
| "highlight"
|
|
9
|
+
| "positive"
|
|
10
|
+
| "success"
|
|
11
|
+
| "neutral"
|
|
12
|
+
| "warning"
|
|
13
|
+
| "negative"
|
|
14
|
+
| "danger";
|
|
15
|
+
|
|
16
|
+
type BadgeShape = "rounded" | "pill";
|
|
17
|
+
type BadgeSize = "sm" | "md";
|
|
18
|
+
|
|
19
|
+
interface Props extends HTMLAttributes<HTMLSpanElement> {
|
|
20
|
+
variant?: BadgeVariant;
|
|
21
|
+
shape?: BadgeShape;
|
|
22
|
+
size?: BadgeSize;
|
|
23
|
+
dot?: boolean;
|
|
24
|
+
label?: string;
|
|
25
|
+
children?: Snippet;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
variant = "default",
|
|
30
|
+
shape = "rounded",
|
|
31
|
+
size = "md",
|
|
32
|
+
dot = false,
|
|
33
|
+
label,
|
|
34
|
+
children,
|
|
35
|
+
class: customClass = "",
|
|
36
|
+
...restProps
|
|
37
|
+
}: Props = $props();
|
|
38
|
+
|
|
39
|
+
const resolvedVariant = $derived(
|
|
40
|
+
variant === "highlight"
|
|
41
|
+
? "primary"
|
|
42
|
+
: variant === "success"
|
|
43
|
+
? "positive"
|
|
44
|
+
: variant === "warning"
|
|
45
|
+
? "neutral"
|
|
46
|
+
: variant === "danger"
|
|
47
|
+
? "negative"
|
|
48
|
+
: variant
|
|
49
|
+
);
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<span
|
|
53
|
+
class="plasma-badge plasma-badge--{resolvedVariant} plasma-badge--{shape} plasma-badge--{size} {customClass}"
|
|
54
|
+
{...restProps}
|
|
55
|
+
>
|
|
56
|
+
{#if dot}
|
|
57
|
+
<span class="plasma-badge-dot"></span>
|
|
58
|
+
{/if}
|
|
59
|
+
|
|
60
|
+
{#if children}
|
|
61
|
+
{@render children()}
|
|
62
|
+
{:else if label}
|
|
63
|
+
{label}
|
|
64
|
+
{/if}
|
|
65
|
+
</span>
|
|
66
|
+
|
|
67
|
+
<style>
|
|
68
|
+
.plasma-badge {
|
|
69
|
+
display: inline-flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
gap: 4px;
|
|
73
|
+
font-family: var(--plasma-font-sans);
|
|
74
|
+
font-weight: var(--plasma-font-weight-medium);
|
|
75
|
+
line-height: 1;
|
|
76
|
+
white-space: nowrap;
|
|
77
|
+
user-select: none;
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* --------------------------------------------------------------------------
|
|
82
|
+
Shapes
|
|
83
|
+
-------------------------------------------------------------------------- */
|
|
84
|
+
.plasma-badge--rounded {
|
|
85
|
+
border-radius: var(--plasma-radius-sm);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.plasma-badge--pill {
|
|
89
|
+
border-radius: var(--plasma-radius-full);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* --------------------------------------------------------------------------
|
|
93
|
+
Sizes
|
|
94
|
+
-------------------------------------------------------------------------- */
|
|
95
|
+
.plasma-badge--sm {
|
|
96
|
+
height: 18px;
|
|
97
|
+
padding: 0 6px;
|
|
98
|
+
font-size: 11px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.plasma-badge--md {
|
|
102
|
+
height: 22px;
|
|
103
|
+
padding: 0 8px;
|
|
104
|
+
font-size: var(--plasma-font-size-xs);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* --------------------------------------------------------------------------
|
|
108
|
+
Variants
|
|
109
|
+
-------------------------------------------------------------------------- */
|
|
110
|
+
.plasma-badge--default {
|
|
111
|
+
background-color: var(--plasma-color-surface-sunken);
|
|
112
|
+
color: var(--plasma-color-text);
|
|
113
|
+
border: 1px solid var(--plasma-color-border);
|
|
114
|
+
}
|
|
115
|
+
.plasma-badge--default .plasma-badge-dot {
|
|
116
|
+
background-color: var(--plasma-color-text-muted);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.plasma-badge--primary {
|
|
120
|
+
background-color: var(--plasma-color-highlight-soft);
|
|
121
|
+
color: var(--plasma-color-highlight);
|
|
122
|
+
border: 1px solid rgba(61, 174, 233, 0.35);
|
|
123
|
+
}
|
|
124
|
+
.plasma-badge--primary .plasma-badge-dot {
|
|
125
|
+
background-color: var(--plasma-color-highlight);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.plasma-badge--positive {
|
|
129
|
+
background-color: var(--plasma-color-positive-soft);
|
|
130
|
+
color: var(--plasma-color-positive);
|
|
131
|
+
border: 1px solid rgba(39, 174, 96, 0.35);
|
|
132
|
+
}
|
|
133
|
+
.plasma-badge--positive .plasma-badge-dot {
|
|
134
|
+
background-color: var(--plasma-color-positive);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.plasma-badge--neutral {
|
|
138
|
+
background-color: var(--plasma-color-neutral-soft);
|
|
139
|
+
color: var(--plasma-color-neutral);
|
|
140
|
+
border: 1px solid rgba(246, 116, 0, 0.35);
|
|
141
|
+
}
|
|
142
|
+
.plasma-badge--neutral .plasma-badge-dot {
|
|
143
|
+
background-color: var(--plasma-color-neutral);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.plasma-badge--negative {
|
|
147
|
+
background-color: var(--plasma-color-negative-soft);
|
|
148
|
+
color: var(--plasma-color-negative);
|
|
149
|
+
border: 1px solid rgba(218, 68, 83, 0.35);
|
|
150
|
+
}
|
|
151
|
+
.plasma-badge--negative .plasma-badge-dot {
|
|
152
|
+
background-color: var(--plasma-color-negative);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* Dot */
|
|
156
|
+
.plasma-badge-dot {
|
|
157
|
+
width: 6px;
|
|
158
|
+
height: 6px;
|
|
159
|
+
border-radius: var(--plasma-radius-full);
|
|
160
|
+
flex-shrink: 0;
|
|
161
|
+
}
|
|
162
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
type BadgeVariant = "default" | "primary" | "highlight" | "positive" | "success" | "neutral" | "warning" | "negative" | "danger";
|
|
4
|
+
type BadgeShape = "rounded" | "pill";
|
|
5
|
+
type BadgeSize = "sm" | "md";
|
|
6
|
+
interface Props extends HTMLAttributes<HTMLSpanElement> {
|
|
7
|
+
variant?: BadgeVariant;
|
|
8
|
+
shape?: BadgeShape;
|
|
9
|
+
size?: BadgeSize;
|
|
10
|
+
dot?: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
}
|
|
14
|
+
declare const Badge: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type Badge = ReturnType<typeof Badge>;
|
|
16
|
+
export default Badge;
|