@code-coaching/vuetiful 0.23.0 → 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 +23 -63
- package/dist/types/utils/theme/theme.service.d.ts +1 -1
- package/dist/vuetiful.es.mjs +82 -150
- package/dist/vuetiful.umd.js +7 -15
- 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 +58 -131
- package/src/utils/theme/theme.service.test.ts +69 -61
- package/src/utils/theme/theme.service.ts +19 -20
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import { VAccordion, VAccordionItem } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { VAccordion, VAccordionItem } from '..';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
test(
|
|
5
|
+
describe('VAccordionItem', () => {
|
|
6
|
+
test('defaults', async () => {
|
|
7
7
|
const wrapper = mount({
|
|
8
8
|
template: /*html*/ `
|
|
9
9
|
<v-accordion>
|
|
@@ -11,36 +11,36 @@ describe("VAccordionItem", () => {
|
|
|
11
11
|
<v-accordion-item title="Is">Janine Duck</v-accordion-item>
|
|
12
12
|
</v-accordion>`,
|
|
13
13
|
components: {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
'v-accordion': VAccordion,
|
|
15
|
+
'v-accordion-item': VAccordionItem,
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const accordionItems = wrapper.findAllComponents(VAccordionItem);
|
|
20
20
|
accordionItems.forEach((accordionItem) => {
|
|
21
|
-
expect(accordionItem.classes()).toEqual([
|
|
21
|
+
expect(accordionItem.classes()).toEqual(['vuetiful-accordion-item']);
|
|
22
22
|
|
|
23
|
-
const accordionItemButton = accordionItem.find(
|
|
23
|
+
const accordionItemButton = accordionItem.find('.vuetiful-accordion-item-button');
|
|
24
24
|
expect(accordionItemButton.classes()).toEqual([
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
'items-center',
|
|
26
|
+
'justify-between',
|
|
27
|
+
'p-4',
|
|
28
|
+
'py-2',
|
|
29
|
+
'rounded-container-token',
|
|
30
|
+
'hover:cursor-pointer',
|
|
31
|
+
'bg-surface-200-700-token',
|
|
32
|
+
'hover:variant-soft',
|
|
33
|
+
'vuetiful-accordion-item-button',
|
|
34
|
+
'flex',
|
|
35
|
+
'w-full',
|
|
36
36
|
]);
|
|
37
37
|
|
|
38
|
-
const accordionItemTitle = accordionItem.find(
|
|
38
|
+
const accordionItemTitle = accordionItem.find('.vuetiful-accordion-title');
|
|
39
39
|
expect(accordionItemTitle.text()).toEqual(accordionItem.props().title);
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
test(
|
|
43
|
+
test('unstyled', async () => {
|
|
44
44
|
const wrapper = mount({
|
|
45
45
|
template: /*html*/ `
|
|
46
46
|
<v-accordion>
|
|
@@ -48,30 +48,30 @@ describe("VAccordionItem", () => {
|
|
|
48
48
|
<v-accordion-item title="Is" unstyled>Janine Duck</v-accordion-item>
|
|
49
49
|
</v-accordion>`,
|
|
50
50
|
components: {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
'v-accordion': VAccordion,
|
|
52
|
+
'v-accordion-item': VAccordionItem,
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
const accordionItems = wrapper.findAllComponents(VAccordionItem);
|
|
57
57
|
accordionItems.forEach((accordionItem) => {
|
|
58
|
-
expect(accordionItem.classes()).toEqual([
|
|
58
|
+
expect(accordionItem.classes()).toEqual(['vuetiful-accordion-item']);
|
|
59
59
|
|
|
60
|
-
const accordionItemButton = accordionItem.find(
|
|
60
|
+
const accordionItemButton = accordionItem.find('.vuetiful-accordion-item-button');
|
|
61
61
|
expect(accordionItemButton.classes()).toEqual([
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
'bg-surface-200-700-token',
|
|
63
|
+
'hover:variant-soft',
|
|
64
|
+
'vuetiful-accordion-item-button',
|
|
65
|
+
'flex',
|
|
66
|
+
'w-full',
|
|
67
67
|
]);
|
|
68
68
|
|
|
69
|
-
const accordionItemTitle = accordionItem.find(
|
|
69
|
+
const accordionItemTitle = accordionItem.find('.vuetiful-accordion-title');
|
|
70
70
|
expect(accordionItemTitle.text()).toEqual(accordionItem.props().title);
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
test(
|
|
74
|
+
test('open', async () => {
|
|
75
75
|
const wrapper = mount({
|
|
76
76
|
template: /*html*/ `
|
|
77
77
|
<v-accordion>
|
|
@@ -79,31 +79,31 @@ describe("VAccordionItem", () => {
|
|
|
79
79
|
<v-accordion-item title="Is">Janine Duck</v-accordion-item>
|
|
80
80
|
</v-accordion>`,
|
|
81
81
|
components: {
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
'v-accordion': VAccordion,
|
|
83
|
+
'v-accordion-item': VAccordionItem,
|
|
84
84
|
},
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
const accordionItems = wrapper.findAllComponents(VAccordionItem);
|
|
88
|
-
const accordionItemButtonOne = accordionItems[0].find(
|
|
89
|
-
const accordionItemButtonTwo = accordionItems[1].find(
|
|
88
|
+
const accordionItemButtonOne = accordionItems[0].find('.vuetiful-accordion-item-button');
|
|
89
|
+
const accordionItemButtonTwo = accordionItems[1].find('.vuetiful-accordion-item-button');
|
|
90
90
|
|
|
91
|
-
await accordionItemButtonOne.trigger(
|
|
91
|
+
await accordionItemButtonOne.trigger('click');
|
|
92
92
|
|
|
93
93
|
expect(accordionItemButtonOne.classes()).toEqual([
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
94
|
+
'!rounded-bl-none',
|
|
95
|
+
'!rounded-br-none',
|
|
96
|
+
'items-center',
|
|
97
|
+
'justify-between',
|
|
98
|
+
'p-4',
|
|
99
|
+
'py-2',
|
|
100
|
+
'rounded-container-token',
|
|
101
|
+
'hover:cursor-pointer',
|
|
102
|
+
'bg-surface-200-700-token',
|
|
103
|
+
'hover:variant-soft',
|
|
104
|
+
'vuetiful-accordion-item-button',
|
|
105
|
+
'flex',
|
|
106
|
+
'w-full',
|
|
107
107
|
]);
|
|
108
108
|
expect(accordionItemButtonTwo.classes()).toEqual([
|
|
109
109
|
'items-center',
|
|
@@ -116,10 +116,10 @@ describe("VAccordionItem", () => {
|
|
|
116
116
|
'hover:variant-soft',
|
|
117
117
|
'vuetiful-accordion-item-button',
|
|
118
118
|
'flex',
|
|
119
|
-
'w-full'
|
|
119
|
+
'w-full',
|
|
120
120
|
]);
|
|
121
|
-
|
|
122
|
-
const accordionItemPanelOne = accordionItems[0].find(
|
|
121
|
+
|
|
122
|
+
const accordionItemPanelOne = accordionItems[0].find('.vuetiful-accordion-item-panel');
|
|
123
123
|
|
|
124
124
|
expect(accordionItemPanelOne.classes()).toEqual([
|
|
125
125
|
'vuetiful-accordion-item-panel',
|
|
@@ -128,7 +128,7 @@ describe("VAccordionItem", () => {
|
|
|
128
128
|
'p-4',
|
|
129
129
|
'py-2',
|
|
130
130
|
'rounded-container-token',
|
|
131
|
-
'bg-surface-200-700-token'
|
|
131
|
+
'bg-surface-200-700-token',
|
|
132
132
|
]);
|
|
133
133
|
});
|
|
134
134
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useSettings } from
|
|
3
|
-
import { Disclosure, DisclosureButton, DisclosurePanel } from
|
|
4
|
-
import { inject } from
|
|
2
|
+
import { useSettings } from '@/services';
|
|
3
|
+
import { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue';
|
|
4
|
+
import { inject } from 'vue';
|
|
5
5
|
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
title: {
|
|
@@ -15,34 +15,25 @@ const props = defineProps({
|
|
|
15
15
|
},
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
const classQuestion = inject(
|
|
19
|
-
const classAnswer = inject(
|
|
18
|
+
const classQuestion = inject('classQuestion');
|
|
19
|
+
const classAnswer = inject('classAnswer');
|
|
20
20
|
|
|
21
21
|
const { settings } = useSettings();
|
|
22
|
-
const isUnstyled =
|
|
23
|
-
settings.global.unstyled || settings.components.accordionItem.unstyled || props.unstyled;
|
|
22
|
+
const isUnstyled = settings.global.unstyled || settings.components.accordionItem.unstyled || props.unstyled;
|
|
24
23
|
</script>
|
|
25
24
|
|
|
26
25
|
<template>
|
|
27
26
|
<Disclosure class="vuetiful-accordion-item" as="div" v-slot="{ open }">
|
|
28
27
|
<DisclosureButton
|
|
29
28
|
:class="`${isUnstyled ? '' : `${open ? '!rounded-bl-none !rounded-br-none' : ''}`}
|
|
30
|
-
${
|
|
31
|
-
isUnstyled
|
|
32
|
-
? ''
|
|
33
|
-
: 'items-center justify-between p-4 py-2 rounded-container-token hover:cursor-pointer'
|
|
34
|
-
}
|
|
29
|
+
${isUnstyled ? '' : 'items-center justify-between p-4 py-2 rounded-container-token hover:cursor-pointer'}
|
|
35
30
|
${classQuestion}`"
|
|
36
31
|
class="vuetiful-accordion-item-button flex w-full"
|
|
37
32
|
>
|
|
38
33
|
<span class="vuetiful-accordion-title">{{ title }}</span>
|
|
39
34
|
<slot v-if="!open" name="open-item">
|
|
40
35
|
<!-- https://fontawesome.com/icons/plus?f=classic&s=solid -->
|
|
41
|
-
<svg
|
|
42
|
-
class="vuetiful-accordion-item-icon-plus icon"
|
|
43
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
44
|
-
viewBox="0 0 448 512"
|
|
45
|
-
>
|
|
36
|
+
<svg class="vuetiful-accordion-item-icon-plus icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
|
|
46
37
|
<!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. -->
|
|
47
38
|
<path
|
|
48
39
|
d="M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32V224H48c-17.7 0-32 14.3-32 32s14.3 32 32 32H192V432c0 17.7 14.3 32 32 32s32-14.3 32-32V288H400c17.7 0 32-14.3 32-32s-14.3-32-32-32H256V80z"
|
|
@@ -51,11 +42,7 @@ const isUnstyled =
|
|
|
51
42
|
</slot>
|
|
52
43
|
<slot v-if="open" name="close-item">
|
|
53
44
|
<!-- https://fontawesome.com/icons/minus?f=classic&s=solid -->
|
|
54
|
-
<svg
|
|
55
|
-
class="vuetiful-accordion-item-icon-minus icon"
|
|
56
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
57
|
-
viewBox="0 0 448 512"
|
|
58
|
-
>
|
|
45
|
+
<svg class="vuetiful-accordion-item-icon-minus icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
|
|
59
46
|
<!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. -->
|
|
60
47
|
<path
|
|
61
48
|
d="M432 256c0 17.7-14.3 32-32 32L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l352 0c17.7 0 32 14.3 32 32z"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import { VAlert } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { VAlert } from '..';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
test(
|
|
5
|
+
describe('VAlert', () => {
|
|
6
|
+
test('types', () => {
|
|
7
7
|
const wrapper = mount({
|
|
8
8
|
template: /*html*/ `
|
|
9
9
|
<v-alert data-test="default"></v-alert>
|
|
@@ -13,88 +13,88 @@ describe("VAlert", () => {
|
|
|
13
13
|
<v-alert data-test="error" type="error"></v-alert>
|
|
14
14
|
`,
|
|
15
15
|
components: {
|
|
16
|
-
|
|
16
|
+
'v-alert': VAlert,
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
const defaultAlert = wrapper.find(
|
|
21
|
-
expect(defaultAlert.classes()).not.toContain(
|
|
20
|
+
const defaultAlert = wrapper.find('[data-test=default]');
|
|
21
|
+
expect(defaultAlert.classes()).not.toContain('variant-filled-primary');
|
|
22
22
|
|
|
23
|
-
const infoAlert = wrapper.find(
|
|
24
|
-
expect(infoAlert.classes()).toContain(
|
|
23
|
+
const infoAlert = wrapper.find('[data-test=info]');
|
|
24
|
+
expect(infoAlert.classes()).toContain('variant-filled');
|
|
25
25
|
|
|
26
|
-
const successAlert = wrapper.find(
|
|
27
|
-
expect(successAlert.classes()).toContain(
|
|
26
|
+
const successAlert = wrapper.find('[data-test=success]');
|
|
27
|
+
expect(successAlert.classes()).toContain('variant-filled-success');
|
|
28
28
|
|
|
29
|
-
const warningAlert = wrapper.find(
|
|
30
|
-
expect(warningAlert.classes()).toContain(
|
|
29
|
+
const warningAlert = wrapper.find('[data-test=warning]');
|
|
30
|
+
expect(warningAlert.classes()).toContain('variant-filled-warning');
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
test(
|
|
33
|
+
test('unstyled', () => {
|
|
34
34
|
const wrapper = mount(VAlert, {
|
|
35
35
|
props: {
|
|
36
36
|
unstyled: true,
|
|
37
37
|
},
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
expect(wrapper.classes()).toEqual([
|
|
40
|
+
expect(wrapper.classes()).toEqual(['vuetiful-alert', 'flex']);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
describe(
|
|
44
|
-
test(
|
|
43
|
+
describe('given close icon is clicked', () => {
|
|
44
|
+
test('should emit close', async () => {
|
|
45
45
|
const wrapper = mount(VAlert, { props: { showClose: true } });
|
|
46
|
-
await wrapper.find(
|
|
47
|
-
expect(wrapper.emitted()[
|
|
46
|
+
await wrapper.find('[data-test=close]').trigger('click');
|
|
47
|
+
expect(wrapper.emitted()['close'][0]).toEqual([]);
|
|
48
48
|
|
|
49
|
-
await wrapper.find(
|
|
50
|
-
expect(wrapper.emitted()[
|
|
49
|
+
await wrapper.find('[data-test=close]').trigger('keydown', { key: 'Enter' });
|
|
50
|
+
expect(wrapper.emitted()['close'][0]).toEqual([]);
|
|
51
51
|
|
|
52
|
-
await wrapper.find(
|
|
53
|
-
expect(wrapper.emitted()[
|
|
52
|
+
await wrapper.find('[data-test=close]').trigger('keydown', { key: ' ' });
|
|
53
|
+
expect(wrapper.emitted()['close'][0]).toEqual([]);
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
describe(
|
|
58
|
-
test(
|
|
57
|
+
describe('given a pre slot is provided', () => {
|
|
58
|
+
test('should render the pre slot', () => {
|
|
59
59
|
const wrapper = mount(VAlert, {
|
|
60
60
|
slots: {
|
|
61
|
-
pre:
|
|
61
|
+
pre: 'John Duck',
|
|
62
62
|
},
|
|
63
63
|
});
|
|
64
|
-
expect(wrapper.text()).toContain(
|
|
64
|
+
expect(wrapper.text()).toContain('John Duck');
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
describe(
|
|
69
|
-
test(
|
|
68
|
+
describe('given a actions slot is provided', () => {
|
|
69
|
+
test('should render the actions slot', () => {
|
|
70
70
|
const wrapper = mount(VAlert, {
|
|
71
71
|
slots: {
|
|
72
|
-
actions:
|
|
72
|
+
actions: 'John Duck',
|
|
73
73
|
},
|
|
74
74
|
});
|
|
75
|
-
expect(wrapper.text()).toContain(
|
|
75
|
+
expect(wrapper.text()).toContain('John Duck');
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
describe(
|
|
80
|
-
test(
|
|
79
|
+
describe('given hide-icon prop is present', () => {
|
|
80
|
+
test('should not render an icon', () => {
|
|
81
81
|
const wrapper = mount(VAlert, {
|
|
82
82
|
props: {
|
|
83
83
|
hideIcon: true,
|
|
84
84
|
},
|
|
85
85
|
});
|
|
86
|
-
expect(wrapper.findAll(
|
|
86
|
+
expect(wrapper.findAll('.icon').length).toBe(0);
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
describe(
|
|
91
|
-
test(
|
|
90
|
+
describe('given show-close prop is present', () => {
|
|
91
|
+
test('should render a close icon', () => {
|
|
92
92
|
const wrapper = mount(VAlert, {
|
|
93
93
|
props: {
|
|
94
94
|
showClose: true,
|
|
95
95
|
},
|
|
96
96
|
});
|
|
97
|
-
expect(wrapper.find(
|
|
97
|
+
expect(wrapper.find('[data-test=close]').exists()).toBe(true);
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useSettings } from
|
|
3
|
-
import { PropType, computed } from
|
|
2
|
+
import { useSettings } from '@/services';
|
|
3
|
+
import { PropType, computed } from 'vue';
|
|
4
4
|
|
|
5
|
-
const emit = defineEmits([
|
|
5
|
+
const emit = defineEmits(['close']);
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
hideIcon: {
|
|
8
8
|
type: Boolean,
|
|
@@ -18,21 +18,21 @@ const props = defineProps({
|
|
|
18
18
|
default: true,
|
|
19
19
|
},
|
|
20
20
|
type: {
|
|
21
|
-
type: String as PropType<
|
|
22
|
-
default:
|
|
21
|
+
type: String as PropType<'info' | 'success' | 'warning' | 'error' | ''>,
|
|
22
|
+
default: '',
|
|
23
23
|
},
|
|
24
24
|
|
|
25
25
|
classPre: {
|
|
26
26
|
type: String,
|
|
27
|
-
default:
|
|
27
|
+
default: '',
|
|
28
28
|
},
|
|
29
29
|
classMessage: {
|
|
30
30
|
type: String,
|
|
31
|
-
default:
|
|
31
|
+
default: '',
|
|
32
32
|
},
|
|
33
33
|
classClose: {
|
|
34
34
|
type: String,
|
|
35
|
-
default:
|
|
35
|
+
default: '',
|
|
36
36
|
},
|
|
37
37
|
|
|
38
38
|
unstyled: {
|
|
@@ -43,22 +43,22 @@ const props = defineProps({
|
|
|
43
43
|
|
|
44
44
|
const typeBackground = computed(() => {
|
|
45
45
|
switch (props.type) {
|
|
46
|
-
case
|
|
47
|
-
return
|
|
48
|
-
case
|
|
49
|
-
return
|
|
50
|
-
case
|
|
51
|
-
return
|
|
52
|
-
case
|
|
53
|
-
return
|
|
54
|
-
case
|
|
55
|
-
return
|
|
46
|
+
case 'info':
|
|
47
|
+
return 'variant-filled';
|
|
48
|
+
case 'success':
|
|
49
|
+
return 'variant-filled-success';
|
|
50
|
+
case 'warning':
|
|
51
|
+
return 'variant-filled-warning';
|
|
52
|
+
case 'error':
|
|
53
|
+
return 'variant-filled-error';
|
|
54
|
+
case '':
|
|
55
|
+
return '';
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
const close = () => emit(
|
|
59
|
+
const close = () => emit('close');
|
|
60
60
|
const handleKeydown = (event: KeyboardEvent) => {
|
|
61
|
-
if (event.key ===
|
|
61
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
62
62
|
close();
|
|
63
63
|
}
|
|
64
64
|
};
|
|
@@ -71,57 +71,35 @@ const isUnstyled = settings.global.unstyled || settings.components.alert.unstyle
|
|
|
71
71
|
<aside
|
|
72
72
|
v-if="show"
|
|
73
73
|
:class="`vuetiful-alert flex ${
|
|
74
|
-
isUnstyled
|
|
75
|
-
? ''
|
|
76
|
-
: 'w-full items-center gap-4 p-4 border-token rounded-container-token'
|
|
74
|
+
isUnstyled ? '' : 'w-full items-center gap-4 p-4 border-token rounded-container-token'
|
|
77
75
|
} ${typeBackground}`"
|
|
78
76
|
>
|
|
79
77
|
<div v-if="!hideIcon" :class="`vuetiful-alert-pre ${classPre}`">
|
|
80
78
|
<slot v-if="$slots.pre" name="pre" />
|
|
81
79
|
<template v-if="!$slots.pre">
|
|
82
80
|
<!-- https://fontawesome.com/icons/circle-info?f=classic&s=solid -->
|
|
83
|
-
<svg
|
|
84
|
-
v-if="type === 'info'"
|
|
85
|
-
class="icon"
|
|
86
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
87
|
-
viewBox="0 0 512 512"
|
|
88
|
-
>
|
|
81
|
+
<svg v-if="type === 'info'" class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
89
82
|
<path
|
|
90
83
|
d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"
|
|
91
84
|
/>
|
|
92
85
|
</svg>
|
|
93
86
|
|
|
94
87
|
<!-- https://fontawesome.com/icons/circle-check?f=classic&s=solid -->
|
|
95
|
-
<svg
|
|
96
|
-
v-if="type === 'success'"
|
|
97
|
-
class="icon"
|
|
98
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
99
|
-
viewBox="0 0 512 512"
|
|
100
|
-
>
|
|
88
|
+
<svg v-if="type === 'success'" class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
101
89
|
<path
|
|
102
90
|
d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"
|
|
103
91
|
/>
|
|
104
92
|
</svg>
|
|
105
93
|
|
|
106
94
|
<!-- https://fontawesome.com/icons/circle-exclamation?f=classic&s=solid -->
|
|
107
|
-
<svg
|
|
108
|
-
v-if="type === 'warning'"
|
|
109
|
-
class="icon"
|
|
110
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
111
|
-
viewBox="0 0 512 512"
|
|
112
|
-
>
|
|
95
|
+
<svg v-if="type === 'warning'" class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
113
96
|
<path
|
|
114
97
|
d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24V264c0 13.3-10.7 24-24 24s-24-10.7-24-24V152c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"
|
|
115
98
|
/>
|
|
116
99
|
</svg>
|
|
117
100
|
|
|
118
101
|
<!-- https://fontawesome.com/icons/triangle-exclamation?f=classic&s=solid -->
|
|
119
|
-
<svg
|
|
120
|
-
v-if="type === 'error'"
|
|
121
|
-
class="icon"
|
|
122
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
123
|
-
viewBox="0 0 512 512"
|
|
124
|
-
>
|
|
102
|
+
<svg v-if="type === 'error'" class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
125
103
|
<path
|
|
126
104
|
d="M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"
|
|
127
105
|
/>
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import { VCard } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { VCard } from '..';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
test(
|
|
5
|
+
describe('VCard', () => {
|
|
6
|
+
test('defaults', async () => {
|
|
7
7
|
const wrapper = mount(VCard);
|
|
8
8
|
expect(wrapper.props()).toEqual({
|
|
9
|
-
background:
|
|
9
|
+
background: 'bg-surface-200-700-token',
|
|
10
10
|
clickable: false,
|
|
11
11
|
hideSeparator: false,
|
|
12
|
-
text:
|
|
12
|
+
text: 'text-surface-900-50-token',
|
|
13
13
|
unstyled: false,
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
describe(
|
|
18
|
-
describe(
|
|
19
|
-
test(
|
|
17
|
+
describe('given the card is clicked', () => {
|
|
18
|
+
describe('given the card is not clickable', () => {
|
|
19
|
+
test('should not emit click', async () => {
|
|
20
20
|
const wrapper = mount(VCard, { props: { clickable: false } });
|
|
21
21
|
expect(wrapper.attributes()['tabindex']).toBeUndefined();
|
|
22
|
-
await wrapper.trigger(
|
|
23
|
-
expect(wrapper.emitted()[
|
|
22
|
+
await wrapper.trigger('click');
|
|
23
|
+
expect(wrapper.emitted()['click']).toBeUndefined();
|
|
24
24
|
|
|
25
|
-
await wrapper.trigger(
|
|
26
|
-
expect(wrapper.emitted()[
|
|
25
|
+
await wrapper.trigger('keydown', { key: 'Enter' });
|
|
26
|
+
expect(wrapper.emitted()['click']).toBeUndefined();
|
|
27
27
|
|
|
28
|
-
await wrapper.trigger(
|
|
29
|
-
expect(wrapper.emitted()[
|
|
28
|
+
await wrapper.trigger('keydown', { key: ' ' });
|
|
29
|
+
expect(wrapper.emitted()['click']).toBeUndefined();
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
-
describe(
|
|
33
|
-
test(
|
|
32
|
+
describe('given the card is clickable', () => {
|
|
33
|
+
test('should emit click', async () => {
|
|
34
34
|
const wrapper = mount(VCard, { props: { clickable: true } });
|
|
35
|
-
expect(wrapper.attributes()['tabindex']).toEqual(
|
|
36
|
-
await wrapper.trigger(
|
|
37
|
-
expect(wrapper.emitted()[
|
|
35
|
+
expect(wrapper.attributes()['tabindex']).toEqual('0');
|
|
36
|
+
await wrapper.trigger('click');
|
|
37
|
+
expect(wrapper.emitted()['click'].length).toEqual(1);
|
|
38
38
|
|
|
39
|
-
await wrapper.trigger(
|
|
40
|
-
expect(wrapper.emitted()[
|
|
39
|
+
await wrapper.trigger('keydown', { key: 'Enter' });
|
|
40
|
+
expect(wrapper.emitted()['click'].length).toEqual(2);
|
|
41
41
|
|
|
42
|
-
await wrapper.trigger(
|
|
43
|
-
expect(wrapper.emitted()[
|
|
42
|
+
await wrapper.trigger('keydown', { key: ' ' });
|
|
43
|
+
expect(wrapper.emitted()['click'].length).toEqual(3);
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
});
|