Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add styled sonner draft #666

Closed
wants to merge 3 commits into from
Closed
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
5 changes: 4 additions & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "@qwik-ui/website",
"description": "The Qwik UI Website",
"private": true
"private": true,
"dependencies": {
"qwik-sonner": "0.2.2"
}
}
1 change: 1 addition & 0 deletions apps/website/src/_state/component-statuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const statusByComponent: ComponentKitsStatuses = {
RadioGroup: ComponentStatus.Draft,
Separator: ComponentStatus.Beta,
Skeleton: ComponentStatus.Beta,
Toast: ComponentStatus.Draft,
Tabs: ComponentStatus.Beta,
Textarea: ComponentStatus.Draft,
},
Expand Down
1 change: 1 addition & 0 deletions apps/website/src/routes/docs/styled/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
- [RadioGroup](/docs/styled/radio-group)
- [Separator](/docs/styled/separator)
- [Skeleton](/docs/styled/skeleton)
- [Toast](/docs/styled/toast)
- [Tabs](/docs/styled/tabs)
- [Textarea](/docs/styled/textarea)
22 changes: 0 additions & 22 deletions apps/website/src/routes/docs/styled/toast/ToastContainer.tsx

This file was deleted.

25 changes: 25 additions & 0 deletions apps/website/src/routes/docs/styled/toast/examples/hero.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { toast } from 'qwik-sonner';
import { component$, $ } from '@builder.io/qwik';
import { Button } from '@qwik-ui/styled';

export default component$(() => {
return (
<div>
<Button
onClick$={() => {
toast('Event has been created', {
description: 'Sunday, December 03, 2023 at 9:00 AM',
action: {
label: 'Undo',
onClick: $(() => {
toast('Event has been deleted');
}),
},
});
}}
>
Show Toast
</Button>
</div>
);
});
60 changes: 57 additions & 3 deletions apps/website/src/routes/docs/styled/toast/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,63 @@ title: Qwik UI | Styled Toast Component

import { statusByComponent } from '~/_state/component-statuses';

<StatusBanner status={statusByComponent.styled.Toast} />

# Toast

Nothing like a smell of breakfast in the morning. That's why we like the Qwik UI Styled toast component.
It will make your app look delicious while keeping your users informed, like on what they can have for desert! nom nom nom...
A succinct message that is displayed temporarily.

<StatusBanner status={statusByComponent.styled.Toast} />
<Showcase name="hero" />

## Installation

### Run the following cli command or copy/paste the component code into your project

```sh
qwik-ui add toast
```

### Add the Toaster component

src/root.tsx

```tsx
import { Toaster } from './components/ui/toast/toast';

import { component$ } from '@builder.io/qwik';
import {
QwikCityProvider,
RouterOutlet,
ServiceWorkerRegister,
} from '@builder.io/qwik-city';
import { RouterHead } from './components/router-head/router-head';

import './global.css';

export default component$(() => {
return (
<QwikCityProvider>
<head>
<meta charSet="utf-8" />
<link rel="manifest" href="/manifest.json" />
<RouterHead />
</head>
<body lang="en">
<RouterOutlet />
<ServiceWorkerRegister />
<Toaster /> /* Add the Toaster Component /*
</body>
</QwikCityProvider>
);
});
```

## Usage

```tsx
import { toast } from 'qwik-sonner';
```

```tsx
toast('Event has been created.');
```
3 changes: 2 additions & 1 deletion apps/website/src/routes/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import docsStyles from './docs.css?inline';
import { MDXProvider } from '~/_state/MDXProvider';
import { components } from '~/components/mdx-components';
import { DashboardTableOfContents } from '~/components/toc/toc';
import { ScrollArea } from '@qwik-ui/styled';
import { ScrollArea, Toaster } from '@qwik-ui/styled';

export default component$(() => {
const { headings } = useContent();
Expand Down Expand Up @@ -46,6 +46,7 @@ export default component$(() => {
</div>
</div>
</MDXProvider>
<Toaster />
<footer></footer>
</>
);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"prettier-plugin-tailwindcss": "0.4.1",
"pretty-quick": "^3.1.3",
"qwik-nx": "^1.0.8",
"qwik-sonner": "0.2.2",
"qwik-themes": "^0.2.0",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/kit-styled/components-registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
"componentFolder": "skeleton",
"files": ["skeleton.tsx"]
},
{
"displayName": "Toast",
"type": "toast",
"componentFolder": "toast",
"files": ["toast.tsx"]
},
{
"displayName": "Tabs",
"type": "tabs",
Expand Down
3 changes: 2 additions & 1 deletion packages/kit-styled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"devDependencies": {
"@qwik-ui/headless": "0.3.3",
"@qwik-ui/utils": "0.2.1"
"@qwik-ui/utils": "0.2.1",
"qwik-sonner": "0.2.2"
}
}
23 changes: 23 additions & 0 deletions packages/kit-styled/src/components/toast/toast.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { component$ } from '@builder.io/qwik';
import { Toaster as Sonner } from 'qwik-sonner';

type ToasterProps = typeof Sonner;
export const Toaster = component$<ToasterProps>(({ ...props }) => {
return (
<Sonner
class="toaster group"
toastOptions={{
classNames: {
toast:
'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',
description: 'group-[.toast]:text-muted-foreground',
actionButton:
'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground group-[.toast]:shadow',
cancelButton:
'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground group-[.toast]:shadow',
},
}}
{...props}
/>
);
});
1 change: 1 addition & 0 deletions packages/kit-styled/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './components/popover/popover';
export * from './components/radio-group/radio-group';
export * from './components/separator/separator';
export * from './components/skeleton/skeleton';
export * from './components/toast/toast';
export * from './components/tabs/tabs';
export * from './components/textarea/textarea';
export * from './components/toggle/toggle';
Expand Down
Loading
Loading