@kiva/kv-components 3.7.1 → 3.9.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/CHANGELOG.md CHANGED
@@ -3,6 +3,35 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.9.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.8.0...@kiva/kv-components@3.9.0) (2022-10-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * removed extra space on line 23 ([c8a3226](https://github.com/kiva/kv-ui-elements/commit/c8a32264ede0b628f578b98c4ac8256a539fd28d))
12
+
13
+
14
+ ### Features
15
+
16
+ * fixed bugs in KvExpandableQuestion (arrow functionality and slot content rendering) ([4ab9f47](https://github.com/kiva/kv-ui-elements/commit/4ab9f477200d53b89ce6a4ae0328215268dd4019))
17
+
18
+
19
+
20
+
21
+
22
+ # [3.8.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.7.1...@kiva/kv-components@3.8.0) (2022-10-04)
23
+
24
+
25
+ ### Features
26
+
27
+ * created and implemented a reusable global component and story (KvExpandableQuestion)[VUE-1318] ([173ae50](https://github.com/kiva/kv-ui-elements/commit/173ae50e88dffa7dabb7392404ccdb813307ea31))
28
+ * removed analyticsCategory prop, edited other code blocks ([2864261](https://github.com/kiva/kv-ui-elements/commit/2864261b55517bab8099b84b404d09aaae37b489))
29
+ * removed line 84, and converted faq into a string ([8f5a3da](https://github.com/kiva/kv-ui-elements/commit/8f5a3dab81556997a6eb7dd0e5dffac2babff104))
30
+
31
+
32
+
33
+
34
+
6
35
  ## [3.7.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.7.0...@kiva/kv-components@3.7.1) (2022-09-27)
7
36
 
8
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "3.7.1",
3
+ "version": "3.9.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -54,6 +54,7 @@
54
54
  "@mdi/js": "^5.9.55",
55
55
  "@vueuse/integrations": "^7.6.0",
56
56
  "aria-hidden": "^1.1.3",
57
+ "change-case": "^4.1.2",
57
58
  "embla-carousel": "^4.5.3",
58
59
  "focus-trap": "^6.7.2",
59
60
  "nanoid": "^3.1.23",
@@ -68,5 +69,5 @@
68
69
  "optional": true
69
70
  }
70
71
  },
71
- "gitHead": "09a3c9d7cf4d42478c2f7362321fe624ae010383"
72
+ "gitHead": "327d1a08978aeb0d03b2764368f558599a379dec"
72
73
  }
@@ -0,0 +1,119 @@
1
+ <template>
2
+ <div>
3
+ <button
4
+ class="tw-w-full tw-py-2 tw-flex tw-justify-between"
5
+ @click="toggleFAQ"
6
+ >
7
+ <h3 class="tw-text-subhead tw-text-left">
8
+ {{ title }}
9
+ </h3>
10
+ <kv-material-icon
11
+ class="tw-w-4 tw-h-4"
12
+ :icon="open ? mdiChevronUp : mdiChevronDown"
13
+ @click="toggleFAQ"
14
+ />
15
+ </button>
16
+ <kv-expandable easing="ease-in-out">
17
+ <div
18
+ v-show="open"
19
+ class="tw-prose tw-pb-4 tw-pt-2"
20
+ >
21
+ <slot></slot>
22
+ <div
23
+ v-if="content !== ''"
24
+ v-html="content"
25
+ >
26
+ </div>
27
+ </div>
28
+ </kv-expandable>
29
+ </div>
30
+ </template>
31
+
32
+ <script>
33
+ import {
34
+ computed,
35
+ onMounted,
36
+ watch,
37
+ ref,
38
+ toRefs,
39
+ } from 'vue-demi';
40
+ import {
41
+ mdiChevronDown,
42
+ mdiChevronUp,
43
+ } from '@mdi/js';
44
+ import { paramCase } from 'change-case';
45
+
46
+ import KvExpandable from './KvExpandable.vue';
47
+ import KvMaterialIcon from './KvMaterialIcon.vue';
48
+
49
+ export default {
50
+ components: {
51
+ KvMaterialIcon,
52
+ KvExpandable,
53
+ },
54
+ props: {
55
+ /**
56
+ * Question Title
57
+ * */
58
+ title: {
59
+ type: String,
60
+ default: '',
61
+ },
62
+ /**
63
+ * Question Content - can accept raw html
64
+ * */
65
+ content: {
66
+ type: String,
67
+ default: '',
68
+ },
69
+ active: {
70
+ type: Boolean,
71
+ default: false,
72
+ },
73
+ routeHash: {
74
+ type: String,
75
+ default: '',
76
+ },
77
+ kvTrackFunction: {
78
+ type: Function,
79
+ default: () => {},
80
+ },
81
+ },
82
+ emits: [
83
+ 'toggle',
84
+ ],
85
+ setup(props, { emit }) {
86
+ const {
87
+ title,
88
+ active,
89
+ } = toRefs(props);
90
+ const open = ref(active.value || false);
91
+ const titleSlugified = computed(() => paramCase(title.value));
92
+
93
+ const toggleFAQ = () => {
94
+ props.kvTrackFunction('faq', 'toggle', titleSlugified, open.value ? 'expand' : 'collapse');
95
+ open.value = !open.value;
96
+ emit('toggle', { title: titleSlugified });
97
+ };
98
+
99
+ watch(active, (val) => {
100
+ open.value = val;
101
+ });
102
+
103
+ onMounted(() => {
104
+ /** Allows directly linking to the question via a hash equal to slugified title */
105
+ if (props.routeHash === `#${titleSlugified.value}`) {
106
+ open.value = true;
107
+ }
108
+ });
109
+
110
+ return {
111
+ open,
112
+ mdiChevronDown,
113
+ mdiChevronUp,
114
+ titleSlugified,
115
+ toggleFAQ,
116
+ };
117
+ },
118
+ };
119
+ </script>
@@ -0,0 +1,86 @@
1
+ import KvExpandableQuestion from '../KvExpandableQuestion.vue';
2
+
3
+ export default {
4
+ title: 'KvExpandableQuestion',
5
+ component: KvExpandableQuestion,
6
+ };
7
+
8
+ const DefaultTemplate = () => ({
9
+ components: { KvExpandableQuestion },
10
+ template: `
11
+ <div style="padding: 20px;">
12
+ <kv-expandable-question
13
+ id="expandable-question-test"
14
+ title="expandable-question-title"
15
+ content="<p> Hello, KvAccordion Contents! </p>"
16
+ />
17
+ </div>
18
+ `,
19
+ });
20
+
21
+ export const Default = DefaultTemplate.bind({});
22
+
23
+ const expandableQuestions = [
24
+ {
25
+ title: 'expandable question one',
26
+ content: '<p> Hello, KvAccordion Contents! </p>',
27
+ id: 'expandable-question-test-1',
28
+ },
29
+ {
30
+ title: 'expandable question two',
31
+ content: '<p> Hello, KvAccordion Contents! </p>',
32
+ id: 'expandable-question-test-2',
33
+ },
34
+ {
35
+ title: 'expandable question three',
36
+ content: '<p> Hello, KvAccordion Contents! </p>',
37
+ id: 'expandable-question-test-3',
38
+ },
39
+ ];
40
+
41
+ const GroupTemplate = () => ({
42
+ components: { KvExpandableQuestion },
43
+ data: () => ({
44
+ questions: expandableQuestions,
45
+ }),
46
+ methods: {
47
+ kvTrackMock(
48
+ category,
49
+ action,
50
+ label,
51
+ ) {
52
+ console.log(category, action, label);
53
+ },
54
+ },
55
+ template: `
56
+ <div style="padding: 20px;">
57
+ <kv-expandable-question
58
+ v-for="(question, index) in questions"
59
+ :key="index"
60
+ :id="question.id"
61
+ :title="question.title"
62
+ :content="question.content"
63
+ :active="question.id === 'expandable-question-test-2'"
64
+ :kv-track-function="kvTrackMock"
65
+ />
66
+ </div>
67
+ `,
68
+ });
69
+
70
+ export const ExpandableSet = GroupTemplate.bind({});
71
+
72
+ const SlotContentTemplate = () => ({
73
+ components: { KvExpandableQuestion },
74
+ template: `
75
+ <div style="padding: 20px;">
76
+ <kv-expandable-question
77
+ id="expandable-question-test"
78
+ title="expandable question with slot content"
79
+ >
80
+ <p> A created slot! </p>
81
+ </kv-expandable-question>
82
+ </div>
83
+ `,
84
+ });
85
+
86
+ export const SlotContent = SlotContentTemplate.bind({});