Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 86 additions & 39 deletions client-app/ui-kit/components/molecules/alert/vc-alert.stories.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { VcAlert } from "..";
import type { Meta, StoryFn } from "@storybook/vue3-vite";
import { VcIcon } from "../../atoms";
import type { Meta, StoryObj } from "@storybook/vue3-vite";

const COLORS = ["info", "success", "warning", "danger"];
const VARIANTS = ["solid", "solid-light", "outline", "outline-dark"];
Expand Down Expand Up @@ -40,59 +41,105 @@ export default {
},
},
},
render: (args) => ({
components: { VcAlert },
setup: () => ({ args }),
template: `<VcAlert v-bind="args">
Lorem praesentium natus cumque tenetur iusto sequi sit repellat! Temporibus tempora fugit vel amet voluptates ipsam Quidem quos repellat at ut earum velit Vero totam voluptates nesciunt eveniet delectus. Quas.
</VcAlert>`,
}),
} as Meta<typeof VcAlert>;

const Template: StoryFn = (args) => ({
components: { VcAlert },
setup: () => ({ args }),
template: `<VcAlert v-bind="args">
Lorem praesentium natus cumque tenetur iusto sequi sit repellat! Temporibus tempora fugit vel amet voluptates ipsam Quidem quos repellat at ut earum velit Vero totam voluptates nesciunt eveniet delectus. Quas.
</VcAlert>`,
});
type StoryType = StoryObj<typeof VcAlert>;

export const Basic = Template.bind({});
// 1. Basic examples
export const Basic: StoryType = { args: {} };

