Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
272 changes: 170 additions & 102 deletions apps/docs/src/routes/docs/components/toast-sileo.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,69 @@
import { Button } from "@solidcn/core";
import { sileo } from "@solidcn/toast";
import { SileoToaster, sileo } from "@solidcn/toast";
import { DocPage } from "../../../components/ui/DocPage.js";

function SileoDemo() {
return (
<div class="flex flex-wrap gap-2">
<Button
variant="outline"
size="sm"
onClick={() => sileo.success({ title: "Saved successfully!" })}
>
Success
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.error({ title: "Something went wrong." })}
>
Error
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.warning({ title: "Disk space low." })}
>
Warning
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.info({ title: "Update available." })}
>
Info
</Button>
<Button
variant="outline"
size="sm"
onClick={() =>
sileo.success({
title: "Event created",
description: "Sunday, December 03, 2023 at 9:00 AM",
preset: "glass",
})
}
>
Glass preset
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.success({ title: "Bounced!", animation: "bounce" })}
>
Bounce
</Button>
</div>
<>
<SileoToaster mode="sileo" position="top-center" />
<div class="flex flex-wrap gap-2">
<Button
variant="outline"
size="sm"
onClick={() => sileo.success({ title: "Changes saved", duration: 6000 })}
>
Success
</Button>
<Button
variant="outline"
size="sm"
onClick={() =>
sileo.error({
title: "Something went wrong",
description: "Please try again later.",
duration: 6000,
})
}
>
Error
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.warning({ title: "Storage almost full", duration: 6000 })}
>
Warning
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.info({ title: "New update available", duration: 6000 })}
>
Info
</Button>
<Button
variant="outline"
size="sm"
onClick={() =>
sileo.success({
title: "Event created",
description: "Sunday, December 03, 2023 at 9:00 AM",
preset: "glass",
duration: 6000,
})
}
>
Glass preset
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.success({ title: "Bounced!", animation: "bounce", duration: 6000 })}
>
Bounce
</Button>
</div>
</>
);
}

