@code-coaching/vuetiful 0.23.1 → 0.24.0
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 +7 -3
- 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 +13 -13
- package/dist/types/services/drawer.service.d.ts +1 -1
- package/dist/types/services/index.d.ts +6 -6
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/utils/colors/colors.service.d.ts +69 -0
- package/dist/types/utils/index.d.ts +7 -3
- package/dist/types/utils/theme/theme-switcher.vue.d.ts +1 -1
- package/dist/types/utils/theme/theme.service.d.ts +9 -24
- package/dist/types/utils/theme/themes.d.ts +35 -0
- package/dist/vuetiful.es.mjs +456 -161
- package/dist/vuetiful.umd.js +71 -16
- 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 +63 -14
- package/src/components/atoms/VLightSwitch.vue +35 -46
- 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.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 +69 -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.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 +64 -194
- package/src/services/dark-mode.service.ts +35 -54
- 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 +6 -6
- 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/colors/colors.service.ts +293 -0
- package/src/utils/index.ts +7 -3
- 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 +11 -7
- package/src/utils/theme/remove.test.ts +11 -9
- package/src/utils/theme/theme-switcher.vue +43 -49
- package/src/utils/theme/theme.service.test.ts +194 -84
- package/src/utils/theme/theme.service.ts +141 -81
- package/src/utils/theme/themes.ts +122 -0
- package/dist/types/components/index.test.d.ts +0 -1
- package/dist/types/index.test.d.ts +0 -1
- package/dist/types/utils/index.test.d.ts +0 -1
- package/src/components/index.test.ts +0 -10
- package/src/index.test.ts +0 -26
- package/src/utils/index.test.ts +0 -11
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useSettings } from
|
|
3
|
-
import { unstyledProp } from
|
|
4
|
-
import { provide } from
|
|
2
|
+
import { useSettings } from '@/index';
|
|
3
|
+
import { unstyledProp } from '@/props';
|
|
4
|
+
import { provide } from 'vue';
|
|
5
5
|
|
|
6
|
-
const emit = defineEmits([
|
|
6
|
+
const emit = defineEmits(['click']);
|
|
7
7
|
|
|
8
8
|
const props = defineProps({
|
|
9
9
|
hideSeparator: {
|
|
@@ -12,11 +12,11 @@ const props = defineProps({
|
|
|
12
12
|
},
|
|
13
13
|
background: {
|
|
14
14
|
type: String,
|
|
15
|
-
default:
|
|
15
|
+
default: 'bg-surface-200-700-token',
|
|
16
16
|
},
|
|
17
17
|
text: {
|
|
18
18
|
type: String,
|
|
19
|
-
default:
|
|
19
|
+
default: 'text-surface-900-50-token',
|
|
20
20
|
},
|
|
21
21
|
clickable: {
|
|
22
22
|
type: Boolean,
|
|
@@ -26,21 +26,21 @@ const props = defineProps({
|
|
|
26
26
|
unstyled: unstyledProp,
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
provide(
|
|
29
|
+
provide('hideSeparator', props.hideSeparator);
|
|
30
30
|
|
|
31
31
|
const onClick = () => {
|
|
32
32
|
if (!props.clickable) return;
|
|
33
|
-
emit(
|
|
33
|
+
emit('click');
|
|
34
34
|
};
|
|
35
35
|
const onKeydown = (event: KeyboardEvent) => {
|
|
36
36
|
if (!props.clickable) return;
|
|
37
|
-
if (event.key ===
|
|
37
|
+
if (event.key === 'Enter') {
|
|
38
38
|
event.preventDefault();
|
|
39
|
-
emit(
|
|
39
|
+
emit('click');
|
|
40
40
|
}
|
|
41
|
-
if (event.key ===
|
|
41
|
+
if (event.key === ' ') {
|
|
42
42
|
event.preventDefault();
|
|
43
|
-
emit(
|
|
43
|
+
emit('click');
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -55,9 +55,7 @@ const isUnstyled = settings.global.unstyled || settings.components.card.unstyled
|
|
|
55
55
|
:tabindex="clickable ? 0 : undefined"
|
|
56
56
|
:class="`vuetiful-card flex flex-col ${
|
|
57
57
|
isUnstyled ? '' : 'border-token rounded-container-token ring-outline-token'
|
|
58
|
-
} ${background} ${text} ${
|
|
59
|
-
clickable ? `${isUnstyled ? '' : 'card-hover'} hover:cursor-pointer` : ''
|
|
60
|
-
}`"
|
|
58
|
+
} ${background} ${text} ${clickable ? `${isUnstyled ? '' : 'card-hover'} hover:cursor-pointer` : ''}`"
|
|
61
59
|
>
|
|
62
60
|
<slot />
|
|
63
61
|
</div>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import { VCard, VCardBody } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { VCard, VCardBody } from '..';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
test(
|
|
5
|
+
describe('VCardBody', () => {
|
|
6
|
+
test('unstyled', () => {
|
|
7
7
|
const wrapper = mount({
|
|
8
8
|
template: /*html*/ `
|
|
9
9
|
<v-card>
|
|
@@ -11,17 +11,17 @@ describe("VCardBody", () => {
|
|
|
11
11
|
</v-card>
|
|
12
12
|
`,
|
|
13
13
|
components: {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
'v-card': VCard,
|
|
15
|
+
'v-card-body': VCardBody,
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const content = wrapper.find("[data-test='vuetiful-card-body-content']");
|
|
20
|
-
expect(content.text()).toEqual(
|
|
21
|
-
expect(content.classes()).not.toContain(
|
|
20
|
+
expect(content.text()).toEqual('John Duck');
|
|
21
|
+
expect(content.classes()).not.toContain('p-4');
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
test(
|
|
24
|
+
test('defaults', async () => {
|
|
25
25
|
const wrapper = mount({
|
|
26
26
|
template: /*html*/ `
|
|
27
27
|
<v-card>
|
|
@@ -29,11 +29,11 @@ describe("VCardBody", () => {
|
|
|
29
29
|
</v-card>
|
|
30
30
|
`,
|
|
31
31
|
components: {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
'v-card': VCard,
|
|
33
|
+
'v-card-body': VCardBody,
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
expect(wrapper.text()).toEqual(
|
|
37
|
+
expect(wrapper.text()).toEqual('John Duck');
|
|
38
38
|
});
|
|
39
|
-
});
|
|
39
|
+
});
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { unstyledProp } from
|
|
3
|
-
import { useSettings } from
|
|
2
|
+
import { unstyledProp } from '@/props';
|
|
3
|
+
import { useSettings } from '@/services';
|
|
4
4
|
|
|
5
5
|
const props = defineProps({
|
|
6
6
|
unstyled: unstyledProp,
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
const { settings } = useSettings();
|
|
10
|
-
const isUnstyled =
|
|
11
|
-
settings.global.unstyled || settings.components.cardBody.unstyled || props.unstyled;
|
|
10
|
+
const isUnstyled = settings.global.unstyled || settings.components.cardBody.unstyled || props.unstyled;
|
|
12
11
|
</script>
|
|
13
12
|
<template>
|
|
14
|
-
<div
|
|
15
|
-
data-test="vuetiful-card-body-content"
|
|
16
|
-
:class="`vuetiful-card-body ${isUnstyled ? '' : 'p-4'}`"
|
|
17
|
-
>
|
|
13
|
+
<div data-test="vuetiful-card-body-content" :class="`vuetiful-card-body ${isUnstyled ? '' : 'p-4'}`">
|
|
18
14
|
<slot />
|
|
19
15
|
</div>
|
|
20
16
|
</template>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import { VCard, VCardFooter } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { VCard, VCardFooter } from '..';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
test(
|
|
5
|
+
describe('VCardFooter', () => {
|
|
6
|
+
test('unstyled', () => {
|
|
7
7
|
const wrapper = mount({
|
|
8
8
|
template: /*html*/ `
|
|
9
9
|
<v-card>
|
|
@@ -11,17 +11,17 @@ describe("VCardFooter", () => {
|
|
|
11
11
|
</v-card>
|
|
12
12
|
`,
|
|
13
13
|
components: {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
'v-card': VCard,
|
|
15
|
+
'v-card-footer': VCardFooter,
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const content = wrapper.find("[data-test='vuetiful-card-footer-content']");
|
|
20
|
-
expect(content.text()).toEqual(
|
|
21
|
-
expect(content.classes()).not.toContain(
|
|
20
|
+
expect(content.text()).toEqual('John Duck');
|
|
21
|
+
expect(content.classes()).not.toContain('p-4');
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
test(
|
|
24
|
+
test('defaults', async () => {
|
|
25
25
|
const wrapper = mount({
|
|
26
26
|
template: /*html*/ `
|
|
27
27
|
<v-card>
|
|
@@ -29,19 +29,19 @@ describe("VCardFooter", () => {
|
|
|
29
29
|
</v-card>
|
|
30
30
|
`,
|
|
31
31
|
components: {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
'v-card': VCard,
|
|
33
|
+
'v-card-footer': VCardFooter,
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
const separator = wrapper.find("[data-test='vuetiful-card-footer-separator']");
|
|
38
38
|
const content = wrapper.find("[data-test='vuetiful-card-footer-content']");
|
|
39
|
-
expect(separator.element.tagName).toEqual(
|
|
40
|
-
expect(content.text()).toEqual(
|
|
39
|
+
expect(separator.element.tagName).toEqual('HR');
|
|
40
|
+
expect(content.text()).toEqual('John Duck');
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
describe(
|
|
44
|
-
test(
|
|
43
|
+
describe('given hideSeparator is true', () => {
|
|
44
|
+
test('should not show separator', async () => {
|
|
45
45
|
const wrapper = mount({
|
|
46
46
|
template: /*html*/ `
|
|
47
47
|
<v-card hide-separator>
|
|
@@ -49,15 +49,15 @@ describe("VCardFooter", () => {
|
|
|
49
49
|
</v-card>
|
|
50
50
|
`,
|
|
51
51
|
components: {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
'v-card': VCard,
|
|
53
|
+
'v-card-footer': VCardFooter,
|
|
54
54
|
},
|
|
55
55
|
});
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
const separator = wrapper.find("[data-test='vuetiful-card-footer-separator']");
|
|
58
58
|
const content = wrapper.find("[data-test='vuetiful-card-footer-content']");
|
|
59
59
|
expect(separator.exists()).toEqual(false);
|
|
60
|
-
expect(content.text()).toEqual(
|
|
61
|
-
})
|
|
62
|
-
})
|
|
60
|
+
expect(content.text()).toEqual('John Duck');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
63
|
});
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { inject, useAttrs } from
|
|
3
|
-
import { unstyledProp } from
|
|
4
|
-
import { useSettings } from
|
|
2
|
+
import { inject, useAttrs } from 'vue';
|
|
3
|
+
import { unstyledProp } from '@/props';
|
|
4
|
+
import { useSettings } from '@/services';
|
|
5
5
|
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
classSeparator: {
|
|
8
8
|
type: String as () => string,
|
|
9
|
-
default:
|
|
9
|
+
default: 'opacity-90',
|
|
10
10
|
},
|
|
11
11
|
unstyled: unstyledProp,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
const hideSeparator = inject(
|
|
14
|
+
const hideSeparator = inject('hideSeparator', false);
|
|
15
15
|
|
|
16
16
|
const attrs = useAttrs();
|
|
17
17
|
const classAttribute = attrs.class as string;
|
|
18
18
|
|
|
19
19
|
const { settings } = useSettings();
|
|
20
|
-
const isUnstyled =
|
|
21
|
-
settings.global.unstyled || settings.components.cardBody.unstyled || props.unstyled;
|
|
20
|
+
const isUnstyled = settings.global.unstyled || settings.components.cardBody.unstyled || props.unstyled;
|
|
22
21
|
</script>
|
|
23
22
|
|
|
24
23
|
<template>
|
|
25
24
|
<hr v-if="!hideSeparator" data-test="vuetiful-card-footer-separator" class="divider" :class="classSeparator" />
|
|
26
|
-
<div
|
|
25
|
+
<div
|
|
26
|
+
data-test="vuetiful-card-footer-content"
|
|
27
|
+
:class="`vuetiful-card-footer ${isUnstyled ? '' : 'p-4'} ${classAttribute}`"
|
|
28
|
+
>
|
|
27
29
|
<slot />
|
|
28
30
|
</div>
|
|
29
31
|
</template>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import { VCard, VCardHeader } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { VCard, VCardHeader } from '..';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
test(
|
|
5
|
+
describe('VCardHeader', () => {
|
|
6
|
+
test('unstyled', () => {
|
|
7
7
|
const wrapper = mount({
|
|
8
8
|
template: /*html*/ `
|
|
9
9
|
<v-card>
|
|
@@ -11,17 +11,17 @@ describe("VCardHeader", () => {
|
|
|
11
11
|
</v-card>
|
|
12
12
|
`,
|
|
13
13
|
components: {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
'v-card': VCard,
|
|
15
|
+
'v-card-header': VCardHeader,
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const content = wrapper.find("[data-test='vuetiful-card-header-content']");
|
|
20
|
-
expect(content.text()).toEqual(
|
|
21
|
-
expect(content.classes()).not.toContain(
|
|
20
|
+
expect(content.text()).toEqual('John Duck');
|
|
21
|
+
expect(content.classes()).not.toContain('p-4');
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
test(
|
|
24
|
+
test('defaults', async () => {
|
|
25
25
|
const wrapper = mount({
|
|
26
26
|
template: /*html*/ `
|
|
27
27
|
<v-card>
|
|
@@ -29,20 +29,20 @@ describe("VCardHeader", () => {
|
|
|
29
29
|
</v-card>
|
|
30
30
|
`,
|
|
31
31
|
components: {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
'v-card': VCard,
|
|
33
|
+
'v-card-header': VCardHeader,
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
const separator = wrapper.find("[data-test='vuetiful-card-header-separator']");
|
|
38
38
|
const content = wrapper.find("[data-test='vuetiful-card-header-content']");
|
|
39
|
-
expect(separator.element.tagName).toEqual(
|
|
40
|
-
expect(content.text()).toEqual(
|
|
41
|
-
expect(content.classes()).toContain(
|
|
39
|
+
expect(separator.element.tagName).toEqual('HR');
|
|
40
|
+
expect(content.text()).toEqual('John Duck');
|
|
41
|
+
expect(content.classes()).toContain('p-4');
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
describe(
|
|
45
|
-
test(
|
|
44
|
+
describe('given hideSeparator is true', () => {
|
|
45
|
+
test('should not show separator', async () => {
|
|
46
46
|
const wrapper = mount({
|
|
47
47
|
template: /*html*/ `
|
|
48
48
|
<v-card hide-separator>
|
|
@@ -50,20 +50,20 @@ describe("VCardHeader", () => {
|
|
|
50
50
|
</v-card>
|
|
51
51
|
`,
|
|
52
52
|
components: {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
'v-card': VCard,
|
|
54
|
+
'v-card-header': VCardHeader,
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
const separator = wrapper.find("[data-test='vuetiful-card-header-separator']");
|
|
59
59
|
const content = wrapper.find("[data-test='vuetiful-card-header-content']");
|
|
60
60
|
expect(separator.exists()).toEqual(false);
|
|
61
|
-
expect(content.text()).toEqual(
|
|
61
|
+
expect(content.text()).toEqual('John Duck');
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
describe(
|
|
66
|
-
test(
|
|
65
|
+
describe('given an image is present', () => {
|
|
66
|
+
test('should not have padding', async () => {
|
|
67
67
|
const wrapper = mount({
|
|
68
68
|
template: /*html*/ `
|
|
69
69
|
<v-card>
|
|
@@ -73,14 +73,14 @@ describe("VCardHeader", () => {
|
|
|
73
73
|
</v-card>
|
|
74
74
|
`,
|
|
75
75
|
components: {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
'v-card': VCard,
|
|
77
|
+
'v-card-header': VCardHeader,
|
|
78
78
|
},
|
|
79
79
|
});
|
|
80
80
|
await wrapper.vm.$nextTick();
|
|
81
81
|
|
|
82
82
|
const content = wrapper.find("[data-test='vuetiful-card-header-content']");
|
|
83
|
-
expect(content.classes()).not.toContain(
|
|
83
|
+
expect(content.classes()).not.toContain('p-4');
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { unstyledProp } from
|
|
3
|
-
import { useSettings } from
|
|
4
|
-
import { Ref, computed, inject, ref, useAttrs } from
|
|
2
|
+
import { unstyledProp } from '@/props';
|
|
3
|
+
import { useSettings } from '@/services';
|
|
4
|
+
import { Ref, computed, inject, ref, useAttrs } from 'vue';
|
|
5
5
|
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
classSeparator: {
|
|
8
8
|
type: String as () => string,
|
|
9
|
-
default:
|
|
9
|
+
default: 'opacity-90',
|
|
10
10
|
},
|
|
11
11
|
unstyled: unstyledProp,
|
|
12
12
|
});
|
|
@@ -17,17 +17,16 @@ const hasImageAsChild = computed(() => {
|
|
|
17
17
|
const children = headerRef.value?.children;
|
|
18
18
|
if (!children) return false;
|
|
19
19
|
const childrenArray = Array.from(children);
|
|
20
|
-
return childrenArray.some((child) => child.tagName ===
|
|
20
|
+
return childrenArray.some((child) => child.tagName === 'IMG');
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const hideSeparator = inject(
|
|
23
|
+
const hideSeparator = inject('hideSeparator', false);
|
|
24
24
|
|
|
25
25
|
const attrs = useAttrs();
|
|
26
26
|
const classAttribute = attrs.class as string;
|
|
27
27
|
|
|
28
28
|
const { settings } = useSettings();
|
|
29
|
-
const isUnstyled =
|
|
30
|
-
settings.global.unstyled || settings.components.cardHeader.unstyled || props.unstyled;
|
|
29
|
+
const isUnstyled = settings.global.unstyled || settings.components.cardHeader.unstyled || props.unstyled;
|
|
31
30
|
</script>
|
|
32
31
|
|
|
33
32
|
<template>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test, vi } from
|
|
3
|
-
import { VCodeBlock } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
3
|
+
import { VCodeBlock } from '../..';
|
|
4
4
|
|
|
5
5
|
const clipboardMock = {
|
|
6
6
|
writeText: vi.fn(),
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
Object.defineProperty(window.navigator,
|
|
9
|
+
Object.defineProperty(window.navigator, 'clipboard', {
|
|
10
10
|
value: clipboardMock,
|
|
11
11
|
writable: true,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
describe(
|
|
15
|
-
test(
|
|
14
|
+
describe('VCodeBlock', () => {
|
|
15
|
+
test('copy button copies code to clipboard', async () => {
|
|
16
16
|
const mockClipboardDirective = {
|
|
17
17
|
mounted(el: HTMLElement, binding: any) {
|
|
18
|
-
el.addEventListener(
|
|
18
|
+
el.addEventListener('click', () => {
|
|
19
19
|
el.dataset.copied = binding.value;
|
|
20
20
|
});
|
|
21
21
|
},
|
|
@@ -23,7 +23,7 @@ describe("VCodeBlock", () => {
|
|
|
23
23
|
|
|
24
24
|
const wrapper = mount(VCodeBlock, {
|
|
25
25
|
props: {
|
|
26
|
-
code:
|
|
26
|
+
code: 'John Duck',
|
|
27
27
|
},
|
|
28
28
|
global: {
|
|
29
29
|
directives: {
|
|
@@ -32,32 +32,32 @@ describe("VCodeBlock", () => {
|
|
|
32
32
|
},
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
await wrapper.find(
|
|
35
|
+
await wrapper.find('.vuetiful-code-block-button').trigger('click');
|
|
36
36
|
|
|
37
|
-
expect(clipboardMock.writeText).toHaveBeenCalledWith(
|
|
37
|
+
expect(clipboardMock.writeText).toHaveBeenCalledWith('John Duck');
|
|
38
38
|
|
|
39
39
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
40
40
|
|
|
41
|
-
expect(wrapper.emitted(
|
|
41
|
+
expect(wrapper.emitted('copy')).toBeTruthy();
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
test(
|
|
44
|
+
test('renders the component with default props', () => {
|
|
45
45
|
const wrapper = mount(VCodeBlock);
|
|
46
46
|
expect(wrapper.exists()).toBe(true);
|
|
47
|
-
expect(wrapper.text()).toContain(
|
|
48
|
-
expect(wrapper.find(
|
|
49
|
-
expect(wrapper.find(
|
|
47
|
+
expect(wrapper.text()).toContain('Copy');
|
|
48
|
+
expect(wrapper.find('.vuetiful-code-block-language').text()).toBe('plaintext');
|
|
49
|
+
expect(wrapper.find('.vuetiful-code-block-code').classes()).toContain('language-plaintext');
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
test(
|
|
52
|
+
test('renders the component with custom props', () => {
|
|
53
53
|
const customProps = {
|
|
54
|
-
language:
|
|
55
|
-
code:
|
|
56
|
-
buttonText:
|
|
57
|
-
buttonCopiedText:
|
|
58
|
-
classButton:
|
|
59
|
-
classLanguage:
|
|
60
|
-
classCode:
|
|
54
|
+
language: 'javascript',
|
|
55
|
+
code: 'const x = 10;',
|
|
56
|
+
buttonText: 'Copy Code',
|
|
57
|
+
buttonCopiedText: 'Copied!',
|
|
58
|
+
classButton: 'custom-button-class',
|
|
59
|
+
classLanguage: 'custom-language-class',
|
|
60
|
+
classCode: 'custom-code-class',
|
|
61
61
|
preventOverflow: true,
|
|
62
62
|
};
|
|
63
63
|
|
|
@@ -65,69 +65,69 @@ describe("VCodeBlock", () => {
|
|
|
65
65
|
props: customProps,
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
expect(wrapper.find(
|
|
69
|
-
expect(wrapper.find(
|
|
70
|
-
expect(wrapper.find(
|
|
71
|
-
expect(wrapper.find(
|
|
68
|
+
expect(wrapper.find('.vuetiful-code-block-button').text()).toContain('Copy Code');
|
|
69
|
+
expect(wrapper.find('.vuetiful-code-block-language').text()).toBe('javascript');
|
|
70
|
+
expect(wrapper.find('.vuetiful-code-block-code').classes()).toContain('language-javascript');
|
|
71
|
+
expect(wrapper.find('.vuetiful-code-block-pre').classes()).toContain('whitespace-pre-wrap');
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
test(
|
|
74
|
+
test('renders the component with custom props', () => {
|
|
75
75
|
const customProps = {
|
|
76
|
-
language:
|
|
77
|
-
code:
|
|
78
|
-
buttonText:
|
|
79
|
-
buttonCopiedText:
|
|
80
|
-
classButton:
|
|
81
|
-
classLanguage:
|
|
82
|
-
classCode:
|
|
76
|
+
language: 'js',
|
|
77
|
+
code: 'const x = 10;',
|
|
78
|
+
buttonText: 'Copy Code',
|
|
79
|
+
buttonCopiedText: 'Copied!',
|
|
80
|
+
classButton: 'custom-button-class',
|
|
81
|
+
classLanguage: 'custom-language-class',
|
|
82
|
+
classCode: 'custom-code-class',
|
|
83
83
|
preventOverflow: true,
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
const wrapper = mount(VCodeBlock, { props: customProps });
|
|
87
87
|
|
|
88
|
-
expect(wrapper.find(
|
|
89
|
-
expect(wrapper.find(
|
|
90
|
-
expect(wrapper.find(
|
|
91
|
-
expect(wrapper.find(
|
|
88
|
+
expect(wrapper.find('.vuetiful-code-block-button').text()).toContain('Copy Code');
|
|
89
|
+
expect(wrapper.find('.vuetiful-code-block-language').text()).toBe('javascript');
|
|
90
|
+
expect(wrapper.find('.vuetiful-code-block-code').classes()).toContain('language-js');
|
|
91
|
+
expect(wrapper.find('.vuetiful-code-block-pre').classes()).toContain('whitespace-pre-wrap');
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
test(
|
|
94
|
+
test('renders the component with custom props', () => {
|
|
95
95
|
const customProps = {
|
|
96
|
-
language:
|
|
97
|
-
code:
|
|
98
|
-
buttonText:
|
|
99
|
-
buttonCopiedText:
|
|
100
|
-
classButton:
|
|
101
|
-
classLanguage:
|
|
102
|
-
classCode:
|
|
96
|
+
language: 'ts',
|
|
97
|
+
code: 'const x = 10;',
|
|
98
|
+
buttonText: 'Copy Code',
|
|
99
|
+
buttonCopiedText: 'Copied!',
|
|
100
|
+
classButton: 'custom-button-class',
|
|
101
|
+
classLanguage: 'custom-language-class',
|
|
102
|
+
classCode: 'custom-code-class',
|
|
103
103
|
preventOverflow: true,
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
const wrapper = mount(VCodeBlock, { props: customProps });
|
|
107
107
|
|
|
108
|
-
expect(wrapper.find(
|
|
109
|
-
expect(wrapper.find(
|
|
110
|
-
expect(wrapper.find(
|
|
111
|
-
expect(wrapper.find(
|
|
108
|
+
expect(wrapper.find('.vuetiful-code-block-button').text()).toContain('Copy Code');
|
|
109
|
+
expect(wrapper.find('.vuetiful-code-block-language').text()).toBe('typescript');
|
|
110
|
+
expect(wrapper.find('.vuetiful-code-block-code').classes()).toContain('language-ts');
|
|
111
|
+
expect(wrapper.find('.vuetiful-code-block-pre').classes()).toContain('whitespace-pre-wrap');
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
test(
|
|
114
|
+
test('renders the component with custom props', () => {
|
|
115
115
|
const customProps = {
|
|
116
|
-
language:
|
|
117
|
-
code:
|
|
118
|
-
buttonText:
|
|
119
|
-
buttonCopiedText:
|
|
120
|
-
classButton:
|
|
121
|
-
classLanguage:
|
|
122
|
-
classCode:
|
|
116
|
+
language: 'sh',
|
|
117
|
+
code: 'const x = 10;',
|
|
118
|
+
buttonText: 'Copy Code',
|
|
119
|
+
buttonCopiedText: 'Copied!',
|
|
120
|
+
classButton: 'custom-button-class',
|
|
121
|
+
classLanguage: 'custom-language-class',
|
|
122
|
+
classCode: 'custom-code-class',
|
|
123
123
|
preventOverflow: true,
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
const wrapper = mount(VCodeBlock, { props: customProps });
|
|
127
127
|
|
|
128
|
-
expect(wrapper.find(
|
|
129
|
-
expect(wrapper.find(
|
|
130
|
-
expect(wrapper.find(
|
|
131
|
-
expect(wrapper.find(
|
|
128
|
+
expect(wrapper.find('.vuetiful-code-block-button').text()).toContain('Copy Code');
|
|
129
|
+
expect(wrapper.find('.vuetiful-code-block-language').text()).toBe('console');
|
|
130
|
+
expect(wrapper.find('.vuetiful-code-block-code').classes()).toContain('language-sh');
|
|
131
|
+
expect(wrapper.find('.vuetiful-code-block-pre').classes()).toContain('whitespace-pre-wrap');
|
|
132
132
|
});
|
|
133
133
|
});
|