From 6e013ea41095bfaa8ac06e315ae46e0e1d6890c2 Mon Sep 17 00:00:00 2001 From: Andrea Leardini Date: Mon, 22 Apr 2024 10:35:21 +0200 Subject: [PATCH] feat: add NeModal component --- src/components/NeModal.vue | 209 +++++++++++++++++++++++++++++++++++++ src/main.ts | 1 + stories/NeModal.stories.ts | 179 +++++++++++++++++++++++++++++++ 3 files changed, 389 insertions(+) create mode 100644 src/components/NeModal.vue create mode 100644 stories/NeModal.stories.ts diff --git a/src/components/NeModal.vue b/src/components/NeModal.vue new file mode 100644 index 0000000..9a3f10e --- /dev/null +++ b/src/components/NeModal.vue @@ -0,0 +1,209 @@ + + + + + diff --git a/src/main.ts b/src/main.ts index 2acc6ff..6790c84 100644 --- a/src/main.ts +++ b/src/main.ts @@ -34,6 +34,7 @@ export { default as NeTextArea } from '@/components/NeTextArea.vue' export { default as NeTextInput } from '@/components/NeTextInput.vue' export { default as NeToggle } from '@/components/NeToggle.vue' export { default as NeToastNotification } from '@/components/NeToastNotification.vue' +export { default as NeModal } from '@/components/NeModal.vue' // types export export type { NeComboboxOption } from '@/components/NeCombobox.vue' diff --git a/stories/NeModal.stories.ts b/stories/NeModal.stories.ts new file mode 100644 index 0000000..b7daac6 --- /dev/null +++ b/stories/NeModal.stories.ts @@ -0,0 +1,179 @@ +// Copyright (C) 2024 Nethesis S.r.l. +// SPDX-License-Identifier: GPL-3.0-or-later + +import type { Meta, StoryObj } from '@storybook/vue3' + +import { NeModal } from '../src/main' + +const meta = { + title: 'Visual/NeModal', + component: NeModal, + argTypes: { + kind: { control: 'inline-radio', options: ['neutral', 'info', 'warning', 'error', 'success'] }, + size: { control: 'inline-radio', options: ['md', 'lg', 'xl', 'xxl'] }, + primaryButtonKind: { control: 'inline-radio', options: ['primary', 'danger'] }, + secondaryButtonKind: { + control: 'inline-radio', + options: ['primary', 'secondary', 'tertiary', 'danger'] + } + }, + args: { + visible: true, + title: 'Title', + kind: 'neutral', + size: 'md', + primaryLabel: 'Primary', + secondaryLabel: '', + cancelLabel: 'Cancel', + primaryButtonKind: 'primary', + primaryButtonDisabled: false, + primaryButtonLoading: false, + secondaryButtonKind: 'secondary', + secondaryButtonDisabled: false, + secondaryButtonLoading: false, + closeAriaLabel: 'Close' + } // default values +} satisfies Meta + +export default meta +type Story = StoryObj + +const template = ` +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua +

+
` + +export const Neutral: Story = { + render: (args) => ({ + components: { NeModal }, + setup() { + return { args } + }, + template: template + }), + args: {} +} + +export const Info: Story = { + render: (args) => ({ + components: { NeModal }, + setup() { + return { args } + }, + template: template + }), + args: { + kind: 'info' + } +} + +const warningTemplate = ` +

+ Delete user John Doe? This action cannot be undone +

+
` + +export const Warning: Story = { + render: (args) => ({ + components: { NeModal }, + setup() { + return { args } + }, + template: warningTemplate + }), + args: { + kind: 'warning', + primaryLabel: 'Delete', + primaryButtonKind: 'danger' + } +} + +export const Error: Story = { + render: (args) => ({ + components: { NeModal }, + setup() { + return { args } + }, + template: template + }), + args: { + kind: 'error' + } +} + +export const Success: Story = { + render: (args) => ({ + components: { NeModal }, + setup() { + return { args } + }, + template: template + }), + args: { + kind: 'success' + } +} + +const singleButtonTemplate = ` +

+ Your system is up to date +

+
` + +export const SingleButton: Story = { + render: (args) => ({ + components: { NeModal }, + setup() { + return { args } + }, + template: singleButtonTemplate + }), + args: { + title: 'System updates', + primaryLabel: 'Got it', + cancelLabel: '' + } +} + +export const ThreeButtons: Story = { + render: (args) => ({ + components: { NeModal }, + setup() { + return { args } + }, + template: template + }), + args: { + primaryLabel: 'Primary', + secondaryLabel: 'Secondary' + } +} + +export const PrimaryLoading: Story = { + render: (args) => ({ + components: { NeModal }, + setup() { + return { args } + }, + template: template + }), + args: { + primaryLabel: 'Save', + primaryButtonLoading: true, + primaryButtonDisabled: true + } +} + +export const Large: Story = { + render: (args) => ({ + components: { NeModal }, + setup() { + return { args } + }, + template: template + }), + args: { + size: 'lg' + } +}