@code-coaching/vuetiful 0.20.0 → 0.21.1
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/styles/all.css +199 -1
- package/dist/types/components/molecules/VAlert.vue.d.ts +3 -3
- package/dist/types/components/molecules/VCard/VCard.test.d.ts +1 -0
- package/dist/types/components/molecules/VCard/VCard.vue.d.ts +52 -0
- package/dist/types/components/molecules/VCard/VCardBody.test.d.ts +1 -0
- package/dist/types/components/molecules/VCard/VCardBody.vue.d.ts +2 -0
- package/dist/types/components/molecules/VCard/VCardFooter.test.d.ts +1 -0
- package/dist/types/components/molecules/VCard/VCardFooter.vue.d.ts +2 -0
- package/dist/types/components/molecules/VCard/VCardHeader.test.d.ts +1 -0
- package/dist/types/components/molecules/VCard/VCardHeader.vue.d.ts +2 -0
- package/dist/types/components/molecules/index.d.ts +5 -1
- package/dist/vuetiful.es.mjs +254 -123
- package/dist/vuetiful.umd.js +9 -9
- package/package.json +1 -1
- package/src/components/molecules/VAlert.test.ts +10 -10
- package/src/components/molecules/VAlert.vue +2 -2
- package/src/components/molecules/VCard/VCard.test.ts +47 -0
- package/src/components/molecules/VCard/VCard.vue +71 -0
- package/src/components/molecules/VCard/VCardBody.test.ts +21 -0
- package/src/components/molecules/VCard/VCardBody.vue +5 -0
- package/src/components/molecules/VCard/VCardFooter.test.ts +45 -0
- package/src/components/molecules/VCard/VCardFooter.vue +11 -0
- package/src/components/molecules/VCard/VCardHeader.test.ts +68 -0
- package/src/components/molecules/VCard/VCardHeader.vue +33 -0
- package/src/components/molecules/index.ts +9 -0
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@ describe("VAlert", () => {
|
|
|
32
32
|
|
|
33
33
|
describe("given close icon is clicked", () => {
|
|
34
34
|
test("should emit close", async () => {
|
|
35
|
-
const wrapper = mount(VAlert);
|
|
35
|
+
const wrapper = mount(VAlert, { props: { showClose: true } });
|
|
36
36
|
await wrapper.find("[data-test=close]").trigger("click");
|
|
37
37
|
expect(wrapper.emitted()["close"][0]).toEqual([]);
|
|
38
38
|
|
|
@@ -53,7 +53,7 @@ describe("VAlert", () => {
|
|
|
53
53
|
});
|
|
54
54
|
expect(wrapper.text()).toContain("John Duck");
|
|
55
55
|
});
|
|
56
|
-
})
|
|
56
|
+
});
|
|
57
57
|
|
|
58
58
|
describe("given a actions slot is provided", () => {
|
|
59
59
|
test("should render the actions slot", () => {
|
|
@@ -64,7 +64,7 @@ describe("VAlert", () => {
|
|
|
64
64
|
});
|
|
65
65
|
expect(wrapper.text()).toContain("John Duck");
|
|
66
66
|
});
|
|
67
|
-
})
|
|
67
|
+
});
|
|
68
68
|
|
|
69
69
|
describe("given hide-icon prop is present", () => {
|
|
70
70
|
test("should not render an icon", () => {
|
|
@@ -73,18 +73,18 @@ describe("VAlert", () => {
|
|
|
73
73
|
hideIcon: true,
|
|
74
74
|
},
|
|
75
75
|
});
|
|
76
|
-
expect(wrapper.findAll(".icon").length).toBe(
|
|
76
|
+
expect(wrapper.findAll(".icon").length).toBe(0);
|
|
77
77
|
});
|
|
78
|
-
})
|
|
78
|
+
});
|
|
79
79
|
|
|
80
|
-
describe("given
|
|
81
|
-
test("should
|
|
80
|
+
describe("given show-close prop is present", () => {
|
|
81
|
+
test("should render a close icon", () => {
|
|
82
82
|
const wrapper = mount(VAlert, {
|
|
83
83
|
props: {
|
|
84
|
-
|
|
84
|
+
showClose: true,
|
|
85
85
|
},
|
|
86
86
|
});
|
|
87
|
-
expect(wrapper.find("[data-test=close]").exists()).toBe(
|
|
87
|
+
expect(wrapper.find("[data-test=close]").exists()).toBe(true);
|
|
88
88
|
});
|
|
89
|
-
})
|
|
89
|
+
});
|
|
90
90
|
});
|
|
@@ -7,7 +7,7 @@ const props = defineProps({
|
|
|
7
7
|
type: Boolean,
|
|
8
8
|
default: false,
|
|
9
9
|
},
|
|
10
|
-
|
|
10
|
+
showClose: {
|
|
11
11
|
type: Boolean,
|
|
12
12
|
default: false,
|
|
13
13
|
},
|
|
@@ -111,7 +111,7 @@ const handleKeydown = (event: KeyboardEvent) => {
|
|
|
111
111
|
<!-- https://fontawesome.com/icons/xmark?f=classic&s=solid -->
|
|
112
112
|
<svg
|
|
113
113
|
data-test="close"
|
|
114
|
-
v-if="
|
|
114
|
+
v-if="showClose"
|
|
115
115
|
tabindex="0"
|
|
116
116
|
@keydown="handleKeydown"
|
|
117
117
|
@click="close"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { VCard } from "..";
|
|
4
|
+
|
|
5
|
+
describe("VCard", () => {
|
|
6
|
+
test("defaults", async () => {
|
|
7
|
+
const wrapper = mount(VCard);
|
|
8
|
+
expect(wrapper.props()).toEqual({
|
|
9
|
+
background: "bg-surface-200-700-token",
|
|
10
|
+
clickable: false,
|
|
11
|
+
hideSeparator: false,
|
|
12
|
+
horizontal: false,
|
|
13
|
+
text: "text-surface-900-50-token",
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe("given the card is clicked", () => {
|
|
18
|
+
describe("given the card is not clickable", () => {
|
|
19
|
+
test("should not emit click", async () => {
|
|
20
|
+
const wrapper = mount(VCard, { props: { clickable: false } });
|
|
21
|
+
expect(wrapper.attributes()['tabindex']).toBeUndefined();
|
|
22
|
+
await wrapper.trigger("click");
|
|
23
|
+
expect(wrapper.emitted()["click"]).toBeUndefined();
|
|
24
|
+
|
|
25
|
+
await wrapper.trigger("keydown", { key: "Enter" });
|
|
26
|
+
expect(wrapper.emitted()["click"]).toBeUndefined();
|
|
27
|
+
|
|
28
|
+
await wrapper.trigger("keydown", { key: " " });
|
|
29
|
+
expect(wrapper.emitted()["click"]).toBeUndefined();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe("given the card is clickable", () => {
|
|
33
|
+
test("should emit click", async () => {
|
|
34
|
+
const wrapper = mount(VCard, { props: { clickable: true } });
|
|
35
|
+
expect(wrapper.attributes()['tabindex']).toEqual("0");
|
|
36
|
+
await wrapper.trigger("click");
|
|
37
|
+
expect(wrapper.emitted()["click"].length).toEqual(1);
|
|
38
|
+
|
|
39
|
+
await wrapper.trigger("keydown", { key: "Enter" });
|
|
40
|
+
expect(wrapper.emitted()["click"].length).toEqual(2);
|
|
41
|
+
|
|
42
|
+
await wrapper.trigger("keydown", { key: " " });
|
|
43
|
+
expect(wrapper.emitted()["click"].length).toEqual(3);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { provide } from "vue";
|
|
3
|
+
|
|
4
|
+
const emit = defineEmits(["click"]);
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
hideSeparator: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: false,
|
|
10
|
+
},
|
|
11
|
+
background: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: "bg-surface-200-700-token",
|
|
14
|
+
},
|
|
15
|
+
text: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: "text-surface-900-50-token",
|
|
18
|
+
},
|
|
19
|
+
horizontal: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false,
|
|
22
|
+
},
|
|
23
|
+
clickable: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
provide("hideSeparator", props.hideSeparator);
|
|
30
|
+
|
|
31
|
+
const onClick = () => {
|
|
32
|
+
if (!props.clickable) return;
|
|
33
|
+
emit("click");
|
|
34
|
+
};
|
|
35
|
+
const onKeydown = (event: KeyboardEvent) => {
|
|
36
|
+
if (!props.clickable) return;
|
|
37
|
+
if (event.key === "Enter") {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
emit("click");
|
|
40
|
+
}
|
|
41
|
+
if (event.key === " ") {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
emit("click");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<div
|
|
50
|
+
@click="onClick"
|
|
51
|
+
@keydown="onKeydown"
|
|
52
|
+
:tabindex="clickable ? 0 : undefined"
|
|
53
|
+
:class="`vuetiful-card flex border-token rounded-container-token ring-outline-token ${
|
|
54
|
+
horizontal ? 'flex-row' : 'flex-col'
|
|
55
|
+
} ${background} ${text} ${clickable ? 'card-hover hover:cursor-pointer' : ''}`"
|
|
56
|
+
>
|
|
57
|
+
<slot />
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<style>
|
|
62
|
+
.vuetiful-card-header {
|
|
63
|
+
border-top-left-radius: inherit;
|
|
64
|
+
border-top-right-radius: inherit;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.vuetiful-card-header > * {
|
|
68
|
+
border-top-left-radius: inherit;
|
|
69
|
+
border-top-right-radius: inherit;
|
|
70
|
+
}
|
|
71
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { VCard, VCardBody } from "..";
|
|
4
|
+
|
|
5
|
+
describe("VCardBody", () => {
|
|
6
|
+
test("defaults", async () => {
|
|
7
|
+
const wrapper = mount({
|
|
8
|
+
template: /*html*/ `
|
|
9
|
+
<v-card>
|
|
10
|
+
<v-card-body>John Duck</v-card-body>
|
|
11
|
+
</v-card>
|
|
12
|
+
`,
|
|
13
|
+
components: {
|
|
14
|
+
"v-card": VCard,
|
|
15
|
+
"v-card-body": VCardBody,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(wrapper.text()).toEqual("John Duck");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { VCard, VCardFooter } from "..";
|
|
4
|
+
|
|
5
|
+
describe("VCardFooter", () => {
|
|
6
|
+
test("defaults", async () => {
|
|
7
|
+
const wrapper = mount({
|
|
8
|
+
template: /*html*/ `
|
|
9
|
+
<v-card>
|
|
10
|
+
<v-card-footer>John Duck</v-card-footer>
|
|
11
|
+
</v-card>
|
|
12
|
+
`,
|
|
13
|
+
components: {
|
|
14
|
+
"v-card": VCard,
|
|
15
|
+
"v-card-footer": VCardFooter,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const separator = wrapper.find("[data-test='vuetiful-card-footer-separator']");
|
|
20
|
+
const content = wrapper.find("[data-test='vuetiful-card-footer-content']");
|
|
21
|
+
expect(separator.element.tagName).toEqual("HR");
|
|
22
|
+
expect(content.text()).toEqual("John Duck");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe("given hideSeparator is true", () => {
|
|
26
|
+
test("should not show separator", async () => {
|
|
27
|
+
const wrapper = mount({
|
|
28
|
+
template: /*html*/ `
|
|
29
|
+
<v-card hide-separator>
|
|
30
|
+
<v-card-footer>John Duck</v-card-footer>
|
|
31
|
+
</v-card>
|
|
32
|
+
`,
|
|
33
|
+
components: {
|
|
34
|
+
"v-card": VCard,
|
|
35
|
+
"v-card-footer": VCardFooter,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const separator = wrapper.find("[data-test='vuetiful-card-footer-separator']");
|
|
40
|
+
const content = wrapper.find("[data-test='vuetiful-card-footer-content']");
|
|
41
|
+
expect(separator.exists()).toEqual(false);
|
|
42
|
+
expect(content.text()).toEqual("John Duck");
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inject } from "vue";
|
|
3
|
+
const hideSeparator = inject("hideSeparator", false);
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<hr v-if="!hideSeparator" data-test="vuetiful-card-footer-separator" class="opacity-90" />
|
|
8
|
+
<div data-test="vuetiful-card-footer-content" class="vuetiful-card-footer p-4">
|
|
9
|
+
<slot />
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { VCard, VCardHeader } from "..";
|
|
4
|
+
|
|
5
|
+
describe("VCardHeader", () => {
|
|
6
|
+
test("defaults", async () => {
|
|
7
|
+
const wrapper = mount({
|
|
8
|
+
template: /*html*/ `
|
|
9
|
+
<v-card>
|
|
10
|
+
<v-card-header>John Duck</v-card-header>
|
|
11
|
+
</v-card>
|
|
12
|
+
`,
|
|
13
|
+
components: {
|
|
14
|
+
"v-card": VCard,
|
|
15
|
+
"v-card-header": VCardHeader,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const separator = wrapper.find("[data-test='vuetiful-card-header-separator']");
|
|
20
|
+
const content = wrapper.find("[data-test='vuetiful-card-header-content']");
|
|
21
|
+
expect(separator.element.tagName).toEqual("HR");
|
|
22
|
+
expect(content.text()).toEqual("John Duck");
|
|
23
|
+
expect(content.classes()).toContain("p-4");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("given hideSeparator is true", () => {
|
|
27
|
+
test("should not show separator", async () => {
|
|
28
|
+
const wrapper = mount({
|
|
29
|
+
template: /*html*/ `
|
|
30
|
+
<v-card hide-separator>
|
|
31
|
+
<v-card-header>John Duck</v-card-header>
|
|
32
|
+
</v-card>
|
|
33
|
+
`,
|
|
34
|
+
components: {
|
|
35
|
+
"v-card": VCard,
|
|
36
|
+
"v-card-header": VCardHeader,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const separator = wrapper.find("[data-test='vuetiful-card-header-separator']");
|
|
41
|
+
const content = wrapper.find("[data-test='vuetiful-card-header-content']");
|
|
42
|
+
expect(separator.exists()).toEqual(false);
|
|
43
|
+
expect(content.text()).toEqual("John Duck");
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("given an image is present", () => {
|
|
48
|
+
test("should not have padding", async () => {
|
|
49
|
+
const wrapper = mount({
|
|
50
|
+
template: /*html*/ `
|
|
51
|
+
<v-card>
|
|
52
|
+
<v-card-header>
|
|
53
|
+
<img src="fakeUrl" />
|
|
54
|
+
</v-card-header>
|
|
55
|
+
</v-card>
|
|
56
|
+
`,
|
|
57
|
+
components: {
|
|
58
|
+
"v-card": VCard,
|
|
59
|
+
"v-card-header": VCardHeader,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
await wrapper.vm.$nextTick();
|
|
63
|
+
|
|
64
|
+
const content = wrapper.find("[data-test='vuetiful-card-header-content']");
|
|
65
|
+
expect(content.classes()).not.toContain("p-4");
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Ref, computed, inject, ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
const headerRef = ref() as Ref<HTMLDivElement>;
|
|
5
|
+
|
|
6
|
+
const hasImageAsChild = computed(() => {
|
|
7
|
+
const children = headerRef.value?.children;
|
|
8
|
+
if (!children) return false;
|
|
9
|
+
const childrenArray = Array.from(children);
|
|
10
|
+
return childrenArray.some((child) => child.tagName === 'IMG');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const hideSeparator = inject('hideSeparator', false);
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div ref="headerRef" data-test='vuetiful-card-header-content' :class="`vuetiful-card-header ${hasImageAsChild ? '' : 'p-4'}`">
|
|
18
|
+
<slot />
|
|
19
|
+
</div>
|
|
20
|
+
<hr v-if="!hideSeparator" data-test='vuetiful-card-header-separator' class="opacity-90" />
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<style>
|
|
24
|
+
.vuetiful-card-header {
|
|
25
|
+
border-top-left-radius: inherit;
|
|
26
|
+
border-top-right-radius: inherit;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.vuetiful-card-header > * {
|
|
30
|
+
border-top-left-radius: inherit;
|
|
31
|
+
border-top-right-radius: inherit;
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
@@ -19,10 +19,19 @@ import VAccordionItem from "./VAccordion/VAccordionItem.vue";
|
|
|
19
19
|
|
|
20
20
|
import VAlert from "./VAlert.vue";
|
|
21
21
|
|
|
22
|
+
import VCard from "./VCard/VCard.vue";
|
|
23
|
+
import VCardBody from "./VCard/VCardBody.vue";
|
|
24
|
+
import VCardFooter from "./VCard/VCardFooter.vue";
|
|
25
|
+
import VCardHeader from "./VCard/VCardHeader.vue";
|
|
26
|
+
|
|
22
27
|
export {
|
|
23
28
|
VAccordion,
|
|
24
29
|
VAccordionItem,
|
|
25
30
|
VAlert,
|
|
31
|
+
VCard,
|
|
32
|
+
VCardBody,
|
|
33
|
+
VCardFooter,
|
|
34
|
+
VCardHeader,
|
|
26
35
|
VDrawer,
|
|
27
36
|
VListbox,
|
|
28
37
|
VListboxButton,
|