export const Title = Template.bind({});
Title.args = {
title: "Alert",
export const WithTitle: StoryType = { args: { title: "Alert" } };

// 2. Variants
export const VariantSolidLight: StoryType = {
args: { variant: "solid-light" },
};

export const Outline = Template.bind({});
Outline.args = {
variant: "outline",
export const VariantOutline: StoryType = { args: { variant: "outline" } };

export const VariantOutlineDark: StoryType = {
args: { variant: "outline-dark" },
};

export const Icon = Template.bind({});
Icon.args = {
icon: true,
// 3. Sizes
export const SizeSm: StoryType = { args: { size: "sm" } };

// 4. Colors
export const ColorInfo: StoryType = { args: { color: "info" } };

export const ColorSuccess: StoryType = { args: { color: "success" } };

export const ColorWarning: StoryType = { args: { color: "warning" } };

export const ColorDanger: StoryType = { args: { color: "danger" } };

// 5. Icons
export const IconAuto: StoryType = { args: { icon: true } };

export const IconCustom: StoryType = {
args: { icon: "cog" },
};

export const Shadow = Template.bind({});
Shadow.args = {
shadow: true,
export const SlotMainIcon: StoryType = {
args: { icon: false },
render: (args) => ({
components: { VcAlert, VcIcon },
setup: () => ({ args }),
template: `<VcAlert v-bind="args">
<template #main-icon>
<VcIcon name="cart" />
</template>
Custom main icon via slot
</VcAlert>`,
}),
};

export const Closable = Template.bind({});
Closable.args = {
closable: true,
export const SlotCloseIcon: StoryType = {
args: { closable: true },
render: (args) => ({
components: { VcAlert, VcIcon },
setup: () => ({ args }),
template: `<VcAlert v-bind="args">
<template #close-icon>
<VcIcon name="delete" />
</template>
Custom close icon via slot
</VcAlert>`,
}),
};

export const AllStates: StoryFn = () => ({
components: { VcAlert },
setup: () => ({ colors: COLORS, variants: VARIANTS, sizes: SIZES }),
template: `<div class="space-y-6">
<div v-for="size in sizes" class="space-y-6">
<div class="text-sm font-bold border-b">Size: {{ size }}</div>
// 6. Shadow & Closable
export const WithShadow: StoryType = { args: { shadow: true } };

<div class="flex flex-wrap gap-1 items-center" v-for="variant in variants">
<div class="w-32 text-xs">Variant: <b>{{ variant }}</b></div>
export const Closable: StoryType = {
args: { closable: true },
parameters: { actions: { handles: ["close"] } },
};

<div class="grow space-y-1">
<VcAlert v-for="color in colors" :color="color" :variant="variant" :size="size" icon closable>
Color: {{ color }}
</VcAlert>
// 7. Kitchen sink
export const AllStates: StoryType = {
render: () => ({
components: { VcAlert },
setup: () => ({ colors: COLORS, variants: VARIANTS, sizes: SIZES }),
template: `<div class="space-y-6">
<div v-for="size in sizes" class="space-y-6">
<div class="text-sm font-bold border-b">Size: {{ size }}</div>
<div class="flex flex-wrap gap-1 items-center" v-for="variant in variants">
<div class="w-32 text-xs">Variant: <b>{{ variant }}</b></div>
<div class="grow space-y-1">
<VcAlert v-for="color in colors" :color="color" :variant="variant" :size="size" icon closable>
Color: {{ color }}
</VcAlert>
</div>
</div>
</div>
</div>
</div>`,
});
</div>`,
}),
};
82 changes: 39 additions & 43 deletions client-app/ui-kit/components/molecules/alert/vc-alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
},
]"
>
<slot name="main-icon">
<VcIcon v-if="icon" :name="iconName" class="vc-alert__icon" />
</slot>
<div v-if="icon || $slots['main-icon']" class="vc-alert__icon">
<slot name="main-icon">
<VcIcon :name="iconName" />
</slot>
</div>

<div class="vc-alert__content">
<div v-if="title" class="vc-alert__title">{{ title }}</div>
Expand All @@ -28,7 +30,7 @@
@click="$emit('close')"
>
<slot name="close-icon">
<VcIcon name="delete-2" />
<VcIcon name="delete-thin" />
</slot>
</button>
</div>
Expand Down Expand Up @@ -86,91 +88,92 @@ const iconName = computed<string>(() => {
<style lang="scss">
.vc-alert {
$colors: success, warning, danger, info;
$sizeSm: "";
$sizeMd: "";

--radius: var(--vc-alert-radius, var(--vc-radius, 0.5rem));
--close-button-icon-color: var(--color-neutral-900);

@apply flex items-stretch border rounded-[--radius];
@apply flex items-start border rounded-[--radius] bg-[--bg-color] border-[--border-color] text-[--text-color];

&--shadow {
@apply shadow-lg;
}

&--size {
&--sm {
$sizeSm: &;
--icon-size: 1.125rem;

@apply px-[0.438rem] py-[0.313rem] min-h-[1.875rem] text-xs/[0.875rem];
@apply ps-[0.438rem] pe-[0.625rem] py-[0.313rem] text-xs/[0.875rem];
}

&--md {
$sizeMd: &;
--icon-size: 1.25rem;

@apply p-[0.688rem] min-h-[2.75rem] text-sm/[1.125rem];
@apply p-[0.688rem] text-sm/[1.125rem];
}
}

&--solid {
@apply text-additional-50;
--text-color: var(--color-additional-50);
--icon-color: var(--color-additional-50);

@each $color in $colors {
&--#{$color} {
@apply bg-[--color-#{$color}-500] border-[--color-#{$color}-500];
--bg-color: var(--color-#{$color}-500);
--border-color: var(--color-#{$color}-500);
}
}

&--warning {
--text-color: var(--color-neutral-900);
--icon-color: var(--color-warning-50);
}
}

&--solid-light {
@apply text-neutral-900;
--text-color: var(--color-neutral-900);

@each $color in $colors {
&--#{$color} {
--vc-icon-color: var(--color-#{$color}-500);

@apply bg-[--color-#{$color}-50] border-[--color-#{$color}-50];
--bg-color: var(--color-#{$color}-50);
--border-color: var(--color-#{$color}-50);
--icon-color: var(--color-#{$color}-500);
}
}
}

&--outline {
@apply bg-additional-50 text-neutral-900;
--bg-color: var(--color-additional-50);
--text-color: var(--color-neutral-900);

@each $color in $colors {
&--#{$color} {
--vc-icon-color: var(--color-#{$color}-500);

@apply border-[--color-#{$color}-500];
--icon-color: var(--color-#{$color}-500);
--border-color: var(--color-#{$color}-500);
}
}
}

&--outline-dark {
@apply text-neutral-900;
--text-color: var(--color-neutral-900);

@each $color in $colors {
&--#{$color} {
--vc-icon-color: var(--color-#{$color}-500);

@apply bg-[--color-#{$color}-50] border-[--color-#{$color}-500];
--bg-color: var(--color-#{$color}-50);
--border-color: var(--color-#{$color}-500);
--icon-color: var(--color-#{$color}-500);
}
}
}

&__icon {
@apply shrink-0 me-2;
--vc-icon-size: var(--icon-size);
--vc-icon-color: var(--icon-color);

#{$sizeSm} & {
--vc-icon-size: 1.125rem;
}

#{$sizeMd} & {
--vc-icon-size: 1.25rem;
}
@apply shrink-0 me-2;
}

&__content {
@apply grow flex flex-col justify-center [word-break:break-word];
@apply grow self-center flex flex-col justify-center [word-break:break-word];

&:first-child {
@apply ps-1;
Expand All @@ -186,17 +189,10 @@ const iconName = computed<string>(() => {
}

&__close-button {
--vc-icon-size: 0.875rem;
--vc-icon-color: currentColor;

#{$sizeSm} & {
--vc-icon-size: 1rem;

@apply p-px;
}

#{$sizeMd} & {
--vc-icon-size: 1.25rem;
}
@apply flex items-center justify-center -my-1 -me-2 size-7;
}
}
</style>