@kiva/kv-components 3.9.0 → 3.10.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,34 @@
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.10.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.9.1...@kiva/kv-components@3.10.0) (2022-11-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * smooth out transition by apply styling to child div ([8f629d7](https://github.com/kiva/kv-ui-elements/commit/8f629d7659aec83493797e8b1bb9d4540457686a))
12
+ * test multiline content for broken state, add .stop event modifier on FAQ icon click ([e4758d5](https://github.com/kiva/kv-ui-elements/commit/e4758d5103233007c5c497b310e5cf4c994885aa))
13
+
14
+
15
+ ### Features
16
+
17
+ * created tests in order to fix FAQ Arrow Functionality ([7bc7c54](https://github.com/kiva/kv-ui-elements/commit/7bc7c54258cb83f74b127f9c5985ff56ba3e9129))
18
+
19
+
20
+
21
+
22
+
23
+ ## [3.9.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.9.0...@kiva/kv-components@3.9.1) (2022-10-14)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * turn off pre-wrap whitespace for KvExpandableQuestion and prose for the title of the component ([753abef](https://github.com/kiva/kv-ui-elements/commit/753abef7b01d2d8928ac432ed87675a95d715688))
29
+
30
+
31
+
32
+
33
+
6
34
  # [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
35
 
8
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "3.9.0",
3
+ "version": "3.10.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -69,5 +69,5 @@
69
69
  "optional": true
70
70
  }
71
71
  },
72
- "gitHead": "327d1a08978aeb0d03b2764368f558599a379dec"
72
+ "gitHead": "6c36724fbfad7b16e6fc613769bb3ec9c5d682c0"
73
73
  }
@@ -0,0 +1,55 @@
1
+ import { fireEvent, render } from '@testing-library/vue';
2
+ import KvExpandableQuestion from '../../../../vue/KvExpandableQuestion.vue';
3
+
4
+ describe('KvExpandableQuestion', () => {
5
+ it('renders KvExpandableQuestion that opens and closes when clicking the title', async () => {
6
+ const { getByText } = render(KvExpandableQuestion, {
7
+ props: {
8
+ title: 'Kv Expandable Question',
9
+ id: 'kv-expandable-question',
10
+ },
11
+ slots: { default: 'Test Question' },
12
+ });
13
+ const titleContent = getByText('Kv Expandable Question');
14
+ expect(titleContent).toBeDefined();
15
+ expect(getByText('Test Question')).not.toBeVisible();
16
+ await fireEvent.click(titleContent);
17
+ expect(getByText('Test Question')).toBeVisible();
18
+ await fireEvent.click(titleContent);
19
+ expect(getByText('Test Question')).not.toBeVisible();
20
+ });
21
+
22
+ it('renders KvExpandableQuestion that opens and closes when clicking the arrow', async () => {
23
+ const { container, getByText } = render(KvExpandableQuestion, {
24
+ props: {
25
+ title: 'Kv Expandable Question',
26
+ id: 'kv-expandable-question',
27
+ testid: 'test-expandable',
28
+ },
29
+ // establish some multi line content
30
+ slots: { default: '<p>renders KvExpandableQuestion that opens and closes when clicking the arrow renders KvExpandableQuestion</p> <p>that opens and closes when clicking the arrow</p> <p>Test Question</p>' },
31
+ });
32
+ const spanEl = container.querySelector("[role='img']");
33
+ const svgEl = container.querySelector("[viewBox= '0 0 24 24']");
34
+
35
+ // Check State prior to clicking Icon
36
+ expect(svgEl).toBeVisible();
37
+ expect(getByText('Test Question')).not.toBeVisible();
38
+
39
+ // Click icon to open expandable and check content visibility
40
+ await fireEvent.click(spanEl);
41
+ const firstLineOpen = getByText('renders KvExpandableQuestion that opens and closes when clicking the arrow renders KvExpandableQuestion');
42
+ expect(firstLineOpen).toBeVisible();
43
+
44
+ const lastLineOpen = getByText('Test Question');
45
+ expect(lastLineOpen).toBeVisible();
46
+
47
+ // Click icon and check content visibility
48
+ await fireEvent.click(spanEl);
49
+ const firstLineClosed = getByText('renders KvExpandableQuestion that opens and closes when clicking the arrow renders KvExpandableQuestion');
50
+ expect(firstLineClosed).not.toBeVisible();
51
+
52
+ const lastLineClosed = getByText('Test Question');
53
+ expect(lastLineClosed).not.toBeVisible();
54
+ });
55
+ });
@@ -1,7 +1,7 @@
1
1
  <template>
2
- <div>
2
+ <div class="tw-whitespace-normal">
3
3
  <button
4
- class="tw-w-full tw-py-2 tw-flex tw-justify-between"
4
+ class="tw-w-full tw-py-2 tw-flex tw-justify-between tw-not-prose"
5
5
  @click="toggleFAQ"
6
6
  >
7
7
  <h3 class="tw-text-subhead tw-text-left">
@@ -10,19 +10,18 @@
10
10
  <kv-material-icon
11
11
  class="tw-w-4 tw-h-4"
12
12
  :icon="open ? mdiChevronUp : mdiChevronDown"
13
- @click="toggleFAQ"
13
+ @click.stop="toggleFAQ"
14
14
  />
15
15
  </button>
16
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
- >
17
+ <div v-show="open">
18
+ <div class="tw-prose tw-pb-4 tw-pt-2">
19
+ <slot></slot>
20
+ <div
21
+ v-if="content !== ''"
22
+ v-html="content"
23
+ >
24
+ </div>
26
25
  </div>
27
26
  </div>
28
27
  </kv-expandable>
@@ -84,3 +84,46 @@ const SlotContentTemplate = () => ({
84
84
  });
85
85
 
86
86
  export const SlotContent = SlotContentTemplate.bind({});
87
+
88
+ const ProseWrappedTemplate = () => ({
89
+ components: { KvExpandableQuestion },
90
+ template: `
91
+ <div class="rich-text-content tw-prose tw-whitespace-pre-wrap tw-mb-2 md:tw-mb-3" data-testid="rich-text-container">
92
+ <h4><!--[-->Our commitment<!--]--></h4>
93
+ <h2><!--[--><!--[-->100% of your loan goes toward <!--]--><!--[--><b><!--[-->supporting borrowers.<!--]--></b><!--]--><!--]--></h2>
94
+ <section class="tw-relative tw-w-full">
95
+ <div class="tw-pt-4 tw-pb-4 lg:tw-pt-8 lg:tw-pb-8 tw-relative tw-w-full tw-overflow-hidden tw-z-1 tw-top-0">
96
+ <div>
97
+ <div style="">
98
+ <div class="tw-divide-y tw-whitespace-normal">
99
+ <kv-expandable-question
100
+ id="expandable-question-test"
101
+ title="Why Lending?"
102
+ >
103
+ <p>If you needed to buy a delivery truck for your business, you probably wouldn’t ask for donations; you’d apply for a loan.</p><p>But what about the billion people without access to traditional finance? That's where you—and Kiva—come in. Kiva loans give people the power and resources to build the life they choose. By crowdfunding smaller amounts—called microloans—we can help more borrowers get funded.</p><p>With Kiva, you can use the same dollars again and again, helping a new borrower each time your loan is repaid. Your same $25 could help someone open a salon, support a child’s education, invest in community solar panels, and so on!</p>
104
+ </kv-expandable-question>
105
+ <kv-expandable-question
106
+ id="expandable-question-test"
107
+ title="How does Kiva make money ?"
108
+ >
109
+ <p>We cover most of our operating costs through voluntary donations made by Kiva lenders. As a 501(c)3 U.S. nonprofit, the remainder of our costs are covered through grants and donations from foundations and supporters. Additionally, select lending partners contribute small platform fees as we continue building innovative technologies that help create a more financially inclusive world.</p>
110
+ <p>Kiva never takes a fee from lenders. 100% of funds lent on Kiva go to funding loans.</p>
111
+ </kv-expandable-question>
112
+ <kv-expandable-question
113
+ id="expandable-question-test"
114
+ title="Do Kiva borrowers pay any interest on their loans?"
115
+ >
116
+ <p>Kiva partners with microfinance institutions, nonprofits, and other organizations to disburse loans in the communities we serve.</p>
117
+ <p>Most borrowers do pay interest to these local lending partners to help cover their operation costs. We verify that these rates are appropriate for the region and we only choose partners who have fair, non-predatory lending practices and prioritize social good.</p>
118
+ <p>Some borrowers funded through Kiva do receive 0% interest loans, including most direct loans, which are loans not made through a local lending partner.</p>
119
+ </kv-expandable-question>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ </section>
125
+ </div>
126
+ `,
127
+ });
128
+
129
+ export const ProseWrappedQuestion = ProseWrappedTemplate.bind({});