Expand All @@ -66,87 +76,145 @@ export default function ToastSileoPage() {
phase="Toast"
componentName="toast"
manualInstall="npm install @solidcn/toast"
usage={`import { sileo } from "@solidcn/toast";
usage={`import { SileoToaster, sileo } from "@solidcn/toast";

// Mount once in this page/layout
<SileoToaster mode="sileo" position="top-center" />

// Trigger a physics-based toast:
sileo.success({ title: "Saved!" });
sileo.error({ title: "Failed." });
sileo.warning({ title: "Heads up." });
sileo.info({ title: "FYI." });
sileo.success({ title: "Changes saved" });

sileo.error({
title: "Something went wrong",
description: "Please try again later.",
duration: 6000,
});

sileo.warning({ title: "Storage almost full", duration: 6000 });

sileo.info({ title: "New update available", duration: 6000 });

// With options:
sileo.success({
title: "Event created",
description: "Sunday, December 03 at 9:00 AM",
preset: "glass",
duration: 6000,
animation: "spring",
});`}
examples={[
{
title: "Variants",
description:
'Click to trigger physics-based toasts. Requires <Toaster mode="sileo" /> in your layout.',
"Click any button to trigger Sileo toasts on this page, including description cards. Each toast stays open briefly before auto-closing.",
preview: <SileoDemo />,
code: `import { sileo } from "@solidcn/toast"
import { Button } from "~/components/ui/button"
code: `import { SileoToaster, sileo } from "@solidcn/toast"
import { Button } from "@solidcn/core"

export function ToastSileoVariants() {
return (
<div class="flex flex-wrap gap-2">
<Button
variant="outline"
size="sm"
onClick={() => sileo.success({ title: "Saved successfully!" })}
>
Success
</Button>
<Button variant="outline" size="sm" onClick={() => sileo.error({ title: "Something went wrong." })}>
Error
</Button>
<Button variant="outline" size="sm" onClick={() => sileo.warning({ title: "Disk space low." })}>
Warning
</Button>
<Button variant="outline" size="sm" onClick={() => sileo.info({ title: "Update available." })}>
Info
</Button>
<Button
variant="outline"
size="sm"
onClick={() =>
sileo.success({
title: "Event created",
description: "Sunday, Dec 03 at 9:00 AM",
preset: "glass",
})
}
>
Glass preset
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.success({ title: "Bounced!", animation: "bounce" })}
>
Bounce
</Button>
</div>
<>
<SileoToaster mode="sileo" position="top-center" />
<div class="flex flex-wrap gap-2">
<Button
variant="outline"
size="sm"
onClick={() => sileo.success({ title: "Changes saved", duration: 6000 })}
>
Success
</Button>
<Button
variant="outline"
size="sm"
onClick={() =>
sileo.error({
title: "Something went wrong",
description: "Please try again later.",
duration: 6000,
})
}
>
Error
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.warning({ title: "Storage almost full", duration: 6000 })}
>
Warning
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.info({ title: "New update available", duration: 6000 })}
>
Info
</Button>
<Button
variant="outline"
size="sm"
onClick={() =>
sileo.success({
title: "Event created",
description: "Sunday, Dec 03 at 9:00 AM",
preset: "glass",
duration: 6000,
})
}
>
Glass preset
</Button>
<Button
variant="outline"
size="sm"
onClick={() => sileo.success({ title: "Bounced!", animation: "bounce", duration: 6000 })}
>
Bounce
</Button>
</div>
</>
)
}`,
},
]}
notes={
<div class="space-y-6">
<div class="rounded-lg border bg-muted/30 p-5 space-y-3">
<h3 class="font-semibold text-sm">Standalone toast item</h3>
<p class="text-sm text-muted-foreground">
Use <code class="bg-muted px-1 rounded text-xs">SileoToast</code> when you want to
render a single toast card from your own state instead of the global store.
</p>
<div class="rounded-lg overflow-hidden border border-zinc-800 bg-zinc-950">
<pre class="p-4 text-sm font-mono text-zinc-300 overflow-x-auto">{`import { SileoToast } from "@solidcn/toast";

<SileoToast
toast={{
id: "demo",
type: "success",
title: "Saved successfully!",
createdAt: Date.now(),
}}
onDismiss={() => {
// remove the toast from your own state
}}
/>
`}</pre>
</div>
</div>

<div class="rounded-lg border bg-muted/30 p-5 space-y-3">
<h3 class="font-semibold text-sm">Setup</h3>
<p class="text-sm text-muted-foreground">
Add <code class="bg-muted px-1 rounded text-xs">{'<Toaster mode="sileo" />'}</code>{" "}
once in your app root:
Add{" "}
<code class="bg-muted px-1 rounded text-xs">{'<SileoToaster mode="sileo" />'}</code>{" "}
where you want Sileo toasts to appear:
</p>
<div class="rounded-lg overflow-hidden border border-zinc-800 bg-zinc-950">
<pre class="p-4 text-sm font-mono text-zinc-300 overflow-x-auto">{`import { Toaster } from "@solidcn/toast";
<pre class="p-4 text-sm font-mono text-zinc-300 overflow-x-auto">{`import { SileoToaster } from "@solidcn/toast";

// In your App component:
<Toaster position="bottom-right" mode="sileo" />`}</pre>
// In your page/layout:
<SileoToaster mode="sileo" position="top-center" />`}</pre>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
".pnpm-store",
"dist",
".turbo",
"packages/mcp-cloudflare/.wrangler",
"apps/docs/.solid",
"apps/docs/.output",
"apps/docs/.vinxi",
Expand Down
27 changes: 23 additions & 4 deletions packages/toast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ export default function App() {
}
```

If you need to render a single toast card manually, you can also use the standalone `SileoToast` component:

```tsx
import { SileoToast } from "@solidcn/toast";

<SileoToast
toast={{
id: "demo",
type: "success",
title: "Saved successfully!",
createdAt: Date.now(),
}}
onDismiss={() => {
/* remove the toast from your own state */
}}
/>
```

```ts
// Sileo toast types
sileo.success({ title: "Success", description? });
Expand Down Expand Up @@ -96,7 +114,7 @@ toast.promise(submitForm(), {

```tsx
interface StandardToasterProps {
position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "top-center";
mode?: "standard";
theme?: "light" | "dark" | "system";
richColors?: boolean;
Expand All @@ -111,7 +129,7 @@ interface StandardToasterProps {

| Prop | Type | Default | Description |
|---|---|---|---|
| `position` | See above | `"bottom-right"` | Toast placement |
| `position` | See above | `"top-center"` | Toast placement |
| `theme` | `"light" \| "dark" \| "system"` | `"system"` | Toast theme override |
| `richColors` | `boolean` | `false` | When enabled, toast color reflects type (success=green, error=red, etc.) |
| `closeButton` | `boolean` | `false` | Show dismiss button on each toast |
Expand Down Expand Up @@ -141,7 +159,7 @@ interface SileoToasterProps {

### ToastPosition (Sileo)

`"top-left" | "top-right" | "bottom-left" | "bottom-right" | "center"`
`"top-left" | "top-right" | "bottom-left" | "top-center" | "center"`

## Toast Options

Expand Down Expand Up @@ -217,13 +235,14 @@ sileo.dismiss();
export { Toaster, toast, sileo };

// Mode-specific
export { StandardToaster, SileoToaster };
export { StandardToaster, SileoToaster, SileoToast };

// Types
export type {
ToasterProps,
StandardToasterProps,
SileoToasterProps,
SileoToastProps,
StandardToastOptions,
SileoToastOptions,
SileoPreset,
Expand Down
Loading
Loading