@vcita/design-system 0.0.12-prod.beta.27 → 0.1.2
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/README.md +30 -21
- package/dist/@vcita/design-system.esm.js +519 -676
- package/dist/@vcita/design-system.min.js +1 -1
- package/dist/@vcita/design-system.ssr.js +449 -608
- package/init/DesignSystem.js +77 -0
- package/init/VcSvg/VcSvg.stories.js +25 -0
- package/{src/components → init}/VcSvg/VcSvg.vue +0 -0
- package/init/vuetify.config.js +132 -0
- package/package.json +6 -5
- package/src/assets/logo.png +0 -0
- package/src/assets/logo.svg +1 -0
- package/src/components/VcActionList/VcActionList.spec.js +57 -0
- package/src/components/VcActionList/VcActionList.stories.js +56 -0
- package/src/components/VcActionList/VcActionList.vue +1 -1
- package/src/components/VcActions/VcActions.spec.js +153 -0
- package/src/components/VcActions/VcActions.stories.js +103 -0
- package/src/components/VcActions/VcActions.vue +14 -6
- package/src/components/VcAlert/VcAlert.spec.js +162 -0
- package/src/components/VcAlert/VcAlert.stories.js +105 -0
- package/src/components/VcAlert/VcAlert.vue +7 -8
- package/src/components/VcAutoComplete/VcAutoComplete.spec.js +67 -0
- package/src/components/VcAutoComplete/VcAutoComplete.stories.js +99 -0
- package/src/components/VcAvatar/VcAvatar.spec.js +110 -0
- package/src/components/VcAvatar/VcAvatar.stories.js +101 -0
- package/src/components/VcBottomActions/VcBottomActions.spec.js +64 -0
- package/src/components/VcBottomActions/VcBottomActions.stories.js +103 -0
- package/src/components/VcBottomActions/VcBottomActions.vue +4 -4
- package/src/components/VcButton/VcButton.spec.js +181 -0
- package/src/components/VcButton/VcButton.stories.js +123 -0
- package/src/components/VcButton/VcButton.stories.mdx.old +40 -0
- package/src/components/VcButtonGroup/VcButtonGroup.spec.js +209 -0
- package/src/components/VcButtonGroup/VcButtonGroup.stories.js +109 -0
- package/src/components/VcButtonGroup/VcButtonGroup.vue +5 -1
- package/src/components/VcCard/VcCard.spec.js +38 -0
- package/src/components/VcCard/VcCard.stories.js +28 -0
- package/src/components/VcCard/VcCard.vue +46 -0
- package/src/components/VcExpansionPanels/VcExpansionPanels.stories.js +36 -0
- package/src/components/VcForm/VcForm.spec.js +38 -0
- package/src/components/VcForm/VcForm.stories.js +44 -0
- package/src/components/VcHourInput/VcHourInput.stories.js +36 -0
- package/src/components/VcIcon/VcIcon.spec.js +38 -0
- package/src/components/VcIcon/VcIcon.stories.js +53 -0
- package/src/components/VcIconWithTooltip/VcIconWithTooltip.spec.js +156 -0
- package/src/components/VcIconWithTooltip/VcIconWithTooltip.stories.js +77 -0
- package/src/components/VcIconWithTooltip/VcIconWithTooltip.vue +7 -6
- package/src/components/VcLayout/VcLayout.spec.js +38 -0
- package/src/components/VcLayout/VcLayout.stories.js +26 -0
- package/src/components/VcLoader/VcLoader.spec.js +38 -0
- package/src/components/VcLoader/VcLoader.stories.js +30 -0
- package/src/components/VcLoader/VcLoader.vue +1 -1
- package/src/components/VcMenu/VcMenu.spec.js +38 -0
- package/src/components/VcMenu/VcMenu.stories.js +45 -0
- package/src/components/VcSwitch/VcSwitch.spec.js +38 -0
- package/src/components/VcSwitch/VcSwitch.stories.js +87 -0
- package/src/components/VcSwitch/VcSwitch.vue +14 -1
- package/src/components/VcTextArea/VcTextArea.spec.js +41 -0
- package/src/components/VcTextArea/VcTextArea.stories.js +144 -0
- package/src/components/VcTextArea/VcTextArea.vue +21 -10
- package/src/components/VcTextField/VcTextField.spec.js +170 -0
- package/src/components/VcTextField/VcTextField.stories.js +65 -0
- package/src/components/VcTextField/VcTextField.vue +4 -3
- package/src/components/VcToast/VcToast.spec.js +75 -0
- package/src/components/VcToast/VcToast.stories.js +80 -0
- package/src/components/VcToast/VcToast.vue +11 -15
- package/src/components/VcTooltip/VcTooltip.spec.js +58 -0
- package/src/components/VcTooltip/VcTooltip.stories.js +163 -0
- package/src/components/VcTooltip/VcTooltip.vue +4 -4
- package/src/components/index.js +26 -0
- package/src/components/modal/VcConfirmModal/VcConfirmModal.spec.js +48 -0
- package/src/components/modal/VcConfirmModal/VcConfirmModal.stories.js +142 -0
- package/src/components/modal/VcConfirmProminentModal/VcConfirmProminentModal.spec.js +49 -0
- package/src/components/modal/VcConfirmProminentModal/VcConfirmProminentModal.stories.js +53 -0
- package/src/components/modal/VcInputModal/VcInputModal.spec.js +79 -0
- package/src/components/modal/VcInputModal/VcInputModal.stories.js +188 -0
- package/src/components/modal/VcNoticeModal/VcNoticeModal.spec.js +54 -0
- package/src/components/modal/VcNoticeModal/VcNoticeModal.stories.js +136 -0
- package/src/components/modal/elements/VcModalContainer.spec.js +38 -0
- package/src/components/modal/elements/VcModalContainer.stories.js +49 -0
- package/src/components/modal/elements/VcModalFooter.spec.js +82 -0
- package/src/components/modal/elements/VcModalFooter.stories.js +47 -0
- package/src/components/modal/elements/VcModalHeader.spec.js +103 -0
- package/src/components/modal/elements/VcModalHeader.stories.js +91 -0
- package/src/components/modal/elements/VcModalWrapper.spec.js +38 -0
- package/src/components/modal/elements/VcModalWrapper.stories.js +34 -0
- package/src/entry.esm.js +16 -0
- package/src/entry.js +13 -0
- package/src/scss/_i18n-mixins.scss +174 -0
- package/src/scss/mixins.scss +7 -0
- package/src/stories/assets/HeaderImage.svg +9 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/rabbit.svg +17 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/stories/colors.stories.mdx +78 -0
- package/src/stories/welcome.stories.mdx +210 -0
- package/styles/variables.scss +65 -7
- package/utils/colorUtil.js +41 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import VcButtonCmp from './VcButton';
|
|
2
|
+
import VcIcon from "@/components/VcIcon/VcIcon";
|
|
3
|
+
|
|
4
|
+
const GeneralTemplate = (args, {argTypes}) => ({
|
|
5
|
+
components: {VcButton: VcButtonCmp},
|
|
6
|
+
props: Object.keys(argTypes),
|
|
7
|
+
template: '<VcButton :color="color" :small="small" :large="large" :x-large="xLarge" :icon="icon"' +
|
|
8
|
+
'elveation="elevation" :fab="fab" :loading="loading"' +
|
|
9
|
+
'@click="onClick">{{label}}</VcButton>',
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export const Playground = GeneralTemplate.bind({});
|
|
13
|
+
|
|
14
|
+
// Set default values
|
|
15
|
+
Playground.args = {
|
|
16
|
+
label: 'label',
|
|
17
|
+
color: 'primary',
|
|
18
|
+
small: false,
|
|
19
|
+
large: false,
|
|
20
|
+
xLarge: false,
|
|
21
|
+
icon: false,
|
|
22
|
+
fab: false,
|
|
23
|
+
loading: false,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const Template = (args, {argTypes}) => ({
|
|
27
|
+
components: {VcButton: VcButtonCmp},
|
|
28
|
+
props: Object.keys(argTypes),
|
|
29
|
+
template: '<div>' +
|
|
30
|
+
'<VcButton :color="color" :small="small" :x-large="xLarge" :loading="loading" @click="onClick">{{label}}</VcButton> ' +
|
|
31
|
+
'</div>',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
export const Secondary = Template.bind({});
|
|
35
|
+
|
|
36
|
+
// default values for controls
|
|
37
|
+
Secondary.args = {
|
|
38
|
+
label: "Secondary",
|
|
39
|
+
color: 'secondary'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const Small = Template.bind({});
|
|
43
|
+
|
|
44
|
+
// default values for controls
|
|
45
|
+
Small.args = {
|
|
46
|
+
label: "Small",
|
|
47
|
+
color: 'secondary',
|
|
48
|
+
small: true
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const ExtraLarge = Template.bind({});
|
|
52
|
+
|
|
53
|
+
// default values for controls
|
|
54
|
+
ExtraLarge.args = {
|
|
55
|
+
label: "Extra large",
|
|
56
|
+
color: 'secondary',
|
|
57
|
+
xLarge: true,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const Loading = Template.bind({});
|
|
61
|
+
|
|
62
|
+
// default values for controls
|
|
63
|
+
Loading.args = {
|
|
64
|
+
label: "Loading",
|
|
65
|
+
color: 'secondary',
|
|
66
|
+
loading: true,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const TemplateWithIcon = (args, {argTypes}) => ({
|
|
70
|
+
components: {VcButton: VcButtonCmp, VcIcon},
|
|
71
|
+
props: Object.keys(argTypes),
|
|
72
|
+
template: '<div><VcButton :label="label" :color="color" @click="onClick">' +
|
|
73
|
+
'<template #prepend><VcIcon>$check_circle</VcIcon></template>' +
|
|
74
|
+
'</VcButton></div>',
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
export const WithIcon = TemplateWithIcon.bind({});
|
|
78
|
+
|
|
79
|
+
// Set default values
|
|
80
|
+
WithIcon.args = {
|
|
81
|
+
label: 'Add Item',
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const TemplateIcon = (args, {argTypes}) => ({
|
|
85
|
+
components: {VcButton: VcButtonCmp, VcIcon},
|
|
86
|
+
props: Object.keys(argTypes),
|
|
87
|
+
template: '<div><VcButton :label="label" :color="color" :icon="icon" fab="fab" @click="onClick">' +
|
|
88
|
+
'<template #prepend><VcIcon>$close_button</VcIcon></template>' +
|
|
89
|
+
'</VcButton></div>',
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
export const Icon = TemplateIcon.bind({});
|
|
93
|
+
|
|
94
|
+
// Set default values
|
|
95
|
+
Icon.args = {
|
|
96
|
+
icon: true,
|
|
97
|
+
color: 'white',
|
|
98
|
+
elevation: 0,
|
|
99
|
+
fab: true,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default {
|
|
103
|
+
title: 'Action / VcButton',
|
|
104
|
+
id: 'VcButton',
|
|
105
|
+
component: VcButtonCmp,
|
|
106
|
+
argTypes: {
|
|
107
|
+
color: {
|
|
108
|
+
options: ['white', 'secondary'],
|
|
109
|
+
control: {type: 'radio'}
|
|
110
|
+
},
|
|
111
|
+
onClick: { action: 'onClick', table: {disable: true}},
|
|
112
|
+
},
|
|
113
|
+
parameters: {
|
|
114
|
+
design: {
|
|
115
|
+
type: 'figma',
|
|
116
|
+
url: 'https://www.figma.com/file/xIOY6fBoA1wpy1tHv3i5js/vcita---ui-library?node-id=70%3A86',
|
|
117
|
+
},
|
|
118
|
+
status: {
|
|
119
|
+
type: 'beta', // 'beta' | 'stable' | 'deprecated' | 'releaseCandidate'
|
|
120
|
+
url: 'http://www.url.com/status', // will make the tag a link
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Meta, Preview, Story, ArgsTable } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import VcButton from './VcButton';
|
|
3
|
+
|
|
4
|
+
<Meta title="Buttons / VcButton" component={VcButton} argTypes={{
|
|
5
|
+
color: {
|
|
6
|
+
options: ["primary", "secondary"],
|
|
7
|
+
control: {type: "radio"}
|
|
8
|
+
}
|
|
9
|
+
}}
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
<style>{`
|
|
13
|
+
.subheading {
|
|
14
|
+
--mediumdark: '#999999';
|
|
15
|
+
font-weight: 900;
|
|
16
|
+
font-size: 14px;
|
|
17
|
+
color: #999;
|
|
18
|
+
letter-spacing: 3px;
|
|
19
|
+
line-height: 24px;
|
|
20
|
+
margin-bottom: 12px;
|
|
21
|
+
margin-top: 40px;
|
|
22
|
+
}
|
|
23
|
+
`}</style>
|
|
24
|
+
|
|
25
|
+
# VcButton Docs
|
|
26
|
+
|
|
27
|
+
Some MDX docs for the `VcButton` component.
|
|
28
|
+
|
|
29
|
+
<Preview>
|
|
30
|
+
<Story name="MDX experiment">
|
|
31
|
+
{{
|
|
32
|
+
components: {VcButton},
|
|
33
|
+
template: `<VcButton label="mdx story button" />`,
|
|
34
|
+
}}
|
|
35
|
+
</Story>
|
|
36
|
+
</Preview>
|
|
37
|
+
|
|
38
|
+
<ArgsTable of={VcButton} />
|
|
39
|
+
|
|
40
|
+
<div className="subheading">CSS Variables</div>
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import '@testing-library/jest-dom'
|
|
2
|
+
import VcButtonGroup from "./VcButtonGroup.vue";
|
|
3
|
+
import Vuetify from 'vuetify'
|
|
4
|
+
import {render} from "@testing-library/vue";
|
|
5
|
+
import {fireEvent, within} from "@testing-library/dom";
|
|
6
|
+
import init from "../../../testing-library.config";
|
|
7
|
+
|
|
8
|
+
init();
|
|
9
|
+
|
|
10
|
+
const allTheButtons = [
|
|
11
|
+
{id: 'today', label: 'Today', disabled: false},
|
|
12
|
+
{id: 'yesterday', label: 'Yesterday', disabled: false},
|
|
13
|
+
{id: '7days', label: '7 days', disabled: false},
|
|
14
|
+
{id: '3months', label: '3 months', disabled: false},
|
|
15
|
+
{id: '6month', label: '6 month', disabled: false},
|
|
16
|
+
{id: '12month', label: '12 month', disabled: false},
|
|
17
|
+
{id: '18months', label: '18 month', disabled: false},
|
|
18
|
+
{id: '24months', label: '2 years', disabled: false},
|
|
19
|
+
{id: '36months', label: '3 years', disabled: false},
|
|
20
|
+
{id: 'tooMany', label: 'too many buttons', disabled: false},
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const defaultProps = {
|
|
24
|
+
buttons: allTheButtons.slice(0, 4),
|
|
25
|
+
selected: 'today'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe("VcButtonGroup.vue", () => {
|
|
29
|
+
|
|
30
|
+
const renderWithVuetify = (component, options, callback) => {
|
|
31
|
+
const root = document.createElement('div')
|
|
32
|
+
root.setAttribute('data-app', 'true')
|
|
33
|
+
|
|
34
|
+
return render(
|
|
35
|
+
component,
|
|
36
|
+
{
|
|
37
|
+
container: document.body.appendChild(root),
|
|
38
|
+
// for Vuetify components that use the vuetify instance property
|
|
39
|
+
vuetify: new Vuetify(),
|
|
40
|
+
...options,
|
|
41
|
+
mocks: {
|
|
42
|
+
$t: value => value,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
callback,
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
it("mounts", () => {
|
|
50
|
+
const {container} = renderWithVuetify(VcButtonGroup, {
|
|
51
|
+
props: defaultProps
|
|
52
|
+
})
|
|
53
|
+
expect(container).toHaveAttribute('data-app', 'true')
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("button is selected by props", () => {
|
|
57
|
+
const {getByTestId} = renderWithVuetify(VcButtonGroup, {
|
|
58
|
+
props: defaultProps
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const buttonGroup = getByTestId('VcButtonGroup');
|
|
62
|
+
const button = within(buttonGroup).getByTestId('item-0');
|
|
63
|
+
expect(button).toHaveClass('selected')
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("button is selected by changing props", async () => {
|
|
67
|
+
const {getByTestId, updateProps} = renderWithVuetify(VcButtonGroup, {
|
|
68
|
+
props: defaultProps
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const buttonGroup = getByTestId('VcButtonGroup');
|
|
72
|
+
await updateProps({selected: 'yesterday'});
|
|
73
|
+
const button = within(buttonGroup).getByTestId('item-1');
|
|
74
|
+
expect(button).toHaveClass('selected');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("emits event when button is clicked", async () => {
|
|
78
|
+
const {getByText, emitted} = renderWithVuetify(VcButtonGroup, {
|
|
79
|
+
props: defaultProps
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const button = getByText('Yesterday')
|
|
83
|
+
expect(button).toBeInTheDocument()
|
|
84
|
+
await fireEvent.click(button);
|
|
85
|
+
expect(emitted().change.length).toBe(1);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("has 4 buttons in horizontal and vertical mode", async () => {
|
|
89
|
+
const {getByTestId, updateProps} = renderWithVuetify(VcButtonGroup, {
|
|
90
|
+
props: {
|
|
91
|
+
...defaultProps,
|
|
92
|
+
direction: 'horizontal',
|
|
93
|
+
buttons: allTheButtons.slice(0, 4)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const buttonGroup = getByTestId('VcButtonGroup');
|
|
98
|
+
expect(buttonGroup).toBeInTheDocument();
|
|
99
|
+
const horizontalRows = within(buttonGroup).getAllByTestId('row');
|
|
100
|
+
expect(horizontalRows.length).toBe(2);
|
|
101
|
+
|
|
102
|
+
await updateProps({direction: 'vertical'});
|
|
103
|
+
const verticalRows = within(buttonGroup).getAllByTestId('row');
|
|
104
|
+
expect(verticalRows.length).toBe(2);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("has 5 buttons in horizontal and vertical mode", async () => {
|
|
108
|
+
const {getByTestId, updateProps} = renderWithVuetify(VcButtonGroup, {
|
|
109
|
+
props: {
|
|
110
|
+
...defaultProps,
|
|
111
|
+
direction: 'horizontal',
|
|
112
|
+
buttons: allTheButtons.slice(0, 5)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const buttonGroup = getByTestId('VcButtonGroup');
|
|
117
|
+
expect(buttonGroup).toBeInTheDocument();
|
|
118
|
+
const horizontalRows = within(buttonGroup).getAllByTestId('row');
|
|
119
|
+
expect(horizontalRows.length).toBe(2);
|
|
120
|
+
|
|
121
|
+
await updateProps({direction: 'vertical'});
|
|
122
|
+
const verticalRows = within(buttonGroup).getAllByTestId('row');
|
|
123
|
+
expect(verticalRows.length).toBe(3);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("has 6 buttons in horizontal and vertical mode", async () => {
|
|
127
|
+
const {getByTestId, updateProps} = renderWithVuetify(VcButtonGroup, {
|
|
128
|
+
props: {
|
|
129
|
+
...defaultProps,
|
|
130
|
+
direction: 'horizontal',
|
|
131
|
+
buttons: allTheButtons.slice(0, 6)
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const buttonGroup = getByTestId('VcButtonGroup');
|
|
136
|
+
expect(buttonGroup).toBeInTheDocument();
|
|
137
|
+
const horizontalRows = within(buttonGroup).getAllByTestId('row');
|
|
138
|
+
expect(horizontalRows.length).toBe(2);
|
|
139
|
+
|
|
140
|
+
await updateProps({direction: 'vertical'});
|
|
141
|
+
const verticalRows = within(buttonGroup).getAllByTestId('row');
|
|
142
|
+
expect(verticalRows.length).toBe(3);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("has 7 buttons in horizontal and vertical mode", async () => {
|
|
146
|
+
const {getByTestId, updateProps} = renderWithVuetify(VcButtonGroup, {
|
|
147
|
+
props: {
|
|
148
|
+
...defaultProps,
|
|
149
|
+
direction: 'horizontal',
|
|
150
|
+
buttons: allTheButtons.slice(0, 7)
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
const buttonGroup = getByTestId('VcButtonGroup');
|
|
155
|
+
expect(buttonGroup).toBeInTheDocument();
|
|
156
|
+
const horizontalRows = within(buttonGroup).getAllByTestId('row');
|
|
157
|
+
expect(horizontalRows.length).toBe(2);
|
|
158
|
+
|
|
159
|
+
await updateProps({direction: 'vertical'});
|
|
160
|
+
const verticalRows = within(buttonGroup).getAllByTestId('row');
|
|
161
|
+
expect(verticalRows.length).toBe(4);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("has 8 buttons in horizontal and vertical mode", async () => {
|
|
165
|
+
const {getByTestId, updateProps} = renderWithVuetify(VcButtonGroup, {
|
|
166
|
+
props: {
|
|
167
|
+
...defaultProps,
|
|
168
|
+
direction: 'horizontal',
|
|
169
|
+
buttons: allTheButtons.slice(0, 8)
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
const buttonGroup = getByTestId('VcButtonGroup');
|
|
174
|
+
expect(buttonGroup).toBeInTheDocument();
|
|
175
|
+
const horizontalRows = within(buttonGroup).getAllByTestId('row');
|
|
176
|
+
expect(horizontalRows.length).toBe(2);
|
|
177
|
+
|
|
178
|
+
await updateProps({direction: 'vertical'});
|
|
179
|
+
const verticalRows = within(buttonGroup).getAllByTestId('row');
|
|
180
|
+
expect(verticalRows.length).toBe(4);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("has 9 buttons in horizontal and vertical mode", async () => {
|
|
184
|
+
const {getByTestId, updateProps} = renderWithVuetify(VcButtonGroup, {
|
|
185
|
+
props: {
|
|
186
|
+
...defaultProps,
|
|
187
|
+
direction: 'horizontal',
|
|
188
|
+
buttons: allTheButtons.slice(0, 9)
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
const buttonGroup = getByTestId('VcButtonGroup');
|
|
193
|
+
expect(buttonGroup).toBeInTheDocument();
|
|
194
|
+
const horizontalRows = within(buttonGroup).getAllByTestId('row');
|
|
195
|
+
expect(horizontalRows.length).toBe(3);
|
|
196
|
+
|
|
197
|
+
await updateProps({direction: 'vertical'});
|
|
198
|
+
const verticalRows = within(buttonGroup).getAllByTestId('row');
|
|
199
|
+
expect(verticalRows.length).toBe(3);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it(" fails when it gets less than 4 buttons", () => {
|
|
203
|
+
const validator = VcButtonGroup.props.buttons.validator;
|
|
204
|
+
expect(validator(allTheButtons.slice(0, 3))).toBeFalsy();
|
|
205
|
+
expect(validator(allTheButtons.slice(0, 4))).toBeTruthy();
|
|
206
|
+
expect(validator(allTheButtons)).toBeFalsy();
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import VcColumnButtonGroupCmp from './VcButtonGroup';
|
|
2
|
+
import {action} from "@storybook/addon-actions";
|
|
3
|
+
|
|
4
|
+
const Template = (args, {argTypes}) => ({
|
|
5
|
+
components: {VcColumnButtonGroup: VcColumnButtonGroupCmp},
|
|
6
|
+
props: Object.keys(argTypes),
|
|
7
|
+
computed: {
|
|
8
|
+
calcButtons() {
|
|
9
|
+
return allTheButtons.slice(0, this.numOfButtons);
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
template: '<div><VcColumnButtonGroup :buttons="calcButtons" v-model="selected" :direction="direction" ' +
|
|
13
|
+
'@change="onChange"/></div>',
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const allTheButtons = [
|
|
17
|
+
{id: 'today', label: 'Today Today Today Today Today Today Today Today TodayToday Today Today Today Today Today Today Today', disabled: false},
|
|
18
|
+
{id: 'yesterday', label: 'Yesterday', disabled: false},
|
|
19
|
+
{id: '7days', label: '7 days', disabled: false},
|
|
20
|
+
{id: '3months', label: '3 months', disabled: false},
|
|
21
|
+
{id: '6month', label: '6 month', disabled: false},
|
|
22
|
+
{id: '12month', label: '12 month', disabled: false},
|
|
23
|
+
{id: '18months', label: '18 month', disabled: false},
|
|
24
|
+
{id: '24months', label: '2 years', disabled: false},
|
|
25
|
+
{id: '36months', label: '3 years', disabled: false},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export const Playground = Template.bind({});
|
|
29
|
+
// Set default values
|
|
30
|
+
Playground.args = {
|
|
31
|
+
selected: "",
|
|
32
|
+
onChange: action('changed'),
|
|
33
|
+
direction: 'vertical',
|
|
34
|
+
numOfButtons: 4,
|
|
35
|
+
buttons: allTheButtons,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const disabledBtns = allTheButtons.map((item, index) => {
|
|
39
|
+
return {...item, disabled: index % 2 > 0}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const DisabledTemplate = (args, {argTypes}) => ({
|
|
43
|
+
components: {VcColumnButtonGroup: VcColumnButtonGroupCmp},
|
|
44
|
+
props: Object.keys(argTypes),
|
|
45
|
+
computed: {
|
|
46
|
+
calcButtons() {
|
|
47
|
+
return disabledBtns.slice(0, this.numOfButtons);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
template: '<div><VcColumnButtonGroup :buttons="calcButtons" v-model="selected" :direction="direction" ' +
|
|
51
|
+
'@change="onChange"/></div>',
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
export const Disabled = DisabledTemplate.bind({});
|
|
55
|
+
// Set default values
|
|
56
|
+
Disabled.args = {
|
|
57
|
+
selected: "",
|
|
58
|
+
onChange: action('changed'),
|
|
59
|
+
numOfButtons: 4,
|
|
60
|
+
buttons: disabledBtns,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const Horizontal = Template.bind({});
|
|
64
|
+
// Set default values
|
|
65
|
+
Horizontal.args = {
|
|
66
|
+
selected: "",
|
|
67
|
+
direction: 'horizontal',
|
|
68
|
+
onChange: action('changed'),
|
|
69
|
+
numOfButtons: 6,
|
|
70
|
+
buttons: allTheButtons,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const Selected = Template.bind({});
|
|
74
|
+
// Set default values
|
|
75
|
+
Selected.args = {
|
|
76
|
+
selected: "today",
|
|
77
|
+
onChange: action('changed'),
|
|
78
|
+
numOfButtons: 4,
|
|
79
|
+
buttons: allTheButtons,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default {
|
|
83
|
+
title: 'controls / VcButtonGroup',
|
|
84
|
+
id: 'VcButtonGroup',
|
|
85
|
+
component: VcColumnButtonGroupCmp,
|
|
86
|
+
argTypes: {
|
|
87
|
+
direction: {
|
|
88
|
+
options: ['horizontal', 'vertical'],
|
|
89
|
+
control: {type: 'radio'}
|
|
90
|
+
},
|
|
91
|
+
buttons: {
|
|
92
|
+
control: "object"
|
|
93
|
+
},
|
|
94
|
+
numOfButtons: {
|
|
95
|
+
options: [4, 5, 6, 7, 8, 9],
|
|
96
|
+
control: {type: 'select'}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
parameters: {
|
|
100
|
+
design: {
|
|
101
|
+
type: 'figma',
|
|
102
|
+
url: 'https://www.figma.com/file/xIOY6fBoA1wpy1tHv3i5js/vcita-ui-library?node-id=2356%3A33394',
|
|
103
|
+
},
|
|
104
|
+
status: {
|
|
105
|
+
type: 'beta', // 'beta' | 'stable' | 'deprecated' | 'releaseCandidate'
|
|
106
|
+
// url: 'http://www.url.com/status', // will make the tag a link
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<v-container class="VcButtonGroup" :data-qa="dataQa">
|
|
3
|
-
<v-row v-for="(row, rowIdx) in rows" data-qa="row" :key="`row-${rowIdx}`">
|
|
3
|
+
<v-row v-for="(row, rowIdx) in rows" data-qa="row" :key="`row-${rowIdx}`" class="button-group-row">
|
|
4
4
|
<v-col :cols="Math.floor(12/cols)" v-for="(button,itemIdx) in row" :key="button.id"
|
|
5
5
|
@click="onSelected(button.id)" class="button-item d-flex align-center justify-center"
|
|
6
6
|
:class="{
|
|
@@ -95,6 +95,10 @@ export default {
|
|
|
95
95
|
font-weight: var(--font-weight-medium2);
|
|
96
96
|
font-size: 13px;
|
|
97
97
|
|
|
98
|
+
.button-group-row {
|
|
99
|
+
margin: 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
98
102
|
.button-item {
|
|
99
103
|
cursor: pointer;
|
|
100
104
|
transition: 0.3s background-color, color ease-out;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import '@testing-library/jest-dom'
|
|
2
|
+
import VcCard from "./VcCard.vue";
|
|
3
|
+
import Vuetify from 'vuetify'
|
|
4
|
+
import {render} from "@testing-library/vue";
|
|
5
|
+
import init from "../../../testing-library.config";
|
|
6
|
+
|
|
7
|
+
init();
|
|
8
|
+
|
|
9
|
+
describe("VcCard.vue", () => {
|
|
10
|
+
|
|
11
|
+
const renderWithVuetify = (component, options, callback) => {
|
|
12
|
+
const root = document.createElement('div')
|
|
13
|
+
root.setAttribute('data-app', 'true')
|
|
14
|
+
|
|
15
|
+
return render(
|
|
16
|
+
component,
|
|
17
|
+
{
|
|
18
|
+
container: document.body.appendChild(root),
|
|
19
|
+
// for Vuetify components that use the vuetify instance property
|
|
20
|
+
vuetify: new Vuetify(),
|
|
21
|
+
...options,
|
|
22
|
+
mocks: {},
|
|
23
|
+
},
|
|
24
|
+
callback,
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
it("mounts", () => {
|
|
29
|
+
// Queries: https://testing-library.com/docs/queries/about#types-of-queries
|
|
30
|
+
const {container} = renderWithVuetify(VcCard, {
|
|
31
|
+
props: {}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// Expect options: https://github.com/testing-library/jest-dom
|
|
35
|
+
expect(container).toHaveAttribute('data-app', 'true')
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import VcCardCmp from './VcCard';
|
|
2
|
+
import VcLoader from "@/components/VcLoader/VcLoader";
|
|
3
|
+
|
|
4
|
+
const Template = (args, {argTypes}) => ({
|
|
5
|
+
components: {VcCard: VcCardCmp, VcLoader},
|
|
6
|
+
props: Object.keys(argTypes),
|
|
7
|
+
template: '<VcCard><VcLoader/></VcCard>',
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
export const Playground = Template.bind({});
|
|
11
|
+
|
|
12
|
+
// Set default values
|
|
13
|
+
Playground.args = {}
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
title: 'Content display / VcCard', // This will control the story sidebar position
|
|
17
|
+
id: 'VcCard', // This will be the link to this component
|
|
18
|
+
component: VcCardCmp,
|
|
19
|
+
parameters: {
|
|
20
|
+
design: {
|
|
21
|
+
type: 'figma',
|
|
22
|
+
url: 'https://www.figma.com/file/xIOY6fBoA1wpy1tHv3i5js/vcita---ui-library?node-id=2498%3A30885',
|
|
23
|
+
},
|
|
24
|
+
status: {
|
|
25
|
+
type: 'stable', // 'beta' | 'stable' | 'deprecated' | 'releaseCandidate'
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-card class="VcCard" tile :data-qa="dataQa">
|
|
3
|
+
<slot>
|
|
4
|
+
{{ this.$slots && this.$slots.default }}
|
|
5
|
+
</slot>
|
|
6
|
+
</v-card>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
export default {
|
|
11
|
+
name: "VcCard",
|
|
12
|
+
props: {
|
|
13
|
+
dataQa: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: 'VcCard'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<style lang="scss" scoped>
|
|
22
|
+
@import "../../scss/mixins.scss";
|
|
23
|
+
|
|
24
|
+
.VcCard {
|
|
25
|
+
position: relative;
|
|
26
|
+
padding: 16px 0px 0px;
|
|
27
|
+
border-bottom: 1px solid #E0E0E0;
|
|
28
|
+
background: #FFFFFF;
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
box-shadow: none !important;
|
|
31
|
+
|
|
32
|
+
@include md-and-up {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
align-items: flex-start;
|
|
36
|
+
padding: 24px;
|
|
37
|
+
border: 1px solid #E0E0E0;
|
|
38
|
+
border-radius: 6px !important;
|
|
39
|
+
|
|
40
|
+
&:hover {
|
|
41
|
+
box-shadow: 0px 4px 18px rgba(145, 152, 160, 0.22) !important;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import VcExpansionPanelsCmp from './VcExpansionPanels';
|
|
2
|
+
|
|
3
|
+
const Template = (args, {argTypes}) => ({
|
|
4
|
+
components: {VcExpansionPanels: VcExpansionPanelsCmp},
|
|
5
|
+
props: Object.keys(argTypes),
|
|
6
|
+
template: `<div><VcExpansionPanels :param="param"/></div>`,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const Playground = Template.bind({});
|
|
10
|
+
|
|
11
|
+
// Set default values
|
|
12
|
+
Playground.args = {
|
|
13
|
+
param: 'value',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
title: 'VcExpansionPanels', // This will control the story sidebar position
|
|
18
|
+
id: 'VcExpansionPanels', // This will be the link to this component
|
|
19
|
+
component: VcExpansionPanelsCmp,
|
|
20
|
+
argTypes: {
|
|
21
|
+
param: {
|
|
22
|
+
options: ['value1', 'value2'],
|
|
23
|
+
control: {type: 'radio'}
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
parameters: {
|
|
27
|
+
design: {
|
|
28
|
+
type: 'figma',
|
|
29
|
+
url: 'https://www.figma.com',
|
|
30
|
+
},
|
|
31
|
+
status: {
|
|
32
|
+
type: 'beta', // 'beta' | 'stable' | 'deprecated' | 'releaseCandidate'
|
|
33
|
+
url: 'http://www.url.com/status', // will make the tag a link
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import '@testing-library/jest-dom'
|
|
2
|
+
import VcForm from "./VcForm.vue";
|
|
3
|
+
import init from "../../../testing-library.config"
|
|
4
|
+
import Vuetify from 'vuetify'
|
|
5
|
+
import {render} from "@testing-library/vue";
|
|
6
|
+
|
|
7
|
+
init();
|
|
8
|
+
|
|
9
|
+
describe("VcForm.vue", () => {
|
|
10
|
+
|
|
11
|
+
const renderWithVuetify = (component, options, callback) => {
|
|
12
|
+
const root = document.createElement('div')
|
|
13
|
+
root.setAttribute('data-app', 'true')
|
|
14
|
+
|
|
15
|
+
return render(
|
|
16
|
+
component,
|
|
17
|
+
{
|
|
18
|
+
container: document.body.appendChild(root),
|
|
19
|
+
// for Vuetify components that use the vuetify instance property
|
|
20
|
+
vuetify: new Vuetify(),
|
|
21
|
+
...options,
|
|
22
|
+
mocks: {},
|
|
23
|
+
},
|
|
24
|
+
callback,
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
it("mounts", () => {
|
|
29
|
+
// Queries: https://testing-library.com/docs/queries/about#types-of-queries
|
|
30
|
+
const {container} = renderWithVuetify(VcForm, {
|
|
31
|
+
props: {}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// Expect options: https://github.com/testing-library/jest-dom
|
|
35
|
+
expect(container).toHaveAttribute('data-app', 'true')
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
});
|