@rovula/ui 0.0.26 → 0.0.28
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/dist/cjs/bundle.css +185 -37
- package/dist/cjs/bundle.js +3 -3
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/AlertDialog/{Alert.stories.d.ts → AlertDialog.stories.d.ts} +4 -0
- package/dist/cjs/types/components/Calendar/Calendar.stories.d.ts +7 -7
- package/dist/cjs/types/components/RadioGroup/RadioGroup.stories.d.ts +1 -1
- package/dist/cjs/types/components/Text/Text.d.ts +5 -6
- package/dist/cjs/types/components/Text/Text.stories.d.ts +10 -2
- package/dist/cjs/types/components/Toast/Toast.d.ts +17 -0
- package/dist/cjs/types/components/Toast/Toast.stories.d.ts +358 -0
- package/dist/cjs/types/components/Toast/Toast.styles.d.ts +12 -0
- package/dist/cjs/types/components/Toast/Toaster.d.ts +1 -0
- package/dist/cjs/types/components/Toast/useToast.d.ts +55 -0
- package/dist/cjs/types/components/Tooltip/Tooltip.d.ts +8 -0
- package/dist/cjs/types/components/Tooltip/Tooltip.stories.d.ts +59 -0
- package/dist/cjs/types/components/Tooltip/TooltipSimple.d.ts +13 -0
- package/dist/cjs/types/icons/material-icon/outline/AllOutIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/outline/FormatAlignCenterIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/outline/FormatAlignJustifyIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/outline/FormatAlignLeftIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/outline/FormatAlignRightIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/outline/FormatBoldIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/outline/FormatItalicIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/outline/FormatListBulletedIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/outline/FormatListNumberedIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/outline/FormatUnderlinedIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/outline/index.d.ts +10 -0
- package/dist/cjs/types/icons/material-icon/solid/AllOutIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/solid/FormatAlignCenterIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/solid/FormatAlignJustifyIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/solid/FormatAlignLeftIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/solid/FormatAlignRightIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/solid/FormatBoldIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/solid/FormatItalicIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/solid/FormatListBulletedIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/solid/FormatListNumberedIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/solid/FormatUnderlinedIcon.d.ts +3 -0
- package/dist/cjs/types/icons/material-icon/solid/index.d.ts +10 -0
- package/dist/cjs/types/index.d.ts +5 -0
- package/dist/components/AlertDialog/{Alert.stories.js → AlertDialog.stories.js} +13 -1
- package/dist/components/Checkbox/Checkbox.js +5 -4
- package/dist/components/Icon/Icon.stories.js +10 -0
- package/dist/components/Popover/Popover.js +1 -1
- package/dist/components/RadioGroup/RadioGroup.js +1 -4
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Text/Text.js +3 -5
- package/dist/components/Toast/Toast.js +52 -0
- package/dist/components/Toast/Toast.stories.js +82 -0
- package/dist/components/Toast/Toast.styles.js +60 -0
- package/dist/components/Toast/Toaster.js +24 -0
- package/dist/components/Toast/useToast.js +121 -0
- package/dist/components/Tooltip/Tooltip.js +26 -0
- package/dist/components/Tooltip/Tooltip.stories.js +61 -0
- package/dist/components/Tooltip/TooltipSimple.js +18 -0
- package/dist/esm/bundle.css +185 -37
- package/dist/esm/bundle.js +3 -3
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/AlertDialog/{Alert.stories.d.ts → AlertDialog.stories.d.ts} +4 -0
- package/dist/esm/types/components/Calendar/Calendar.stories.d.ts +7 -7
- package/dist/esm/types/components/RadioGroup/RadioGroup.stories.d.ts +1 -1
- package/dist/esm/types/components/Text/Text.d.ts +5 -6
- package/dist/esm/types/components/Text/Text.stories.d.ts +10 -2
- package/dist/esm/types/components/Toast/Toast.d.ts +17 -0
- package/dist/esm/types/components/Toast/Toast.stories.d.ts +358 -0
- package/dist/esm/types/components/Toast/Toast.styles.d.ts +12 -0
- package/dist/esm/types/components/Toast/Toaster.d.ts +1 -0
- package/dist/esm/types/components/Toast/useToast.d.ts +55 -0
- package/dist/esm/types/components/Tooltip/Tooltip.d.ts +8 -0
- package/dist/esm/types/components/Tooltip/Tooltip.stories.d.ts +59 -0
- package/dist/esm/types/components/Tooltip/TooltipSimple.d.ts +13 -0
- package/dist/esm/types/icons/material-icon/outline/AllOutIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/outline/FormatAlignCenterIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/outline/FormatAlignJustifyIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/outline/FormatAlignLeftIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/outline/FormatAlignRightIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/outline/FormatBoldIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/outline/FormatItalicIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/outline/FormatListBulletedIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/outline/FormatListNumberedIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/outline/FormatUnderlinedIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/outline/index.d.ts +10 -0
- package/dist/esm/types/icons/material-icon/solid/AllOutIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/solid/FormatAlignCenterIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/solid/FormatAlignJustifyIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/solid/FormatAlignLeftIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/solid/FormatAlignRightIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/solid/FormatBoldIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/solid/FormatItalicIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/solid/FormatListBulletedIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/solid/FormatListNumberedIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/solid/FormatUnderlinedIcon.d.ts +3 -0
- package/dist/esm/types/icons/material-icon/solid/index.d.ts +10 -0
- package/dist/esm/types/index.d.ts +5 -0
- package/dist/icons/material-icon/outline/AllOutIcon.js +3 -0
- package/dist/icons/material-icon/outline/FormatAlignCenterIcon.js +3 -0
- package/dist/icons/material-icon/outline/FormatAlignJustifyIcon.js +3 -0
- package/dist/icons/material-icon/outline/FormatAlignLeftIcon.js +3 -0
- package/dist/icons/material-icon/outline/FormatAlignRightIcon.js +3 -0
- package/dist/icons/material-icon/outline/FormatBoldIcon.js +3 -0
- package/dist/icons/material-icon/outline/FormatItalicIcon.js +3 -0
- package/dist/icons/material-icon/outline/FormatListBulletedIcon.js +3 -0
- package/dist/icons/material-icon/outline/FormatListNumberedIcon.js +3 -0
- package/dist/icons/material-icon/outline/FormatUnderlinedIcon.js +3 -0
- package/dist/icons/material-icon/outline/index.js +10 -0
- package/dist/icons/material-icon/solid/AllOutIcon.js +3 -0
- package/dist/icons/material-icon/solid/FormatAlignCenterIcon.js +3 -0
- package/dist/icons/material-icon/solid/FormatAlignJustifyIcon.js +3 -0
- package/dist/icons/material-icon/solid/FormatAlignLeftIcon.js +3 -0
- package/dist/icons/material-icon/solid/FormatAlignRightIcon.js +3 -0
- package/dist/icons/material-icon/solid/FormatBoldIcon.js +3 -0
- package/dist/icons/material-icon/solid/FormatItalicIcon.js +3 -0
- package/dist/icons/material-icon/solid/FormatListBulletedIcon.js +3 -0
- package/dist/icons/material-icon/solid/FormatListNumberedIcon.js +3 -0
- package/dist/icons/material-icon/solid/FormatUnderlinedIcon.js +3 -0
- package/dist/icons/material-icon/solid/index.js +10 -0
- package/dist/index.d.ts +94 -6
- package/dist/index.js +5 -0
- package/dist/src/theme/global.css +230 -46
- package/dist/theme/themes/xspector/state.css +1 -1
- package/package.json +4 -1
- package/src/components/AlertDialog/{Alert.stories.tsx → AlertDialog.stories.tsx} +41 -1
- package/src/components/Checkbox/Checkbox.tsx +9 -4
- package/src/components/Icon/Icon.stories.tsx +10 -0
- package/src/components/Popover/Popover.tsx +1 -1
- package/src/components/RadioGroup/RadioGroup.tsx +6 -7
- package/src/components/Switch/Switch.tsx +8 -5
- package/src/components/Text/Text.tsx +33 -40
- package/src/components/Toast/Toast.stories.tsx +144 -0
- package/src/components/Toast/Toast.styles.tsx +73 -0
- package/src/components/Toast/Toast.tsx +116 -0
- package/src/components/Toast/Toaster.tsx +50 -0
- package/src/components/Toast/useToast.ts +222 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +152 -0
- package/src/components/Tooltip/Tooltip.tsx +38 -0
- package/src/components/Tooltip/TooltipSimple.tsx +46 -0
- package/src/icons/material-icon/outline/AllOutIcon.tsx +20 -0
- package/src/icons/material-icon/outline/FormatAlignCenterIcon.tsx +20 -0
- package/src/icons/material-icon/outline/FormatAlignJustifyIcon.tsx +20 -0
- package/src/icons/material-icon/outline/FormatAlignLeftIcon.tsx +20 -0
- package/src/icons/material-icon/outline/FormatAlignRightIcon.tsx +20 -0
- package/src/icons/material-icon/outline/FormatBoldIcon.tsx +20 -0
- package/src/icons/material-icon/outline/FormatItalicIcon.tsx +20 -0
- package/src/icons/material-icon/outline/FormatListBulletedIcon.tsx +20 -0
- package/src/icons/material-icon/outline/FormatListNumberedIcon.tsx +20 -0
- package/src/icons/material-icon/outline/FormatUnderlinedIcon.tsx +20 -0
- package/src/icons/material-icon/outline/index.ts +10 -0
- package/src/icons/material-icon/solid/AllOutIcon.tsx +20 -0
- package/src/icons/material-icon/solid/FormatAlignCenterIcon.tsx +20 -0
- package/src/icons/material-icon/solid/FormatAlignJustifyIcon.tsx +20 -0
- package/src/icons/material-icon/solid/FormatAlignLeftIcon.tsx +20 -0
- package/src/icons/material-icon/solid/FormatAlignRightIcon.tsx +20 -0
- package/src/icons/material-icon/solid/FormatBoldIcon.tsx +20 -0
- package/src/icons/material-icon/solid/FormatItalicIcon.tsx +20 -0
- package/src/icons/material-icon/solid/FormatListBulletedIcon.tsx +20 -0
- package/src/icons/material-icon/solid/FormatListNumberedIcon.tsx +20 -0
- package/src/icons/material-icon/solid/FormatUnderlinedIcon.tsx +20 -0
- package/src/icons/material-icon/solid/index.ts +10 -0
- package/src/index.ts +5 -0
- package/src/theme/themes/xspector/state.css +1 -1
|
@@ -19,7 +19,7 @@ const PopoverContent = React.forwardRef<
|
|
|
19
19
|
align={align}
|
|
20
20
|
sideOffset={sideOffset}
|
|
21
21
|
className={cn(
|
|
22
|
-
"z-50 min-w-72 rounded-md border bg-
|
|
22
|
+
"z-50 min-w-72 rounded-md border bg-surface border-none overflow-hidden p-0 text-surface-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
23
23
|
className
|
|
24
24
|
)}
|
|
25
25
|
{...props}
|
|
@@ -27,13 +27,12 @@ const RadioGroupItem = React.forwardRef<
|
|
|
27
27
|
<RadioGroupPrimitive.Item
|
|
28
28
|
ref={ref}
|
|
29
29
|
className={cn(
|
|
30
|
-
"aspect-square
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
30
|
+
"aspect-square box-border size-4 rounded-full border border-primary text-primary",
|
|
31
|
+
"hover:border-primary-hover",
|
|
32
|
+
"focus:outline-none",
|
|
33
|
+
"data-[state=checked]:border-secondary data-[state=checked]:text-secondary",
|
|
34
|
+
"hover:data-[state=checked]:border-secondary-hover hover:data-[state=checked]:text-secondary-hover",
|
|
35
|
+
"data-[disabled]:border-state-disable-solid data-[disabled]:fill-state-disable-solid data-[disabled]:cursor-not-allowed data-[disabled]:pointer-events-none data-[disabled]:text-state-disable-solid",
|
|
37
36
|
className
|
|
38
37
|
)}
|
|
39
38
|
{...props}
|
|
@@ -11,9 +11,10 @@ const Switch = React.forwardRef<
|
|
|
11
11
|
>(({ className, ...props }, ref) => (
|
|
12
12
|
<SwitchPrimitives.Root
|
|
13
13
|
className={cn(
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
14
|
+
"group inline-flex h-3 w-[32px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors",
|
|
15
|
+
"data-[state=checked]:bg-secondary-active/[0.32] data-[state=unchecked]:bg-tertiary-active/[0.32]",
|
|
16
|
+
"hover:data-[state=checked]:bg-secondary-active/[0.48] hover:data-[state=unchecked]:bg-tertiary-active/[0.48]",
|
|
17
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:bg-state-disable-solid/[0.32] data-[disabled]:pointer-events-none ",
|
|
17
18
|
className
|
|
18
19
|
)}
|
|
19
20
|
{...props}
|
|
@@ -21,8 +22,10 @@ const Switch = React.forwardRef<
|
|
|
21
22
|
>
|
|
22
23
|
<SwitchPrimitives.Thumb
|
|
23
24
|
className={cn(
|
|
24
|
-
"
|
|
25
|
-
"
|
|
25
|
+
" block size-4 rounded-full bg-secondary-active shadow-lg transition-transform",
|
|
26
|
+
"data-[state=checked]:translate-x-4 data-[state=unchecked]:-translate-x-[2px] data-[state=unchecked]:bg-tertiary-active",
|
|
27
|
+
"group-hover:ring group-hover:data-[state=checked]:ring-secondary-hover-bg group-hover:data-[state=unchecked]:ring-tertiary-hover-bg",
|
|
28
|
+
"group-disabled:bg-state-disable-solid"
|
|
26
29
|
)}
|
|
27
30
|
/>
|
|
28
31
|
</SwitchPrimitives.Root>
|
|
@@ -2,7 +2,7 @@ import { cn } from "@/utils/cn";
|
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
4
|
|
|
5
|
-
export type TextProps
|
|
5
|
+
export type TextProps = {
|
|
6
6
|
variant?:
|
|
7
7
|
| "h1"
|
|
8
8
|
| "h2"
|
|
@@ -39,15 +39,10 @@ export type TextProps<T extends React.ElementType> = {
|
|
|
39
39
|
| "error";
|
|
40
40
|
children?: React.ReactNode;
|
|
41
41
|
className?: string;
|
|
42
|
-
tag?:
|
|
42
|
+
tag?: React.ElementType;
|
|
43
43
|
style?: React.CSSProperties;
|
|
44
44
|
id?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type TextComponent<T extends React.ElementType> =
|
|
48
|
-
React.ForwardRefExoticComponent<
|
|
49
|
-
TextProps<T> & React.RefAttributes<HTMLElement>
|
|
50
|
-
>;
|
|
45
|
+
};
|
|
51
46
|
|
|
52
47
|
const textVariants = cva(["text-foreground"], {
|
|
53
48
|
variants: {
|
|
@@ -66,36 +61,34 @@ const textVariants = cva(["text-foreground"], {
|
|
|
66
61
|
// montserrat: ["Montserrat", "sans-serif"],
|
|
67
62
|
// poppins: ["Poppins", "sans-serif"], font-montserrat, font-poppins
|
|
68
63
|
// TODO font, fontBold, elipt
|
|
69
|
-
const Text = <
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
ForwardedText.displayName = "Text";
|
|
64
|
+
const Text = forwardRef<React.ElementRef<React.ElementType>, TextProps>(
|
|
65
|
+
(
|
|
66
|
+
{
|
|
67
|
+
variant = "body1",
|
|
68
|
+
tag: Tag = "p",
|
|
69
|
+
children,
|
|
70
|
+
className = "",
|
|
71
|
+
color,
|
|
72
|
+
style,
|
|
73
|
+
...props
|
|
74
|
+
},
|
|
75
|
+
ref
|
|
76
|
+
) => {
|
|
77
|
+
return (
|
|
78
|
+
<Tag
|
|
79
|
+
ref={ref}
|
|
80
|
+
className={cn(
|
|
81
|
+
`typography-${variant}`,
|
|
82
|
+
textVariants({ color }),
|
|
83
|
+
className
|
|
84
|
+
)}
|
|
85
|
+
style={style}
|
|
86
|
+
{...props}
|
|
87
|
+
>
|
|
88
|
+
{children}
|
|
89
|
+
</Tag>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
100
93
|
|
|
101
|
-
export default
|
|
94
|
+
export default Text;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
import { Markdown } from "@storybook/blocks";
|
|
5
|
+
import { Toast, ToastAction } from "./Toast";
|
|
6
|
+
import { Toaster } from "./Toaster";
|
|
7
|
+
import { useToast } from "./useToast";
|
|
8
|
+
import Button from "../Button/Button";
|
|
9
|
+
|
|
10
|
+
const meta = {
|
|
11
|
+
title: "Components/Toast",
|
|
12
|
+
component: Toast,
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: "fullscreen",
|
|
16
|
+
},
|
|
17
|
+
decorators: [
|
|
18
|
+
(Story) => (
|
|
19
|
+
<div className="flex max-h-screen w-full">
|
|
20
|
+
<Story />
|
|
21
|
+
</div>
|
|
22
|
+
),
|
|
23
|
+
],
|
|
24
|
+
} satisfies Meta<typeof Toast>;
|
|
25
|
+
|
|
26
|
+
export default meta;
|
|
27
|
+
|
|
28
|
+
export const Simple = {
|
|
29
|
+
argTypes: {
|
|
30
|
+
variant: {
|
|
31
|
+
control: "select",
|
|
32
|
+
options: ["default", "success", "info", "warning", "error"],
|
|
33
|
+
},
|
|
34
|
+
contentMode: {
|
|
35
|
+
control: "select",
|
|
36
|
+
options: ["horizontal", "vertical"],
|
|
37
|
+
},
|
|
38
|
+
position: {
|
|
39
|
+
control: "select",
|
|
40
|
+
options: [
|
|
41
|
+
"top-center",
|
|
42
|
+
"top-left",
|
|
43
|
+
"top-right",
|
|
44
|
+
"bottom-center",
|
|
45
|
+
"bottom-left",
|
|
46
|
+
"bottom-right",
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
args: {
|
|
51
|
+
variant: "default",
|
|
52
|
+
contentMode: "horizontal",
|
|
53
|
+
position: "top-center",
|
|
54
|
+
},
|
|
55
|
+
render: (args) => {
|
|
56
|
+
console.log("args ", args);
|
|
57
|
+
const props: typeof args = {
|
|
58
|
+
...args,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const { toast } = useToast({
|
|
62
|
+
position: props.position,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
toast({
|
|
67
|
+
variant: props.variant,
|
|
68
|
+
title: "Success",
|
|
69
|
+
description: "This is an Info alert — check it out!",
|
|
70
|
+
contentMode: props.contentMode,
|
|
71
|
+
});
|
|
72
|
+
}, [props.variant, props.contentMode]);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div className="flex flex-row gap-4 w-full">
|
|
76
|
+
<Toaster />
|
|
77
|
+
<Button
|
|
78
|
+
onClick={() => {
|
|
79
|
+
toast({
|
|
80
|
+
title: "Scheduled: Catch up",
|
|
81
|
+
description: "Friday, February 10, 2023 at 5:57 PM",
|
|
82
|
+
});
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
Show Toast
|
|
86
|
+
</Button>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
} satisfies StoryObj<{
|
|
91
|
+
variant:
|
|
92
|
+
| "default"
|
|
93
|
+
| "success"
|
|
94
|
+
| "info"
|
|
95
|
+
| "warning"
|
|
96
|
+
| "error"
|
|
97
|
+
| null
|
|
98
|
+
| undefined;
|
|
99
|
+
contentMode: "horizontal" | "vertical";
|
|
100
|
+
position?:
|
|
101
|
+
| "top-center"
|
|
102
|
+
| "top-left"
|
|
103
|
+
| "top-right"
|
|
104
|
+
| "bottom-center"
|
|
105
|
+
| "bottom-left"
|
|
106
|
+
| "bottom-right"
|
|
107
|
+
| undefined;
|
|
108
|
+
}>;
|
|
109
|
+
|
|
110
|
+
export const WithAction = {
|
|
111
|
+
args: {},
|
|
112
|
+
render: (args) => {
|
|
113
|
+
console.log("args ", args);
|
|
114
|
+
const props: typeof args = {
|
|
115
|
+
...args,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const { toast } = useToast();
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<div className="flex flex-row gap-4 w-full">
|
|
122
|
+
<Toaster />
|
|
123
|
+
<Button
|
|
124
|
+
onClick={() => {
|
|
125
|
+
toast({
|
|
126
|
+
title: "Uh oh! Something went wrong.",
|
|
127
|
+
description: "There was a problem with your request.",
|
|
128
|
+
action: (
|
|
129
|
+
<ToastAction
|
|
130
|
+
altText="Try again"
|
|
131
|
+
onClick={() => alert("My action")}
|
|
132
|
+
>
|
|
133
|
+
Try again
|
|
134
|
+
</ToastAction>
|
|
135
|
+
),
|
|
136
|
+
});
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
Show Toast
|
|
140
|
+
</Button>
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
} satisfies StoryObj;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export const toastVariants = cva(
|
|
4
|
+
[
|
|
5
|
+
"group pointer-events-auto relative flex w-full",
|
|
6
|
+
"rounded-md shadow-lg px-4 py-3 gap-1",
|
|
7
|
+
"transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
|
8
|
+
"bg-base-popup text-base-popup-foreground",
|
|
9
|
+
],
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: "border",
|
|
14
|
+
success: "border border-success-stroke",
|
|
15
|
+
info: "border border-info-stroke",
|
|
16
|
+
warning: "border border-warning-stroke",
|
|
17
|
+
error: "border border-error-stroke",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
variant: "success",
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const toastViewportVariants = cva(
|
|
27
|
+
["fixed z-[100] flex w-full md:w-auto flex-col-reverse px-4"],
|
|
28
|
+
{
|
|
29
|
+
variants: {
|
|
30
|
+
position: {
|
|
31
|
+
"top-center": "top-[40px] left-0 right-0 justify-self-center",
|
|
32
|
+
"top-left": "top-[40px] left-0 md:left-[40px]",
|
|
33
|
+
"top-right": "top-[40px] right-0 md:right-[40px]",
|
|
34
|
+
"bottom-center": "bottom-[40px] left-0 right-0 justify-self-center",
|
|
35
|
+
"bottom-left": "bottom-[40px] left-0 md:left-[40px]",
|
|
36
|
+
"bottom-right": "bottom-[40px] right-0 md:right-[40px]",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: {
|
|
40
|
+
position: "top-center",
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const toastIconVariants = cva(
|
|
46
|
+
["flex items-center justify-center mr-2 rounded-full size-7"],
|
|
47
|
+
{
|
|
48
|
+
variants: {
|
|
49
|
+
variant: {
|
|
50
|
+
default: "",
|
|
51
|
+
success: "bg-success-transparent-8 text-success",
|
|
52
|
+
info: "bg-info-transparent-8 text-info",
|
|
53
|
+
warning: "bg-warning-transparent-8 text-warning",
|
|
54
|
+
error: "bg-error-transparent-8 text-error",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
variant: "success",
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export const toastContentVariants = cva(["flex flex-1"], {
|
|
64
|
+
variants: {
|
|
65
|
+
contentMode: {
|
|
66
|
+
horizontal: "items-center flex-row gap-2",
|
|
67
|
+
vertical: "flex-col gap-[2px]",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
defaultVariants: {
|
|
71
|
+
contentMode: "vertical",
|
|
72
|
+
},
|
|
73
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as ToastPrimitives from "@radix-ui/react-toast";
|
|
5
|
+
import { type VariantProps } from "class-variance-authority";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/utils/cn";
|
|
8
|
+
import Icon from "../Icon/Icon";
|
|
9
|
+
import { toastVariants, toastViewportVariants } from "./Toast.styles";
|
|
10
|
+
import ActionButton from "../ActionButton/ActionButton";
|
|
11
|
+
import Button from "../Button/Button";
|
|
12
|
+
|
|
13
|
+
const ToastProvider = ToastPrimitives.Provider;
|
|
14
|
+
|
|
15
|
+
const ToastViewport = React.forwardRef<
|
|
16
|
+
React.ElementRef<typeof ToastPrimitives.Viewport>,
|
|
17
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport> &
|
|
18
|
+
VariantProps<typeof toastViewportVariants>
|
|
19
|
+
>(({ className, position, ...props }, ref) => (
|
|
20
|
+
<ToastPrimitives.Viewport
|
|
21
|
+
ref={ref}
|
|
22
|
+
className={cn(toastViewportVariants({ position }), className)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
));
|
|
26
|
+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
27
|
+
|
|
28
|
+
const Toast = React.forwardRef<
|
|
29
|
+
React.ElementRef<typeof ToastPrimitives.Root>,
|
|
30
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
|
|
31
|
+
VariantProps<typeof toastVariants>
|
|
32
|
+
>(({ className, variant, ...props }, ref) => {
|
|
33
|
+
return (
|
|
34
|
+
<ToastPrimitives.Root
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn(toastVariants({ variant }), className)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
Toast.displayName = ToastPrimitives.Root.displayName;
|
|
42
|
+
|
|
43
|
+
const ToastAction = React.forwardRef<
|
|
44
|
+
React.ElementRef<typeof ToastPrimitives.Action>,
|
|
45
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
|
|
46
|
+
>(({ className, children, ...props }, ref) => (
|
|
47
|
+
<ToastPrimitives.Action
|
|
48
|
+
ref={ref}
|
|
49
|
+
className={cn("", className)}
|
|
50
|
+
{...props}
|
|
51
|
+
asChild
|
|
52
|
+
>
|
|
53
|
+
<Button variant="outline" size="sm">
|
|
54
|
+
{children}
|
|
55
|
+
</Button>
|
|
56
|
+
</ToastPrimitives.Action>
|
|
57
|
+
));
|
|
58
|
+
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
59
|
+
|
|
60
|
+
const ToastClose = React.forwardRef<
|
|
61
|
+
React.ElementRef<typeof ToastPrimitives.Close>,
|
|
62
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
|
|
63
|
+
>(({ className, ...props }, ref) => (
|
|
64
|
+
<ToastPrimitives.Close
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={cn("-mr-2 self-center text-input-default-text", className)}
|
|
67
|
+
toast-close=""
|
|
68
|
+
{...props}
|
|
69
|
+
asChild
|
|
70
|
+
>
|
|
71
|
+
<ActionButton variant="icon" size="sm">
|
|
72
|
+
<Icon type="heroicons" name="xmark" />
|
|
73
|
+
</ActionButton>
|
|
74
|
+
</ToastPrimitives.Close>
|
|
75
|
+
));
|
|
76
|
+
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
77
|
+
|
|
78
|
+
const ToastTitle = React.forwardRef<
|
|
79
|
+
React.ElementRef<typeof ToastPrimitives.Title>,
|
|
80
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
|
|
81
|
+
>(({ className, ...props }, ref) => (
|
|
82
|
+
<ToastPrimitives.Title
|
|
83
|
+
ref={ref}
|
|
84
|
+
className={cn("typography-subtitile6", className)}
|
|
85
|
+
{...props}
|
|
86
|
+
/>
|
|
87
|
+
));
|
|
88
|
+
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
89
|
+
|
|
90
|
+
const ToastDescription = React.forwardRef<
|
|
91
|
+
React.ElementRef<typeof ToastPrimitives.Description>,
|
|
92
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
|
|
93
|
+
>(({ className, ...props }, ref) => (
|
|
94
|
+
<ToastPrimitives.Description
|
|
95
|
+
ref={ref}
|
|
96
|
+
className={cn("typography-subtitile5 text-text-grey-dark", className)}
|
|
97
|
+
{...props}
|
|
98
|
+
/>
|
|
99
|
+
));
|
|
100
|
+
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
101
|
+
|
|
102
|
+
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
|
|
103
|
+
|
|
104
|
+
type ToastActionElement = React.ReactElement<typeof ToastAction>;
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
type ToastProps,
|
|
108
|
+
type ToastActionElement,
|
|
109
|
+
ToastProvider,
|
|
110
|
+
ToastViewport,
|
|
111
|
+
Toast,
|
|
112
|
+
ToastTitle,
|
|
113
|
+
ToastDescription,
|
|
114
|
+
ToastClose,
|
|
115
|
+
ToastAction,
|
|
116
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {
|
|
5
|
+
Toast,
|
|
6
|
+
ToastClose,
|
|
7
|
+
ToastDescription,
|
|
8
|
+
ToastProvider,
|
|
9
|
+
ToastTitle,
|
|
10
|
+
ToastViewport,
|
|
11
|
+
} from "./Toast";
|
|
12
|
+
import { useToast } from "./useToast";
|
|
13
|
+
import Icon from "../Icon/Icon";
|
|
14
|
+
import { toastContentVariants, toastIconVariants } from "./Toast.styles";
|
|
15
|
+
|
|
16
|
+
export function Toaster() {
|
|
17
|
+
const { toasts, position } = useToast();
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<ToastProvider>
|
|
21
|
+
{toasts.map(function ({
|
|
22
|
+
id,
|
|
23
|
+
title,
|
|
24
|
+
description,
|
|
25
|
+
action,
|
|
26
|
+
contentMode,
|
|
27
|
+
...props
|
|
28
|
+
}) {
|
|
29
|
+
return (
|
|
30
|
+
<Toast key={id} {...props}>
|
|
31
|
+
<div className={toastIconVariants({ variant: props.variant })}>
|
|
32
|
+
<Icon type="heroicons" name="check-circle" className="size-6" />
|
|
33
|
+
</div>
|
|
34
|
+
<div className={toastContentVariants({ contentMode })}>
|
|
35
|
+
{title && <ToastTitle>{title}</ToastTitle>}
|
|
36
|
+
{description && (
|
|
37
|
+
<ToastDescription>{description}</ToastDescription>
|
|
38
|
+
)}
|
|
39
|
+
</div>
|
|
40
|
+
<div className="self-center ml-[var(--spacing-spacing-xl)]">
|
|
41
|
+
{action}
|
|
42
|
+
</div>
|
|
43
|
+
<ToastClose />
|
|
44
|
+
</Toast>
|
|
45
|
+
);
|
|
46
|
+
})}
|
|
47
|
+
<ToastViewport position={position} />
|
|
48
|
+
</ToastProvider>
|
|
49
|
+
);
|
|
50
|
+
}
|