@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
package/src/assets/main.css
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
@font-face {
|
|
2
|
-
font-family:
|
|
3
|
-
src: url(
|
|
2
|
+
font-family: 'myfont';
|
|
3
|
+
src: url('fonts/myfont.woff');
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
[class^=
|
|
7
|
-
[class*=
|
|
8
|
-
font-family:
|
|
6
|
+
[class^='icon-'],
|
|
7
|
+
[class*=' icon-'] {
|
|
8
|
+
font-family: 'myfont' !important;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.icon-heart:before {
|
|
12
|
-
content:
|
|
12
|
+
content: '\e9da';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.global-example {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { Variant } from
|
|
3
|
-
import { PropType } from
|
|
2
|
+
import { Variant } from '@/types';
|
|
3
|
+
import { PropType } from 'vue';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* VBoostrap is a component that should not be used directly.
|
|
@@ -14,47 +14,47 @@ defineProps({
|
|
|
14
14
|
variant: {
|
|
15
15
|
// explicit string union because TypeScript type won't throw error if invalid value is passed
|
|
16
16
|
type: String as PropType<
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
17
|
+
| ''
|
|
18
|
+
| 'variant-filled'
|
|
19
|
+
| 'variant-filled-primary'
|
|
20
|
+
| 'variant-filled-secondary'
|
|
21
|
+
| 'variant-filled-tertiary'
|
|
22
|
+
| 'variant-filled-success'
|
|
23
|
+
| 'variant-filled-warning'
|
|
24
|
+
| 'variant-filled-error'
|
|
25
|
+
| 'variant-filled-surface'
|
|
26
|
+
| 'variant-ringed'
|
|
27
|
+
| 'variant-ringed-primary'
|
|
28
|
+
| 'variant-ringed-secondary'
|
|
29
|
+
| 'variant-ringed-tertiary'
|
|
30
|
+
| 'variant-ringed-success'
|
|
31
|
+
| 'variant-ringed-warning'
|
|
32
|
+
| 'variant-ringed-error'
|
|
33
|
+
| 'variant-ringed-surface'
|
|
34
|
+
| 'variant-ghost'
|
|
35
|
+
| 'variant-ghost-primary'
|
|
36
|
+
| 'variant-ghost-secondary'
|
|
37
|
+
| 'variant-ghost-tertiary'
|
|
38
|
+
| 'variant-ghost-success'
|
|
39
|
+
| 'variant-ghost-warning'
|
|
40
|
+
| 'variant-ghost-error'
|
|
41
|
+
| 'variant-ghost-surface'
|
|
42
|
+
| 'variant-soft'
|
|
43
|
+
| 'variant-soft-primary'
|
|
44
|
+
| 'variant-soft-secondary'
|
|
45
|
+
| 'variant-soft-tertiary'
|
|
46
|
+
| 'variant-soft-success'
|
|
47
|
+
| 'variant-soft-warning'
|
|
48
|
+
| 'variant-soft-error'
|
|
49
|
+
| 'variant-soft-surface'
|
|
50
|
+
| 'variant-glass'
|
|
51
|
+
| 'variant-glass-primary'
|
|
52
|
+
| 'variant-glass-secondary'
|
|
53
|
+
| 'variant-glass-tertiary'
|
|
54
|
+
| 'variant-glass-success'
|
|
55
|
+
| 'variant-glass-warning'
|
|
56
|
+
| 'variant-glass-error'
|
|
57
|
+
| 'variant-glass-surface'
|
|
58
58
|
>,
|
|
59
59
|
default: Variant.Filled,
|
|
60
60
|
},
|
|
@@ -1,175 +1,175 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import { VAvatar } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { VAvatar } from '.';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
test(
|
|
5
|
+
describe('VAvatar', () => {
|
|
6
|
+
test('defaults', () => {
|
|
7
7
|
const wrapper = mount(VAvatar);
|
|
8
8
|
|
|
9
|
-
expect(wrapper.classes()).toContain(
|
|
10
|
-
expect(wrapper.classes()).toContain(
|
|
11
|
-
expect(wrapper.classes()).toContain(
|
|
9
|
+
expect(wrapper.classes()).toContain('vuetiful-avatar');
|
|
10
|
+
expect(wrapper.classes()).toContain('w-16');
|
|
11
|
+
expect(wrapper.classes()).toContain('rounded-token');
|
|
12
12
|
|
|
13
|
-
const avatarText = wrapper.find(
|
|
13
|
+
const avatarText = wrapper.find('.vuetiful-avatar-text');
|
|
14
14
|
expect(avatarText.exists()).toBe(true);
|
|
15
|
-
expect(avatarText.text()).toBe(
|
|
16
|
-
expect(avatarText.classes()).toEqual([
|
|
15
|
+
expect(avatarText.text()).toBe('');
|
|
16
|
+
expect(avatarText.classes()).toEqual(['vuetiful-avatar-text', 'fill-white', 'dark:fill-black']);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
test(
|
|
19
|
+
test('custom variant', () => {
|
|
20
20
|
const wrapper = mount(VAvatar, {
|
|
21
21
|
props: {
|
|
22
|
-
variant:
|
|
22
|
+
variant: 'ghost',
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
const avatarText = wrapper.find(
|
|
27
|
-
expect(avatarText.classes()).toEqual([
|
|
26
|
+
const avatarText = wrapper.find('.vuetiful-avatar-text');
|
|
27
|
+
expect(avatarText.classes()).toEqual(['vuetiful-avatar-text', 'fill-black', 'dark:fill-white']);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
test(
|
|
30
|
+
test('variant with hyphen', () => {
|
|
31
31
|
const wrapper = mount(VAvatar, {
|
|
32
32
|
props: {
|
|
33
|
-
variant:
|
|
33
|
+
variant: 'filled-primary',
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
expect(wrapper.classes()).toContain(
|
|
38
|
-
})
|
|
37
|
+
expect(wrapper.classes()).toContain('variant-filled-primary');
|
|
38
|
+
});
|
|
39
39
|
|
|
40
|
-
test(
|
|
40
|
+
test('initials', () => {
|
|
41
41
|
const wrapper = mount(VAvatar, {
|
|
42
42
|
props: {
|
|
43
|
-
initials:
|
|
44
|
-
variant:
|
|
43
|
+
initials: 'JD',
|
|
44
|
+
variant: 'filled',
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
expect(wrapper.classes()).toContain(
|
|
49
|
-
expect(wrapper.classes()).toContain(
|
|
50
|
-
expect(wrapper.classes()).toContain(
|
|
48
|
+
expect(wrapper.classes()).toContain('vuetiful-avatar');
|
|
49
|
+
expect(wrapper.classes()).toContain('w-16');
|
|
50
|
+
expect(wrapper.classes()).toContain('rounded-token');
|
|
51
51
|
|
|
52
|
-
const avatarText = wrapper.find(
|
|
52
|
+
const avatarText = wrapper.find('.vuetiful-avatar-text');
|
|
53
53
|
expect(avatarText.exists()).toBe(true);
|
|
54
|
-
expect(avatarText.text()).toBe(
|
|
55
|
-
expect(avatarText.classes()).toEqual([
|
|
54
|
+
expect(avatarText.text()).toBe('JD');
|
|
55
|
+
expect(avatarText.classes()).toEqual(['vuetiful-avatar-text', 'fill-white', 'dark:fill-black']);
|
|
56
56
|
|
|
57
|
-
const avatarImage = wrapper.find(
|
|
57
|
+
const avatarImage = wrapper.find('.vuetiful-avatar-image');
|
|
58
58
|
expect(avatarImage.exists()).toBe(false);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
test(
|
|
61
|
+
test('initials fill', () => {
|
|
62
62
|
const wrapper = mount(VAvatar, {
|
|
63
63
|
props: {
|
|
64
|
-
initials:
|
|
65
|
-
fill:
|
|
64
|
+
initials: 'JD',
|
|
65
|
+
fill: 'custom-fill-class',
|
|
66
66
|
},
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
expect(wrapper.classes()).toContain(
|
|
70
|
-
expect(wrapper.classes()).toContain(
|
|
71
|
-
expect(wrapper.classes()).toContain(
|
|
69
|
+
expect(wrapper.classes()).toContain('vuetiful-avatar');
|
|
70
|
+
expect(wrapper.classes()).toContain('w-16');
|
|
71
|
+
expect(wrapper.classes()).toContain('rounded-token');
|
|
72
72
|
|
|
73
|
-
const avatarText = wrapper.find(
|
|
73
|
+
const avatarText = wrapper.find('.vuetiful-avatar-text');
|
|
74
74
|
expect(avatarText.exists()).toBe(true);
|
|
75
|
-
expect(avatarText.text()).toBe(
|
|
76
|
-
expect(avatarText.classes()).toContain(
|
|
75
|
+
expect(avatarText.text()).toBe('JD');
|
|
76
|
+
expect(avatarText.classes()).toContain('custom-fill-class');
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
test(
|
|
79
|
+
test('image', () => {
|
|
80
80
|
const wrapper = mount(VAvatar, {
|
|
81
81
|
props: {
|
|
82
|
-
src:
|
|
82
|
+
src: 'https://via.placeholder.com/150',
|
|
83
83
|
},
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
expect(wrapper.classes()).toContain(
|
|
87
|
-
expect(wrapper.classes()).toContain(
|
|
88
|
-
expect(wrapper.classes()).toContain(
|
|
86
|
+
expect(wrapper.classes()).toContain('vuetiful-avatar');
|
|
87
|
+
expect(wrapper.classes()).toContain('w-16');
|
|
88
|
+
expect(wrapper.classes()).toContain('rounded-token');
|
|
89
89
|
|
|
90
|
-
const avatarText = wrapper.find(
|
|
90
|
+
const avatarText = wrapper.find('.vuetiful-avatar-text');
|
|
91
91
|
expect(avatarText.exists()).toBe(false);
|
|
92
92
|
|
|
93
|
-
const avatarImage = wrapper.find(
|
|
93
|
+
const avatarImage = wrapper.find('.vuetiful-avatar-image');
|
|
94
94
|
expect(avatarImage.exists()).toBe(true);
|
|
95
|
-
expect(avatarImage.attributes(
|
|
95
|
+
expect(avatarImage.attributes('src')).toBe('https://via.placeholder.com/150');
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
test(
|
|
98
|
+
test('image fallback', async () => {
|
|
99
99
|
const wrapper = mount(VAvatar, {
|
|
100
100
|
props: {
|
|
101
|
-
src:
|
|
102
|
-
fallback:
|
|
101
|
+
src: 'https://via.placeholder.com/150',
|
|
102
|
+
fallback: '/image/john-duck.png',
|
|
103
103
|
},
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
expect(wrapper.classes()).toContain(
|
|
107
|
-
expect(wrapper.classes()).toContain(
|
|
108
|
-
expect(wrapper.classes()).toContain(
|
|
106
|
+
expect(wrapper.classes()).toContain('vuetiful-avatar');
|
|
107
|
+
expect(wrapper.classes()).toContain('w-16');
|
|
108
|
+
expect(wrapper.classes()).toContain('rounded-token');
|
|
109
109
|
|
|
110
|
-
const avatarText = wrapper.find(
|
|
110
|
+
const avatarText = wrapper.find('.vuetiful-avatar-text');
|
|
111
111
|
expect(avatarText.exists()).toBe(false);
|
|
112
112
|
|
|
113
|
-
const avatarImage = wrapper.find(
|
|
114
|
-
avatarImage.trigger(
|
|
113
|
+
const avatarImage = wrapper.find('.vuetiful-avatar-image');
|
|
114
|
+
avatarImage.trigger('error');
|
|
115
115
|
await wrapper.vm.$nextTick();
|
|
116
116
|
|
|
117
117
|
expect(avatarImage.exists()).toBe(true);
|
|
118
|
-
expect(avatarImage.attributes(
|
|
118
|
+
expect(avatarImage.attributes('src')).toBe('/image/john-duck.png');
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
test(
|
|
121
|
+
test('size xs', () => {
|
|
122
122
|
const wrapper = mount(VAvatar, {
|
|
123
123
|
props: {
|
|
124
|
-
size:
|
|
124
|
+
size: 'xs',
|
|
125
125
|
},
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
const avatar = wrapper.find("[data-test='avatar']");
|
|
129
|
-
expect(avatar.attributes(
|
|
129
|
+
expect(avatar.attributes('class')).toContain('w-8');
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
test(
|
|
132
|
+
test('size sm', () => {
|
|
133
133
|
const wrapper = mount(VAvatar, {
|
|
134
134
|
props: {
|
|
135
|
-
size:
|
|
135
|
+
size: 'sm',
|
|
136
136
|
},
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
const avatar = wrapper.find("[data-test='avatar']");
|
|
140
|
-
expect(avatar.attributes(
|
|
140
|
+
expect(avatar.attributes('class')).toContain('w-12');
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
test(
|
|
143
|
+
test('size md', () => {
|
|
144
144
|
const wrapper = mount(VAvatar, {
|
|
145
145
|
props: {
|
|
146
|
-
size:
|
|
146
|
+
size: 'md',
|
|
147
147
|
},
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
const avatar = wrapper.find("[data-test='avatar']");
|
|
151
|
-
expect(avatar.attributes(
|
|
151
|
+
expect(avatar.attributes('class')).toContain('w-16');
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
-
test(
|
|
154
|
+
test('size lg', () => {
|
|
155
155
|
const wrapper = mount(VAvatar, {
|
|
156
156
|
props: {
|
|
157
|
-
size:
|
|
157
|
+
size: 'lg',
|
|
158
158
|
},
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
const avatar = wrapper.find("[data-test='avatar']");
|
|
162
|
-
expect(avatar.attributes(
|
|
162
|
+
expect(avatar.attributes('class')).toContain('w-20');
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
-
test(
|
|
165
|
+
test('size xl', () => {
|
|
166
166
|
const wrapper = mount(VAvatar, {
|
|
167
167
|
props: {
|
|
168
|
-
size:
|
|
168
|
+
size: 'xl',
|
|
169
169
|
},
|
|
170
170
|
});
|
|
171
171
|
|
|
172
172
|
const avatar = wrapper.find("[data-test='avatar']");
|
|
173
|
-
expect(avatar.attributes(
|
|
173
|
+
expect(avatar.attributes('class')).toContain('w-24');
|
|
174
174
|
});
|
|
175
175
|
});
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { CssClasses, useSettings } from
|
|
3
|
-
import { sizeProp, unstyledProp, variantProp } from
|
|
4
|
-
import { Size } from
|
|
5
|
-
import { computed, ref } from
|
|
2
|
+
import { CssClasses, useSettings } from '@/index';
|
|
3
|
+
import { sizeProp, unstyledProp, variantProp } from '@/props';
|
|
4
|
+
import { Size } from '@/types';
|
|
5
|
+
import { computed, ref } from 'vue';
|
|
6
6
|
|
|
7
7
|
const props = defineProps({
|
|
8
8
|
// Initials
|
|
9
|
-
initials: { type: String, default:
|
|
10
|
-
fill: { type: String as () => CssClasses, default:
|
|
11
|
-
classInitials: { type: String, default:
|
|
9
|
+
initials: { type: String, default: '' },
|
|
10
|
+
fill: { type: String as () => CssClasses, default: '' },
|
|
11
|
+
classInitials: { type: String, default: '' },
|
|
12
12
|
|
|
13
13
|
// Image
|
|
14
|
-
src: { type: String, default:
|
|
15
|
-
alt: { type: String, default:
|
|
16
|
-
fallback: { type: String, default:
|
|
17
|
-
classImage: { type: String, default:
|
|
14
|
+
src: { type: String, default: '' },
|
|
15
|
+
alt: { type: String, default: '' },
|
|
16
|
+
fallback: { type: String, default: '' },
|
|
17
|
+
classImage: { type: String, default: '' },
|
|
18
18
|
|
|
19
19
|
size: sizeProp,
|
|
20
20
|
variant: variantProp,
|
|
@@ -26,32 +26,31 @@ const fillInitials = computed(() => {
|
|
|
26
26
|
if (props.fill) return props.fill;
|
|
27
27
|
|
|
28
28
|
const variantString = props.variant as string | undefined;
|
|
29
|
-
const type = variantString?.split(
|
|
30
|
-
if (variantString?.includes(
|
|
31
|
-
if (!type) return
|
|
32
|
-
return
|
|
29
|
+
const type = variantString?.split('-')[1];
|
|
30
|
+
if (variantString?.includes('filled')) {
|
|
31
|
+
if (!type) return 'fill-white dark:fill-black';
|
|
32
|
+
return 'fill-white';
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return 'fill-black dark:fill-white';
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
const avatarSize = computed(() => {
|
|
38
38
|
switch (props.size) {
|
|
39
39
|
case Size.XS:
|
|
40
|
-
return
|
|
40
|
+
return 'w-8';
|
|
41
41
|
case Size.SM:
|
|
42
|
-
return
|
|
42
|
+
return 'w-12';
|
|
43
43
|
case Size.MD:
|
|
44
|
-
return
|
|
44
|
+
return 'w-16';
|
|
45
45
|
case Size.LG:
|
|
46
|
-
return
|
|
46
|
+
return 'w-20';
|
|
47
47
|
case Size.XL:
|
|
48
|
-
return
|
|
48
|
+
return 'w-24';
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
const { settings } = useSettings();
|
|
53
|
-
const isUnstyled =
|
|
54
|
-
settings.global.unstyled || settings.components.avatar.unstyled || props.unstyled;
|
|
53
|
+
const isUnstyled = settings.global.unstyled || settings.components.avatar.unstyled || props.unstyled;
|
|
55
54
|
</script>
|
|
56
55
|
<template>
|
|
57
56
|
<figure
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { expect, test } from
|
|
3
|
-
import { VBadge } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { expect, test } from 'vitest';
|
|
3
|
+
import { VBadge } from '.';
|
|
4
4
|
|
|
5
|
-
test(
|
|
5
|
+
test('VBadge', () => {
|
|
6
6
|
expect(VBadge).toBeTruthy();
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
test(
|
|
9
|
+
test('VBadge using slot', () => {
|
|
10
10
|
const wrapper = mount(VBadge, {
|
|
11
11
|
slots: {
|
|
12
|
-
default:
|
|
12
|
+
default: 'John Duck',
|
|
13
13
|
},
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
expect(wrapper.text()).toContain(
|
|
17
|
-
expect(wrapper.classes()).toContain(
|
|
16
|
+
expect(wrapper.text()).toContain('John Duck');
|
|
17
|
+
expect(wrapper.classes()).toContain('badge');
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
test(
|
|
20
|
+
test('VBadge unstyled', () => {
|
|
21
21
|
const wrapper = mount(VBadge, {
|
|
22
22
|
props: {
|
|
23
23
|
unstyled: true,
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
expect(wrapper.classes()).not.toContain(
|
|
28
|
-
})
|
|
27
|
+
expect(wrapper.classes()).not.toContain('badge');
|
|
28
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
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
6
|
variant: variantProp,
|