diff --git a/.changeset/tiny-monkeys-invite.md b/.changeset/tiny-monkeys-invite.md new file mode 100644 index 0000000000..47e75126bc --- /dev/null +++ b/.changeset/tiny-monkeys-invite.md @@ -0,0 +1,5 @@ +--- +"@ultraviolet/ui": minor +--- + +Refactor components `Toaster` and `Notification` to use vanilla extract instead of Emotion diff --git a/packages/ui/src/components/Notification/__tests__/__snapshots__/index.test.tsx.snap b/packages/ui/src/components/Notification/__tests__/__snapshots__/index.test.tsx.snap index e774954ff5..924aad00dd 100644 --- a/packages/ui/src/components/Notification/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/ui/src/components/Notification/__tests__/__snapshots__/index.test.tsx.snap @@ -12,28 +12,7 @@ exports[`toaster > renders correctly with close button 1`] = ` exports[`toaster > renders correctly with close button 2`] = ` - .emotion-0 { - border-radius: 0.25rem; -} - -.emotion-0.Toastify__toast { - background-color: #ffffff; - color: #3f4250; - padding: 1rem; - box-shadow: 0px 4px 8px 0px #22263829,0px 8px 24px 0px #2226383d; -} - -.emotion-0.Toastify__toast-container { - width: 19.5rem; -} - -.emotion-0 .Toastify__toast-body { - margin: 0; - padding: 0; - display: none; -} - -
renders correctly with close button 2`] = ` id="notification" >
renders correctly with all kind of toast 4`] = `
) type ContentProps = { @@ -181,34 +132,24 @@ export const ToastContainer = ({ className, autoClose, containerId = 'toaster', -}: ToastContainerProps) => { - const theme = useTheme() - - return ( - - {/* eslint-disable-next-line @typescript-eslint/unbound-method */} - {({ css: localCss }) => ( - - )} - - ) -} +}: ToastContainerProps) => ( + +) export const Toast = { Button: ToastButton, diff --git a/packages/ui/src/components/Toaster/styles.css.ts b/packages/ui/src/components/Toaster/styles.css.ts new file mode 100644 index 0000000000..c723fa275b --- /dev/null +++ b/packages/ui/src/components/Toaster/styles.css.ts @@ -0,0 +1,49 @@ +import { theme } from '@ultraviolet/themes' +import { globalStyle, style } from '@vanilla-extract/css' + +const PREFIX = '.Toastify' + +export const toaster = style({ + borderRadius: theme.radii.default, + minHeight: theme.sizing[700], +}) + +globalStyle(`${toaster} ${PREFIX}__toast-container`, { + width: '21.5rem', +}) + +globalStyle(`${toaster} ${PREFIX}__toast-body`, { + margin: 0, + padding: 0, +}) + +globalStyle(`${toaster} ${PREFIX}__toast--success`, { + backgroundColor: theme.colors.neutral.backgroundStronger, + color: theme.colors.neutral.textStronger, + padding: theme.space[2], +}) + +globalStyle(`${toaster} ${PREFIX}__toast--error`, { + backgroundColor: theme.colors.danger.backgroundStrong, + color: theme.colors.neutral.textStronger, + padding: theme.space[2], +}) + +globalStyle(`${toaster} ${PREFIX}__toast--warning`, { + backgroundColor: theme.colors.warning.backgroundStrong, + color: theme.colors.warning.textStrong, + padding: theme.space[2], +}) + +export const closeButtonToaster = style({ + background: 'none', + margin: 'auto', + marginLeft: theme.space[1], + selectors: { + '&:hover, &:active': { + background: 'none', + boxShadow: 'none', + border: 'none', + }, + }, +})