@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.
Files changed (159) hide show
  1. package/dist/cjs/bundle.css +185 -37
  2. package/dist/cjs/bundle.js +3 -3
  3. package/dist/cjs/bundle.js.map +1 -1
  4. package/dist/cjs/types/components/AlertDialog/{Alert.stories.d.ts → AlertDialog.stories.d.ts} +4 -0
  5. package/dist/cjs/types/components/Calendar/Calendar.stories.d.ts +7 -7
  6. package/dist/cjs/types/components/RadioGroup/RadioGroup.stories.d.ts +1 -1
  7. package/dist/cjs/types/components/Text/Text.d.ts +5 -6
  8. package/dist/cjs/types/components/Text/Text.stories.d.ts +10 -2
  9. package/dist/cjs/types/components/Toast/Toast.d.ts +17 -0
  10. package/dist/cjs/types/components/Toast/Toast.stories.d.ts +358 -0
  11. package/dist/cjs/types/components/Toast/Toast.styles.d.ts +12 -0
  12. package/dist/cjs/types/components/Toast/Toaster.d.ts +1 -0
  13. package/dist/cjs/types/components/Toast/useToast.d.ts +55 -0
  14. package/dist/cjs/types/components/Tooltip/Tooltip.d.ts +8 -0
  15. package/dist/cjs/types/components/Tooltip/Tooltip.stories.d.ts +59 -0
  16. package/dist/cjs/types/components/Tooltip/TooltipSimple.d.ts +13 -0
  17. package/dist/cjs/types/icons/material-icon/outline/AllOutIcon.d.ts +3 -0
  18. package/dist/cjs/types/icons/material-icon/outline/FormatAlignCenterIcon.d.ts +3 -0
  19. package/dist/cjs/types/icons/material-icon/outline/FormatAlignJustifyIcon.d.ts +3 -0
  20. package/dist/cjs/types/icons/material-icon/outline/FormatAlignLeftIcon.d.ts +3 -0
  21. package/dist/cjs/types/icons/material-icon/outline/FormatAlignRightIcon.d.ts +3 -0
  22. package/dist/cjs/types/icons/material-icon/outline/FormatBoldIcon.d.ts +3 -0
  23. package/dist/cjs/types/icons/material-icon/outline/FormatItalicIcon.d.ts +3 -0
  24. package/dist/cjs/types/icons/material-icon/outline/FormatListBulletedIcon.d.ts +3 -0
  25. package/dist/cjs/types/icons/material-icon/outline/FormatListNumberedIcon.d.ts +3 -0
  26. package/dist/cjs/types/icons/material-icon/outline/FormatUnderlinedIcon.d.ts +3 -0
  27. package/dist/cjs/types/icons/material-icon/outline/index.d.ts +10 -0
  28. package/dist/cjs/types/icons/material-icon/solid/AllOutIcon.d.ts +3 -0
  29. package/dist/cjs/types/icons/material-icon/solid/FormatAlignCenterIcon.d.ts +3 -0
  30. package/dist/cjs/types/icons/material-icon/solid/FormatAlignJustifyIcon.d.ts +3 -0
  31. package/dist/cjs/types/icons/material-icon/solid/FormatAlignLeftIcon.d.ts +3 -0
  32. package/dist/cjs/types/icons/material-icon/solid/FormatAlignRightIcon.d.ts +3 -0
  33. package/dist/cjs/types/icons/material-icon/solid/FormatBoldIcon.d.ts +3 -0
  34. package/dist/cjs/types/icons/material-icon/solid/FormatItalicIcon.d.ts +3 -0
  35. package/dist/cjs/types/icons/material-icon/solid/FormatListBulletedIcon.d.ts +3 -0
  36. package/dist/cjs/types/icons/material-icon/solid/FormatListNumberedIcon.d.ts +3 -0
  37. package/dist/cjs/types/icons/material-icon/solid/FormatUnderlinedIcon.d.ts +3 -0
  38. package/dist/cjs/types/icons/material-icon/solid/index.d.ts +10 -0
  39. package/dist/cjs/types/index.d.ts +5 -0
  40. package/dist/components/AlertDialog/{Alert.stories.js → AlertDialog.stories.js} +13 -1
  41. package/dist/components/Checkbox/Checkbox.js +5 -4
  42. package/dist/components/Icon/Icon.stories.js +10 -0
  43. package/dist/components/Popover/Popover.js +1 -1
  44. package/dist/components/RadioGroup/RadioGroup.js +1 -4
  45. package/dist/components/Switch/Switch.js +1 -1
  46. package/dist/components/Text/Text.js +3 -5
  47. package/dist/components/Toast/Toast.js +52 -0
  48. package/dist/components/Toast/Toast.stories.js +82 -0
  49. package/dist/components/Toast/Toast.styles.js +60 -0
  50. package/dist/components/Toast/Toaster.js +24 -0
  51. package/dist/components/Toast/useToast.js +121 -0
  52. package/dist/components/Tooltip/Tooltip.js +26 -0
  53. package/dist/components/Tooltip/Tooltip.stories.js +61 -0
  54. package/dist/components/Tooltip/TooltipSimple.js +18 -0
  55. package/dist/esm/bundle.css +185 -37
  56. package/dist/esm/bundle.js +3 -3
  57. package/dist/esm/bundle.js.map +1 -1
  58. package/dist/esm/types/components/AlertDialog/{Alert.stories.d.ts → AlertDialog.stories.d.ts} +4 -0
  59. package/dist/esm/types/components/Calendar/Calendar.stories.d.ts +7 -7
  60. package/dist/esm/types/components/RadioGroup/RadioGroup.stories.d.ts +1 -1
  61. package/dist/esm/types/components/Text/Text.d.ts +5 -6
  62. package/dist/esm/types/components/Text/Text.stories.d.ts +10 -2
  63. package/dist/esm/types/components/Toast/Toast.d.ts +17 -0
  64. package/dist/esm/types/components/Toast/Toast.stories.d.ts +358 -0
  65. package/dist/esm/types/components/Toast/Toast.styles.d.ts +12 -0
  66. package/dist/esm/types/components/Toast/Toaster.d.ts +1 -0
  67. package/dist/esm/types/components/Toast/useToast.d.ts +55 -0
  68. package/dist/esm/types/components/Tooltip/Tooltip.d.ts +8 -0
  69. package/dist/esm/types/components/Tooltip/Tooltip.stories.d.ts +59 -0
  70. package/dist/esm/types/components/Tooltip/TooltipSimple.d.ts +13 -0
  71. package/dist/esm/types/icons/material-icon/outline/AllOutIcon.d.ts +3 -0
  72. package/dist/esm/types/icons/material-icon/outline/FormatAlignCenterIcon.d.ts +3 -0
  73. package/dist/esm/types/icons/material-icon/outline/FormatAlignJustifyIcon.d.ts +3 -0
  74. package/dist/esm/types/icons/material-icon/outline/FormatAlignLeftIcon.d.ts +3 -0
  75. package/dist/esm/types/icons/material-icon/outline/FormatAlignRightIcon.d.ts +3 -0
  76. package/dist/esm/types/icons/material-icon/outline/FormatBoldIcon.d.ts +3 -0
  77. package/dist/esm/types/icons/material-icon/outline/FormatItalicIcon.d.ts +3 -0
  78. package/dist/esm/types/icons/material-icon/outline/FormatListBulletedIcon.d.ts +3 -0
  79. package/dist/esm/types/icons/material-icon/outline/FormatListNumberedIcon.d.ts +3 -0
  80. package/dist/esm/types/icons/material-icon/outline/FormatUnderlinedIcon.d.ts +3 -0
  81. package/dist/esm/types/icons/material-icon/outline/index.d.ts +10 -0
  82. package/dist/esm/types/icons/material-icon/solid/AllOutIcon.d.ts +3 -0
  83. package/dist/esm/types/icons/material-icon/solid/FormatAlignCenterIcon.d.ts +3 -0
  84. package/dist/esm/types/icons/material-icon/solid/FormatAlignJustifyIcon.d.ts +3 -0
  85. package/dist/esm/types/icons/material-icon/solid/FormatAlignLeftIcon.d.ts +3 -0
  86. package/dist/esm/types/icons/material-icon/solid/FormatAlignRightIcon.d.ts +3 -0
  87. package/dist/esm/types/icons/material-icon/solid/FormatBoldIcon.d.ts +3 -0
  88. package/dist/esm/types/icons/material-icon/solid/FormatItalicIcon.d.ts +3 -0
  89. package/dist/esm/types/icons/material-icon/solid/FormatListBulletedIcon.d.ts +3 -0
  90. package/dist/esm/types/icons/material-icon/solid/FormatListNumberedIcon.d.ts +3 -0
  91. package/dist/esm/types/icons/material-icon/solid/FormatUnderlinedIcon.d.ts +3 -0
  92. package/dist/esm/types/icons/material-icon/solid/index.d.ts +10 -0
  93. package/dist/esm/types/index.d.ts +5 -0
  94. package/dist/icons/material-icon/outline/AllOutIcon.js +3 -0
  95. package/dist/icons/material-icon/outline/FormatAlignCenterIcon.js +3 -0
  96. package/dist/icons/material-icon/outline/FormatAlignJustifyIcon.js +3 -0
  97. package/dist/icons/material-icon/outline/FormatAlignLeftIcon.js +3 -0
  98. package/dist/icons/material-icon/outline/FormatAlignRightIcon.js +3 -0
  99. package/dist/icons/material-icon/outline/FormatBoldIcon.js +3 -0
  100. package/dist/icons/material-icon/outline/FormatItalicIcon.js +3 -0
  101. package/dist/icons/material-icon/outline/FormatListBulletedIcon.js +3 -0
  102. package/dist/icons/material-icon/outline/FormatListNumberedIcon.js +3 -0
  103. package/dist/icons/material-icon/outline/FormatUnderlinedIcon.js +3 -0
  104. package/dist/icons/material-icon/outline/index.js +10 -0
  105. package/dist/icons/material-icon/solid/AllOutIcon.js +3 -0
  106. package/dist/icons/material-icon/solid/FormatAlignCenterIcon.js +3 -0
  107. package/dist/icons/material-icon/solid/FormatAlignJustifyIcon.js +3 -0
  108. package/dist/icons/material-icon/solid/FormatAlignLeftIcon.js +3 -0
  109. package/dist/icons/material-icon/solid/FormatAlignRightIcon.js +3 -0
  110. package/dist/icons/material-icon/solid/FormatBoldIcon.js +3 -0
  111. package/dist/icons/material-icon/solid/FormatItalicIcon.js +3 -0
  112. package/dist/icons/material-icon/solid/FormatListBulletedIcon.js +3 -0
  113. package/dist/icons/material-icon/solid/FormatListNumberedIcon.js +3 -0
  114. package/dist/icons/material-icon/solid/FormatUnderlinedIcon.js +3 -0
  115. package/dist/icons/material-icon/solid/index.js +10 -0
  116. package/dist/index.d.ts +94 -6
  117. package/dist/index.js +5 -0
  118. package/dist/src/theme/global.css +230 -46
  119. package/dist/theme/themes/xspector/state.css +1 -1
  120. package/package.json +4 -1
  121. package/src/components/AlertDialog/{Alert.stories.tsx → AlertDialog.stories.tsx} +41 -1
  122. package/src/components/Checkbox/Checkbox.tsx +9 -4
  123. package/src/components/Icon/Icon.stories.tsx +10 -0
  124. package/src/components/Popover/Popover.tsx +1 -1
  125. package/src/components/RadioGroup/RadioGroup.tsx +6 -7
  126. package/src/components/Switch/Switch.tsx +8 -5
  127. package/src/components/Text/Text.tsx +33 -40
  128. package/src/components/Toast/Toast.stories.tsx +144 -0
  129. package/src/components/Toast/Toast.styles.tsx +73 -0
  130. package/src/components/Toast/Toast.tsx +116 -0
  131. package/src/components/Toast/Toaster.tsx +50 -0
  132. package/src/components/Toast/useToast.ts +222 -0
  133. package/src/components/Tooltip/Tooltip.stories.tsx +152 -0
  134. package/src/components/Tooltip/Tooltip.tsx +38 -0
  135. package/src/components/Tooltip/TooltipSimple.tsx +46 -0
  136. package/src/icons/material-icon/outline/AllOutIcon.tsx +20 -0
  137. package/src/icons/material-icon/outline/FormatAlignCenterIcon.tsx +20 -0
  138. package/src/icons/material-icon/outline/FormatAlignJustifyIcon.tsx +20 -0
  139. package/src/icons/material-icon/outline/FormatAlignLeftIcon.tsx +20 -0
  140. package/src/icons/material-icon/outline/FormatAlignRightIcon.tsx +20 -0
  141. package/src/icons/material-icon/outline/FormatBoldIcon.tsx +20 -0
  142. package/src/icons/material-icon/outline/FormatItalicIcon.tsx +20 -0
  143. package/src/icons/material-icon/outline/FormatListBulletedIcon.tsx +20 -0
  144. package/src/icons/material-icon/outline/FormatListNumberedIcon.tsx +20 -0
  145. package/src/icons/material-icon/outline/FormatUnderlinedIcon.tsx +20 -0
  146. package/src/icons/material-icon/outline/index.ts +10 -0
  147. package/src/icons/material-icon/solid/AllOutIcon.tsx +20 -0
  148. package/src/icons/material-icon/solid/FormatAlignCenterIcon.tsx +20 -0
  149. package/src/icons/material-icon/solid/FormatAlignJustifyIcon.tsx +20 -0
  150. package/src/icons/material-icon/solid/FormatAlignLeftIcon.tsx +20 -0
  151. package/src/icons/material-icon/solid/FormatAlignRightIcon.tsx +20 -0
  152. package/src/icons/material-icon/solid/FormatBoldIcon.tsx +20 -0
  153. package/src/icons/material-icon/solid/FormatItalicIcon.tsx +20 -0
  154. package/src/icons/material-icon/solid/FormatListBulletedIcon.tsx +20 -0
  155. package/src/icons/material-icon/solid/FormatListNumberedIcon.tsx +20 -0
  156. package/src/icons/material-icon/solid/FormatUnderlinedIcon.tsx +20 -0
  157. package/src/icons/material-icon/solid/index.ts +10 -0
  158. package/src/index.ts +5 -0
  159. 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-base-popup-highlight border-none overflow-hidden p-0 text-popover-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",
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 h-4 w-4 rounded-full border text-primary disabled:fill-state-disable-solid ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:state-disable-solid",
31
- {
32
- "border-primary-30 data-[state=checked]:border-primary":
33
- !props.disabled,
34
- "border-state-disable-solid data-disabled:border-state-disable-solid text-state-disable-solid fill-state-disable-solid":
35
- props.disabled,
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
- "peer inline-flex h-3 w-[32px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors",
15
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
16
- "disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-secondary-active/[0.32] data-[state=unchecked]:bg-tertiary-active/[0.32]",
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
- "pointer-events-none block size-4 rounded-full bg-secondary-active shadow-lg ring-0",
25
- "transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:-translate-x-[2px] data-[state=unchecked]:bg-tertiary-active"
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<T extends React.ElementType> = {
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?: T;
42
+ tag?: React.ElementType;
43
43
  style?: React.CSSProperties;
44
44
  id?: string;
45
- } & React.ComponentProps<T>;
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 = <T extends React.ElementType = "p">(
70
- {
71
- variant = "body1",
72
- tag: Tag = "p",
73
- children,
74
- className = "",
75
- color,
76
- style,
77
- ...props
78
- }: TextProps<T>,
79
- ref: React.Ref<any>
80
- ) => {
81
- return (
82
- <Tag
83
- ref={ref}
84
- className={cn(
85
- `typography-${variant}`,
86
- textVariants({ color }),
87
- className
88
- )}
89
- style={style}
90
- {...props}
91
- >
92
- {children}
93
- </Tag>
94
- );
95
- };
96
-
97
- const ForwardedText = forwardRef(Text) as TextComponent<any>;
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 ForwardedText;
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
+ }