@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,203 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
import Tooltip from './RTooltip.vue';
|
|
3
|
+
import Button from '../Button/RButton.vue';
|
|
4
|
+
import Icon from '../Icon/RIcon.vue';
|
|
5
|
+
import { vTooltip } from '../../directives';
|
|
6
|
+
|
|
7
|
+
const DefaultArgTypes = {
|
|
8
|
+
placement: {
|
|
9
|
+
type: 'select',
|
|
10
|
+
options: [
|
|
11
|
+
'top',
|
|
12
|
+
'right',
|
|
13
|
+
'bottom',
|
|
14
|
+
'left',
|
|
15
|
+
'top-start',
|
|
16
|
+
'top-end',
|
|
17
|
+
'right-start',
|
|
18
|
+
'right-end',
|
|
19
|
+
'bottom-start',
|
|
20
|
+
'bottom-end',
|
|
21
|
+
'left-start',
|
|
22
|
+
'left-end',
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
triggers: {
|
|
26
|
+
type: 'select',
|
|
27
|
+
options: ['hover', 'click', 'manual'],
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
offset: {
|
|
31
|
+
control: {
|
|
32
|
+
type: 'range',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
padding: {
|
|
36
|
+
control: {
|
|
37
|
+
type: 'range',
|
|
38
|
+
},
|
|
39
|
+
defaultValue: 0,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const DefaultArgs = {
|
|
44
|
+
placement: 'top',
|
|
45
|
+
text: 'Tooltips are used to describe or identify an element. In most scenarios, tooltips help the user understand the meaning, function or alt-text of an element.',
|
|
46
|
+
dark: true,
|
|
47
|
+
light: false,
|
|
48
|
+
triggers: 'hover',
|
|
49
|
+
autoHide: false,
|
|
50
|
+
hideDelay: 3000,
|
|
51
|
+
showDelay: 0,
|
|
52
|
+
shown: false,
|
|
53
|
+
disabled: false,
|
|
54
|
+
offset: 12,
|
|
55
|
+
padding: 0,
|
|
56
|
+
outsideClick: false,
|
|
57
|
+
resizable: false,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const TooltipStory = {
|
|
61
|
+
title: 'Components/Tooltip',
|
|
62
|
+
render: (args: any) => ({
|
|
63
|
+
components: { Tooltip, Button },
|
|
64
|
+
setup: () => {
|
|
65
|
+
return {
|
|
66
|
+
args,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
template: `
|
|
70
|
+
<Tooltip
|
|
71
|
+
v-bind="args"
|
|
72
|
+
@show="show"
|
|
73
|
+
@hide="hide"
|
|
74
|
+
>
|
|
75
|
+
<template #trigger>
|
|
76
|
+
<Button variant="primary">Tooltip</Button>
|
|
77
|
+
</template>
|
|
78
|
+
</Tooltip>
|
|
79
|
+
`,
|
|
80
|
+
}),
|
|
81
|
+
argTypes: DefaultArgTypes,
|
|
82
|
+
args: DefaultArgs,
|
|
83
|
+
} as Meta<typeof Tooltip>;
|
|
84
|
+
|
|
85
|
+
export default TooltipStory;
|
|
86
|
+
|
|
87
|
+
type Story = StoryObj<typeof TooltipStory>;
|
|
88
|
+
|
|
89
|
+
const WithContentSlotStory = {
|
|
90
|
+
render: (args: any) => ({
|
|
91
|
+
components: { Tooltip, Icon },
|
|
92
|
+
setup() {
|
|
93
|
+
return {
|
|
94
|
+
args,
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
template: `
|
|
98
|
+
<Tooltip
|
|
99
|
+
v-bind="args"
|
|
100
|
+
@show="show"
|
|
101
|
+
@hide="hide"
|
|
102
|
+
>
|
|
103
|
+
<template #trigger>
|
|
104
|
+
<Icon name="mdiInformation" />
|
|
105
|
+
</template>
|
|
106
|
+
<template #content>
|
|
107
|
+
<span style="background: red; color: #fff; padding: 8px;">This is a tooltip</span>
|
|
108
|
+
</template>
|
|
109
|
+
</Tooltip>
|
|
110
|
+
`,
|
|
111
|
+
}),
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const ToggleTemplate = {
|
|
115
|
+
render: (args: any) => ({
|
|
116
|
+
components: { Tooltip },
|
|
117
|
+
setup() {
|
|
118
|
+
return {
|
|
119
|
+
args,
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
template: `
|
|
123
|
+
<Tooltip
|
|
124
|
+
v-bind="args"
|
|
125
|
+
@show="show"
|
|
126
|
+
@hide="hide"
|
|
127
|
+
>
|
|
128
|
+
<template #trigger>
|
|
129
|
+
<span>Toggle tooltip</span>
|
|
130
|
+
</template>
|
|
131
|
+
</Tooltip>
|
|
132
|
+
`,
|
|
133
|
+
}),
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const WithDirectivesStory = {
|
|
137
|
+
render: (args: any) => ({
|
|
138
|
+
components: { Button },
|
|
139
|
+
directives: { tooltip: vTooltip },
|
|
140
|
+
setup: () => ({
|
|
141
|
+
args,
|
|
142
|
+
}),
|
|
143
|
+
template: `
|
|
144
|
+
<div
|
|
145
|
+
v-tooltip="{
|
|
146
|
+
triggerContent: '<div>Hello World!</div>',
|
|
147
|
+
text: 'Directive tooltip',
|
|
148
|
+
autoHide: false,
|
|
149
|
+
placement: 'right',
|
|
150
|
+
offset: 30,
|
|
151
|
+
}"
|
|
152
|
+
|
|
153
|
+
/>
|
|
154
|
+
`,
|
|
155
|
+
}),
|
|
156
|
+
args: {},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const Overview: Story = {
|
|
160
|
+
args: {},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const Default: Story = {
|
|
164
|
+
args: {},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const WithClickTrigger: Story = {
|
|
168
|
+
render: ToggleTemplate.render,
|
|
169
|
+
|
|
170
|
+
args: {
|
|
171
|
+
triggers: 'click',
|
|
172
|
+
text: 'Clicked!',
|
|
173
|
+
outsideClick: true,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const WithManualTrigger: Story = {
|
|
178
|
+
args: {
|
|
179
|
+
triggers: 'manual',
|
|
180
|
+
dark: false,
|
|
181
|
+
light: true,
|
|
182
|
+
text: 'Manual!',
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const WithContentSlot: Story = {
|
|
187
|
+
render: WithContentSlotStory.render,
|
|
188
|
+
|
|
189
|
+
args: {
|
|
190
|
+
text: '',
|
|
191
|
+
triggers: 'hover',
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const WithDirectives: Story = {
|
|
196
|
+
render: WithDirectivesStory.render,
|
|
197
|
+
|
|
198
|
+
parameters: {
|
|
199
|
+
controls: {
|
|
200
|
+
disable: true,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computePosition,
|
|
3
|
+
flip,
|
|
4
|
+
shift,
|
|
5
|
+
offset,
|
|
6
|
+
arrow,
|
|
7
|
+
hide,
|
|
8
|
+
} from '@floating-ui/dom';
|
|
9
|
+
import type { Ref } from 'vue';
|
|
10
|
+
|
|
11
|
+
export function update(
|
|
12
|
+
{ value: trigger }: Ref<HTMLDivElement>,
|
|
13
|
+
{ value: tooltip }: Ref<HTMLDivElement>,
|
|
14
|
+
{ value: arrowElement }: Ref<HTMLDivElement>,
|
|
15
|
+
placement: Placements,
|
|
16
|
+
offsetParam: number,
|
|
17
|
+
padding: number
|
|
18
|
+
) {
|
|
19
|
+
if (!trigger || !tooltip) return;
|
|
20
|
+
computePosition(trigger, tooltip, {
|
|
21
|
+
placement,
|
|
22
|
+
middleware: [
|
|
23
|
+
offset(offsetParam),
|
|
24
|
+
shift({ padding }),
|
|
25
|
+
arrow({ element: arrowElement }),
|
|
26
|
+
flip(),
|
|
27
|
+
hide(),
|
|
28
|
+
],
|
|
29
|
+
}).then(({ x, y, placement, middlewareData }) => {
|
|
30
|
+
Object.assign(tooltip.style, {
|
|
31
|
+
left: `${x}px`,
|
|
32
|
+
top: `${y}px`,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (arrowElement && middlewareData.arrow) {
|
|
36
|
+
const { x: arrowX, y: arrowY } = middlewareData.arrow;
|
|
37
|
+
|
|
38
|
+
const staticSide = {
|
|
39
|
+
top: Placement.Bottom,
|
|
40
|
+
right: Placement.Left,
|
|
41
|
+
bottom: Placement.Top,
|
|
42
|
+
left: Placement.Right,
|
|
43
|
+
}[placement.split('-')[0]];
|
|
44
|
+
|
|
45
|
+
Object.assign(arrowElement.style, {
|
|
46
|
+
left: x != null ? `${arrowX}px` : '',
|
|
47
|
+
top: y != null ? `${arrowY}px` : '',
|
|
48
|
+
right: '',
|
|
49
|
+
bottom: '',
|
|
50
|
+
[`${staticSide}`]: '-4px',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type Placements =
|
|
57
|
+
| 'top'
|
|
58
|
+
| 'bottom'
|
|
59
|
+
| 'left'
|
|
60
|
+
| 'right'
|
|
61
|
+
| 'top-start'
|
|
62
|
+
| 'top-end'
|
|
63
|
+
| 'right-start'
|
|
64
|
+
| 'right-end'
|
|
65
|
+
| 'bottom-start'
|
|
66
|
+
| 'bottom-end'
|
|
67
|
+
| 'left-start'
|
|
68
|
+
| 'left-end';
|
|
69
|
+
|
|
70
|
+
export enum Placement {
|
|
71
|
+
Top = 'top',
|
|
72
|
+
Bottom = 'bottom',
|
|
73
|
+
Left = 'left',
|
|
74
|
+
Right = 'right',
|
|
75
|
+
TopStart = 'top-start',
|
|
76
|
+
TopEnd = 'top-end',
|
|
77
|
+
RightStart = 'right-start',
|
|
78
|
+
RightEnd = 'right-end',
|
|
79
|
+
BottomStart = 'bottom-start',
|
|
80
|
+
BottomEnd = 'bottom-end',
|
|
81
|
+
LeftStart = 'left-start',
|
|
82
|
+
LeftEnd = 'left-end',
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type Triggers = 'click' | 'hover' | 'manual';
|
|
86
|
+
|
|
87
|
+
export enum Trigger {
|
|
88
|
+
Click = 'click',
|
|
89
|
+
Hover = 'hover',
|
|
90
|
+
Manual = 'manual',
|
|
91
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@import '../../index.css';
|
|
2
|
+
|
|
3
|
+
.trigger {
|
|
4
|
+
@apply relative inline-block cursor-pointer bg-transparent rounded-full;
|
|
5
|
+
}
|
|
6
|
+
.tooltip {
|
|
7
|
+
@apply z-50 bg-transparent m-0 p-0 top-0 left-0 absolute w-max hidden;
|
|
8
|
+
|
|
9
|
+
&__content {
|
|
10
|
+
@apply font-normal p-4 rounded-lg text-xs max-w-xs;
|
|
11
|
+
|
|
12
|
+
&--dark {
|
|
13
|
+
@apply text-white bg-[var(--neutral-900)];
|
|
14
|
+
}
|
|
15
|
+
&--light {
|
|
16
|
+
@apply text-[var(--neutral-900)] bg-white;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__arrow {
|
|
21
|
+
@apply absolute w-4 h-4 rotate-45 -z-10;
|
|
22
|
+
|
|
23
|
+
&--dark {
|
|
24
|
+
@apply bg-[var(--neutral-900)];
|
|
25
|
+
}
|
|
26
|
+
&--light {
|
|
27
|
+
@apply bg-white;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&--light {
|
|
32
|
+
@apply shadow-2xl rounded-lg;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { mount } from '@vue/test-utils';
|
|
4
|
+
|
|
5
|
+
import Tooltip from './RTooltip.vue';
|
|
6
|
+
import { Trigger } from './common';
|
|
7
|
+
|
|
8
|
+
describe('Tooltip', () => {
|
|
9
|
+
it('click trigger', () => {
|
|
10
|
+
const wrapper = mount(Tooltip, {
|
|
11
|
+
props: {
|
|
12
|
+
triggers: Trigger.Click,
|
|
13
|
+
outsideClick: true,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
expect(wrapper.exists()).toBe(true);
|
|
17
|
+
expect(wrapper.find('.trigger').exists()).toBe(true);
|
|
18
|
+
expect(wrapper.find('.tooltip').exists()).toBe(true);
|
|
19
|
+
expect(
|
|
20
|
+
wrapper
|
|
21
|
+
.find('.trigger')
|
|
22
|
+
.trigger('click')
|
|
23
|
+
.then(() => {
|
|
24
|
+
expect(wrapper.find('.tooltip').attributes('style')).toBe(
|
|
25
|
+
'display: block;'
|
|
26
|
+
);
|
|
27
|
+
})
|
|
28
|
+
.then(() => {
|
|
29
|
+
wrapper.find('.trigger').trigger('click');
|
|
30
|
+
expect(wrapper.find('.tooltip').attributes('style')).toBe(
|
|
31
|
+
'display: "";'
|
|
32
|
+
);
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
it('hover trigger', () => {
|
|
37
|
+
const wrapper = mount(Tooltip, {
|
|
38
|
+
props: {
|
|
39
|
+
triggers: Trigger.Hover,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
expect(wrapper.exists()).toBe(true);
|
|
43
|
+
expect(wrapper.find('.trigger').exists()).toBe(true);
|
|
44
|
+
expect(wrapper.find('.tooltip').exists()).toBe(true);
|
|
45
|
+
expect(
|
|
46
|
+
wrapper
|
|
47
|
+
.find('.trigger')
|
|
48
|
+
.trigger('mouseenter')
|
|
49
|
+
.then(() => {
|
|
50
|
+
expect(wrapper.find('.tooltip').attributes('style')).toBe(
|
|
51
|
+
'display: block;'
|
|
52
|
+
);
|
|
53
|
+
})
|
|
54
|
+
.then(() => {
|
|
55
|
+
wrapper.find('.trigger').trigger('mouseleave');
|
|
56
|
+
expect(wrapper.find('.tooltip').attributes('style')).toBe(
|
|
57
|
+
'display: "";'
|
|
58
|
+
);
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
it('manual trigger', () => {
|
|
63
|
+
const wrapper = mount(Tooltip, {
|
|
64
|
+
props: {
|
|
65
|
+
triggers: Trigger.Manual,
|
|
66
|
+
shown: true,
|
|
67
|
+
autoHide: true,
|
|
68
|
+
hideDelay: 1000,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
expect(wrapper.exists()).toBe(true);
|
|
72
|
+
expect(wrapper.find('.trigger').exists()).toBe(true);
|
|
73
|
+
expect(wrapper.find('.tooltip').exists()).toBe(true);
|
|
74
|
+
expect(wrapper.find('.tooltip').attributes('style')).toBe(
|
|
75
|
+
'display: block;'
|
|
76
|
+
);
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
expect(wrapper.find('.tooltip').attributes('style')).toBe('""');
|
|
79
|
+
}, 1000);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks';
|
|
2
|
+
import './typography.css';
|
|
3
|
+
|
|
4
|
+
<Meta
|
|
5
|
+
title="Design Tokens/Typography"
|
|
6
|
+
parameters={{
|
|
7
|
+
viewMode: 'docs',
|
|
8
|
+
previewTabs: {
|
|
9
|
+
canvas: { hidden: true },
|
|
10
|
+
},
|
|
11
|
+
}}
|
|
12
|
+
/>
|
|
13
|
+
|
|
14
|
+
export const Thing = ({
|
|
15
|
+
fontSize,
|
|
16
|
+
lineHeight,
|
|
17
|
+
fontWeight = '400',
|
|
18
|
+
as = 'p',
|
|
19
|
+
text,
|
|
20
|
+
}) => {
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<component is={as} style={{ fontSize, lineHeight, fontWeight }}>
|
|
24
|
+
{text}
|
|
25
|
+
</component>
|
|
26
|
+
<p
|
|
27
|
+
style={{ fontSize: '12px' }}
|
|
28
|
+
>{`Font size: ${fontSize} | Line height: ${lineHeight} | Font Weight: ${fontWeight}`}</p>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
# Typography
|
|
34
|
+
|
|
35
|
+
## Heading
|
|
36
|
+
|
|
37
|
+
<Thing as={'h1'} text={'Heading 1'} fontSize={'72px'} lineHeight={'91.2px'} />
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
.text-h1
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
<Thing as={'h2'} text={'Heading 2'} fontSize={'48px'} lineHeight={'60.8px'} />
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
.text-h2;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
<Thing as={'h3'} text={'Heading 3'} fontSize={'36px'} lineHeight={'45.6px'} />
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
.text-h3
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
<Thing as={'h4'} text={'Heading 4'} fontSize={'24px'} lineHeight={'30.4px'} />
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
.text-h4
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
<Thing as={'h5'} text={'Heading 5'} fontSize={'18px'} lineHeight={'22.4px'} />
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
.text-h5
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Paragraph
|
|
68
|
+
|
|
69
|
+
<Thing text={'Title'} fontSize={'24px'} lineHeight={'32px'} />
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
.text-title
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
<Thing text={'Subtitle Large'} fontSize={'20px'} lineHeight={'28px'} />
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
.text-sub-title-1
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
<Thing text={'Subtitle Small'} fontSize={'18px'} lineHeight={'26px'} />
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
.text-sub-title-2
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
<Thing text={'Body Large'} fontSize={'16px'} lineHeight={'24px'} />
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
.text-body
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
<Thing text={'Body Medium'} fontSize={'14px'} lineHeight={'20px'} />
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
.text-body-1
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
<Thing text={'Body Small'} fontSize={'12px'} lineHeight={'16px'} />
|
|
100
|
+
|
|
101
|
+
```html
|
|
102
|
+
.text-body-2
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
<Thing text={'Caption'} fontSize={'10px'} lineHeight={'14px'} />
|
|
106
|
+
|
|
107
|
+
```html
|
|
108
|
+
.text-caption
|
|
109
|
+
```
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
@import '../../index.css';
|
|
2
|
+
|
|
3
|
+
.text-h1 {
|
|
4
|
+
font-size: 4.5rem;
|
|
5
|
+
font-weight: 400;
|
|
6
|
+
line-height: 5.7rem;
|
|
7
|
+
|
|
8
|
+
@media (max-width: 767px) {
|
|
9
|
+
font-size: 3rem;
|
|
10
|
+
line-height: 3.5rem;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.text-h2 {
|
|
15
|
+
font-size: 3.75rem;
|
|
16
|
+
font-weight: 400;
|
|
17
|
+
line-height: 4.75rem;
|
|
18
|
+
|
|
19
|
+
@media (max-width: 767px) {
|
|
20
|
+
font-size: 2.5rem;
|
|
21
|
+
line-height: 3rem;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.text-h3 {
|
|
26
|
+
font-size: 3rem;
|
|
27
|
+
font-weight: 400;
|
|
28
|
+
line-height: 3.875rem;
|
|
29
|
+
|
|
30
|
+
@media (max-width: 767px) {
|
|
31
|
+
font-size: 2rem;
|
|
32
|
+
line-height: 2.5rem;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.text-h4 {
|
|
37
|
+
font-size: 2.5rem;
|
|
38
|
+
font-weight: 400;
|
|
39
|
+
line-height: 3.25rem;
|
|
40
|
+
|
|
41
|
+
@media (max-width: 767px) {
|
|
42
|
+
font-size: 1.5rem;
|
|
43
|
+
line-height: 2rem;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.text-h5 {
|
|
48
|
+
font-size: 2rem;
|
|
49
|
+
font-weight: 400;
|
|
50
|
+
line-height: 2.625rem;
|
|
51
|
+
|
|
52
|
+
@media (max-width: 767px) {
|
|
53
|
+
font-size: 1.25rem;
|
|
54
|
+
line-height: 1.75rem;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.text-title {
|
|
59
|
+
font-size: 1.5rem;
|
|
60
|
+
font-weight: 400;
|
|
61
|
+
line-height: 2rem;
|
|
62
|
+
|
|
63
|
+
@media (max-width: 767px) {
|
|
64
|
+
font-size: 1.125rem;
|
|
65
|
+
line-height: 1.5rem;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.text-sub-title-1 {
|
|
70
|
+
font-size: 1.25rem;
|
|
71
|
+
font-weight: 400;
|
|
72
|
+
line-height: 1.75rem;
|
|
73
|
+
|
|
74
|
+
@media (max-width: 767px) {
|
|
75
|
+
font-size: 1rem;
|
|
76
|
+
line-height: 1.5rem;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.text-sub-title-2 {
|
|
81
|
+
font-size: 1.125rem;
|
|
82
|
+
font-weight: 400;
|
|
83
|
+
line-height: 1.625rem;
|
|
84
|
+
|
|
85
|
+
@media (max-width: 767px) {
|
|
86
|
+
font-size: 0.875rem;
|
|
87
|
+
line-height: 1.25rem;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.text-body {
|
|
92
|
+
font-size: 1rem;
|
|
93
|
+
font-weight: 400;
|
|
94
|
+
line-height: 1.5rem;
|
|
95
|
+
|
|
96
|
+
@media (max-width: 767px) {
|
|
97
|
+
font-size: 0.875rem;
|
|
98
|
+
line-height: 1.25rem;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.text-body-1 {
|
|
103
|
+
font-size: 0.875rem;
|
|
104
|
+
font-weight: 400;
|
|
105
|
+
line-height: 1.25rem;
|
|
106
|
+
|
|
107
|
+
@media (max-width: 767px) {
|
|
108
|
+
font-size: 0.75rem;
|
|
109
|
+
line-height: 1rem;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.text-body-2 {
|
|
114
|
+
font-size: 0.75rem;
|
|
115
|
+
font-weight: 400;
|
|
116
|
+
line-height: 1rem;
|
|
117
|
+
|
|
118
|
+
@media (max-width: 767px) {
|
|
119
|
+
font-size: 0.625rem;
|
|
120
|
+
line-height: 0.875rem;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.text-caption {
|
|
125
|
+
font-size: 0.625rem;
|
|
126
|
+
font-weight: 400;
|
|
127
|
+
line-height: 0.875rem;
|
|
128
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type App, createApp, h, ref, type DirectiveBinding } from 'vue';
|
|
2
|
+
import Tooltip from '../components/Tooltip/RTooltip.vue';
|
|
3
|
+
|
|
4
|
+
export const vTooltip = {
|
|
5
|
+
mounted(el: HTMLElement, binding: DirectiveBinding) {
|
|
6
|
+
console.log('vTooltip');
|
|
7
|
+
const app: App = createApp({
|
|
8
|
+
setup() {
|
|
9
|
+
const props = ref(binding.value);
|
|
10
|
+
|
|
11
|
+
return () =>
|
|
12
|
+
h(Tooltip, {
|
|
13
|
+
...props.value,
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
app.mount(el);
|
|
18
|
+
},
|
|
19
|
+
};
|