From b6083ce1047cb3ebc05a05edb624db42dd91f2d2 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 1 May 2024 18:12:10 +0300 Subject: [PATCH] docs: added documentation for toast component changes (#7141) * docs: added documentation for toast component changes * added redirect from use-toast docs to upgrade guide * remove unused file * content linting fixes * update UI package version * updated ui preset * fix upgrade guides main page --- .../upgrade-guides/medusa-ui/3-0-0.mdx | 115 ++++++++ .../docs/src/utils/get-first-category-item.ts | 2 +- www/apps/ui/package.json | 4 +- www/apps/ui/src/config/colors.ts | 250 +++++++++--------- www/apps/ui/src/config/docs.tsx | 5 - .../ui/src/content/docs/components/toast.mdx | 45 +++- .../ui/src/content/docs/hooks/use-toast.mdx | 30 --- www/apps/ui/src/examples/toaster-demo.tsx | 7 +- www/apps/ui/src/examples/toaster-dismiss.tsx | 19 ++ www/apps/ui/src/examples/toaster-error.tsx | 8 +- www/apps/ui/src/examples/toaster-loading.tsx | 8 +- www/apps/ui/src/examples/toaster-success.tsx | 8 +- www/apps/ui/src/examples/toaster-warning.tsx | 8 +- .../ui/src/examples/toaster-with-action.tsx | 8 +- www/apps/ui/src/props/hooks/ToasterToast.tsx | 44 --- www/apps/ui/src/props/hooks/useToast.tsx | 34 --- .../ui/src/registries/example-registry.tsx | 5 + www/apps/ui/src/registries/hook-registry.tsx | 6 - .../ui/src/specs/Toast/Toast.Viewport.json | 6 - www/apps/ui/src/specs/Toast/Toast.json | 106 +++++--- .../specs/ToastProvider/ToastProvider.json | 6 - www/apps/ui/src/specs/Toaster/Toaster.json | 93 ++++++- www/apps/ui/vercel.json | 8 +- www/yarn.lock | 77 +++++- 24 files changed, 559 insertions(+), 343 deletions(-) create mode 100644 www/apps/docs/content/upgrade-guides/medusa-ui/3-0-0.mdx delete mode 100644 www/apps/ui/src/content/docs/hooks/use-toast.mdx create mode 100644 www/apps/ui/src/examples/toaster-dismiss.tsx delete mode 100644 www/apps/ui/src/props/hooks/ToasterToast.tsx delete mode 100644 www/apps/ui/src/props/hooks/useToast.tsx delete mode 100644 www/apps/ui/src/specs/Toast/Toast.Viewport.json delete mode 100644 www/apps/ui/src/specs/ToastProvider/ToastProvider.json diff --git a/www/apps/docs/content/upgrade-guides/medusa-ui/3-0-0.mdx b/www/apps/docs/content/upgrade-guides/medusa-ui/3-0-0.mdx new file mode 100644 index 0000000000..cc7e41997f --- /dev/null +++ b/www/apps/docs/content/upgrade-guides/medusa-ui/3-0-0.mdx @@ -0,0 +1,115 @@ +--- +description: "Actions Required for v.3.0.0" +sidebar_custom_props: + iconName: "component-solid" +--- + +import Tabs from "@theme/Tabs" +import TabItem from "@theme/TabItem" + +# v3.0.0 + +Version 3.0.0 of Medusa UI introduces a breaking change for the toast components. This is due to a change in the underlying toast library from Radix UI to [Sonner](https://sonner.emilkowal.ski/). + +## How to Update + +Run the following command in your project: + +```bash npm2yarn +npm install @medusajs/ui@3.0.0 +``` + +--- + +## Breaking Changes + +### useToast Hook + +Previously, you created a toast using the `useToast` hook, which provides a utility function. In this version, the `useToast` hook is removed and, instead, a new `toast` utility is exported. The `toast` utility has functions that create toasts for different variants, such as `warning` and `error`. + +For example, here's before and after update code to see the difference: + + + + + ```tsx + import { Button, Toaster, useToast } from "@medusajs/ui" + + export default function ToasterDemo() { + const { toast } = useToast() + + return ( + <> + + + + ) + } + ``` + + + + + ```tsx + import { Button, Toaster, toast } from "@medusajs/ui" + + export default function ToasterDemo() { + return ( + <> + + + + ) + } + ``` + + + + +Learn more about the `toast` utility in the [UI documentation](https://docs.medusajs.com/ui/components/toast). + +### Toaster Default Position + +The default position has changed from `top-right` to `bottom-right`. You can change the position of the created toasts by passing the `position` prop to the `Toaster` component. + +For example: + +```tsx +import { Button, Toaster, toast } from "@medusajs/ui" + +export default function ToasterDemo() { + return ( + <> + + + + ) +} +``` + +Learn more about the `Toaster`'s props in the [UI documentation](https://docs.medusajs.com/ui/components/toast). diff --git a/www/apps/docs/src/utils/get-first-category-item.ts b/www/apps/docs/src/utils/get-first-category-item.ts index 41910645c1..5ffd0ff2db 100644 --- a/www/apps/docs/src/utils/get-first-category-item.ts +++ b/www/apps/docs/src/utils/get-first-category-item.ts @@ -14,7 +14,7 @@ export function getCategoryItems({ categoryLabel, categoryCustomId }: Options) { useDocsSidebar().items, (item) => item.label === categoryLabel || - item.customProps.category_id === categoryCustomId + (categoryCustomId && item.customProps.category_id === categoryCustomId) )?.items } diff --git a/www/apps/ui/package.json b/www/apps/ui/package.json index 0380d09fdc..7c32f84a23 100644 --- a/www/apps/ui/package.json +++ b/www/apps/ui/package.json @@ -15,8 +15,8 @@ "dependencies": { "@faker-js/faker": "^8.0.2", "@medusajs/icons": "^1.2.0", - "@medusajs/ui": "^2.4.1", - "@medusajs/ui-preset": "latest", + "@medusajs/ui": "^3.0.0", + "@medusajs/ui-preset": "^1.1.3", "@radix-ui/react-dialog": "^1.0.4", "@radix-ui/react-scroll-area": "^1.0.4", "@radix-ui/react-tabs": "^1.0.4", diff --git a/www/apps/ui/src/config/colors.ts b/www/apps/ui/src/config/colors.ts index c1314dd592..87acddcdd0 100644 --- a/www/apps/ui/src/config/colors.ts +++ b/www/apps/ui/src/config/colors.ts @@ -1,33 +1,8 @@ export const colors = { dark: { - "--button-transparent-pressed": "rgba(46, 48, 53, 1)", - "--border-base": "rgba(46, 48, 53, 1)", - "--tag-neutral-icon": "rgba(125, 130, 138, 1)", - "--bg-switch-off-hover": "rgba(70, 75, 80, 1)", "--fg-on-color": "rgba(255, 255, 255, 1)", - "--bg-switch-off": "rgba(53, 55, 60, 1)", - "--border-strong": "rgba(53, 55, 60, 1)", - "--fg-subtle": "rgba(173, 177, 184, 1)", - "--fg-base": "rgba(237, 238, 240, 1)", - "--bg-base-hover": "rgba(39, 40, 45, 1)", - "--bg-subtle-hover": "rgba(27, 27, 31, 1)", - "--fg-disabled": "rgba(60, 63, 68, 1)", - "--bg-subtle": "rgba(24, 24, 26, 1)", - "--tag-neutral-border": "rgba(60, 63, 68, 1)", - "--bg-subtle-pressed": "rgba(39, 40, 45, 1)", - "--tag-neutral-text": "rgba(173, 177, 184, 1)", - "--fg-muted": "rgba(105, 110, 119, 1)", - "--border-loud": "rgba(237, 238, 240, 1)", - "--bg-base-pressed": "rgba(46, 48, 53, 1)", - "--bg-disabled": "rgba(39, 40, 45, 1)", - "--code-fg-subtle": "rgba(105, 110, 119, 1)", - "--code-fg-base": "rgba(237, 238, 240, 1)", - "--code-bg-subtle": "rgba(24, 24, 26, 1)", - "--code-fg-muted": "rgba(70, 75, 80, 1)", - "--bg-highlight-hover": "rgba(30, 58, 138, 1)", "--border-danger": "rgba(190, 18, 60, 1)", "--border-interactive": "rgba(96, 165, 250, 1)", - "--bg-highlight": "rgba(23, 37, 84, 1)", "--fg-interactive-hover": "rgba(59, 130, 246, 1)", "--fg-error": "rgba(251, 113, 133, 1)", "--bg-interactive": "rgba(96, 165, 250, 1)", @@ -36,24 +11,18 @@ export const colors = { "--button-danger-gradient-from": "rgba(255, 255, 255, 1)", "--button-danger-gradient-to": "rgba(255, 255, 255, 0)", "--fg-interactive": "rgba(96, 165, 250, 1)", - "--bg-overlay": "rgba(24, 24, 26, 0.7)", - "--fg-on-inverted": "rgba(24, 24, 26, 1)", "--tag-red-border": "rgba(136, 19, 55, 1)", "--tag-red-bg": "rgba(76, 5, 25, 1)", - "--button-transparent-hover": "rgba(39, 40, 45, 1)", "--tag-blue-text": "rgba(96, 165, 250, 1)", "--tag-orange-text": "rgba(251, 191, 36, 1)", "--tag-green-text": "rgba(52, 211, 153, 1)", - "--tag-neutral-bg": "rgba(46, 48, 53, 1)", "--tag-orange-border": "rgba(120, 53, 15, 1)", "--tag-green-border": "rgba(6, 78, 59, 1)", - "--bg-base": "rgba(27, 27, 31, 1)", "--tag-red-text": "rgba(251, 113, 133, 1)", "--tag-green-bg-hover": "rgba(6, 78, 59, 1)", "--tag-purple-bg-hover": "rgba(76, 29, 149, 1)", "--tag-red-bg-hover": "rgba(136, 19, 55, 1)", "--border-transparent": "rgba(255, 255, 255, 0)", - "--code-border": "rgba(46, 48, 53, 1)", "--tag-orange-icon": "rgba(245, 158, 11, 1)", "--tag-purple-bg": "rgba(46, 16, 100, 1)", "--tag-blue-bg": "rgba(23, 37, 84, 1)", @@ -63,42 +32,11 @@ export const colors = { "--tag-blue-bg-hover": "rgba(30, 42, 138, 1)", "--tag-orange-bg": "rgba(69, 26, 3, 1)", "--tag-orange-bg-hover": "rgba(120, 53, 15, 1)", - "--code-bg-base": "rgba(27, 27, 31, 1)", - "--button-neutral": "rgba(39, 40, 45, 1)", - "--button-neutral-gradient-from": "rgba(255, 255, 255, 1)", - "--button-neutral-gradient-to": "rgba(255, 255, 255, 0)", - "--tag-neutral-bg-hover": "rgba(53, 55, 60, 1)", "--tag-blue-icon": "rgba(59, 130, 246, 1)", "--tag-red-icon": "rgba(244, 63, 94, 1)", "--tag-purple-icon": "rgba(139, 92, 246, 1)", "--tag-purple-text": "rgba(167, 139, 250, 1)", "--tag-green-icon": "rgba(16, 185, 129, 1)", - "--button-inverted": "rgba(237, 238, 240, 1)", - "--button-inverted-gradient-from": "rgba(24, 24, 26, 0)", - "--button-inverted-gradient-to": "rgba(24, 24, 26, 1)", - "--bg-component": "rgba(39, 40, 45, 1)", - "--bg-field": "rgba(39, 40, 45, 1)", - "--bg-field-hover": "rgba(46, 48, 53, 1)", - "--contrast-fg-primary": "rgba(28, 32, 36, 1)", - "--contrast-bg-base": "rgba(228, 228, 233, 1)", - "--contrast-fg-secondary": "rgba(96, 100, 108, 1)", - "--contrast-border-base": "rgba(185, 187, 198, 1)", - "--contrast-bg-base-pressed": "rgba(242, 242, 245, 1)", - "--contrast-bg-subtle": "rgba(211, 212, 219, 1)", - "--contrast-bg-base-hover": "rgba(235, 235, 239, 1)", - "--contrast-bg-highlight": "rgba(242, 242, 245, 1)", - "--button-neutral-pressed": "rgba(60, 63, 68, 1)", - "--button-neutral-pressed-gradient-from": "rgba(255, 255, 255, 1)", - "--button-neutral-pressed-gradient-to": "rgba(255, 255, 255, 0)", - "--button-inverted-pressed": "rgba(237, 238, 240, 1)", - "--button-inverted-pressed-gradient-from": "rgba(0, 0, 0, 0)", - "--button-inverted-pressed-gradient-to": "rgba(24, 24, 26, 1)", - "--button-neutral-hover": "rgba(53, 55, 60, 1)", - "--button-neutral-hover-gradient-from": "rgba(255, 255, 255, 1)", - "--button-neutral-hover-gradient-to": "rgba(255, 255, 255, 0)", - "--button-inverted-hover": "rgba(255, 255, 255, 1)", - "--button-inverted-hover-gradient-from": "rgba(24, 24, 26, 0)", - "--button-inverted-hover-gradient-to": "rgba(24, 24, 26, 1)", "--button-danger-pressed": "rgba(225, 29, 72, 1)", "--button-danger-pressed-gradient-from": "rgba(255, 255, 255, 1)", "--button-danger-pressed-gradient-to": "rgba(255, 255, 255, 0)", @@ -106,113 +44,183 @@ export const colors = { "--button-danger-hover-gradient-from": "rgba(255, 255, 255, 1)", "--button-danger-hover-gradient-to": "rgba(255, 255, 255, 0)", "--button-transparent": "rgba(0, 0, 0, 0.01)", - }, - light: { - "--button-inverted": "rgba(3, 7, 18, 1)", + "--code-bg-base": "rgba(9, 9, 11, 1)", + "--button-neutral": "rgba(39, 39, 42, 1)", + "--button-neutral-gradient-from": "rgba(255, 255, 255, 1)", + "--button-neutral-gradient-to": "rgba(255, 255, 255, 0)", + "--button-transparent-hover": "rgba(39, 39, 42, 1)", + "--code-fg-subtle": "rgba(161, 161, 170, 1)", + "--tag-neutral-bg-hover": "rgba(63, 63, 70, 1)", + "--contrast-border-base": "rgba(82, 82, 91, 1)", + "--button-neutral-pressed": "rgba(82, 82, 91, 1)", + "--button-neutral-pressed-gradient-from": "rgba(255, 255, 255, 1)", + "--button-neutral-pressed-gradient-to": "rgba(255, 255, 255, 0)", + "--tag-neutral-bg": "rgba(39, 39, 42, 1)", + "--bg-highlight": "rgba(23, 37, 84, 1)", + "--border-base": "rgba(255, 255, 255, 0.1)", + "--code-fg-base": "rgba(250, 250, 250, 1)", + "--tag-neutral-icon": "rgba(113, 113, 122, 1)", + "--bg-switch-off-hover": "rgba(82, 82, 91, 1)", + "--bg-base": "rgba(24, 24, 27, 1)", + "--button-inverted-pressed": "rgba(161, 161, 170, 1)", + "--button-inverted-pressed-gradient-from": "rgba(255, 255, 255, 1)", + "--button-inverted-pressed-gradient-to": "rgba(255, 255, 255, 0)", + "--button-neutral-hover": "rgba(63, 63, 70, 1)", + "--button-neutral-hover-gradient-from": "rgba(255, 255, 255, 1)", + "--button-neutral-hover-gradient-to": "rgba(255, 255, 255, 0)", + "--bg-switch-off": "rgba(63, 63, 70, 1)", + "--border-strong": "rgba(255, 255, 255, 0.15)", + "--fg-subtle": "rgba(161, 161, 170, 1)", + "--bg-highlight-hover": "rgba(30, 58, 138, 1)", + "--button-inverted": "rgba(82, 82, 91, 1)", "--button-inverted-gradient-from": "rgba(255, 255, 255, 1)", "--button-inverted-gradient-to": "rgba(255, 255, 255, 0)", - "--code-fg-subtle": "rgba(156, 163, 175, 1)", - "--code-fg-muted": "rgba(107, 114, 128, 1)", - "--code-bg-subtle": "rgba(31, 41, 55, 1)", - "--code-fg-base": "rgba(249, 250, 251, 1)", + "--fg-base": "rgba(250, 250, 250, 1)", + "--code-border": "rgba(39, 39, 42, 1)", + "--contrast-bg-subtle": "rgba(39, 39, 42, 1)", + "--contrast-bg-base-hover": "rgba(82, 82, 91, 1)", + "--bg-base-hover": "rgba(39, 39, 42, 1)", + "--bg-subtle-hover": "rgba(24, 24, 27, 1)", + "--fg-disabled": "rgba(63, 63, 70, 1)", + "--bg-subtle": "rgba(9, 9, 11, 1)", + "--tag-neutral-border": "rgba(63, 63, 70, 1)", + "--bg-subtle-pressed": "rgba(39, 39, 42, 1)", + "--tag-neutral-text": "rgba(161, 161, 170, 1)", + "--fg-muted": "rgba(82, 82, 91, 1)", + "--bg-overlay": "rgba(9, 9, 11, 0.7)", + "--button-inverted-hover": "rgba(113, 113, 122, 1)", + "--button-inverted-hover-gradient-from": "rgba(255, 255, 255, 1)", + "--button-inverted-hover-gradient-to": "rgba(255, 255, 255, 0)", + "--fg-on-inverted": "rgba(9, 9, 11, 1)", + "--code-bg-subtle": "rgba(24, 24, 27, 1)", + "--bg-component": "rgba(39, 39, 42, 1)", + "--border-loud": "rgba(250, 250, 250, 1)", + "--bg-base-pressed": "rgba(63, 63, 70, 1)", + "--bg-disabled": "rgba(39, 39, 42, 1)", + "--contrast-bg-highlight": "rgba(82, 82, 91, 1)", + "--button-transparent-pressed": "rgba(63, 63, 70, 1)", + "--code-fg-muted": "rgba(82, 82, 91, 1)", + "--contrast-fg-secondary": "rgba(161, 161, 170, 1)", + "--contrast-bg-base-pressed": "rgba(113, 113, 122, 1)", + "--contrast-fg-primary": "rgba(250, 250, 250, 1)", + "--contrast-bg-base": "rgba(63, 63, 70, 1)", + "--bg-component-pressed": "rgba(82, 82, 91, 1)", + "--bg-component-hover": "rgba(63, 63, 70, 1)", + "--bg-field": "rgba(39, 39, 42, 1)", + "--bg-field-component": "rgba(24, 24, 27, 1)", + "--bg-field-component-hover": "rgba(24, 24, 27, 1)", + "--bg-field-hover": "rgba(39, 39, 42, 1)", + }, + light: { "--tag-green-bg": "rgba(209, 250, 229, 1)", - "--border-strong": "rgba(209, 213, 219, 1)", "--border-interactive": "rgba(59, 130, 246, 1)", "--bg-highlight": "rgba(239, 246, 255, 1)", - "--tag-neutral-bg": "rgba(243, 244, 246, 1)", "--tag-red-bg": "rgba(255, 228, 230, 1)", "--tag-orange-bg": "rgba(254, 244, 199, 1)", "--bg-base": "rgba(255, 255, 255, 1)", - "--border-base": "rgba(229, 231, 235, 1)", "--tag-green-icon": "rgba(5, 150, 105, 1)", "--tag-purple-bg-hover": "rgba(221, 214, 254, 1)", "--tag-blue-border": "rgba(191, 219, 254, 1)", "--tag-orange-icon": "rgba(217, 119, 6, 1)", "--tag-purple-bg": "rgba(237, 233, 254, 1)", - "--bg-subtle": "rgba(249, 250, 251, 1)", "--tag-purple-text": "rgba(109, 40, 217, 1)", "--tag-blue-bg": "rgba(219, 234, 254, 1)", "--tag-blue-icon": "rgba(37, 99, 235, 1)", "--border-error": "rgba(225, 29, 72, 1)", - "--border-loud": "rgba(3, 7, 18, 1)", "--fg-on-inverted": "rgba(255, 255, 255, 1)", "--fg-on-color": "rgba(255, 255, 255, 1)", "--fg-interactive-hover": "rgba(37, 99, 235, 1)", "--fg-interactive": "rgba(59, 130, 246, 1)", "--fg-error": "rgba(225, 29, 72, 1)", "--border-danger": "rgba(190, 18, 60, 1)", - "--border-transparent": "rgba(3, 7, 18, 0)", - "--fg-base": "rgba(3, 7, 18, 1)", - "--fg-disabled": "rgba(209, 213, 219, 1)", - "--bg-subtle-pressed": "rgba(229, 231, 235, 1)", - "--fg-subtle": "rgba(75, 85, 99, 1)", - "--fg-muted": "rgba(156, 163, 175, 1)", - "--bg-subtle-hover": "rgba(243, 244, 246, 1)", - "--tag-neutral-border": "rgba(229, 231, 235, 1)", + "--fg-muted": "rgba(161, 161, 170, 1)", + "--bg-subtle-pressed": "rgba(228, 228, 231, 1)", "--tag-green-bg-hover": "rgba(167, 243, 208, 1)", "--tag-blue-bg-hover": "rgba(191, 219, 254, 1)", "--tag-red-icon": "rgba(225, 29, 72, 1)", - "--tag-neutral-text": "rgba(75, 85, 99, 1)", "--tag-red-bg-hover": "rgba(254, 205, 211, 1)", "--tag-red-text": "rgba(190, 18, 60, 1)", "--tag-purple-icon": "rgba(124, 58, 237, 1)", "--tag-blue-text": "rgba(29, 78, 216, 1)", "--tag-orange-bg-hover": "rgba(253, 230, 138, 1)", - "--tag-neutral-bg-hover": "rgba(229, 231, 235, 1)", "--tag-purple-border": "rgba(221, 214, 254, 1)", "--tag-orange-text": "rgba(180, 83, 9, 1)", - "--tag-neutral-icon": "rgba(107, 114, 128, 1)", "--tag-orange-border": "rgba(253, 230, 138, 1)", "--tag-red-border": "rgba(254, 205, 211, 1)", "--tag-green-border": "rgba(167, 243, 208, 1)", "--tag-green-text": "rgba(4, 120, 87, 1)", - "--code-bg-base": "rgba(17, 24, 39, 1)", - "--code-border": "rgba(55, 65, 81, 1)", - "--button-neutral": "rgba(255, 255, 255, 1)", - "--button-neutral-gradient-from": "rgba(3, 7, 18, 0)", - "--button-neutral-gradient-to": "rgba(3, 7, 18, 1)", "--button-danger": "rgba(225, 29, 72, 1)", "--button-danger-gradient-from": "rgba(255, 255, 255, 1)", "--button-danger-gradient-to": "rgba(255, 255, 255, 0)", - "--button-inverted-pressed": "rgba(31, 41, 55, 1)", - "--button-inverted-pressed-gradient-from": "rgba(255, 255, 255, 1)", - "--button-inverted-pressed-gradient-to": "rgba(255, 255, 255, 0)", "--button-danger-pressed": "rgba(159, 18, 57, 1)", "--button-danger-pressed-gradient-from": "rgba(255, 255, 255, 1)", "--button-danger-pressed-gradient-to": "rgba(255, 255, 255, 0)", - "--button-inverted-hover": "rgba(17, 24, 39, 1)", - "--button-inverted-hover-gradient-from": "rgba(255, 255, 255, 1)", - "--button-inverted-hover-gradient-to": "rgba(255, 255, 255, 0)", "--button-danger-hover": "rgba(190, 18, 60, 1)", "--button-danger-hover-gradient-from": "rgba(255, 255, 255, 1)", "--button-danger-hover-gradient-to": "rgba(255, 255, 255, 0)", - "--bg-component": "rgba(241, 243, 245, 1)", - "--bg-overlay": "rgba(3, 7, 18, 0.4)", - "--bg-switch-off": "rgba(229, 231, 235, 1)", - "--bg-field-hover": "rgba(243, 244, 246, 1)", - "--bg-field": "rgba(249, 250, 251, 1)", "--bg-interactive": "rgba(59, 130, 246, 1)", "--bg-highlight-hover": "rgba(219, 234, 254, 1)", - "--bg-switch-off-hover": "rgba(209, 213, 219, 1)", - "--bg-disabled": "rgba(243, 244, 246, 1)", - "--contrast-bg-subtle": "rgba(46, 48, 53, 1)", - "--contrast-bg-base": "rgba(27, 27, 31, 1)", - "--contrast-border-base": "rgba(60, 63, 68, 1)", - "--contrast-fg-primary": "rgba(237, 238, 240, 1)", - "--contrast-bg-base-pressed": "rgba(53, 55, 60, 1)", - "--contrast-fg-secondary": "rgba(173, 177, 184, 1)", - "--contrast-bg-highlight": "rgba(53, 55, 60, 1)", - "--contrast-bg-base-hover": "rgba(46, 48, 53, 1)", - "--button-transparent-hover": "rgba(243, 244, 246, 1)", - "--button-neutral-pressed": "rgba(229, 231, 235, 1)", - "--button-neutral-pressed-gradient-from": "rgba(3, 7, 18, 0)", - "--button-neutral-pressed-gradient-to": "rgba(3, 7, 18, 1)", - "--button-transparent-pressed": "rgba(229, 231, 235, 1)", - "--button-neutral-hover": "rgba(243, 244, 246, 1)", - "--button-neutral-hover-gradient-from": "rgba(3, 7, 18, 0)", - "--button-neutral-hover-gradient-to": "rgba(3, 7, 18, 1)", - "--bg-base-pressed": "rgba(243, 244, 246, 1)", - "--bg-base-hover": "rgba(249, 250, 251, 1)", "--button-transparent": "rgba(255, 255, 255, 0.01)", + "--bg-overlay": "rgba(9, 9, 11, 0.4)", + "--tag-neutral-border": "rgba(228, 228, 231, 1)", + "--border-loud": "rgba(9, 9, 11, 1)", + "--contrast-fg-primary": "rgba(250, 250, 250, 1)", + "--bg-switch-off": "rgba(228, 228, 231, 1)", + "--contrast-bg-base-pressed": "rgba(63, 63, 70, 1)", + "--bg-base-pressed": "rgba(228, 228, 231, 1)", + "--tag-neutral-text": "rgba(82, 82, 91, 1)", + "--button-transparent-hover": "rgba(244, 244, 245, 1)", + "--contrast-bg-base": "rgba(24, 24, 27, 1)", + "--fg-disabled": "rgba(212, 212, 216, 1)", + "--bg-field": "rgba(250, 250, 250, 1)", + "--border-strong": "rgba(212, 212, 216, 1)", + "--bg-field-hover": "rgba(244, 244, 245, 1)", + "--contrast-border-base": "rgba(82, 82, 91, 1)", + "--fg-base": "rgba(9, 9, 11, 1)", + "--contrast-bg-subtle": "rgba(39, 39, 42, 1)", + "--contrast-fg-secondary": "rgba(161, 161, 170, 1)", + "--code-fg-subtle": "rgba(161, 161, 170, 1)", + "--tag-neutral-bg": "rgba(244, 244, 245, 1)", + "--button-transparent-pressed": "rgba(228, 228, 231, 1)", + "--tag-neutral-bg-hover": "rgba(228, 228, 231, 1)", + "--code-fg-muted": "rgba(113, 113, 122, 1)", + "--contrast-bg-highlight": "rgba(63, 63, 70, 1)", + "--tag-neutral-icon": "rgba(113, 113, 122, 1)", + "--border-base": "rgba(228, 228, 231, 1)", + "--code-bg-base": "rgba(24, 24, 27, 1)", + "--button-neutral": "rgba(255, 255, 255, 1)", + "--button-neutral-gradient-from": "rgba(9, 9, 11, 0)", + "--button-neutral-gradient-to": "rgba(9, 9, 11, 1)", + "--code-bg-subtle": "rgba(39, 39, 42, 1)", + "--button-neutral-hover": "rgba(244, 244, 245, 1)", + "--button-neutral-hover-gradient-from": "rgba(9, 9, 11, 0)", + "--button-neutral-hover-gradient-to": "rgba(9, 9, 11, 1)", + "--contrast-bg-base-hover": "rgba(39, 39, 42, 1)", + "--bg-subtle": "rgba(250, 250, 250, 1)", + "--bg-switch-off-hover": "rgba(212, 212, 216, 1)", + "--code-fg-base": "rgba(250, 250, 250, 1)", + "--bg-disabled": "rgba(244, 244, 245, 1)", + "--code-border": "rgba(63, 63, 70, 1)", + "--fg-subtle": "rgba(82, 82, 91, 1)", + "--bg-subtle-hover": "rgba(244, 244, 245, 1)", + "--button-neutral-pressed": "rgba(228, 228, 231, 1)", + "--button-neutral-pressed-gradient-from": "rgba(9, 9, 11, 0)", + "--button-neutral-pressed-gradient-to": "rgba(9, 9, 11, 1)", + "--border-transparent": "rgba(9, 9, 11, 0)", + "--button-inverted": "rgba(9, 9, 11, 1)", + "--button-inverted-gradient-from": "rgba(255, 255, 255, 1)", + "--button-inverted-gradient-to": "rgba(255, 255, 255, 0)", + "--button-inverted-pressed": "rgba(39, 39, 42, 1)", + "--button-inverted-pressed-gradient-from": "rgba(255, 255, 255, 1)", + "--button-inverted-pressed-gradient-to": "rgba(255, 255, 255, 0)", + "--button-inverted-hover": "rgba(24, 24, 27, 1)", + "--button-inverted-hover-gradient-from": "rgba(255, 255, 255, 1)", + "--button-inverted-hover-gradient-to": "rgba(255, 255, 255, 0)", + "--bg-component-hover": "rgba(244, 244, 245, 1)", + "--bg-field-component": "rgba(255, 255, 255, 1)", + "--bg-field-component-hover": "rgba(250, 250, 250, 1)", + "--bg-component-pressed": "rgba(228, 228, 231, 1)", + "--bg-component": "rgba(250, 250, 250, 1)", + "--bg-base-hover": "rgba(244, 244, 245, 1)", }, } diff --git a/www/apps/ui/src/config/docs.tsx b/www/apps/ui/src/config/docs.tsx index ac98c6c225..e9dd26b5ed 100644 --- a/www/apps/ui/src/config/docs.tsx +++ b/www/apps/ui/src/config/docs.tsx @@ -261,11 +261,6 @@ export const docsConfig: DocsConfig = { path: "/hooks/use-prompt", isPathHref: true, }, - { - title: "useToast", - path: "/hooks/use-toast", - isPathHref: true, - }, { title: "useToggleState", path: "/hooks/use-toggle-state", diff --git a/www/apps/ui/src/content/docs/components/toast.mdx b/www/apps/ui/src/content/docs/components/toast.mdx index 1a8b9fcf88..45dec5f500 100644 --- a/www/apps/ui/src/content/docs/components/toast.mdx +++ b/www/apps/ui/src/content/docs/components/toast.mdx @@ -10,31 +10,25 @@ component: true --- -Add the Toaster component somewhere in your tree +Import the `toast` utility and `Toaster` component from `@medusajs/ui`: ```tsx -import { Toaster } from "@medusajs/ui" +import { Toaster, toast } from "@medusajs/ui" ``` +Then, add the `Toaster` component somewhere in your tree: + ```tsx ``` -The `useToast` hook returns a `toast` function that you can use to display a toast. +Finally, use the `toast` utility to display a toast: ```tsx -import { useToast } from "@medusajs/ui" -``` - -```tsx -const { toast } = useToast() - return ( - + + ) +} diff --git a/www/apps/ui/src/examples/toaster-error.tsx b/www/apps/ui/src/examples/toaster-error.tsx index a591342600..728861c85f 100644 --- a/www/apps/ui/src/examples/toaster-error.tsx +++ b/www/apps/ui/src/examples/toaster-error.tsx @@ -1,17 +1,13 @@ -import { Button, Toaster, useToast } from "@medusajs/ui" +import { Button, Toaster, toast } from "@medusajs/ui" export default function ToasterError() { - const { toast } = useToast() - return ( <>