forked from cerc-io/snowballtools-base
🔧 chore: add toast render page
This commit is contained in:
parent
675112079c
commit
bb7a88f7e9
@ -17,17 +17,14 @@ import {
|
|||||||
renderTabs,
|
renderTabs,
|
||||||
renderVerticalTabs,
|
renderVerticalTabs,
|
||||||
} from './renders/tabs';
|
} from './renders/tabs';
|
||||||
import { useToast } from 'components/shared/Toast/useToast';
|
|
||||||
import { Button } from 'components/shared/Button';
|
|
||||||
import {
|
import {
|
||||||
renderInlineNotificationWithDescriptions,
|
renderInlineNotificationWithDescriptions,
|
||||||
renderInlineNotifications,
|
renderInlineNotifications,
|
||||||
} from './renders/inlineNotifications';
|
} from './renders/inlineNotifications';
|
||||||
import { renderInputs } from './renders/input';
|
import { renderInputs } from './renders/input';
|
||||||
|
import { renderToast, renderToastsWithCta } from './renders/toast';
|
||||||
|
|
||||||
const Page = () => {
|
const Page = () => {
|
||||||
const { toast } = useToast();
|
|
||||||
|
|
||||||
const [singleDate, setSingleDate] = useState<Value>();
|
const [singleDate, setSingleDate] = useState<Value>();
|
||||||
const [dateRange, setDateRange] = useState<Value>();
|
const [dateRange, setDateRange] = useState<Value>();
|
||||||
|
|
||||||
@ -47,10 +44,12 @@ const Page = () => {
|
|||||||
{/* Toast */}
|
{/* Toast */}
|
||||||
<div className="flex flex-col gap-10 items-center justify-between">
|
<div className="flex flex-col gap-10 items-center justify-between">
|
||||||
<h1 className="text-2xl font-bold">Toasts</h1>
|
<h1 className="text-2xl font-bold">Toasts</h1>
|
||||||
<Button onClick={() => toast({ id: 'test', title: 'Hello, world!' })}>
|
{renderToastsWithCta()}
|
||||||
Toast
|
{renderToast()}
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="w-full h border border-gray-200 px-20 my-10" />
|
||||||
|
|
||||||
{/* Button */}
|
{/* Button */}
|
||||||
<div className="flex flex-col gap-10 items-center justify-between">
|
<div className="flex flex-col gap-10 items-center justify-between">
|
||||||
<h1 className="text-2xl font-bold">Input</h1>
|
<h1 className="text-2xl font-bold">Input</h1>
|
||||||
|
66
packages/frontend/src/pages/components/renders/toast.tsx
Normal file
66
packages/frontend/src/pages/components/renders/toast.tsx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Button } from 'components/shared/Button';
|
||||||
|
import { useToast } from 'components/shared/Toast/useToast';
|
||||||
|
|
||||||
|
export const renderToastsWithCta = () => {
|
||||||
|
const { toast, dismiss } = useToast();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex gap-10">
|
||||||
|
{(['success', 'error', 'warning', 'info', 'loading'] as const).map(
|
||||||
|
(variant, index) => (
|
||||||
|
<Button
|
||||||
|
onClick={() =>
|
||||||
|
toast({
|
||||||
|
onDismiss: dismiss,
|
||||||
|
id: `${variant}_${index}`,
|
||||||
|
title: 'Project created',
|
||||||
|
cta: [
|
||||||
|
{
|
||||||
|
buttonLabel: 'Button',
|
||||||
|
size: 'xs',
|
||||||
|
variant: 'tertiary',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
buttonLabel: 'Button',
|
||||||
|
size: 'xs',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
variant,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
key={`${variant}_${index}`}
|
||||||
|
>
|
||||||
|
{variant} with cta
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const renderToast = () => {
|
||||||
|
const { toast, dismiss } = useToast();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex gap-10">
|
||||||
|
{(['success', 'error', 'warning', 'info', 'loading'] as const).map(
|
||||||
|
(variant, index) => (
|
||||||
|
<Button
|
||||||
|
onClick={() =>
|
||||||
|
toast({
|
||||||
|
onDismiss: dismiss,
|
||||||
|
id: `${variant}_${index}`,
|
||||||
|
title: 'Project created',
|
||||||
|
variant,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
key={`${variant}_${index}`}
|
||||||
|
>
|
||||||
|
{variant}
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user