diff --git a/src/plugins/components/toast/index.ts b/src/plugins/components/toast/index.ts index ab5637b..40bdda4 100644 --- a/src/plugins/components/toast/index.ts +++ b/src/plugins/components/toast/index.ts @@ -50,43 +50,34 @@ export default plugin(({ addComponents, theme }) => { '.nui-button-close': { '@apply ms-auto': {}, }, - //Type:default - '&.nui-toast-default': { - [`@apply border-2 border-${config.type.default.border.light} dark:border-${config.type.default.border.dark}`]: + //Type:low-contrast + '&.nui-toast-low-contrast': { + //Background + [`@apply bg-${config.contrast.lowContrast.background.light} dark:bg-${config.contrast.lowContrast.background.dark}`]: {}, - }, - //Type:contrast - '&.nui-toast-contrast': { - [`@apply border-2 border-${config.type.contrast.border.light} dark:border-${config.type.contrast.border.dark}`]: + //Border + [`@apply border-2 border-${config.contrast.lowContrast.border.light} dark:border-${config.contrast.lowContrast.border.dark}`]: {}, }, - //Color:white - '&.nui-toast-white': { - [`@apply bg-${config.color.white.background.light} dark:bg-${config.color.white.background.dark}`]: + //Type:high-contrast + '&.nui-toast-high-contrast': { + //Background + [`@apply bg-${config.contrast.highContrast.background.light} dark:bg-${config.contrast.highContrast.background.dark}`]: {}, - //Icon:inner - '.nui-toast-icon': { - [`@apply text-${config.color.white.icon.inner.color.light} dark:text-${config.color.white.icon.inner.color.dark}`]: - {}, - }, - //Icon:outer - '.nui-toast-icon-block': { - [`@apply bg-${config.color.white.icon.outer.background.light} dark:bg-${config.color.white.icon.outer.background.dark}`]: - {}, - }, - }, - //Color:whiteContrast - '&.nui-toast-white-contrast': { - [`@apply bg-${config.color.whiteContrast.background.light} dark:bg-${config.color.whiteContrast.background.dark}`]: + //Border + [`@apply border-2 border-${config.contrast.highContrast.border.light} dark:border-${config.contrast.highContrast.border.dark}`]: {}, + }, + //Color:default + '&.nui-toast-default': { //Icon:inner '.nui-toast-icon': { - [`@apply text-${config.color.whiteContrast.icon.inner.color.light} dark:text-${config.color.whiteContrast.icon.inner.color.dark}`]: + [`@apply text-${config.color.default.icon.inner.color.light} dark:text-${config.color.default.icon.inner.color.dark}`]: {}, }, //Icon:outer '.nui-toast-icon-block': { - [`@apply bg-${config.color.whiteContrast.icon.outer.background.light} dark:bg-${config.color.whiteContrast.icon.outer.background.dark}`]: + [`@apply bg-${config.color.default.icon.outer.background.light} dark:bg-${config.color.default.icon.outer.background.dark}`]: {}, }, }, @@ -170,6 +161,38 @@ export default plugin(({ addComponents, theme }) => { {}, }, }, + //Color:dark + '&.nui-toast-dark': { + //Border + [`@apply border-2 border-${config.color.dark.border.light} dark:border-${config.color.dark.border.dark}`]: + {}, + //Icon:inner + '.nui-toast-icon': { + [`@apply text-${config.color.dark.icon.inner.color.light} dark:text-${config.color.dark.icon.inner.color.dark}`]: + {}, + }, + //Icon:outer + '.nui-toast-icon-block': { + [`@apply bg-${config.color.dark.icon.outer.background.light} dark:bg-${config.color.dark.icon.outer.background.dark}`]: + {}, + }, + }, + //Color:black + '&.nui-toast-black': { + //Border + [`@apply border-2 border-${config.color.black.border.light} dark:border-${config.color.black.border.dark}`]: + {}, + //Icon:inner + '.nui-toast-icon': { + [`@apply text-${config.color.black.icon.inner.color.light} dark:text-${config.color.black.icon.inner.color.dark}`]: + {}, + }, + //Icon:outer + '.nui-toast-icon-block': { + [`@apply bg-${config.color.black.icon.outer.background.light} dark:bg-${config.color.black.icon.outer.background.dark}`]: + {}, + }, + }, //Rounded:sm '&.nui-toast-rounded': { [`@apply rounded-${config.rounded.sm}`]: {}, diff --git a/src/plugins/components/toast/toast.component.ts b/src/plugins/components/toast/toast.component.ts index 359fa5e..5896a36 100644 --- a/src/plugins/components/toast/toast.component.ts +++ b/src/plugins/components/toast/toast.component.ts @@ -11,7 +11,7 @@ import { ButtonClose } from '../button-close/button-close.component' export const Toast = ({ title, text, - contrast = 'white', + contrast = 'low-contrast', color = 'default', rounded = 'md', borderless, diff --git a/src/plugins/components/toast/toast.config.ts b/src/plugins/components/toast/toast.config.ts index 21c6cc5..9d7d92a 100644 --- a/src/plugins/components/toast/toast.config.ts +++ b/src/plugins/components/toast/toast.config.ts @@ -31,14 +31,22 @@ export const defaultConfig = { size: '6', }, }, - type: { - default: { + contrast: { + lowContrast: { + background: { + light: 'white', + dark: 'muted-800', + }, border: { light: 'muted-300', dark: 'muted-700', }, }, - contrast: { + highContrast: { + background: { + light: 'white', + dark: 'muted-950', + }, border: { light: 'muted-300', dark: 'muted-800', @@ -46,11 +54,7 @@ export const defaultConfig = { }, }, color: { - white: { - background: { - light: 'white', - dark: 'muted-800', - }, + default: { icon: { outer: { background: { @@ -66,31 +70,7 @@ export const defaultConfig = { }, }, }, - whiteContrast: { - background: { - light: 'white', - dark: 'muted-950', - }, - icon: { - outer: { - background: { - light: 'muted-100', - dark: 'muted-800', - }, - }, - inner: { - color: { - light: 'muted-500', - dark: 'muted-500', - }, - }, - }, - }, primary: { - background: { - light: 'primary-500', - dark: 'primary-500', - }, border: { light: 'primary-500', dark: 'primary-500', @@ -111,10 +91,6 @@ export const defaultConfig = { }, }, info: { - background: { - light: 'info-500', - dark: 'info-500', - }, border: { light: 'info-500', dark: 'info-500', @@ -135,10 +111,6 @@ export const defaultConfig = { }, }, success: { - background: { - light: 'success-500', - dark: 'success-500', - }, border: { light: 'success-500', dark: 'success-500', @@ -159,10 +131,6 @@ export const defaultConfig = { }, }, warning: { - background: { - light: 'warning-500', - dark: 'warning-500', - }, border: { light: 'warning-500', dark: 'warning-500', @@ -183,10 +151,6 @@ export const defaultConfig = { }, }, danger: { - background: { - light: 'danger-500', - dark: 'danger-500', - }, border: { light: 'danger-500', dark: 'danger-500', @@ -206,6 +170,46 @@ export const defaultConfig = { }, }, }, + dark: { + border: { + light: 'muted-900', + dark: 'muted-100', + }, + icon: { + outer: { + background: { + light: 'muted-900/10', + dark: 'muted-100/10', + }, + }, + inner: { + color: { + light: 'muted-900', + dark: 'muted-100', + }, + }, + }, + }, + black: { + border: { + light: 'black', + dark: 'white', + }, + icon: { + outer: { + background: { + light: 'black/10', + dark: 'white/10', + }, + }, + inner: { + color: { + light: 'black', + dark: 'white', + }, + }, + }, + }, }, rounded: { sm: 'md', diff --git a/src/plugins/components/toast/toast.doc.mdx b/src/plugins/components/toast/toast.doc.mdx index b358e0a..9435615 100644 --- a/src/plugins/components/toast/toast.doc.mdx +++ b/src/plugins/components/toast/toast.doc.mdx @@ -82,6 +82,12 @@ Toasts can have different colors. The following example shows the available colo
+
+ +
+
+ +
@@ -111,6 +117,12 @@ Toasts can be borderless and display a light shadow.
+
+ +
+
+ +
@@ -143,6 +155,12 @@ Toasts have an icon slot that you can use to display an icon.
+
+ +
+
+ +
@@ -172,6 +190,12 @@ Toasts have an icon slot that you can use to display an icon block.
+
+ +
+
+ +
diff --git a/src/plugins/components/toast/toast.stories.ts b/src/plugins/components/toast/toast.stories.ts index bf8e4e1..e70c847 100644 --- a/src/plugins/components/toast/toast.stories.ts +++ b/src/plugins/components/toast/toast.stories.ts @@ -28,6 +28,8 @@ const meta = { 'success', 'warning', 'danger', + 'dark', + 'black', 'none', ], defaultValue: 'default', @@ -39,8 +41,8 @@ const meta = { }, contrast: { control: { type: 'select' }, - options: ['white', 'contrast'], - defaultValue: 'white', + options: ['low-contrast', 'high-contrast'], + defaultValue: 'low-contrast', }, }, } satisfies Meta @@ -69,7 +71,7 @@ export const White: Story = { rounded: 'sm', title: 'Toast title', text: 'You need to take some action.', - contrast: 'white', + contrast: 'low-contrast', }, } @@ -79,7 +81,7 @@ export const Contrast: Story = { rounded: 'sm', title: 'Toast title', text: 'You need to take some action.', - contrast: 'contrast', + contrast: 'high-contrast', }, } // #endregion @@ -176,6 +178,26 @@ export const Danger: Story = { style: 'max-width: 340px;', }, } + +export const Dark: Story = { + name: 'Color: dark', + args: { + color: 'dark', + title: 'Toast title', + text: 'You need to take some action.', + style: 'max-width: 340px;', + }, +} + +export const Black: Story = { + name: 'Color: black', + args: { + color: 'black', + title: 'Toast title', + text: 'You need to take some action.', + style: 'max-width: 340px;', + }, +} // #endregion // #region Slot: icon (default) @@ -355,6 +377,66 @@ export const SlotIconDanger: Story = { } // #endregion +// #region Slot: icon (dark) +export const SlotIconDark: Story = { + name: 'Slot: icon', + args: { + color: 'dark', + title: 'Dark', + text: 'You need to take some action.', + icon: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon (black) +export const SlotIconBlack: Story = { + name: 'Slot: icon', + args: { + color: 'black', + title: 'Black', + text: 'You need to take some action.', + icon: html` + + + + + + + `, + }, +} +// #endregion + // #region Slot: icon block (default) export const SlotIconBlockDefault: Story = { name: 'Slot: icon', @@ -532,6 +614,66 @@ export const SlotIconBlockDanger: Story = { } // #endregion +// #region Slot: icon block (dark) +export const SlotIconBlockDark: Story = { + name: 'Slot: icon', + args: { + color: 'dark', + title: 'Dark', + text: 'You need to take some action.', + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block (black) +export const SlotIconBlockBlack: Story = { + name: 'Slot: icon', + args: { + color: 'black', + title: 'Black', + text: 'You need to take some action.', + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + // #region Slot: icon block borderless (default) export const SlotIconBlockBorderlessDefault: Story = { name: 'Slot: icon', @@ -714,3 +856,65 @@ export const SlotIconBlockBorderlessDanger: Story = { }, } // #endregion + +// #region Slot: icon block borderless (dark) +export const SlotIconBlockBorderlessDark: Story = { + name: 'Slot: icon', + args: { + color: 'dark', + title: 'Dark', + text: 'You need to take some action.', + borderless: true, + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block borderless (black) +export const SlotIconBlockBorderlessBlack: Story = { + name: 'Slot: icon', + args: { + color: 'black', + title: 'Black', + text: 'You need to take some action.', + borderless: true, + iconBlock: html` + + + + + + + `, + }, +} +// #endregion diff --git a/src/plugins/components/toast/toast.types.ts b/src/plugins/components/toast/toast.types.ts index fd40907..029c9be 100644 --- a/src/plugins/components/toast/toast.types.ts +++ b/src/plugins/components/toast/toast.types.ts @@ -11,8 +11,10 @@ export interface ToastProps extends Record { | 'success' | 'warning' | 'danger' + | 'dark' + | 'black' | 'none' - contrast?: 'white' | 'contrast' + contrast?: 'low-contrast' | 'high-contrast' borderless?: boolean classes?: { wrapper?: string | string[] diff --git a/src/plugins/components/toast/toast.variants.ts b/src/plugins/components/toast/toast.variants.ts index 2a5c0ba..5bfc3c2 100644 --- a/src/plugins/components/toast/toast.variants.ts +++ b/src/plugins/components/toast/toast.variants.ts @@ -14,10 +14,12 @@ export const color = { success: 'nui-toast-success', warning: 'nui-toast-warning', danger: 'nui-toast-danger', + dark: 'nui-toast-dark', + black: 'nui-toast-black', none: '', } as const satisfies ToastVariant<'color'> export const contrast = { - white: 'nui-toast-white', - contrast: 'nui-toast-contrast', + 'low-contrast': 'nui-toast-low-contrast', + 'high-contrast': 'nui-toast-high-contrast', } as const satisfies ToastVariant<'contrast'>