@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,97 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, type CSSProperties, type HTMLAttributes } from 'vue';
|
|
3
|
+
import '../../index.css';
|
|
4
|
+
export interface IProps extends HTMLAttributes {
|
|
5
|
+
/**
|
|
6
|
+
* The HTML tag to use for the root element.
|
|
7
|
+
* @type HTMLAttributes['is']
|
|
8
|
+
* @default 'div'
|
|
9
|
+
* @example
|
|
10
|
+
* <Box is="span" />
|
|
11
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/is
|
|
12
|
+
*/
|
|
13
|
+
is: HTMLAttributes['is'];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Shorthand for `width` style prop
|
|
17
|
+
* @type CSSProperties["width"]
|
|
18
|
+
* @default 'auto'
|
|
19
|
+
* @example
|
|
20
|
+
* <Box width="100%" />
|
|
21
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/CSS/width
|
|
22
|
+
*/
|
|
23
|
+
width?: CSSProperties['width'];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Shorthand for `height` style prop
|
|
27
|
+
* @type CSSProperties["height"]
|
|
28
|
+
* @default 'auto'
|
|
29
|
+
* @example
|
|
30
|
+
* <Box height="100%" />
|
|
31
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/CSS/height
|
|
32
|
+
*/
|
|
33
|
+
height?: CSSProperties['height'];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Shorthand for `minWidth` style prop
|
|
37
|
+
* @type CSSProperties["minWidth"]
|
|
38
|
+
* @example
|
|
39
|
+
* <Box minWidth="100%" />
|
|
40
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/CSS/min-width
|
|
41
|
+
*/
|
|
42
|
+
minWidth?: CSSProperties['minWidth'];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Shorthand for `minHeight` style prop
|
|
46
|
+
* @type CSSProperties["minHeight"]
|
|
47
|
+
* @example
|
|
48
|
+
* <Box minHeight="100%" />
|
|
49
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/CSS/min-height
|
|
50
|
+
*/
|
|
51
|
+
minHeight?: CSSProperties['minHeight'];
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Shorthand for `maxWidth` style prop
|
|
55
|
+
* @type CSSProperties["maxWidth"]
|
|
56
|
+
* @example
|
|
57
|
+
* <Box maxWidth="100%" />
|
|
58
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/CSS/max-width
|
|
59
|
+
*/
|
|
60
|
+
maxWidth?: CSSProperties['maxWidth'];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Shorthand for `maxHeight` style prop
|
|
64
|
+
* @type CSSProperties["maxHeight"]
|
|
65
|
+
* @example
|
|
66
|
+
* <Box maxHeight="100%" />
|
|
67
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/CSS/max-height
|
|
68
|
+
*/
|
|
69
|
+
maxHeight?: CSSProperties['maxHeight'];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Shorthand for `display` style prop
|
|
73
|
+
* @type CSSProperties["display"]
|
|
74
|
+
* @default 'block'
|
|
75
|
+
* @example
|
|
76
|
+
* <Box display="flex" />
|
|
77
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/CSS/display
|
|
78
|
+
*/
|
|
79
|
+
display?: CSSProperties['display'];
|
|
80
|
+
}
|
|
81
|
+
const props = defineProps<IProps>();
|
|
82
|
+
const styles = computed(() => ({
|
|
83
|
+
display: props.display || 'block',
|
|
84
|
+
width: props.width,
|
|
85
|
+
height: props.height,
|
|
86
|
+
minWidth: props.minWidth,
|
|
87
|
+
minHeight: props.minHeight,
|
|
88
|
+
maxWidth: props.maxWidth,
|
|
89
|
+
}));
|
|
90
|
+
const as = computed(() => props.is || 'div');
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<template>
|
|
94
|
+
<component :is="as" class="box" :style="styles">
|
|
95
|
+
<slot />
|
|
96
|
+
</component>
|
|
97
|
+
</template>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
import Breadcrumb from './RBreadcrumb.vue';
|
|
3
|
+
|
|
4
|
+
const BreadcrumbStory = {
|
|
5
|
+
title: 'Components/Breadcrumb',
|
|
6
|
+
component: Breadcrumb,
|
|
7
|
+
setup: (args: typeof Breadcrumb) => {
|
|
8
|
+
return { args };
|
|
9
|
+
},
|
|
10
|
+
template: `<Breadcrumb v-bind="args" />`,
|
|
11
|
+
args: {
|
|
12
|
+
items: [
|
|
13
|
+
{
|
|
14
|
+
title: 'Ads Accounts',
|
|
15
|
+
to: '/ads-accounts',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
title: 'Ad Account Detail',
|
|
19
|
+
to: '/ads-accounts/123',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: 'Transaction History',
|
|
23
|
+
to: '/ads-accounts/123/transaction-history',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
seperator: 'mdiSlashForward',
|
|
27
|
+
},
|
|
28
|
+
tags: ['autodocs'],
|
|
29
|
+
} as Meta<typeof Breadcrumb>;
|
|
30
|
+
|
|
31
|
+
export default BreadcrumbStory;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<typeof BreadcrumbStory>;
|
|
34
|
+
|
|
35
|
+
export const Overview: Story = {};
|
|
36
|
+
|
|
37
|
+
export const WithSeperator: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
seperator: 'mdiChevronRight',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const WithItemIcon: Story = {
|
|
44
|
+
args: {
|
|
45
|
+
items: [
|
|
46
|
+
{
|
|
47
|
+
title: 'Ads Accounts',
|
|
48
|
+
to: '/ads-accounts',
|
|
49
|
+
icon: 'mdiAdvertisements',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
title: 'Ad Account Detail',
|
|
53
|
+
to: '/ads-accounts/123',
|
|
54
|
+
icon: 'mdiAccount',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
title: 'Transaction History',
|
|
58
|
+
to: '/ads-accounts/123/transaction-history',
|
|
59
|
+
icon: 'mdiAccountFilter',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
seperator: 'mdiSlashForward',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const WithItemOnlyIcon: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
items: [
|
|
69
|
+
{
|
|
70
|
+
title: 'Ads Accounts',
|
|
71
|
+
to: '/ads-accounts',
|
|
72
|
+
icon: 'mdiAdvertisements',
|
|
73
|
+
onlyIcon: true,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
title: 'Ad Account Detail',
|
|
77
|
+
to: '/ads-accounts/123',
|
|
78
|
+
icon: 'mdiAccount',
|
|
79
|
+
onlyIcon: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
title: 'Transaction History',
|
|
83
|
+
to: '/ads-accounts/123/transaction-history',
|
|
84
|
+
icon: 'mdiAccountFilter',
|
|
85
|
+
onlyIcon: true,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
seperator: 'mdiChevronRight',
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const LastItemWithIcon: Story = {
|
|
93
|
+
args: {
|
|
94
|
+
items: [
|
|
95
|
+
{
|
|
96
|
+
title: 'Ads Accounts',
|
|
97
|
+
to: '/ads-accounts',
|
|
98
|
+
icon: 'mdiAdvertisements',
|
|
99
|
+
onlyIcon: true,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
title: 'Ad Account Detail',
|
|
103
|
+
to: '/ads-accounts/123',
|
|
104
|
+
icon: 'mdiAccount',
|
|
105
|
+
onlyIcon: true,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
title: 'Transaction History',
|
|
109
|
+
to: '/ads-accounts/123/transaction-history',
|
|
110
|
+
icon: 'mdiAccountFilter',
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
seperator: 'mdiSlashForward',
|
|
114
|
+
},
|
|
115
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import './breadcrumb.css';
|
|
3
|
+
import { defineProps, withDefaults } from 'vue';
|
|
4
|
+
import RIcon from '../Icon/RIcon.vue';
|
|
5
|
+
export interface BreadcrumbItem {
|
|
6
|
+
title: string;
|
|
7
|
+
to: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
onlyIcon?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(
|
|
13
|
+
defineProps<{
|
|
14
|
+
items: BreadcrumbItem[];
|
|
15
|
+
seperator?: string;
|
|
16
|
+
}>(),
|
|
17
|
+
{
|
|
18
|
+
items: () => [] as BreadcrumbItem[],
|
|
19
|
+
seperator: 'mdiChevronRight',
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
</script>
|
|
23
|
+
<template>
|
|
24
|
+
<div class="r-breadcrumb">
|
|
25
|
+
<div class="r-breadcrumb__item" v-for="(item, i) in props.items" :key="i">
|
|
26
|
+
<router-link :to="item.to" class="r-breadcrumb__link">
|
|
27
|
+
<slot name="item-icon">
|
|
28
|
+
<RIcon v-if="item.icon" :name="item.icon" />
|
|
29
|
+
</slot>
|
|
30
|
+
<span v-if="!item.onlyIcon" class="r-breadcrumb__title">{{
|
|
31
|
+
item.title
|
|
32
|
+
}}</span>
|
|
33
|
+
</router-link>
|
|
34
|
+
<slot name="custom-seperator">
|
|
35
|
+
<RIcon
|
|
36
|
+
v-if="i !== items.length - 1 && props.seperator"
|
|
37
|
+
:name="props.seperator"
|
|
38
|
+
class="r-breadcrumb__separator"
|
|
39
|
+
/>
|
|
40
|
+
</slot>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@import '../../index.css';
|
|
2
|
+
|
|
3
|
+
.r-breadcrumb {
|
|
4
|
+
@apply flex items-center;
|
|
5
|
+
|
|
6
|
+
&__item {
|
|
7
|
+
@apply flex items-center cursor-pointer;
|
|
8
|
+
|
|
9
|
+
&:last-child {
|
|
10
|
+
@apply pointer-events-none;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&__link {
|
|
15
|
+
@apply flex text-2xl text-[var(--breadcrumb-text-color)] hover:text-[var(--breadcrumb-text-color-hover)] gap-2 items-center;
|
|
16
|
+
|
|
17
|
+
&:last-child {
|
|
18
|
+
@apply font-bold !text-[var(--breadcrumb-text-color-active)];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:not(:last-child) {
|
|
22
|
+
@apply hover:underline font-medium;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&__separator {
|
|
27
|
+
@apply flex items-center mx-2 text-[var(--breadcrumb-text-color)];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Canvas, Meta, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
import * as ButtonStories from './Button.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={ButtonStories} />
|
|
5
|
+
|
|
6
|
+
# Button
|
|
7
|
+
|
|
8
|
+
Button is a clickable element that is used to trigger an action or event, such as submitting a form, opening a dialog, canceling an action, or performing a delete operation.
|
|
9
|
+
|
|
10
|
+
- [Overview](#overview)
|
|
11
|
+
|
|
12
|
+
- [Playground](#playground)
|
|
13
|
+
|
|
14
|
+
- [Usage with props](#usage)
|
|
15
|
+
|
|
16
|
+
- [Variants](#variants)
|
|
17
|
+
|
|
18
|
+
- [Tips](#tips)
|
|
19
|
+
|
|
20
|
+
### Overview <a id="overview" />
|
|
21
|
+
|
|
22
|
+
A button component is a reusable piece of code that can be used in any part of a website or application. It is typically represented by a text or an icon that represents the action that will be performed when the user clicks on it.
|
|
23
|
+
|
|
24
|
+
<Canvas>
|
|
25
|
+
<Story of={ButtonStories.Overview} />
|
|
26
|
+
</Canvas>
|
|
27
|
+
|
|
28
|
+
### Playground <a id="playground" />
|
|
29
|
+
|
|
30
|
+
<Controls
|
|
31
|
+
of={ButtonStories.Overview}
|
|
32
|
+
exclude={/^(click|content|default|custom-icon|on.*)$/}
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
## Usage with props <a id="usage" />
|
|
36
|
+
|
|
37
|
+
### variant (required)
|
|
38
|
+
|
|
39
|
+
The **variant** prop allows you to specify the appearance of the button. The possible values for this prop are primary, secondary, text, and outline.
|
|
40
|
+
|
|
41
|
+
### loading (optional)
|
|
42
|
+
|
|
43
|
+
The **loading** prop allows you to specify whether the button is in a loading state. When the button is in a loading state, it will display a loading indicator (e.g. a spinning spinner) instead of the button text.
|
|
44
|
+
To set the button to a loading state, you can pass in the value true to the loading prop.
|
|
45
|
+
|
|
46
|
+
### disabled (optional)
|
|
47
|
+
|
|
48
|
+
The **disabled** prop allows you to specify whether the button is disabled. A disabled button is not interactive and cannot be clicked on.
|
|
49
|
+
To disable a button, you can pass in the value true to the disabled prop.
|
|
50
|
+
|
|
51
|
+
### prependIcon (optional)
|
|
52
|
+
|
|
53
|
+
The **prependIcon** prop allows you to specify an icon that will be placed before the button text. This can be used to add visual context to the button.
|
|
54
|
+
To add an icon to the button, you can pass in the name of the icon as a string to the prependIcon prop.
|
|
55
|
+
|
|
56
|
+
### appendIcon (optional)
|
|
57
|
+
|
|
58
|
+
The **appendIcon** prop is similar to the prependIcon prop, but it allows you to specify an icon that will be placed after the button text.
|
|
59
|
+
To add an icon to the button, you can pass in the name of the icon as a string to the appendIcon prop.
|
|
60
|
+
|
|
61
|
+
### size (optional)
|
|
62
|
+
|
|
63
|
+
The **size** prop allows you to specify the size of the button. The possible values for this prop are: small, medium, and large.
|
|
64
|
+
|
|
65
|
+
### height (optional)
|
|
66
|
+
|
|
67
|
+
The **height** prop allows you to specify the height of the button. This can be useful if you want to create buttons with different heights, or if you want to match the height of the button to the height of other elements on the page.
|
|
68
|
+
To specify the height of the button, you can pass in a numeric value (in pixels) to the height prop.
|
|
69
|
+
|
|
70
|
+
### block (optional)
|
|
71
|
+
|
|
72
|
+
The **block** prop allows you to specify whether the button should be displayed as a block element. When a button is a block element, it will take up the full width of its container.
|
|
73
|
+
To make a button a block element, you can pass in the value true to the block prop.
|
|
74
|
+
|
|
75
|
+
### backgroundColor (optional)
|
|
76
|
+
|
|
77
|
+
The **backgroundColor** prop allows you to specify the background color of the button. This can be useful if you want to create buttons with different background colors, or if you want to match the background color of the button to the color scheme of your website or application.
|
|
78
|
+
To specify the background color of the button, you can pass in a valid CSS color value to the backgroundColor prop.
|
|
79
|
+
|
|
80
|
+
## Variants <a id="variants" />
|
|
81
|
+
|
|
82
|
+
### Primary
|
|
83
|
+
|
|
84
|
+
<Canvas>
|
|
85
|
+
<Story of={ButtonStories.Primary} />
|
|
86
|
+
</Canvas>
|
|
87
|
+
|
|
88
|
+
### Secondary
|
|
89
|
+
|
|
90
|
+
<Canvas>
|
|
91
|
+
<Story of={ButtonStories.Secondary} />
|
|
92
|
+
</Canvas>
|
|
93
|
+
|
|
94
|
+
### Outline
|
|
95
|
+
|
|
96
|
+
<Canvas>
|
|
97
|
+
<Story of={ButtonStories.Outline} />
|
|
98
|
+
</Canvas>
|
|
99
|
+
|
|
100
|
+
### Text
|
|
101
|
+
|
|
102
|
+
<Canvas>
|
|
103
|
+
<Story of={ButtonStories.Text} />
|
|
104
|
+
</Canvas>
|
|
105
|
+
|
|
106
|
+
### Danger
|
|
107
|
+
|
|
108
|
+
<Canvas>
|
|
109
|
+
<Story of={ButtonStories.Danger} />
|
|
110
|
+
</Canvas>
|
|
111
|
+
|
|
112
|
+
### Link
|
|
113
|
+
|
|
114
|
+
<Canvas>
|
|
115
|
+
<Story of={ButtonStories.Link} />
|
|
116
|
+
</Canvas>
|
|
117
|
+
|
|
118
|
+
### `#Custom Icon Slot`
|
|
119
|
+
|
|
120
|
+
<Canvas>
|
|
121
|
+
<Story of={ButtonStories.CustomIcon} />
|
|
122
|
+
</Canvas>
|
|
123
|
+
|
|
124
|
+
### Unstyled
|
|
125
|
+
|
|
126
|
+
#### \* Not yet implemented in the library
|
|
127
|
+
|
|
128
|
+
<Canvas>
|
|
129
|
+
<Story of={ButtonStories.Unstyled} />
|
|
130
|
+
</Canvas>
|
|
131
|
+
|
|
132
|
+
### Tips <a id="tips" />
|
|
133
|
+
|
|
134
|
+
💡 Use the variant prop to create buttons with different appearances, such as primary, secondary, text, and outline.
|
|
135
|
+
|
|
136
|
+
💡 Use the loading prop to show a loading indicator on the button when it is performing an action.
|
|
137
|
+
|
|
138
|
+
💡 Use the disabled prop to make a button non-interactive when it is not needed.
|
|
139
|
+
|
|
140
|
+
💡 Use the prependIcon and appendIcon props to add visual context to the button.
|
|
141
|
+
|
|
142
|
+
💡 Use the size prop to create buttons with different sizes, such as small, medium, and large.
|
|
143
|
+
|
|
144
|
+
💡 Use the height prop to match the height of the button to the height of other elements on the page.
|
|
145
|
+
|
|
146
|
+
💡 Use the block prop to make the button take up the full width of its container.
|
|
147
|
+
|
|
148
|
+
💡 Use the backgroundColor prop to match the background color of the button to the color scheme of your website or application.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { mount } from '@vue/test-utils';
|
|
4
|
+
import Button from './RButton.vue';
|
|
5
|
+
|
|
6
|
+
describe('Button', () => {
|
|
7
|
+
it('renders properly', () => {
|
|
8
|
+
const wrapper = mount(Button, {
|
|
9
|
+
props: {
|
|
10
|
+
variant: 'primary',
|
|
11
|
+
size: 'large',
|
|
12
|
+
type: 'button',
|
|
13
|
+
backgroundColor: '#fff',
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
expect(wrapper.classes()).toContain('button');
|
|
17
|
+
expect(wrapper.classes()).toContain('button--primary');
|
|
18
|
+
expect(wrapper.attributes('type')).toBe('button');
|
|
19
|
+
expect(wrapper.exists()).toBe(true);
|
|
20
|
+
expect(wrapper.find('.button').attributes('type')).toBe('button');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('when clicked', () => {
|
|
24
|
+
it('emits an event', () => {
|
|
25
|
+
const wrapper = mount(Button);
|
|
26
|
+
wrapper.trigger('click');
|
|
27
|
+
expect(wrapper.emitted().click).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
import Button from './RButton.vue';
|
|
3
|
+
import Icon from '../Icon/RIcon.vue';
|
|
4
|
+
|
|
5
|
+
const DefaultArgTypes = {
|
|
6
|
+
variant: {
|
|
7
|
+
type: 'select',
|
|
8
|
+
options: ['primary', 'secondary', 'text', 'outline'],
|
|
9
|
+
},
|
|
10
|
+
size: {
|
|
11
|
+
type: 'select',
|
|
12
|
+
options: ['small', 'medium', 'large'],
|
|
13
|
+
},
|
|
14
|
+
backgroundColor: {
|
|
15
|
+
control: {
|
|
16
|
+
type: 'color',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
onClick: {
|
|
20
|
+
action: 'click',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const WithCustomIconSlot = {
|
|
25
|
+
render: (args: any) => ({
|
|
26
|
+
components: { Button, Icon },
|
|
27
|
+
setup: () => {
|
|
28
|
+
return {
|
|
29
|
+
args,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
template: `
|
|
33
|
+
<Button v-bind="args">
|
|
34
|
+
<template v-slot:custom-icon>
|
|
35
|
+
<Icon name="mdiFingerprint"/>
|
|
36
|
+
</template>
|
|
37
|
+
</Button>`,
|
|
38
|
+
}),
|
|
39
|
+
argTypes: DefaultArgTypes,
|
|
40
|
+
args: {},
|
|
41
|
+
} as Meta<typeof Button>;
|
|
42
|
+
|
|
43
|
+
const ButtonStory = {
|
|
44
|
+
title: 'Form/Button',
|
|
45
|
+
component: Button,
|
|
46
|
+
setup(args: typeof Button) {
|
|
47
|
+
return {
|
|
48
|
+
args,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
template: `<Button v-bind="args"/>`,
|
|
52
|
+
args: {
|
|
53
|
+
variant: 'primary',
|
|
54
|
+
default: 'Button',
|
|
55
|
+
},
|
|
56
|
+
argTypes: DefaultArgTypes,
|
|
57
|
+
} as Meta<typeof Button>;
|
|
58
|
+
|
|
59
|
+
export default ButtonStory;
|
|
60
|
+
|
|
61
|
+
type Story = StoryObj<typeof ButtonStory>;
|
|
62
|
+
|
|
63
|
+
export const Overview: Story = {
|
|
64
|
+
args: {
|
|
65
|
+
variant: 'primary',
|
|
66
|
+
default: 'Button',
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Primary: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
variant: 'primary',
|
|
73
|
+
default: 'Primary',
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const Secondary: Story = {
|
|
78
|
+
args: {
|
|
79
|
+
variant: 'secondary',
|
|
80
|
+
default: 'Secondary',
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const Outline: Story = {
|
|
85
|
+
args: {
|
|
86
|
+
variant: 'outline',
|
|
87
|
+
default: 'Outline',
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const Text: Story = {
|
|
92
|
+
args: {
|
|
93
|
+
variant: 'text',
|
|
94
|
+
default: 'Text',
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const Danger: Story = {
|
|
99
|
+
args: {
|
|
100
|
+
variant: 'danger',
|
|
101
|
+
default: 'Danger',
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const Link: Story = {
|
|
106
|
+
args: {
|
|
107
|
+
variant: 'link',
|
|
108
|
+
default: 'Link',
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const CustomIcon = {
|
|
113
|
+
render: WithCustomIconSlot.render,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const Unstyled = {
|
|
117
|
+
render: WithCustomIconSlot.render,
|
|
118
|
+
};
|