@rocketui/vue 0.0.46 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +79 -0
- package/.gitattributes +2 -0
- package/.github/workflows/chromatic.yml +28 -0
- package/.github/workflows/publish-storybook.yml +41 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc.cjs +10 -0
- package/.storybook/Theme.js +17 -0
- package/.storybook/main.ts +20 -0
- package/.storybook/manager-head.html +3 -0
- package/.storybook/manager.js +8 -0
- package/.storybook/preview-head.html +3 -0
- package/.storybook/preview.ts +36 -0
- package/.storybook/source-panel/manager.js +28 -0
- package/.storybook/withSource.js +91 -0
- package/.vscode/extensions.json +11 -0
- package/.vscode/settings.json +20 -0
- package/index.html +13 -0
- package/lib/main.ts +48 -0
- package/package.json +2 -8
- package/postcss.config.cjs +9 -0
- package/resources/rocket-ui-logo-dark.svg +27 -0
- package/resources/rocket-ui-logo-light.svg +27 -0
- package/shims-rocketui.d.ts +9 -0
- package/src/App.vue +15 -0
- package/src/assets/blank-avatar.svg +3 -0
- package/src/assets/icons/mdi.js +7302 -0
- package/src/assets/logo.svg +1 -0
- package/src/components/Accordion/Accordion.mdx +88 -0
- package/src/components/Accordion/Accordion.stories.ts +257 -0
- package/src/components/Accordion/RAccordion.vue +73 -0
- package/src/components/Accordion/accordion.css +75 -0
- package/src/components/Accordion/accordion.spec.ts +123 -0
- package/src/components/Alert/Alert.mdx +120 -0
- package/src/components/Alert/Alert.stories.ts +118 -0
- package/src/components/Alert/RAlert.vue +119 -0
- package/src/components/Alert/alert.css +136 -0
- package/src/components/Alert/alert.spec.ts +32 -0
- package/src/components/Avatar/Avatar.mdx +96 -0
- package/src/components/Avatar/Avatar.stories.ts +65 -0
- package/src/components/Avatar/RAvatar.vue +115 -0
- package/src/components/Avatar/avatar.css +82 -0
- package/src/components/Avatar/avatar.spec.ts +38 -0
- package/src/components/Badge/Badge.mdx +112 -0
- package/src/components/Badge/Badge.stories.ts +99 -0
- package/src/components/Badge/RBadge.vue +89 -0
- package/src/components/Badge/badge.css +63 -0
- package/src/components/Badge/badge.spec.ts +20 -0
- package/src/components/Box/Box.mdx +20 -0
- package/src/components/Box/Box.stories.ts +56 -0
- package/src/components/Box/RBox.vue +97 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.ts +115 -0
- package/src/components/Breadcrumb/RBreadcrumb.vue +43 -0
- package/src/components/Breadcrumb/breadcrumb.css +29 -0
- package/src/components/Button/Button.mdx +148 -0
- package/src/components/Button/Button.spec.ts +29 -0
- package/src/components/Button/Button.stories.ts +118 -0
- package/src/components/Button/RButton.vue +179 -0
- package/src/components/Button/button.css +146 -0
- package/src/components/Checkbox/Checkbox.mdx +100 -0
- package/src/components/Checkbox/Checkbox.stories.ts +67 -0
- package/src/components/Checkbox/RCheckbox.vue +195 -0
- package/src/components/Checkbox/checkbox.css +67 -0
- package/src/components/Checkbox/checkbox.spec.ts +60 -0
- package/src/components/Chips/Chip.mdx +113 -0
- package/src/components/Chips/Chip.stories.ts +122 -0
- package/src/components/Chips/RChip.vue +125 -0
- package/src/components/Chips/chip.css +62 -0
- package/src/components/Chips/chip.spec.ts +40 -0
- package/src/components/Dropdown/Dropdown.mdx +135 -0
- package/src/components/Dropdown/Dropdown.stories.ts +84 -0
- package/src/components/Dropdown/RDropdown.vue +392 -0
- package/src/components/Dropdown/dropdown.css +113 -0
- package/src/components/Dropdown/dropdown.spec.ts +98 -0
- package/src/components/Flex/Flex.mdx +20 -0
- package/src/components/Flex/Flex.stories.js +127 -0
- package/src/components/Flex/RFlex.vue +91 -0
- package/src/components/Grid/Grid.mdx +20 -0
- package/src/components/Grid/Grid.stories.js +107 -0
- package/src/components/Grid/RGrid.vue +138 -0
- package/src/components/Icon/Icon.mdx +68 -0
- package/src/components/Icon/Icon.stories.ts +33 -0
- package/src/components/Icon/RIcon.vue +56 -0
- package/src/components/Icon/icon.spec.ts +25 -0
- package/src/components/ItemGroup/ItemGroup.stories.ts +91 -0
- package/src/components/ItemGroup/RItem.vue +74 -0
- package/src/components/ItemGroup/RItemGroup.vue +122 -0
- package/src/components/ItemGroup/__snapshots__/itemgroup.spec.ts.snap +13 -0
- package/src/components/ItemGroup/itemgroup.spec.ts +67 -0
- package/src/components/Label/Label.mdx +50 -0
- package/src/components/Label/Label.stories.ts +38 -0
- package/src/components/Label/RLabel.vue +42 -0
- package/src/components/Label/label.css +0 -0
- package/src/components/Modal/Modal.mdx +91 -0
- package/src/components/Modal/Modal.stories.ts +125 -0
- package/src/components/Modal/RModal.vue +130 -0
- package/src/components/Modal/modal.css +41 -0
- package/src/components/Modal/modal.spec.ts +25 -0
- package/src/components/Pagination/Pagination.stories.ts +24 -0
- package/src/components/Pagination/RPagination.vue +103 -0
- package/src/components/Pagination/pagination.css +47 -0
- package/src/components/Pagination/pagination.spec.ts +17 -0
- package/src/components/ProgressBar/ProgressBar.stories.ts +34 -0
- package/src/components/ProgressBar/RProgressBar.vue +21 -0
- package/src/components/ProgressBar/progressbar.css +24 -0
- package/src/components/ProgressBar/progressbar.spec.ts +17 -0
- package/src/components/Shared/Enums.ts +1 -0
- package/src/components/Sidebar/RSidebar.vue +27 -0
- package/src/components/Sidebar/Sidebar.mdx +31 -0
- package/src/components/Sidebar/Sidebar.stories.ts +34 -0
- package/src/components/Sidebar/sidebar.css +18 -0
- package/src/components/Sidebar/sidebar.spec.ts +33 -0
- package/src/components/Snackbar/RSnackbar.vue +136 -0
- package/src/components/Snackbar/Snackbar.mdx +126 -0
- package/src/components/Snackbar/Snackbar.stories.ts +93 -0
- package/src/components/Snackbar/snackbar.css +99 -0
- package/src/components/Snackbar/snackbar.spec.ts +56 -0
- package/src/components/Switch/RSwitch.vue +147 -0
- package/src/components/Switch/Switch.mdx +102 -0
- package/src/components/Switch/Switch.stories.ts +79 -0
- package/src/components/Switch/switch.css +102 -0
- package/src/components/Switch/switch.spec.ts +31 -0
- package/src/components/TabItem/RTabItem.vue +175 -0
- package/src/components/TabItem/TabItem.mdx +95 -0
- package/src/components/TabItem/TabItem.spec.ts +29 -0
- package/src/components/TabItem/TabItem.stories.ts +97 -0
- package/src/components/TabItem/common.ts +6 -0
- package/src/components/TabItem/tab-item.css +29 -0
- package/src/components/Tabs/RTabs.vue +94 -0
- package/src/components/Tabs/Tabs.mdx +78 -0
- package/src/components/Tabs/Tabs.spec.ts +28 -0
- package/src/components/Tabs/Tabs.stories.ts +191 -0
- package/src/components/Tabs/tabs.css +13 -0
- package/src/components/Tabs/types.ts +11 -0
- package/src/components/TextArea/RTextArea.vue +142 -0
- package/src/components/TextArea/TextArea.mdx +108 -0
- package/src/components/TextArea/TextArea.stories.ts +55 -0
- package/src/components/TextArea/textarea.css +51 -0
- package/src/components/TextArea/textarea.spec.ts +36 -0
- package/src/components/Textfield/RTextfield.vue +372 -0
- package/src/components/Textfield/Textfield.mdx +159 -0
- package/src/components/Textfield/Textfield.stories.ts +121 -0
- package/src/components/Textfield/textfield.css +81 -0
- package/src/components/Textfield/textfield.spec.ts +34 -0
- package/src/components/Tooltip/RTooltip.vue +325 -0
- package/src/components/Tooltip/Tooltip.mdx +111 -0
- package/src/components/Tooltip/Tooltip.stories.ts +203 -0
- package/src/components/Tooltip/common.ts +91 -0
- package/src/components/Tooltip/tooltip.css +34 -0
- package/src/components/Tooltip/tooltip.spec.ts +81 -0
- package/src/components/Typography/Typography.mdx +109 -0
- package/src/components/Typography/typography.css +128 -0
- package/src/directives/index.ts +19 -0
- package/src/index.css +241 -0
- package/src/main.ts +5 -0
- package/src/scripts/buildIcons.js +21 -0
- package/src/stories/Colors.mdx +355 -0
- package/src/stories/GettingStarted.mdx +121 -0
- package/src/stories/Layout.mdx +15 -0
- package/tailwind.config.cjs +16 -0
- package/tsconfig.json +24 -0
- package/vite.config.ts +39 -0
- package/vitest.config.ts +12 -0
- package/dist/rocket-ui-vue.js +0 -9381
- package/dist/rocket-ui-vue.umd.cjs +0 -1
- package/dist/style.css +0 -2
- package/dist/types/main.d.ts +0 -25
- /package/{dist → public}/design-tokens.source.json +0 -0
- /package/{dist → public}/favicon.ico +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Canvas, Meta, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as AlertStories from './Alert.stories';
|
|
4
|
+
|
|
5
|
+
<Meta of={AlertStories} />
|
|
6
|
+
|
|
7
|
+
# Alert
|
|
8
|
+
|
|
9
|
+
Alert is a component that displays a message to the user. It is often used to display information, warning, error, or success messages.
|
|
10
|
+
|
|
11
|
+
- [Overview](#overview)
|
|
12
|
+
|
|
13
|
+
- [Playground](#playground)
|
|
14
|
+
|
|
15
|
+
- [Usage with props](#usage)
|
|
16
|
+
|
|
17
|
+
- [Variants](#variants)
|
|
18
|
+
|
|
19
|
+
- [Customizable Slots](#customizable-slots)
|
|
20
|
+
|
|
21
|
+
- [Tips](#tips)
|
|
22
|
+
|
|
23
|
+
## Overview <a id="overview" />
|
|
24
|
+
|
|
25
|
+
An Alert component is a user interface (UI) element that is used to display important information to the user. It can be used to provide feedback, success or error messages, or to simply draw the user's attention to something. Alert components are typically used in situations where the user needs to be notified of something immediately, or where the information being displayed is important and requires the user's attention.
|
|
26
|
+
|
|
27
|
+
For example, an Alert component could be used to display a success message after the user has completed a form or submitted some data, to display an error message if there is a problem with the user's input, to display a warning if the user is about to perform an action that could have unintended consequences, or just to pass important information to the user.
|
|
28
|
+
|
|
29
|
+
In general, Alert components should be used sparingly, as overusing them can make your UI cluttered and difficult to read. It's important to use Alert components only when necessary, and to provide clear and concise messages that help the user understand what is happening.
|
|
30
|
+
|
|
31
|
+
<Canvas>
|
|
32
|
+
<Story of={AlertStories.Overview} />
|
|
33
|
+
</Canvas>
|
|
34
|
+
|
|
35
|
+
## Playground <a id="playground" />
|
|
36
|
+
|
|
37
|
+
> Changes you make in the controls will be reflected in the example above. Try it yourself!
|
|
38
|
+
|
|
39
|
+
<Controls of={AlertStories.Overview} exclude={/^(click|close|on.*)$/} />
|
|
40
|
+
|
|
41
|
+
## Usage with props <a id="usage" />
|
|
42
|
+
|
|
43
|
+
### type (required)
|
|
44
|
+
|
|
45
|
+
The **type** prop determines the variant of the Alert component. The following values are accepted:
|
|
46
|
+
|
|
47
|
+
- **success**: Indicates that a successful action has occurred.
|
|
48
|
+
- **error**: Indicates that an error has occurred.
|
|
49
|
+
- **warning**: Indicates that the user should be cautious about something.
|
|
50
|
+
- **info**: Provides additional information to the user.
|
|
51
|
+
|
|
52
|
+
### title (optional)
|
|
53
|
+
|
|
54
|
+
The **title** prop specifies the title of the Alert component. It should be short and concise, and should clearly convey the purpose of the Alert.
|
|
55
|
+
|
|
56
|
+
## description (optional)
|
|
57
|
+
|
|
58
|
+
The **description** prop provides a longer description of the Alert component. It can be used to provide more detailed information or instructions to the user.
|
|
59
|
+
|
|
60
|
+
### size (optional)
|
|
61
|
+
|
|
62
|
+
The **size** prop determines the size of the Alert component. The following values are accepted:
|
|
63
|
+
|
|
64
|
+
- **small**: Renders a small Alert component.
|
|
65
|
+
- **medium**: Renders a medium-sized Alert component.
|
|
66
|
+
- **large**: Renders a large Alert component.
|
|
67
|
+
|
|
68
|
+
### closable (optional)
|
|
69
|
+
|
|
70
|
+
If **closable** prop is set to true, the Alert component will include a close button that the user can use to dismiss the Alert.
|
|
71
|
+
|
|
72
|
+
## Variants <a id="variants" />
|
|
73
|
+
|
|
74
|
+
> Our system has 4 Alert variants: **Success**, **Error**, **Information** and **Warning**.
|
|
75
|
+
|
|
76
|
+
### Success
|
|
77
|
+
|
|
78
|
+
<Canvas>
|
|
79
|
+
<Story of={AlertStories.Success} />
|
|
80
|
+
</Canvas>
|
|
81
|
+
|
|
82
|
+
### Error
|
|
83
|
+
|
|
84
|
+
<Canvas>
|
|
85
|
+
<Story of={AlertStories.Error} />
|
|
86
|
+
</Canvas>
|
|
87
|
+
|
|
88
|
+
### Information
|
|
89
|
+
|
|
90
|
+
<Canvas>
|
|
91
|
+
<Story of={AlertStories.Information} />
|
|
92
|
+
</Canvas>
|
|
93
|
+
|
|
94
|
+
### Warning
|
|
95
|
+
|
|
96
|
+
<Canvas>
|
|
97
|
+
<Story of={AlertStories.Warning} />
|
|
98
|
+
</Canvas>
|
|
99
|
+
|
|
100
|
+
## Customizable Slots <a id="customizable-slots" />
|
|
101
|
+
|
|
102
|
+
### `#close`
|
|
103
|
+
|
|
104
|
+
> This `close` slot can be used for creating your own custom close buttons like this one example below 👇
|
|
105
|
+
|
|
106
|
+
<Canvas>
|
|
107
|
+
<Story of={AlertStories.CustomCloseButton} />
|
|
108
|
+
</Canvas>
|
|
109
|
+
|
|
110
|
+
### Tips <a id="tips" />
|
|
111
|
+
|
|
112
|
+
💡 Use the title prop to provide a clear and concise message to the user.
|
|
113
|
+
|
|
114
|
+
💡 Use the description prop to provide more detailed information or instructions, if necessary.
|
|
115
|
+
|
|
116
|
+
💡 Choose the appropriate variant (success, error, warning, or info) for the Alert based on the content it is displaying.
|
|
117
|
+
|
|
118
|
+
💡 Keep the Alert small and concise. If you need to provide a lot of information, consider using a separate component or modal instead of trying to cram everything into the Alert.
|
|
119
|
+
|
|
120
|
+
💡 If the Alert is closable, make sure to provide clear instructions on how to dismiss it (e.g. "Click the 'X' to close this Alert").
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
import Alert from './RAlert.vue';
|
|
3
|
+
import Icon from '../Icon/RIcon.vue';
|
|
4
|
+
|
|
5
|
+
const DefaultArgs = {
|
|
6
|
+
type: 'success',
|
|
7
|
+
title: 'Alert Title',
|
|
8
|
+
variant: 'ghost',
|
|
9
|
+
description: '',
|
|
10
|
+
closable: true,
|
|
11
|
+
closeText: 'Close',
|
|
12
|
+
block: false,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const DefaultArgTypes = {
|
|
16
|
+
type: {
|
|
17
|
+
type: 'select',
|
|
18
|
+
options: ['success', 'info', 'warning', 'error'],
|
|
19
|
+
},
|
|
20
|
+
variant: {
|
|
21
|
+
type: 'select',
|
|
22
|
+
options: ['outline', 'solid', 'ghost'],
|
|
23
|
+
},
|
|
24
|
+
onClose: {
|
|
25
|
+
action: 'close',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const AlertStory = {
|
|
30
|
+
component: Alert,
|
|
31
|
+
setup: (args: typeof Alert) => {
|
|
32
|
+
return { args };
|
|
33
|
+
},
|
|
34
|
+
template: `<Alert v-bind="args" @close="click"/>`,
|
|
35
|
+
args: DefaultArgs,
|
|
36
|
+
argTypes: DefaultArgTypes,
|
|
37
|
+
} as Meta<typeof Alert>;
|
|
38
|
+
|
|
39
|
+
export default AlertStory;
|
|
40
|
+
|
|
41
|
+
type Story = StoryObj<typeof AlertStory>;
|
|
42
|
+
|
|
43
|
+
export const Overview: Story = {
|
|
44
|
+
args: {
|
|
45
|
+
type: 'success',
|
|
46
|
+
title: 'Alert Title',
|
|
47
|
+
description:
|
|
48
|
+
'A type of alert which appears in a layer above other content, visually similar to a mobile or desktop push notification.',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const Success: Story = {
|
|
53
|
+
args: {
|
|
54
|
+
type: 'success',
|
|
55
|
+
title: 'Success',
|
|
56
|
+
description:
|
|
57
|
+
'Success Variant! This is a short but descriptive message that indicates a successful action.',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const Error: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
type: 'error',
|
|
64
|
+
title: 'Error',
|
|
65
|
+
description:
|
|
66
|
+
'Error Variant! This is a short but descriptive message that indicates a negative action.',
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Information: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
type: 'info',
|
|
73
|
+
title: 'Info',
|
|
74
|
+
description:
|
|
75
|
+
'Info Variant! This is a short but descriptive message that indicates a neutral informative action.',
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const Warning: Story = {
|
|
80
|
+
args: {
|
|
81
|
+
type: 'warning',
|
|
82
|
+
title: 'Warning',
|
|
83
|
+
description:
|
|
84
|
+
'Warning Variant! This is a short but descriptive message that indicates a negative or dangerous action.',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const OnlyTitle: Story = {
|
|
89
|
+
args: {
|
|
90
|
+
type: 'success',
|
|
91
|
+
title: 'Only Title',
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const CustomCloseButton = {
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
+
render: (args: any) => ({
|
|
98
|
+
components: { Alert, Icon },
|
|
99
|
+
setup: () => {
|
|
100
|
+
return { args };
|
|
101
|
+
},
|
|
102
|
+
template: `
|
|
103
|
+
<Alert
|
|
104
|
+
v-bind="args"
|
|
105
|
+
>
|
|
106
|
+
<template #custom-close>
|
|
107
|
+
<Icon name="mdiClose" />
|
|
108
|
+
</template>
|
|
109
|
+
</Alert>
|
|
110
|
+
`,
|
|
111
|
+
}),
|
|
112
|
+
args: {
|
|
113
|
+
type: 'info',
|
|
114
|
+
title: 'With a custom button',
|
|
115
|
+
description:
|
|
116
|
+
'This alert box looks very similar to our default examples but it contains a custom close button in it!',
|
|
117
|
+
},
|
|
118
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import './alert.css';
|
|
3
|
+
import { computed } from 'vue';
|
|
4
|
+
import Icon from '../Icon/RIcon.vue';
|
|
5
|
+
|
|
6
|
+
export interface Props {
|
|
7
|
+
/**
|
|
8
|
+
* Type of the Alert
|
|
9
|
+
* @type 'success' | 'error' | 'warning' | 'info'
|
|
10
|
+
* @default 'info'
|
|
11
|
+
* @example
|
|
12
|
+
* <Alert type="success" />
|
|
13
|
+
*/
|
|
14
|
+
type: 'success' | 'error' | 'warning' | 'info';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Title of the Alert
|
|
18
|
+
* @type string
|
|
19
|
+
* @default ''
|
|
20
|
+
* @example
|
|
21
|
+
* <Alert title="Title" />
|
|
22
|
+
*/
|
|
23
|
+
title: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Variant of the Alert
|
|
27
|
+
* @type 'solid' | 'outline' | 'ghost'
|
|
28
|
+
* @default 'ghost'
|
|
29
|
+
* @example
|
|
30
|
+
* <Alert variant="ghost" />
|
|
31
|
+
*/
|
|
32
|
+
variant?: 'solid' | 'outline' | 'ghost';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Description of the Alert
|
|
36
|
+
* @type string
|
|
37
|
+
* @default ''
|
|
38
|
+
* @example
|
|
39
|
+
* <Alert description="Description" />
|
|
40
|
+
*/
|
|
41
|
+
description?: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Allow to close the Alert
|
|
45
|
+
* @type boolean
|
|
46
|
+
* @default true
|
|
47
|
+
* @example
|
|
48
|
+
* <Alert closable />
|
|
49
|
+
*/
|
|
50
|
+
closable?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Block appearance of the Alert
|
|
54
|
+
* @type boolean
|
|
55
|
+
* @default false
|
|
56
|
+
* @example
|
|
57
|
+
* <Alert block />
|
|
58
|
+
*/
|
|
59
|
+
block?: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const emit = defineEmits(['close']);
|
|
63
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
64
|
+
type: 'info',
|
|
65
|
+
title: '',
|
|
66
|
+
variant: 'ghost',
|
|
67
|
+
description: '',
|
|
68
|
+
closable: true,
|
|
69
|
+
block: false,
|
|
70
|
+
});
|
|
71
|
+
const classes = computed(() => {
|
|
72
|
+
return {
|
|
73
|
+
' r-alert': true,
|
|
74
|
+
[`r-alert--${props.variant}`]: true,
|
|
75
|
+
'r-alert--block': props.block,
|
|
76
|
+
[`r-alert--${props.variant}--${props.type}`]: true,
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const icon = computed(() => {
|
|
81
|
+
return {
|
|
82
|
+
success: 'mdiCheckCircle',
|
|
83
|
+
error: 'mdiAlertCircle',
|
|
84
|
+
warning: 'mdiAlert',
|
|
85
|
+
info: 'mdiInformation',
|
|
86
|
+
}[props.type];
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const close = () => {
|
|
90
|
+
emit('close');
|
|
91
|
+
};
|
|
92
|
+
</script>
|
|
93
|
+
<template>
|
|
94
|
+
<div :class="classes">
|
|
95
|
+
<div class="r-alert__icon">
|
|
96
|
+
<slot name="alert-icon">
|
|
97
|
+
<Icon :name="icon" :size="24" />
|
|
98
|
+
</slot>
|
|
99
|
+
</div>
|
|
100
|
+
<div class="r-alert__content">
|
|
101
|
+
<slot name="content">
|
|
102
|
+
<p class="r-alert__content__title">{{ props.title }}</p>
|
|
103
|
+
<p v-if="props.description" class="r-alert__content__description">
|
|
104
|
+
{{ props.description }}
|
|
105
|
+
</p>
|
|
106
|
+
</slot>
|
|
107
|
+
</div>
|
|
108
|
+
<div v-if="props.closable" class="r-alert__close">
|
|
109
|
+
<slot name="custom-close">
|
|
110
|
+
<Icon
|
|
111
|
+
class="r-alert__close__button"
|
|
112
|
+
name="mdiClose"
|
|
113
|
+
:size="16"
|
|
114
|
+
@click="close"
|
|
115
|
+
/>
|
|
116
|
+
</slot>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</template>
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
@import '../../index.css';
|
|
2
|
+
|
|
3
|
+
.r-alert {
|
|
4
|
+
@apply inline-flex px-4 py-3 rounded-lg text-sm transition-transform duration-1000 box-border;
|
|
5
|
+
|
|
6
|
+
&--block {
|
|
7
|
+
@apply w-full;
|
|
8
|
+
|
|
9
|
+
.r-alert__content {
|
|
10
|
+
@apply max-w-full;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
&--solid {
|
|
14
|
+
@apply text-[var(--white)];
|
|
15
|
+
|
|
16
|
+
.r-alert__content {
|
|
17
|
+
@apply text-[var(--white)];
|
|
18
|
+
|
|
19
|
+
.r-alert__content__description {
|
|
20
|
+
@apply text-[var(--white)];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.r-alert__close {
|
|
25
|
+
@apply text-[var(--white)];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&--success {
|
|
29
|
+
@apply bg-[var(--success-500)];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&--error {
|
|
33
|
+
@apply bg-[var(--error-500)];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&--warning {
|
|
37
|
+
@apply bg-[var(--warning-500)];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&--info {
|
|
41
|
+
@apply bg-[var(--info-500)];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&--outline {
|
|
46
|
+
@apply bg-transparent border border-solid;
|
|
47
|
+
|
|
48
|
+
&--success {
|
|
49
|
+
@apply border-[var(--success-500)] text-[var(--success-500)];
|
|
50
|
+
|
|
51
|
+
.r-alert__content__description {
|
|
52
|
+
@apply text-[var(--success-500)];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&--error {
|
|
57
|
+
@apply border-[var(--error-500)] text-[var(--error-500)];
|
|
58
|
+
|
|
59
|
+
.r-alert__content__description {
|
|
60
|
+
@apply text-[var(--error-500)];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&--warning {
|
|
65
|
+
@apply border-[var(--warning-500)] text-[var(--warning-500)];
|
|
66
|
+
|
|
67
|
+
.r-alert__content__description {
|
|
68
|
+
@apply text-[var(--warning-500)];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&--info {
|
|
73
|
+
@apply border-[var(--info-500)] text-[var(--info-500)];
|
|
74
|
+
|
|
75
|
+
.r-alert__content__description {
|
|
76
|
+
@apply text-[var(--info-500)];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&--ghost {
|
|
82
|
+
@apply border-none text-[var(--neutral-900)];
|
|
83
|
+
|
|
84
|
+
&--success {
|
|
85
|
+
@apply bg-[var(--success-100)];
|
|
86
|
+
|
|
87
|
+
.r-alert__icon {
|
|
88
|
+
@apply text-[var(--success-500)];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&--error {
|
|
93
|
+
@apply bg-[var(--error-100)];
|
|
94
|
+
|
|
95
|
+
.r-alert__icon {
|
|
96
|
+
@apply text-[var(--error-500)];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&--warning {
|
|
101
|
+
@apply bg-[var(--warning-100)];
|
|
102
|
+
|
|
103
|
+
.r-alert__icon {
|
|
104
|
+
@apply text-[var(--warning-500)];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&--info {
|
|
109
|
+
@apply bg-[var(--info-100)];
|
|
110
|
+
|
|
111
|
+
.r-alert__icon {
|
|
112
|
+
@apply text-[var(--info-500)];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&__icon {
|
|
118
|
+
@apply grid place-items-start;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
&__content {
|
|
122
|
+
@apply w-full grid place-items-start justify-items-start px-4 min-w-[21rem] max-w-sm;
|
|
123
|
+
|
|
124
|
+
&__title {
|
|
125
|
+
@apply font-medium;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&__description {
|
|
129
|
+
@apply text-[var(--neutral-600)];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&__close {
|
|
134
|
+
@apply grid place-items-start cursor-pointer text-[var(--neutral-900)];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { mount } from '@vue/test-utils';
|
|
3
|
+
import Alert from './RAlert.vue';
|
|
4
|
+
|
|
5
|
+
describe('Alert', () => {
|
|
6
|
+
it('should render correctly', () => {
|
|
7
|
+
const wrapper = mount(Alert, {
|
|
8
|
+
props: {
|
|
9
|
+
type: 'success',
|
|
10
|
+
title: 'Alert Title',
|
|
11
|
+
description: 'Alert Description',
|
|
12
|
+
size: 'small',
|
|
13
|
+
closable: true,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(wrapper.classes()).toContain('alert');
|
|
18
|
+
expect(wrapper.find('.texts__title').text()).toBe('Alert Title');
|
|
19
|
+
expect(wrapper.find('.texts__description').text()).toBe(
|
|
20
|
+
'Alert Description'
|
|
21
|
+
);
|
|
22
|
+
expect(wrapper.find('.alert').classes()).toContain('alert--small');
|
|
23
|
+
expect(
|
|
24
|
+
wrapper
|
|
25
|
+
.find('.alert')
|
|
26
|
+
.trigger('click')
|
|
27
|
+
.then(() => {
|
|
28
|
+
expect(wrapper.emitted('close')).toBeTruthy();
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Canvas, Meta, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
import * as AvatarStories from './Avatar.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={AvatarStories} />
|
|
5
|
+
|
|
6
|
+
# Avatar
|
|
7
|
+
|
|
8
|
+
Avatar component displays a visual representation of a user or an entity.
|
|
9
|
+
|
|
10
|
+
- [Overview](#overview)
|
|
11
|
+
|
|
12
|
+
- [Playground](#playground)
|
|
13
|
+
|
|
14
|
+
- [Usage with props](#usage)
|
|
15
|
+
|
|
16
|
+
- [Tips](#tips)
|
|
17
|
+
|
|
18
|
+
### Overview <a id="overview" />
|
|
19
|
+
|
|
20
|
+
Avatar is typically used to identify a user or entity within a user interface, and can be displayed in various forms such as an image, text, or initials.
|
|
21
|
+
|
|
22
|
+
To use an Avatar component, you can pass the necessary props to configure it to display the avatar in the desired way. For example, you can specify the type of avatar to display (e.g. image or text), the size of the avatar, and any additional props such as the source of the image or the text to display.
|
|
23
|
+
|
|
24
|
+
<Canvas>
|
|
25
|
+
<Story of={AvatarStories.Overview} />
|
|
26
|
+
</Canvas>
|
|
27
|
+
|
|
28
|
+
### Playground <a id="playground" />
|
|
29
|
+
|
|
30
|
+
> Changes you make in the controls will be reflected in the example above.
|
|
31
|
+
|
|
32
|
+
<Controls of={AvatarStories.Overview} exclude={/^(click|close.*)$/} />
|
|
33
|
+
|
|
34
|
+
## Stories
|
|
35
|
+
|
|
36
|
+
### Image
|
|
37
|
+
|
|
38
|
+
<Canvas>
|
|
39
|
+
<Story of={AvatarStories.Image} />
|
|
40
|
+
</Canvas>
|
|
41
|
+
|
|
42
|
+
### Text
|
|
43
|
+
|
|
44
|
+
<Canvas>
|
|
45
|
+
<Story of={AvatarStories.Text} />
|
|
46
|
+
</Canvas>
|
|
47
|
+
|
|
48
|
+
### Anonymous
|
|
49
|
+
|
|
50
|
+
<Canvas>
|
|
51
|
+
<Story of={AvatarStories.Anonymous} />
|
|
52
|
+
</Canvas>
|
|
53
|
+
|
|
54
|
+
### Online
|
|
55
|
+
|
|
56
|
+
<Canvas>
|
|
57
|
+
<Story of={AvatarStories.Online} />
|
|
58
|
+
</Canvas>
|
|
59
|
+
|
|
60
|
+
## Usage with props <a id="usage" />
|
|
61
|
+
|
|
62
|
+
### type (optional)
|
|
63
|
+
|
|
64
|
+
The **type** props is for the type of avatar to display. Can be either "image" or "text".
|
|
65
|
+
|
|
66
|
+
### src (optional)
|
|
67
|
+
|
|
68
|
+
The **src** props is for the source of the image to display. This prop is only used when type is set to "image".
|
|
69
|
+
|
|
70
|
+
### alt (optional)
|
|
71
|
+
|
|
72
|
+
The **alt** props is for the alt text for the image. This prop is only used when type is set to "image".
|
|
73
|
+
|
|
74
|
+
### size (optional)
|
|
75
|
+
|
|
76
|
+
The **size** props is for the size of the avatar. Can be one of "xs", "sm", "md", "lg", "xl", or "2xl".
|
|
77
|
+
|
|
78
|
+
### online (optional)
|
|
79
|
+
|
|
80
|
+
The **online** props is for whether to show a green circle indicator to signify that the user is online.
|
|
81
|
+
|
|
82
|
+
### text (optional)
|
|
83
|
+
|
|
84
|
+
The **text** props is for the text to display when type is set to "text".
|
|
85
|
+
|
|
86
|
+
### Tips <a id="tips" />
|
|
87
|
+
|
|
88
|
+
💡 Use appropriate sizes for different contexts: The size of the avatar should be appropriate for the context in which it is being used. For example, a small avatar might be suitable for a list of users, while a larger avatar might be more suitable for a profile page.
|
|
89
|
+
|
|
90
|
+
💡 Use initials for text avatars: If you are using a text avatar, it is a good idea to use the user's initials rather than their full name. This can help to keep the avatar compact and easy to read.
|
|
91
|
+
|
|
92
|
+
💡 Use images sparingly: If you are using an image avatar, be mindful of the number of images you are loading on the page. If you are displaying a large number of avatars, it may be more efficient to use text avatars instead.
|
|
93
|
+
|
|
94
|
+
💡 Use alternative text for accessibility: When using an image avatar, make sure to include alt text to provide a textual representation of the image for screen readers and other assistive technologies.
|
|
95
|
+
|
|
96
|
+
💡 Consider the context of use: Think about the context in which the avatar will be used and design it accordingly. For example, if the avatar is being used in a chat application, you might want to include an online status indicator.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
import Avatar from './RAvatar.vue';
|
|
3
|
+
|
|
4
|
+
const DefaultArgs = {
|
|
5
|
+
type: 'image',
|
|
6
|
+
size: '2xl',
|
|
7
|
+
src: 'https://avatars.githubusercontent.com/u/12534660?v=4',
|
|
8
|
+
alt: 'Avatar',
|
|
9
|
+
online: false,
|
|
10
|
+
text: '',
|
|
11
|
+
};
|
|
12
|
+
const DefaultArgTypes = {
|
|
13
|
+
type: {
|
|
14
|
+
type: 'select',
|
|
15
|
+
options: ['image', 'text'],
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
type: 'select',
|
|
19
|
+
options: ['xs', 'sm', 'md', 'lg', 'xl', '2xl'],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const AvatarStory = {
|
|
24
|
+
title: 'Components/Avatar',
|
|
25
|
+
component: Avatar,
|
|
26
|
+
setup: (args: typeof Avatar) => {
|
|
27
|
+
return { args };
|
|
28
|
+
},
|
|
29
|
+
template: `<Avatar v-bind="args"/>`,
|
|
30
|
+
args: DefaultArgs,
|
|
31
|
+
argTypes: DefaultArgTypes,
|
|
32
|
+
} as Meta<typeof Avatar>;
|
|
33
|
+
|
|
34
|
+
export default AvatarStory;
|
|
35
|
+
|
|
36
|
+
type Story = StoryObj<typeof AvatarStory>;
|
|
37
|
+
|
|
38
|
+
export const Overview: Story = {
|
|
39
|
+
args: {},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const Image: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
type: 'image',
|
|
45
|
+
src: 'https://avatars.githubusercontent.com/u/12534660?v=4',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const Text: Story = {
|
|
50
|
+
args: {
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: 'Avatar Text',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Anonymous: Story = {
|
|
57
|
+
args: {},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const Online: Story = {
|
|
61
|
+
args: {
|
|
62
|
+
online: true,
|
|
63
|
+
src: 'https://avatars.githubusercontent.com/u/12534660?v=4',
|
|
64
|
+
},
|
|
65
|
+
};
|