sileo-solid 0.1.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/LICENSE +21 -0
- package/README.md +134 -0
- package/dist/index.d.mts +63 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +827 -0
- package/dist/index.mjs +824 -0
- package/dist/styles.css +478 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Klaus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Sileo SolidJS
|
|
2
|
+
|
|
3
|
+
> An opinionated, physics-based toast notification library for SolidJS.
|
|
4
|
+
|
|
5
|
+
A faithful SolidJS port of [sileo](https://github.com/hiaaryan/sileo) — replacing React hooks with SolidJS primitives and `motion/react` with the vanilla `motion` DOM animation API.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Physics-based animations** — SVG gooey effect with spring easing
|
|
12
|
+
- **Swipe to dismiss** — pointer-based gesture support
|
|
13
|
+
- **Header layer transitions** — smooth state/icon/title swaps
|
|
14
|
+
- **Auto expand/collapse** — hover or timed reveal
|
|
15
|
+
- **Promise support** — loading → success/error flow
|
|
16
|
+
- **Theme aware** — light/dark/system with CSS variable fills
|
|
17
|
+
- **Zero React dependencies** — pure SolidJS + motion DOM
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
The library is included locally at `packages/ui/src/lib/sileo/`. No npm install needed.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Toaster, sileo } from "./lib/sileo"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### 1. Add the Toaster
|
|
30
|
+
|
|
31
|
+
Place `<Toaster />` near the root of your app (e.g. `App.tsx`):
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { Toaster } from "./lib/sileo"
|
|
35
|
+
|
|
36
|
+
function App() {
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
{/* your app */}
|
|
40
|
+
<Toaster position="top-center" offset={12} options={{ duration: 2500 }} />
|
|
41
|
+
</>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Show Toasts
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { sileo } from "./lib/sileo"
|
|
50
|
+
|
|
51
|
+
// Basic
|
|
52
|
+
sileo.success({ title: "Saved!", description: "Your changes have been saved" })
|
|
53
|
+
sileo.error({ title: "Error", description: "Something went wrong" })
|
|
54
|
+
sileo.warning({ title: "Warning", description: "Please review before continuing" })
|
|
55
|
+
sileo.info({ title: "Info", description: "New version available" })
|
|
56
|
+
|
|
57
|
+
// With action button
|
|
58
|
+
sileo.action({
|
|
59
|
+
title: "New message",
|
|
60
|
+
description: "You have a new message from Alice",
|
|
61
|
+
button: { title: "View", onClick: () => navigate("/messages/1") },
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
// Promise
|
|
65
|
+
sileo.promise(
|
|
66
|
+
fetch("/api/data").then(r => r.json()),
|
|
67
|
+
{
|
|
68
|
+
loading: { title: "Loading...", description: "Fetching data" },
|
|
69
|
+
success: { title: "Done!", description: "Data loaded successfully" },
|
|
70
|
+
error: { title: "Failed", description: "Could not fetch data" },
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
// Dismiss
|
|
75
|
+
sileo.dismiss("my-toast-id")
|
|
76
|
+
sileo.clear()
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## API
|
|
80
|
+
|
|
81
|
+
### `sileo.show(options)`
|
|
82
|
+
### `sileo.success(options)`
|
|
83
|
+
### `sileo.error(options)`
|
|
84
|
+
### `sileo.warning(options)`
|
|
85
|
+
### `sileo.info(options)`
|
|
86
|
+
### `sileo.action(options)`
|
|
87
|
+
|
|
88
|
+
| Option | Type | Description |
|
|
89
|
+
|--------|------|-------------|
|
|
90
|
+
| `title` | `string` | Toast title text |
|
|
91
|
+
| `description` | `string \| JSX.Element` | Description content |
|
|
92
|
+
| `position` | `"top-left" \| "top-center" \| "top-right" \| "bottom-left" \| "bottom-center" \| "bottom-right"` | Toast position |
|
|
93
|
+
| `duration` | `number \| null` | Auto-dismiss duration in ms. `null` = no auto-dismiss |
|
|
94
|
+
| `icon` | `JSX.Element \| null` | Custom icon (overrides state icon) |
|
|
95
|
+
| `fill` | `string` | SVG fill color |
|
|
96
|
+
| `roundness` | `number` | Border radius (default: 16) |
|
|
97
|
+
| `button` | `{ title: string; onClick: () => void }` | Action button |
|
|
98
|
+
| `styles` | `{ title?: string; description?: string; badge?: string; button?: string }` | CSS class overrides |
|
|
99
|
+
| `autopilot` | `boolean \| { expand?: number; collapse?: number }` | Auto expand/collapse timing |
|
|
100
|
+
|
|
101
|
+
### `sileo.promise(promise, options)`
|
|
102
|
+
|
|
103
|
+
| Option | Type | Description |
|
|
104
|
+
|--------|------|-------------|
|
|
105
|
+
| `loading` | `SileoOptions` | Shown while promise is pending |
|
|
106
|
+
| `success` | `SileoOptions \| ((data) => SileoOptions)` | Shown on resolve |
|
|
107
|
+
| `error` | `SileoOptions \| ((err) => SileoOptions)` | Shown on reject |
|
|
108
|
+
| `action` | `SileoOptions \| ((data) => SileoOptions)` | Optional action state instead of success |
|
|
109
|
+
| `position` | `SileoPosition` | Override position |
|
|
110
|
+
|
|
111
|
+
### `<Toaster />` Props
|
|
112
|
+
|
|
113
|
+
| Prop | Type | Default | Description |
|
|
114
|
+
|------|------|---------|-------------|
|
|
115
|
+
| `position` | `SileoPosition` | `"top-right"` | Default position for toasts |
|
|
116
|
+
| `offset` | `number \| string \| { top?, right?, bottom?, left? }` | — | Viewport offset |
|
|
117
|
+
| `options` | `Partial<SileoOptions>` | — | Default options for all toasts |
|
|
118
|
+
| `theme` | `"light" \| "dark" \| "system"` | — | Color theme |
|
|
119
|
+
|
|
120
|
+
## Differences from Original (React)
|
|
121
|
+
|
|
122
|
+
| React (original) | SolidJS (this port) |
|
|
123
|
+
|-----------------|---------------------|
|
|
124
|
+
| `useState`, `useMemo`, `useEffect` | `createSignal`, `createMemo`, `createEffect` |
|
|
125
|
+
| `useRef` | `let` refs / plain objects |
|
|
126
|
+
| `<motion.rect>` from `motion/react` | `<rect>` + `animate()` from `motion` (DOM API) |
|
|
127
|
+
| `ReactNode` | `JSX.Element` |
|
|
128
|
+
| `className` | `class` |
|
|
129
|
+
| `key` prop for lists | `<For>` / `<Index>` from solid-js |
|
|
130
|
+
| `"use client"` directive | Not needed |
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT — same as the original [sileo](https://github.com/hiaaryan/sileo).
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
|
|
3
|
+
type SileoState = "success" | "loading" | "error" | "warning" | "info" | "action";
|
|
4
|
+
interface SileoStyles {
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
badge?: string;
|
|
8
|
+
button?: string;
|
|
9
|
+
}
|
|
10
|
+
interface SileoButton {
|
|
11
|
+
title: string;
|
|
12
|
+
onClick: () => void;
|
|
13
|
+
}
|
|
14
|
+
declare const SILEO_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
|
|
15
|
+
type SileoPosition = (typeof SILEO_POSITIONS)[number];
|
|
16
|
+
interface SileoOptions {
|
|
17
|
+
title?: string;
|
|
18
|
+
description?: JSX.Element | string;
|
|
19
|
+
type?: SileoState;
|
|
20
|
+
position?: SileoPosition;
|
|
21
|
+
duration?: number | null;
|
|
22
|
+
icon?: JSX.Element | null;
|
|
23
|
+
styles?: SileoStyles;
|
|
24
|
+
fill?: string;
|
|
25
|
+
roundness?: number;
|
|
26
|
+
autopilot?: boolean | {
|
|
27
|
+
expand?: number;
|
|
28
|
+
collapse?: number;
|
|
29
|
+
};
|
|
30
|
+
button?: SileoButton;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type SileoOffsetValue = number | string;
|
|
34
|
+
type SileoOffsetConfig = Partial<Record<"top" | "right" | "bottom" | "left", SileoOffsetValue>>;
|
|
35
|
+
interface SileoToasterProps {
|
|
36
|
+
children?: JSX.Element;
|
|
37
|
+
position?: SileoPosition;
|
|
38
|
+
offset?: SileoOffsetValue | SileoOffsetConfig;
|
|
39
|
+
options?: Partial<SileoOptions>;
|
|
40
|
+
theme?: "light" | "dark" | "system";
|
|
41
|
+
}
|
|
42
|
+
interface SileoPromiseOptions<T = unknown> {
|
|
43
|
+
loading: SileoOptions;
|
|
44
|
+
success: SileoOptions | ((data: T) => SileoOptions);
|
|
45
|
+
error: SileoOptions | ((err: unknown) => SileoOptions);
|
|
46
|
+
action?: SileoOptions | ((data: T) => SileoOptions);
|
|
47
|
+
position?: SileoPosition;
|
|
48
|
+
}
|
|
49
|
+
declare const sileo: {
|
|
50
|
+
show: (opts: SileoOptions) => string;
|
|
51
|
+
success: (opts: SileoOptions) => string;
|
|
52
|
+
error: (opts: SileoOptions) => string;
|
|
53
|
+
warning: (opts: SileoOptions) => string;
|
|
54
|
+
info: (opts: SileoOptions) => string;
|
|
55
|
+
action: (opts: SileoOptions) => string;
|
|
56
|
+
promise: <T>(promise: Promise<T> | (() => Promise<T>), opts: SileoPromiseOptions<T>) => Promise<T>;
|
|
57
|
+
dismiss: (id: string) => void;
|
|
58
|
+
clear: (position?: SileoPosition) => void;
|
|
59
|
+
};
|
|
60
|
+
declare function Toaster(props: SileoToasterProps): JSX.Element;
|
|
61
|
+
|
|
62
|
+
export { Toaster, sileo };
|
|
63
|
+
export type { SileoButton, SileoOptions, SileoPosition, SileoState, SileoStyles };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
|
|
3
|
+
type SileoState = "success" | "loading" | "error" | "warning" | "info" | "action";
|
|
4
|
+
interface SileoStyles {
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
badge?: string;
|
|
8
|
+
button?: string;
|
|
9
|
+
}
|
|
10
|
+
interface SileoButton {
|
|
11
|
+
title: string;
|
|
12
|
+
onClick: () => void;
|
|
13
|
+
}
|
|
14
|
+
declare const SILEO_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
|
|
15
|
+
type SileoPosition = (typeof SILEO_POSITIONS)[number];
|
|
16
|
+
interface SileoOptions {
|
|
17
|
+
title?: string;
|
|
18
|
+
description?: JSX.Element | string;
|
|
19
|
+
type?: SileoState;
|
|
20
|
+
position?: SileoPosition;
|
|
21
|
+
duration?: number | null;
|
|
22
|
+
icon?: JSX.Element | null;
|
|
23
|
+
styles?: SileoStyles;
|
|
24
|
+
fill?: string;
|
|
25
|
+
roundness?: number;
|
|
26
|
+
autopilot?: boolean | {
|
|
27
|
+
expand?: number;
|
|
28
|
+
collapse?: number;
|
|
29
|
+
};
|
|
30
|
+
button?: SileoButton;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type SileoOffsetValue = number | string;
|
|
34
|
+
type SileoOffsetConfig = Partial<Record<"top" | "right" | "bottom" | "left", SileoOffsetValue>>;
|
|
35
|
+
interface SileoToasterProps {
|
|
36
|
+
children?: JSX.Element;
|
|
37
|
+
position?: SileoPosition;
|
|
38
|
+
offset?: SileoOffsetValue | SileoOffsetConfig;
|
|
39
|
+
options?: Partial<SileoOptions>;
|
|
40
|
+
theme?: "light" | "dark" | "system";
|
|
41
|
+
}
|
|
42
|
+
interface SileoPromiseOptions<T = unknown> {
|
|
43
|
+
loading: SileoOptions;
|
|
44
|
+
success: SileoOptions | ((data: T) => SileoOptions);
|
|
45
|
+
error: SileoOptions | ((err: unknown) => SileoOptions);
|
|
46
|
+
action?: SileoOptions | ((data: T) => SileoOptions);
|
|
47
|
+
position?: SileoPosition;
|
|
48
|
+
}
|
|
49
|
+
declare const sileo: {
|
|
50
|
+
show: (opts: SileoOptions) => string;
|
|
51
|
+
success: (opts: SileoOptions) => string;
|
|
52
|
+
error: (opts: SileoOptions) => string;
|
|
53
|
+
warning: (opts: SileoOptions) => string;
|
|
54
|
+
info: (opts: SileoOptions) => string;
|
|
55
|
+
action: (opts: SileoOptions) => string;
|
|
56
|
+
promise: <T>(promise: Promise<T> | (() => Promise<T>), opts: SileoPromiseOptions<T>) => Promise<T>;
|
|
57
|
+
dismiss: (id: string) => void;
|
|
58
|
+
clear: (position?: SileoPosition) => void;
|
|
59
|
+
};
|
|
60
|
+
declare function Toaster(props: SileoToasterProps): JSX.Element;
|
|
61
|
+
|
|
62
|
+
export { Toaster, sileo };
|
|
63
|
+
export type { SileoButton, SileoOptions, SileoPosition, SileoState, SileoStyles };
|