From 12105e532c826d6be5555a6c7acfe525afd43828 Mon Sep 17 00:00:00 2001 From: Driss Chelouati Date: Sat, 9 Dec 2023 15:58:33 +0100 Subject: [PATCH] feat(Toast): rework stories, add missing examples --- src/plugins/components/toast/index.ts | 4 +- .../components/toast/toast.component.ts | 2 +- src/plugins/components/toast/toast.doc.mdx | 180 ++++--- src/plugins/components/toast/toast.stories.ts | 483 +++++++++++++++++- tailwind.config.ts | 3 +- 5 files changed, 587 insertions(+), 85 deletions(-) diff --git a/src/plugins/components/toast/index.ts b/src/plugins/components/toast/index.ts index b8de201..dbcb03e 100644 --- a/src/plugins/components/toast/index.ts +++ b/src/plugins/components/toast/index.ts @@ -165,12 +165,12 @@ export default plugin.withOptions( {}, //Icon:inner [`.${prefix}toast-icon`]: { - [`@apply text-${config.color.white.icon.inner.color.light} dark:text-${config.color.white.icon.inner.color.dark}`]: + [`@apply text-${config.color.danger.icon.inner.color.light} dark:text-${config.color.danger.icon.inner.color.dark}`]: {}, }, //Icon:outer [`.${prefix}toast-icon-block`]: { - [`@apply bg-${config.color.white.icon.outer.background.light} dark:bg-${config.color.white.icon.outer.background.dark}`]: + [`@apply bg-${config.color.danger.icon.outer.background.light} dark:bg-${config.color.danger.icon.outer.background.dark}`]: {}, }, }, diff --git a/src/plugins/components/toast/toast.component.ts b/src/plugins/components/toast/toast.component.ts index 84d2b81..359fa5e 100644 --- a/src/plugins/components/toast/toast.component.ts +++ b/src/plugins/components/toast/toast.component.ts @@ -45,7 +45,7 @@ export const Toast = ({ ${icon} ` : ''} -
+

${title}

${text}

diff --git a/src/plugins/components/toast/toast.doc.mdx b/src/plugins/components/toast/toast.doc.mdx index a72ee86..b358e0a 100644 --- a/src/plugins/components/toast/toast.doc.mdx +++ b/src/plugins/components/toast/toast.doc.mdx @@ -18,92 +18,71 @@ Toasts allow you to display important information popups users should see.
-### Rounded: none +### Contrast -Toasts can have different shapes. The following example shows the straight shape. +Toasts can have different contrasts. The type of contrast defines the main background shade.
- -
- -
- -### Rounded: sm - -Toasts can have different shapes. The following example shows the rounded shape. - -
- -
- -
- -### Rounded: md - -Toasts can have different shapes. The following example shows the smooth shape. - -
- -
- -
- -### Rounded: lg - -Toasts can have different shapes. The following example shows the curved shape. - -
- -
- -
- -### Color: primary - -Toasts can have different colors. The following example shows the primary color. - -
- -
- -
- -### Color: info - -Toasts can have different colors. The following example shows the info color. - -
- -
- -
- -### Color: success - -Toasts can have different colors. The following example shows the success color. - -
- +
+
+ +
+
+ +
+

-### Color: warning +### Rounded -Toasts can have different colors. The following example shows the warning color. +Toasts can have different border radiuses. The following example shows the available variations.
- +
+
+ +
+
+ +
+
+ +
+
+ +
+

-### Color: danger +### Colors -Toasts can have different colors. The following example shows the danger color. +Toasts can have different colors. The following example shows the available colors.
- +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+

@@ -113,7 +92,26 @@ Toasts can have different colors. The following example shows the danger color. Toasts can be borderless and display a light shadow.
- +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+

@@ -126,7 +124,26 @@ Toasts can be borderless and display a light shadow. Toasts have an icon slot that you can use to display an icon.
- +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+

@@ -136,7 +153,26 @@ Toasts have an icon slot that you can use to display an icon. 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 eaef97e..bf8e4e1 100644 --- a/src/plugins/components/toast/toast.stories.ts +++ b/src/plugins/components/toast/toast.stories.ts @@ -62,6 +62,28 @@ export const Solid: Story = { } // #endregion +// #region Contrast +export const White: Story = { + name: 'Contrast: white', + args: { + rounded: 'sm', + title: 'Toast title', + text: 'You need to take some action.', + contrast: 'white', + }, +} + +export const Contrast: Story = { + name: 'Contrast: contrast', + args: { + rounded: 'sm', + title: 'Toast title', + text: 'You need to take some action.', + contrast: 'contrast', + }, +} +// #endregion + // #region Rounded export const Straight: Story = { name: 'Rounded: none', @@ -156,8 +178,95 @@ export const Danger: Story = { } // #endregion -// #region Slot: icon -export const SlotIcon: Story = { +// #region Slot: icon (default) +export const SlotIconDefault: Story = { + name: 'Slot: icon', + args: { + color: 'default', + title: 'Default', + text: 'You need to take some action.', + icon: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon (primary) +export const SlotIconPrimary: Story = { + name: 'Slot: icon', + args: { + color: 'primary', + title: 'Primary', + text: 'You need to take some action.', + icon: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon (info) +export const SlotIconInfo: Story = { + name: 'Slot: icon', + args: { + color: 'info', + title: 'Info', + text: 'You need to take some action.', + icon: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon (success) +export const SlotIconSuccess: Story = { name: 'Slot: icon', args: { color: 'success', @@ -182,13 +291,159 @@ export const SlotIcon: Story = { `, - style: 'max-width: 340px;', }, } // #endregion -// #region Slot: icon block -export const SlotIconBlock: Story = { +// #region Slot: icon (warning) +export const SlotIconWarning: Story = { + name: 'Slot: icon', + args: { + color: 'warning', + title: 'Warning', + text: 'You need to take some action.', + icon: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon (danger) +export const SlotIconDanger: Story = { + name: 'Slot: icon', + args: { + color: 'danger', + title: 'Danger', + text: 'You need to take some action.', + icon: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block (default) +export const SlotIconBlockDefault: Story = { + name: 'Slot: icon', + args: { + color: 'default', + title: 'Default', + text: 'You need to take some action.', + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block (primary) +export const SlotIconBlockPrimary: Story = { + name: 'Slot: icon', + args: { + color: 'primary', + title: 'Primary', + text: 'You need to take some action.', + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block (info) +export const SlotIconBlockInfo: Story = { + name: 'Slot: icon', + args: { + color: 'info', + title: 'Info', + text: 'You need to take some action.', + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block (success) +export const SlotIconBlockSuccess: Story = { name: 'Slot: icon', args: { color: 'success', @@ -213,13 +468,162 @@ export const SlotIconBlock: Story = { `, - style: 'max-width: 340px;', }, } // #endregion -// #region Slot: icon block borderless -export const SlotIconBlockBorderless: Story = { +// #region Slot: icon block (warning) +export const SlotIconBlockWarning: Story = { + name: 'Slot: icon', + args: { + color: 'warning', + title: 'Warning', + text: 'You need to take some action.', + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block (danger) +export const SlotIconBlockDanger: Story = { + name: 'Slot: icon', + args: { + color: 'danger', + title: 'Danger', + text: 'You need to take some action.', + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block borderless (default) +export const SlotIconBlockBorderlessDefault: Story = { + name: 'Slot: icon', + args: { + color: 'default', + title: 'Default', + text: 'You need to take some action.', + borderless: true, + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block borderless (primary) +export const SlotIconBlockBorderlessPrimary: Story = { + name: 'Slot: icon', + args: { + color: 'primary', + title: 'Primary', + text: 'You need to take some action.', + borderless: true, + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block borderless (info) +export const SlotIconBlockBorderlessInfo: Story = { + name: 'Slot: icon', + args: { + color: 'info', + title: 'Info', + text: 'You need to take some action.', + borderless: true, + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block borderless (success) +export const SlotIconBlockBorderlessSuccess: Story = { name: 'Slot: icon', args: { color: 'success', @@ -245,7 +649,68 @@ export const SlotIconBlockBorderless: Story = { `, - style: 'max-width: 340px;', + }, +} +// #endregion + +// #region Slot: icon block borderless (warning) +export const SlotIconBlockBorderlessWarning: Story = { + name: 'Slot: icon', + args: { + color: 'warning', + title: 'Warning', + text: 'You need to take some action.', + borderless: true, + iconBlock: html` + + + + + + + `, + }, +} +// #endregion + +// #region Slot: icon block borderless (danger) +export const SlotIconBlockBorderlessDanger: Story = { + name: 'Slot: icon', + args: { + color: 'danger', + title: 'Danger', + text: 'You need to take some action.', + borderless: true, + iconBlock: html` + + + + + + + `, }, } // #endregion diff --git a/tailwind.config.ts b/tailwind.config.ts index 068e798..2486f56 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -3,10 +3,11 @@ import { withShurikenUI } from './src' export default withShurikenUI({ content: [ // './.storybook/*.ts', + './src/**/*.index.ts', './src/**/*.component.ts', './src/**/*.variants.ts', './src/**/*.stories.ts', - './src/**/*.docs.mdx', + './src/**/*.doc.mdx', ], theme: { fontFamily: {