@code-coaching/vuetiful 0.23.1 → 0.23.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/dist/style.css +1 -1
- package/dist/types/components/VBootstrap.vue.d.ts +1 -1
- package/dist/types/components/atoms/VAvatar.vue.d.ts +1 -1
- package/dist/types/components/atoms/VLightSwitch.vue.d.ts +2 -2
- package/dist/types/components/atoms/index.d.ts +13 -13
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/components/molecules/VAlert.vue.d.ts +1 -1
- package/dist/types/components/molecules/VCodeBlock.vue.d.ts +2 -2
- package/dist/types/components/molecules/VDrawer.vue.d.ts +1 -1
- package/dist/types/components/molecules/VListbox/VListbox.vue.d.ts +1 -1
- package/dist/types/components/molecules/VRail/VRail.vue.d.ts +1 -1
- package/dist/types/components/molecules/VRail/VRailTile.vue.d.ts +1 -1
- package/dist/types/components/molecules/index.d.ts +21 -21
- package/dist/types/directives/clipboard.d.ts +1 -1
- package/dist/types/directives/index.d.ts +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/props/props.d.ts +1 -1
- package/dist/types/services/dark-mode.service.d.ts +1 -1
- package/dist/types/services/drawer.service.d.ts +1 -1
- package/dist/types/services/index.d.ts +5 -5
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/theme/theme-switcher.vue.d.ts +1 -1
- package/dist/types/utils/theme/theme.service.d.ts +1 -1
- package/dist/vuetiful.es.mjs +12 -18
- package/dist/vuetiful.umd.js +3 -3
- package/package.json +1 -1
- package/src/assets/main.css +6 -6
- package/src/components/VBootstrap.vue +43 -43
- package/src/components/atoms/VAvatar.test.ts +71 -71
- package/src/components/atoms/VAvatar.vue +22 -23
- package/src/components/atoms/VBadge.test.ts +11 -11
- package/src/components/atoms/VBadge.vue +2 -2
- package/src/components/atoms/VButton.test.ts +82 -82
- package/src/components/atoms/VButton.vue +20 -21
- package/src/components/atoms/VChip.test.ts +11 -11
- package/src/components/atoms/VChip.vue +3 -3
- package/src/components/atoms/VLightSwitch.test.ts +6 -6
- package/src/components/atoms/VLightSwitch.vue +26 -31
- package/src/components/atoms/VRadio/VRadioDescription.test.ts +13 -13
- package/src/components/atoms/VRadio/VRadioDescription.vue +2 -2
- package/src/components/atoms/VRadio/VRadioGroup.test.ts +40 -40
- package/src/components/atoms/VRadio/VRadioGroup.vue +19 -22
- package/src/components/atoms/VRadio/VRadioItem.test.ts +67 -67
- package/src/components/atoms/VRadio/VRadioItem.vue +10 -13
- package/src/components/atoms/VRadio/VRadioLabel.test.ts +13 -13
- package/src/components/atoms/VRadio/VRadioLabel.vue +5 -3
- package/src/components/atoms/VSwitch/VSwitch.test.ts +33 -33
- package/src/components/atoms/VSwitch/VSwitch.vue +24 -27
- package/src/components/atoms/VSwitch/VSwitchDescription.test.ts +13 -13
- package/src/components/atoms/VSwitch/VSwitchDescription.vue +2 -2
- package/src/components/atoms/VSwitch/VSwitchGroup.test.ts +9 -9
- package/src/components/atoms/VSwitch/VSwitchGroup.vue +2 -2
- package/src/components/atoms/VSwitch/VSwitchLabel.test.ts +19 -19
- package/src/components/atoms/VSwitch/VSwitchLabel.vue +2 -2
- package/src/components/atoms/index.ts +13 -13
- package/src/components/index.test.ts +3 -3
- package/src/components/index.ts +2 -2
- package/src/components/molecules/VAccordion/VAccordion.test.ts +11 -17
- package/src/components/molecules/VAccordion/VAccordion.vue +3 -3
- package/src/components/molecules/VAccordion/VAccordionItem.test.ts +55 -55
- package/src/components/molecules/VAccordion/VAccordionItem.vue +9 -22
- package/src/components/molecules/VAlert.test.ts +38 -38
- package/src/components/molecules/VAlert.vue +25 -47
- package/src/components/molecules/VCard/VCard.test.ts +25 -25
- package/src/components/molecules/VCard/VCard.vue +13 -15
- package/src/components/molecules/VCard/VCardBody.test.ts +14 -14
- package/src/components/molecules/VCard/VCardBody.vue +4 -8
- package/src/components/molecules/VCard/VCardFooter.test.ts +22 -22
- package/src/components/molecules/VCard/VCardFooter.vue +10 -8
- package/src/components/molecules/VCard/VCardHeader.test.ts +25 -25
- package/src/components/molecules/VCard/VCardHeader.vue +7 -8
- package/src/components/molecules/VCodeBlock.test.ts +63 -63
- package/src/components/molecules/VCodeBlock.vue +27 -34
- package/src/components/molecules/VDrawer.test.ts +5 -5
- package/src/components/molecules/VDrawer.vue +10 -10
- package/src/components/molecules/VListbox/VListbox.test.ts +53 -53
- package/src/components/molecules/VListbox/VListbox.vue +31 -32
- package/src/components/molecules/VListbox/VListboxButton.test.ts +13 -13
- package/src/components/molecules/VListbox/VListboxButton.vue +5 -5
- package/src/components/molecules/VListbox/VListboxItem.test.ts +25 -25
- package/src/components/molecules/VListbox/VListboxItem.vue +7 -8
- package/src/components/molecules/VListbox/VListboxItems.test.ts +14 -14
- package/src/components/molecules/VListbox/VListboxItems.vue +9 -11
- package/src/components/molecules/VListbox/VListboxLabel.test.ts +10 -10
- package/src/components/molecules/VListbox/VListboxLabel.vue +2 -2
- package/src/components/molecules/VPreview.test.ts +26 -26
- package/src/components/molecules/VPreview.vue +22 -27
- package/src/components/molecules/VRail/VRail.test.ts +5 -5
- package/src/components/molecules/VRail/VRail.vue +7 -7
- package/src/components/molecules/VRail/VRailTile.test.ts +26 -28
- package/src/components/molecules/VRail/VRailTile.vue +13 -11
- package/src/components/molecules/VShell.test.ts +5 -5
- package/src/components/molecules/VShell.vue +11 -20
- package/src/components/molecules/VTabs/VTab.test.ts +48 -52
- package/src/components/molecules/VTabs/VTab.vue +13 -17
- package/src/components/molecules/VTabs/VTabPanel.test.ts +8 -8
- package/src/components/molecules/VTabs/VTabPanel.vue +1 -1
- package/src/components/molecules/VTabs/VTabs.test.ts +36 -36
- package/src/components/molecules/VTabs/VTabs.vue +18 -22
- package/src/components/molecules/index.ts +21 -21
- package/src/directives/clipboard.test.ts +9 -9
- package/src/directives/clipboard.ts +2 -2
- package/src/directives/index.ts +1 -1
- package/src/env.d.ts +2 -2
- package/src/index.test.ts +6 -6
- package/src/index.ts +7 -7
- package/src/props/index.ts +1 -1
- package/src/props/props.ts +44 -44
- package/src/services/dark-mode.service.test.ts +115 -93
- package/src/services/dark-mode.service.ts +9 -9
- package/src/services/drawer.service.test.ts +21 -21
- package/src/services/drawer.service.ts +10 -10
- package/src/services/highlight.service.test.ts +12 -12
- package/src/services/highlight.service.ts +1 -1
- package/src/services/index.ts +5 -5
- package/src/services/rail.service.test.ts +7 -7
- package/src/services/rail.service.ts +2 -2
- package/src/services/settings.service.test.ts +5 -5
- package/src/services/settings.service.ts +1 -1
- package/src/styles/all.css +7 -7
- package/src/styles/elements/buttons.css +1 -1
- package/src/styles/elements/forms.css +7 -7
- package/src/styles/elements.css +13 -13
- package/src/styles/transitions.css +2 -2
- package/src/styles/typography.css +5 -5
- package/src/themes/theme-rocket.css +10 -10
- package/src/themes/theme-sahara.css +13 -13
- package/src/themes/theme-seafoam.css +13 -13
- package/src/themes/theme-seasonal.css +4 -4
- package/src/themes/theme-skeleton.css +7 -7
- package/src/themes/theme-vintage.css +12 -12
- package/src/themes/theme-vuetiful-0.0.1.css +13 -13
- package/src/types/index.ts +46 -46
- package/src/types/tailwind.ts +2 -21
- package/src/utils/index.test.ts +3 -3
- package/src/utils/index.ts +2 -2
- package/src/utils/platform/platform.service.test.ts +6 -6
- package/src/utils/platform/platform.service.ts +1 -1
- package/src/utils/theme/callback.test.ts +6 -6
- package/src/utils/theme/remove.test.ts +8 -8
- package/src/utils/theme/theme-switcher.vue +10 -13
- package/src/utils/theme/theme.service.test.ts +69 -61
- package/src/utils/theme/theme.service.ts +19 -20
|
@@ -1,179 +1,179 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test, vi } from
|
|
3
|
-
import { VButton } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
3
|
+
import { VButton } from '.';
|
|
4
4
|
|
|
5
|
-
test(
|
|
5
|
+
test('VButton', () => {
|
|
6
6
|
expect(VButton).toBeTruthy();
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
test(
|
|
9
|
+
test('VButton using slot', () => {
|
|
10
10
|
const wrapper = mount(VButton, {
|
|
11
11
|
slots: {
|
|
12
|
-
default:
|
|
12
|
+
default: 'John Duck',
|
|
13
13
|
},
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
expect(wrapper.text()).toContain(
|
|
16
|
+
expect(wrapper.text()).toContain('John Duck');
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
describe(
|
|
20
|
-
describe(
|
|
21
|
-
test(
|
|
19
|
+
describe('VButton props', () => {
|
|
20
|
+
describe('size', () => {
|
|
21
|
+
test('xs', () => {
|
|
22
22
|
const wrapper = mount(VButton, {
|
|
23
23
|
props: {
|
|
24
|
-
size:
|
|
24
|
+
size: 'xs',
|
|
25
25
|
},
|
|
26
26
|
});
|
|
27
|
-
expect(wrapper.classes()).toContain(
|
|
28
|
-
expect(wrapper.classes()).toContain(
|
|
29
|
-
expect(wrapper.classes()).toContain(
|
|
27
|
+
expect(wrapper.classes()).toContain('px-2.5');
|
|
28
|
+
expect(wrapper.classes()).toContain('py-1.5');
|
|
29
|
+
expect(wrapper.classes()).toContain('text-xs');
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
test(
|
|
32
|
+
test('sm', () => {
|
|
33
33
|
const wrapper = mount(VButton, {
|
|
34
34
|
props: {
|
|
35
|
-
size:
|
|
35
|
+
size: 'sm',
|
|
36
36
|
},
|
|
37
37
|
});
|
|
38
|
-
expect(wrapper.classes()).toContain(
|
|
39
|
-
expect(wrapper.classes()).toContain(
|
|
40
|
-
expect(wrapper.classes()).toContain(
|
|
41
|
-
expect(wrapper.classes()).toContain(
|
|
38
|
+
expect(wrapper.classes()).toContain('px-3');
|
|
39
|
+
expect(wrapper.classes()).toContain('py-2');
|
|
40
|
+
expect(wrapper.classes()).toContain('text-sm');
|
|
41
|
+
expect(wrapper.classes()).toContain('leading-4');
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
test(
|
|
44
|
+
test('md', () => {
|
|
45
45
|
const wrapper = mount(VButton, {
|
|
46
46
|
props: {
|
|
47
|
-
size:
|
|
47
|
+
size: 'md',
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
|
-
expect(wrapper.classes()).toContain(
|
|
51
|
-
expect(wrapper.classes()).toContain(
|
|
52
|
-
expect(wrapper.classes()).toContain(
|
|
50
|
+
expect(wrapper.classes()).toContain('px-4');
|
|
51
|
+
expect(wrapper.classes()).toContain('py-2');
|
|
52
|
+
expect(wrapper.classes()).toContain('text-sm');
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
test(
|
|
55
|
+
test('lg', () => {
|
|
56
56
|
const wrapper = mount(VButton, {
|
|
57
57
|
props: {
|
|
58
|
-
size:
|
|
58
|
+
size: 'lg',
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
|
-
expect(wrapper.classes()).toContain(
|
|
62
|
-
expect(wrapper.classes()).toContain(
|
|
63
|
-
expect(wrapper.classes()).toContain(
|
|
61
|
+
expect(wrapper.classes()).toContain('px-4');
|
|
62
|
+
expect(wrapper.classes()).toContain('py-2');
|
|
63
|
+
expect(wrapper.classes()).toContain('text-base');
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
test(
|
|
66
|
+
test('xl', () => {
|
|
67
67
|
const wrapper = mount(VButton, {
|
|
68
68
|
props: {
|
|
69
|
-
size:
|
|
69
|
+
size: 'xl',
|
|
70
70
|
},
|
|
71
71
|
});
|
|
72
|
-
expect(wrapper.classes()).toContain(
|
|
73
|
-
expect(wrapper.classes()).toContain(
|
|
74
|
-
expect(wrapper.classes()).toContain(
|
|
72
|
+
expect(wrapper.classes()).toContain('px-6');
|
|
73
|
+
expect(wrapper.classes()).toContain('py-3');
|
|
74
|
+
expect(wrapper.classes()).toContain('text-base');
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
describe(
|
|
79
|
-
test(
|
|
78
|
+
describe('given icon is true', () => {
|
|
79
|
+
test('should have btn-icon class, not have btn class', () => {
|
|
80
80
|
const wrapper = mount(VButton, {
|
|
81
81
|
props: {
|
|
82
82
|
icon: true,
|
|
83
83
|
},
|
|
84
84
|
});
|
|
85
|
-
expect(wrapper.classes()).toContain(
|
|
86
|
-
expect(wrapper.classes()).not.toContain(
|
|
85
|
+
expect(wrapper.classes()).toContain('btn-icon');
|
|
86
|
+
expect(wrapper.classes()).not.toContain('btn');
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
|
-
describe(
|
|
90
|
-
test(
|
|
89
|
+
describe('given icon is false', () => {
|
|
90
|
+
test('should have btn class, not have btn-icon class', () => {
|
|
91
91
|
const wrapper = mount(VButton, {
|
|
92
92
|
props: {
|
|
93
93
|
icon: false,
|
|
94
94
|
},
|
|
95
95
|
});
|
|
96
|
-
expect(wrapper.classes()).not.toContain(
|
|
97
|
-
expect(wrapper.classes()).toContain(
|
|
96
|
+
expect(wrapper.classes()).not.toContain('btn-icon');
|
|
97
|
+
expect(wrapper.classes()).toContain('btn');
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
describe(
|
|
103
|
-
describe(
|
|
104
|
-
test(
|
|
102
|
+
describe('VButton events', () => {
|
|
103
|
+
describe('given click event', () => {
|
|
104
|
+
test('should preventDefault and emit click event', async () => {
|
|
105
105
|
const wrapper = mount(VButton);
|
|
106
106
|
const clickEvent = { preventDefault: () => {} };
|
|
107
|
-
const preventDefaultSpy = vi.spyOn(clickEvent,
|
|
108
|
-
wrapper.trigger(
|
|
107
|
+
const preventDefaultSpy = vi.spyOn(clickEvent, 'preventDefault');
|
|
108
|
+
wrapper.trigger('click', clickEvent);
|
|
109
109
|
await wrapper.vm.$nextTick();
|
|
110
110
|
expect(preventDefaultSpy).toHaveBeenCalled();
|
|
111
|
-
expect(wrapper.emitted(
|
|
111
|
+
expect(wrapper.emitted('click')).toBeTruthy();
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
describe(
|
|
117
|
-
describe(
|
|
118
|
-
test(
|
|
116
|
+
describe('VButton a11y', () => {
|
|
117
|
+
describe('a11y role', () => {
|
|
118
|
+
test('should have role button', () => {
|
|
119
119
|
const wrapper = mount(VButton);
|
|
120
|
-
expect(wrapper.attributes(
|
|
120
|
+
expect(wrapper.attributes('role')).toBe('button');
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
|
-
describe(
|
|
124
|
-
test(
|
|
123
|
+
describe('a11y tabindex', () => {
|
|
124
|
+
test('should have tabindex 0', () => {
|
|
125
125
|
const wrapper = mount(VButton);
|
|
126
|
-
expect(wrapper.attributes(
|
|
126
|
+
expect(wrapper.attributes('tabindex')).toBe('0');
|
|
127
127
|
});
|
|
128
128
|
});
|
|
129
|
-
describe(
|
|
130
|
-
describe(
|
|
131
|
-
test(
|
|
129
|
+
describe('given keydown event', () => {
|
|
130
|
+
describe('given key is Enter', () => {
|
|
131
|
+
test('should preventDefault and emit click event', async () => {
|
|
132
132
|
const wrapper = mount(VButton);
|
|
133
|
-
const keydownEvent = { key:
|
|
134
|
-
const preventDefaultSpy = vi.spyOn(keydownEvent,
|
|
135
|
-
wrapper.trigger(
|
|
133
|
+
const keydownEvent = { key: 'Enter', preventDefault: () => {} };
|
|
134
|
+
const preventDefaultSpy = vi.spyOn(keydownEvent, 'preventDefault');
|
|
135
|
+
wrapper.trigger('keydown', keydownEvent);
|
|
136
136
|
await wrapper.vm.$nextTick();
|
|
137
137
|
expect(preventDefaultSpy).toHaveBeenCalled();
|
|
138
|
-
expect(wrapper.emitted(
|
|
138
|
+
expect(wrapper.emitted('click')).toBeTruthy();
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
-
describe(
|
|
143
|
-
test(
|
|
142
|
+
describe('given key is Space', () => {
|
|
143
|
+
test('should preventDefault and not emit click event', async () => {
|
|
144
144
|
const wrapper = mount(VButton);
|
|
145
|
-
const keydownEvent = { key:
|
|
146
|
-
const preventDefaultSpy = vi.spyOn(keydownEvent,
|
|
147
|
-
wrapper.trigger(
|
|
145
|
+
const keydownEvent = { key: ' ', preventDefault: () => {} };
|
|
146
|
+
const preventDefaultSpy = vi.spyOn(keydownEvent, 'preventDefault');
|
|
147
|
+
wrapper.trigger('keydown', keydownEvent);
|
|
148
148
|
await wrapper.vm.$nextTick();
|
|
149
149
|
expect(preventDefaultSpy).toHaveBeenCalled();
|
|
150
|
-
expect(wrapper.emitted(
|
|
150
|
+
expect(wrapper.emitted('click')).toBeFalsy();
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
-
describe(
|
|
155
|
-
test(
|
|
154
|
+
describe('given key is not Enter or Space', () => {
|
|
155
|
+
test('should not preventDefault and not emit click event', async () => {
|
|
156
156
|
const wrapper = mount(VButton);
|
|
157
|
-
const keydownEvent = { key:
|
|
158
|
-
const preventDefaultSpy = vi.spyOn(keydownEvent,
|
|
159
|
-
wrapper.trigger(
|
|
157
|
+
const keydownEvent = { key: 'a', preventDefault: () => {} };
|
|
158
|
+
const preventDefaultSpy = vi.spyOn(keydownEvent, 'preventDefault');
|
|
159
|
+
wrapper.trigger('keydown', keydownEvent);
|
|
160
160
|
await wrapper.vm.$nextTick();
|
|
161
161
|
expect(preventDefaultSpy).not.toHaveBeenCalled();
|
|
162
|
-
expect(wrapper.emitted(
|
|
162
|
+
expect(wrapper.emitted('click')).toBeFalsy();
|
|
163
163
|
});
|
|
164
164
|
});
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
-
describe(
|
|
168
|
-
describe(
|
|
169
|
-
test(
|
|
167
|
+
describe('given keyup event', () => {
|
|
168
|
+
describe('given key is Space', () => {
|
|
169
|
+
test('should preventDefault and emit click event', async () => {
|
|
170
170
|
const wrapper = mount(VButton);
|
|
171
|
-
const keyupEvent = { key:
|
|
172
|
-
const preventDefaultSpy = vi.spyOn(keyupEvent,
|
|
173
|
-
wrapper.trigger(
|
|
171
|
+
const keyupEvent = { key: ' ', preventDefault: () => {} };
|
|
172
|
+
const preventDefaultSpy = vi.spyOn(keyupEvent, 'preventDefault');
|
|
173
|
+
wrapper.trigger('keyup', keyupEvent);
|
|
174
174
|
await wrapper.vm.$nextTick();
|
|
175
175
|
expect(preventDefaultSpy).toHaveBeenCalled();
|
|
176
|
-
expect(wrapper.emitted(
|
|
176
|
+
expect(wrapper.emitted('click')).toBeTruthy();
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
179
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { sizeProp, unstyledProp, variantProp } from
|
|
3
|
-
import { useSettings } from
|
|
4
|
-
import { computed } from
|
|
2
|
+
import { sizeProp, unstyledProp, variantProp } from '@/props';
|
|
3
|
+
import { useSettings } from '@/services';
|
|
4
|
+
import { computed } from 'vue';
|
|
5
5
|
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
icon: {
|
|
@@ -10,17 +10,17 @@ const props = defineProps({
|
|
|
10
10
|
},
|
|
11
11
|
tag: {
|
|
12
12
|
type: String as () => string,
|
|
13
|
-
default:
|
|
13
|
+
default: 'button',
|
|
14
14
|
},
|
|
15
15
|
|
|
16
16
|
size: sizeProp,
|
|
17
17
|
variant: variantProp,
|
|
18
18
|
unstyled: unstyledProp,
|
|
19
19
|
});
|
|
20
|
-
const emit = defineEmits<{ (event:
|
|
20
|
+
const emit = defineEmits<{ (event: 'click'): void }>();
|
|
21
21
|
|
|
22
22
|
const activate = () => {
|
|
23
|
-
emit(
|
|
23
|
+
emit('click');
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const clickHandler = (event: MouseEvent) => {
|
|
@@ -29,12 +29,12 @@ const clickHandler = (event: MouseEvent) => {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const keydownHandler = (event: KeyboardEvent) => {
|
|
32
|
-
if ([
|
|
33
|
-
if (event.key ===
|
|
32
|
+
if (['Enter', ' '].includes(event.key)) event.preventDefault();
|
|
33
|
+
if (event.key === 'Enter') activate();
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const keyupHandler = (event: KeyboardEvent) => {
|
|
37
|
-
if (event.key ===
|
|
37
|
+
if (event.key === ' ') {
|
|
38
38
|
event.preventDefault();
|
|
39
39
|
activate();
|
|
40
40
|
}
|
|
@@ -42,22 +42,21 @@ const keyupHandler = (event: KeyboardEvent) => {
|
|
|
42
42
|
|
|
43
43
|
const btnSize = computed(() => {
|
|
44
44
|
switch (props.size) {
|
|
45
|
-
case
|
|
46
|
-
return
|
|
47
|
-
case
|
|
48
|
-
return
|
|
49
|
-
case
|
|
50
|
-
return
|
|
51
|
-
case
|
|
52
|
-
return
|
|
53
|
-
case
|
|
54
|
-
return
|
|
45
|
+
case 'xs':
|
|
46
|
+
return 'px-2.5 py-1.5 text-xs';
|
|
47
|
+
case 'sm':
|
|
48
|
+
return 'px-3 py-2 text-sm leading-4';
|
|
49
|
+
case 'md':
|
|
50
|
+
return 'px-4 py-2 text-sm';
|
|
51
|
+
case 'lg':
|
|
52
|
+
return 'px-4 py-2 text-base';
|
|
53
|
+
case 'xl':
|
|
54
|
+
return 'px-6 py-3 text-base';
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
const { settings } = useSettings();
|
|
59
|
-
const isUnstyled =
|
|
60
|
-
settings.global.unstyled || settings.components.button.unstyled || props.unstyled;
|
|
59
|
+
const isUnstyled = settings.global.unstyled || settings.components.button.unstyled || props.unstyled;
|
|
61
60
|
</script>
|
|
62
61
|
|
|
63
62
|
<template>
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import { VChip } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { VChip } from '.';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
test(
|
|
5
|
+
describe('VChip', () => {
|
|
6
|
+
test('default slot', () => {
|
|
7
7
|
const wrapper = mount({
|
|
8
8
|
template: `<v-chip>John Duck</v-chip>`,
|
|
9
9
|
components: { VChip },
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
expect(wrapper.text()).toContain(
|
|
13
|
-
expect(wrapper.classes()).toContain(
|
|
12
|
+
expect(wrapper.text()).toContain('John Duck');
|
|
13
|
+
expect(wrapper.classes()).toContain('chip');
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
test(
|
|
16
|
+
test('unstyled', () => {
|
|
17
17
|
const wrapper = mount({
|
|
18
18
|
template: `<v-chip unstyled>John Duck</v-chip>`,
|
|
19
19
|
components: { VChip },
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
expect(wrapper.classes()).not.toContain(
|
|
22
|
+
expect(wrapper.classes()).not.toContain('chip');
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
test(
|
|
25
|
+
test('variant', () => {
|
|
26
26
|
const wrapper = mount({
|
|
27
27
|
template: `<v-chip variant="primary">John Duck</v-chip>`,
|
|
28
28
|
components: { VChip },
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
expect(wrapper.classes()).toContain(
|
|
31
|
+
expect(wrapper.classes()).toContain('variant-primary');
|
|
32
32
|
});
|
|
33
33
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { unstyledProp, variantProp } from
|
|
3
|
-
import { useSettings } from
|
|
2
|
+
import { unstyledProp, variantProp } from '@/props';
|
|
3
|
+
import { useSettings } from '@/services';
|
|
4
4
|
|
|
5
5
|
const props = defineProps({
|
|
6
|
-
unstyled: unstyledProp,
|
|
6
|
+
unstyled: unstyledProp,
|
|
7
7
|
variant: variantProp,
|
|
8
8
|
});
|
|
9
9
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { expect, test, vi } from
|
|
3
|
-
import { VLightSwitch } from
|
|
4
|
-
import { useDarkMode } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { expect, test, vi } from 'vitest';
|
|
3
|
+
import { VLightSwitch } from '.';
|
|
4
|
+
import { useDarkMode } from '@/services';
|
|
5
5
|
|
|
6
6
|
const { MODE } = useDarkMode();
|
|
7
7
|
|
|
8
8
|
const matchMediaMock = (matches: boolean) => vi.fn(() => ({ matches, onchange: vi.fn() }));
|
|
9
9
|
|
|
10
|
-
test(
|
|
10
|
+
test('VLightSwitch', () => {
|
|
11
11
|
expect(VLightSwitch).toBeTruthy();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
// TODO: add tests
|
|
15
|
-
test(
|
|
15
|
+
test('VLightSwitch using slot', () => {
|
|
16
16
|
window.matchMedia = matchMediaMock(MODE.LIGHT) as any;
|
|
17
17
|
const wrapper = mount(VLightSwitch);
|
|
18
18
|
|
|
@@ -24,42 +24,42 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script lang="ts">
|
|
27
|
-
import { CssClasses, useDarkMode } from
|
|
28
|
-
import { computed, ComputedRef, defineComponent, onMounted } from
|
|
27
|
+
import { CssClasses, useDarkMode } from '@/index';
|
|
28
|
+
import { computed, ComputedRef, defineComponent, onMounted } from 'vue';
|
|
29
29
|
|
|
30
30
|
export default defineComponent({
|
|
31
31
|
props: {
|
|
32
32
|
bgLight: {
|
|
33
33
|
type: String as () => CssClasses,
|
|
34
|
-
default:
|
|
34
|
+
default: 'bg-surface-50',
|
|
35
35
|
},
|
|
36
36
|
bgDark: {
|
|
37
37
|
type: String as () => CssClasses,
|
|
38
|
-
default:
|
|
38
|
+
default: 'bg-surface-900',
|
|
39
39
|
},
|
|
40
40
|
textLight: {
|
|
41
41
|
type: String as () => CssClasses,
|
|
42
|
-
default:
|
|
42
|
+
default: 'text-surface-50',
|
|
43
43
|
},
|
|
44
44
|
textDark: {
|
|
45
45
|
type: String as () => CssClasses,
|
|
46
|
-
default:
|
|
46
|
+
default: 'text-surface-900',
|
|
47
47
|
},
|
|
48
48
|
width: {
|
|
49
49
|
type: String as () => CssClasses,
|
|
50
|
-
default:
|
|
50
|
+
default: 'w-12',
|
|
51
51
|
},
|
|
52
52
|
height: {
|
|
53
53
|
type: String as () => CssClasses,
|
|
54
|
-
default:
|
|
54
|
+
default: 'h-6',
|
|
55
55
|
},
|
|
56
56
|
ring: {
|
|
57
57
|
type: String as () => CssClasses,
|
|
58
|
-
default:
|
|
58
|
+
default: 'ring-[1px] ring-surface-500/30',
|
|
59
59
|
},
|
|
60
60
|
rounded: {
|
|
61
61
|
type: String as () => CssClasses,
|
|
62
|
-
default:
|
|
62
|
+
default: 'rounded-token',
|
|
63
63
|
},
|
|
64
64
|
},
|
|
65
65
|
setup(props, { attrs }) {
|
|
@@ -70,13 +70,13 @@ export default defineComponent({
|
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
const cTransition = `transition-all duration-[200ms]`;
|
|
73
|
-
const cTrack =
|
|
74
|
-
const cThumb =
|
|
75
|
-
const cIcon =
|
|
73
|
+
const cTrack = 'cursor-pointer';
|
|
74
|
+
const cThumb = 'aspect-square scale-[0.8] flex justify-center items-center';
|
|
75
|
+
const cIcon = 'w-[70%] aspect-square';
|
|
76
76
|
|
|
77
77
|
const svgPath = {
|
|
78
|
-
sun:
|
|
79
|
-
moon:
|
|
78
|
+
sun: 'M361.5 1.2c5 2.1 8.6 6.6 9.6 11.9L391 121l107.9 19.8c5.3 1 9.8 4.6 11.9 9.6s1.5 10.7-1.6 15.2L446.9 256l62.3 90.3c3.1 4.5 3.7 10.2 1.6 15.2s-6.6 8.6-11.9 9.6L391 391 371.1 498.9c-1 5.3-4.6 9.8-9.6 11.9s-10.7 1.5-15.2-1.6L256 446.9l-90.3 62.3c-4.5 3.1-10.2 3.7-15.2 1.6s-8.6-6.6-9.6-11.9L121 391 13.1 371.1c-5.3-1-9.8-4.6-11.9-9.6s-1.5-10.7 1.6-15.2L65.1 256 2.8 165.7c-3.1-4.5-3.7-10.2-1.6-15.2s6.6-8.6 11.9-9.6L121 121 140.9 13.1c1-5.3 4.6-9.8 9.6-11.9s10.7-1.5 15.2 1.6L256 65.1 346.3 2.8c4.5-3.1 10.2-3.7 15.2-1.6zM352 256c0 53-43 96-96 96s-96-43-96-96s43-96 96-96s96 43 96 96zm32 0c0-70.7-57.3-128-128-128s-128 57.3-128 128s57.3 128 128 128s128-57.3 128-128z',
|
|
79
|
+
moon: 'M223.5 32C100 32 0 132.3 0 256S100 480 223.5 480c60.6 0 115.5-24.2 155.8-63.4c5-4.9 6.3-12.5 3.1-18.7s-10.1-9.7-17-8.5c-9.8 1.7-19.8 2.6-30.1 2.6c-96.9 0-175.5-78.8-175.5-176c0-65.8 36-123.1 89.3-153.3c6.1-3.5 9.2-10.5 7.7-17.3s-7.3-11.9-14.3-12.5c-6.3-.5-12.6-.8-19-.8z',
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
const onToggleHandler = () => {
|
|
@@ -85,35 +85,30 @@ export default defineComponent({
|
|
|
85
85
|
setModeCurrent(toggle);
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
type OnKeyDownEvent = KeyboardEvent & {
|
|
88
|
+
type OnKeyDownEvent = KeyboardEvent & {
|
|
89
|
+
currentTarget: EventTarget & HTMLDivElement;
|
|
90
|
+
};
|
|
89
91
|
const onKeyDown = (event: KeyboardEvent) => {
|
|
90
|
-
if ([
|
|
92
|
+
if (['Enter', 'Space'].includes(event.code)) {
|
|
91
93
|
event.preventDefault();
|
|
92
94
|
(event as OnKeyDownEvent).currentTarget.click();
|
|
93
95
|
}
|
|
94
96
|
};
|
|
95
97
|
|
|
96
|
-
const trackBg = computed(() =>
|
|
97
|
-
|
|
98
|
-
);
|
|
99
|
-
const thumbBg = computed(() =>
|
|
100
|
-
currentMode.value === MODE.LIGHT ? props.bgDark : props.bgLight
|
|
101
|
-
);
|
|
102
|
-
const thumbPosition = computed(() =>
|
|
103
|
-
currentMode.value === MODE.LIGHT ? "translate-x-[100%]" : ""
|
|
104
|
-
);
|
|
98
|
+
const trackBg = computed(() => (currentMode.value === MODE.LIGHT ? props.bgLight : props.bgDark));
|
|
99
|
+
const thumbBg = computed(() => (currentMode.value === MODE.LIGHT ? props.bgDark : props.bgLight));
|
|
100
|
+
const thumbPosition = computed(() => (currentMode.value === MODE.LIGHT ? 'translate-x-[100%]' : ''));
|
|
105
101
|
const iconFill = computed(() => {
|
|
106
102
|
return currentMode.value === MODE.LIGHT ? props.textLight : props.textDark;
|
|
107
103
|
});
|
|
108
104
|
|
|
109
105
|
const classesTrack: ComputedRef<string> = computed(() => {
|
|
110
|
-
return `${cTrack} ${cTransition} ${props.width} ${props.height} ${props.ring} ${
|
|
111
|
-
|
|
112
|
-
}
|
|
106
|
+
return `${cTrack} ${cTransition} ${props.width} ${props.height} ${props.ring} ${props.rounded} ${trackBg.value} ${
|
|
107
|
+
attrs.class ?? ''
|
|
108
|
+
}`;
|
|
113
109
|
});
|
|
114
110
|
const classesThumb: ComputedRef<string> = computed(
|
|
115
|
-
() =>
|
|
116
|
-
`${cThumb} ${cTransition} ${props.height} ${props.rounded} ${thumbBg.value} ${thumbPosition.value}`
|
|
111
|
+
() => `${cThumb} ${cTransition} ${props.height} ${props.rounded} ${thumbBg.value} ${thumbPosition.value}`,
|
|
117
112
|
);
|
|
118
113
|
const classesIcon: ComputedRef<string> = computed(() => `${cIcon}`);
|
|
119
114
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import VRadioGroup from
|
|
4
|
-
import VRadioDescription from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import VRadioGroup from './VRadioGroup.vue';
|
|
4
|
+
import VRadioDescription from './VRadioDescription.vue';
|
|
5
5
|
|
|
6
|
-
test(
|
|
6
|
+
test('VRadioDescription using slot', () => {
|
|
7
7
|
const wrapper = mount({
|
|
8
8
|
template: `
|
|
9
9
|
<v-radio-group>
|
|
@@ -11,15 +11,15 @@ test("VRadioDescription using slot", () => {
|
|
|
11
11
|
</v-radio-group>
|
|
12
12
|
`,
|
|
13
13
|
components: {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
'v-radio-description': VRadioDescription,
|
|
15
|
+
'v-radio-group': VRadioGroup,
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
expect(wrapper.text()).toContain(
|
|
19
|
+
expect(wrapper.text()).toContain('John Duck');
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
describe(
|
|
22
|
+
describe('VRadioDescription props', () => {
|
|
23
23
|
test("default 'as' prop", () => {
|
|
24
24
|
const wrapper = mount({
|
|
25
25
|
template: `
|
|
@@ -28,8 +28,8 @@ describe("VRadioDescription props", () => {
|
|
|
28
28
|
</v-radio-group>
|
|
29
29
|
`,
|
|
30
30
|
components: {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
'v-radio-label': VRadioDescription,
|
|
32
|
+
'v-radio-group': VRadioGroup,
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -44,8 +44,8 @@ describe("VRadioDescription props", () => {
|
|
|
44
44
|
</v-radio-group>
|
|
45
45
|
`,
|
|
46
46
|
components: {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
'v-radio-label': VRadioDescription,
|
|
48
|
+
'v-radio-group': VRadioGroup,
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
|