Skip to content

Commit 48a0f57

Browse files
authored
refactor(components): DLT-3284 refactor props to not have native html attributes names (#1204)
Co-authored-by: iropolo <ignacio.ropolo@dialpad.com>
1 parent 1054875 commit 48a0f57

29 files changed

Lines changed: 186 additions & 166 deletions

packages/combinator/src/components/renderer/renderer_target.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function renderError (exception, container) {
136136
render(h(DtNotice, {
137137
kind: 'critical',
138138
showClose: false,
139-
title: ERROR_MESSAGE,
139+
headerText: ERROR_MESSAGE,
140140
}, {
141141
default: () => exception.toString(),
142142
}), container);

packages/combinator/src/variants/variants_banner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* eslint-disable max-len */
21

2+
33
export default {
44
default: {
55
slots: {
@@ -8,7 +8,7 @@ export default {
88
},
99
},
1010
props: {
11-
title: {
11+
headerText: {
1212
initialValue: 'Example banner',
1313
},
1414
kind: {

packages/combinator/src/variants/variants_modal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable max-len */
2-
2+
33
export default {
44
default: {
55
props: {
6-
title: {
6+
headerText: {
77
initialValue: 'Example title',
88
},
99
copy: {
@@ -18,7 +18,7 @@ export default {
1818
},
1919
danger: {
2020
props: {
21-
title: {
21+
headerText: {
2222
initialValue: 'Example title',
2323
},
2424
copy: {

packages/combinator/src/variants/variants_notice.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ export default {
1717
},
1818
},
1919
props: {
20-
title: {
20+
headerText: {
2121
initialValue: 'Base title',
2222
},
2323
},
2424
},
2525

2626
'info with action and hide close': {
2727
props: {
28-
title: { initialValue: 'Info title' },
28+
headerText: { initialValue: 'Info title' },
2929
kind: { initialValue: 'info' },
3030
showClose: { initialValue: false },
3131
},
@@ -37,7 +37,7 @@ export default {
3737

3838
'important warning with no message': {
3939
props: {
40-
title: { initialValue: 'Warning title' },
40+
headerText: { initialValue: 'Warning title' },
4141
kind: { initialValue: 'warning' },
4242
important: { initialValue: true },
4343
},

packages/combinator/src/variants/variants_toast.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22

33
export default {
44
defaults: {
@@ -14,7 +14,7 @@ export default {
1414
},
1515
},
1616
props: {
17-
title: {
17+
headerText: {
1818
initialValue: 'Base title (optional)',
1919
},
2020
show: {
@@ -25,7 +25,7 @@ export default {
2525

2626
'info with action and hide close': {
2727
props: {
28-
title: { initialValue: 'Info title' },
28+
headerText: { initialValue: 'Info title' },
2929
kind: { initialValue: 'info' },
3030
showClose: { initialValue: false },
3131
show: { initialValue: true },
@@ -38,7 +38,7 @@ export default {
3838

3939
'important warning with no message': {
4040
props: {
41-
title: { initialValue: 'Warning title' },
41+
headerText: { initialValue: 'Warning title' },
4242
kind: { initialValue: 'warning' },
4343
important: { initialValue: true },
4444
show: { initialValue: true },

packages/dialtone-vue/components/banner/banner.stories.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ export const argTypesData = {
4646
},
4747

4848
// Props
49+
headerText: {
50+
control: {
51+
type: 'text',
52+
},
53+
},
4954
kind: {
5055
options: NOTICE_KINDS,
5156
control: {
@@ -57,7 +62,7 @@ export const argTypesData = {
5762
disable: true,
5863
},
5964
},
60-
titleId: {
65+
headerId: {
6166
table: {
6267
defaultValue: {
6368
summary: 'generated unique ID',
@@ -130,7 +135,7 @@ export const Default = {
130135
render: Template,
131136

132137
args: {
133-
title: 'Optional title',
138+
headerText: 'Optional title',
134139
action: 'Action',
135140
kind: 'base',
136141
},
@@ -181,7 +186,7 @@ export const CustomBackground = {
181186
...Default.args,
182187
backgroundImage,
183188
backgroundSize: 'contain',
184-
title: '',
189+
headerText: '',
185190
action: '',
186191
showIcon: false,
187192
dialogClass: 'd-fc-neutral-white',

packages/dialtone-vue/components/banner/banner.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
class="d-banner__dialog"
1010
:class="dialogClass"
1111
:role="role"
12-
:aria-labelledby="titleId"
12+
:aria-labelledby="headerId"
1313
:aria-describedby="contentId"
1414
>
1515
<dt-notice-icon
1616
v-if="showIcon"
1717
:kind="kind"
18-
:class="{ 'd-notice__icon--has-title': title || $slots.title }"
18+
:class="{ 'd-notice__icon--has-title': headerText || $slots.header }"
1919
>
2020
<!-- @slot Slot for custom icon -->
2121
<slot name="icon" />
2222
</dt-notice-icon>
2323
<dt-notice-content
24-
:title-id="titleId"
24+
:header-id="headerId"
2525
:content-id="contentId"
26-
:title="title"
26+
:header-text="headerText"
2727
>
28-
<template #title>
29-
<!-- @slot Slot for the title -->
30-
<slot name="title" />
28+
<template #header>
29+
<!-- @slot Slot for the header -->
30+
<slot name="header" />
3131
</template>
3232
<!-- @slot the main textual content of the banner -->
3333
<slot />
@@ -68,10 +68,10 @@ export default {
6868
6969
props: {
7070
/**
71-
* Sets an ID on the title element of the component. Useful for aria-describedby
72-
* or aria-labelledby or any other reason you may need an id to refer to the title.
71+
* Sets an ID on the header element of the component. Useful for aria-describedby
72+
* or aria-labelledby or any other reason you may need an id to refer to the header.
7373
*/
74-
titleId: {
74+
headerId: {
7575
type: String,
7676
default () { return utils.getUniqueString(); },
7777
},
@@ -86,11 +86,11 @@ export default {
8686
},
8787
8888
/**
89-
* Title header of the notice. This can be left blank to remove the title from the notice entirely.
89+
* Header text of the banner. This can be left blank to remove the header from the banner entirely.
9090
*/
91-
title: {
91+
headerText: {
9292
type: String,
93-
default: '',
93+
default: undefined,
9494
},
9595
9696
/**

packages/dialtone-vue/components/banner/banner_default.story.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<dt-banner
1111
v-show="displayBanner"
1212
:kind="$attrs.kind"
13-
:title="$attrs.title"
14-
:title-id="$attrs.titleId"
13+
:header-text="$attrs.headerText"
14+
:header-id="$attrs.headerId"
1515
:content-id="$attrs.contentId"
1616
:important="$attrs.important"
1717
:pinned="$attrs.pinned"

packages/dialtone-vue/components/modal/modal.stories.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ viverra iaculis. Interdum et malesuada fames ac ante ipsum primis in faucibus. V
1717
maximus ipsum ex. Curabitur elementum luctus augue, quis eleifend tortor feugiat vel. \
1818
Maecenas maximus, ipsum et laoreet congue, diam massa aliquam libero, at pellentesque \
1919
orci ipsum et velit.`,
20-
title: 'Example Title',
20+
headerText: 'Example Title',
2121
onClose: action('update:open'),
2222
};
2323

@@ -57,6 +57,16 @@ export const argTypesData = {
5757
},
5858

5959
// Props
60+
headerText: {
61+
control: {
62+
type: 'text',
63+
},
64+
},
65+
bannerHeaderText: {
66+
control: {
67+
type: 'text',
68+
},
69+
},
6070
contentMode: CONTENT_MODE_ARG_TYPE,
6171
size: {
6272
options: Object.keys(MODAL_SIZE_MODIFIERS),
@@ -183,7 +193,7 @@ export const WithBanner = {
183193
render: DefaultTemplate,
184194

185195
args: {
186-
bannerTitle: 'Example banner',
196+
bannerHeaderText: 'Example banner',
187197
},
188198

189199
parameters: { ...Default.parameters },

packages/dialtone-vue/components/modal/modal.test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import { mount } from '@vue/test-utils';
44
const SYNC_EVENT_NAME = 'update:open';
55

66
const MOCK_MODAL_COPY = 'test modal copy';
7-
const MOCK_MODAL_TITLE = 'test modal title';
7+
const MOCK_MODAL_HEADER_TEXT = 'test modal header text';
88
const MOCK_MODAL_BANNER = 'test modal banner';
99
const MOCK_MODAL_DEFAULT_SLOT = 'test content';
1010
const MOCK_MODAL_HEADER_SLOT = 'test header';
1111
const MOCK_MODAL_BANNER_SLOT = 'title';
1212

1313
const baseProps = {
14-
title: MOCK_MODAL_TITLE,
14+
headerText: MOCK_MODAL_HEADER_TEXT,
1515
copy: MOCK_MODAL_COPY,
16-
bannerTitle: MOCK_MODAL_BANNER,
16+
bannerHeaderText: MOCK_MODAL_BANNER,
1717
open: true,
1818
};
1919

@@ -81,9 +81,9 @@ describe('DtModal Tests', () => {
8181
expect(overlay.element.tagName).toBe('DIALOG');
8282
});
8383

84-
it('should render the title content', () => {
84+
it('should render the header text content', () => {
8585
expect(title.exists()).toBe(true);
86-
expect(title.text()).toEqual(MOCK_MODAL_TITLE);
86+
expect(title.text()).toEqual(MOCK_MODAL_HEADER_TEXT);
8787
});
8888

8989
it('should render the banner content', () => {
@@ -129,7 +129,7 @@ describe('DtModal Tests', () => {
129129
});
130130

131131
describe('When slots are provided', () => {
132-
it('Should display slotted header instead of title', () => {
132+
it('Should display slotted header instead of headerText', () => {
133133
mockSlots = {
134134
header: MOCK_MODAL_HEADER_SLOT,
135135
};
@@ -139,7 +139,7 @@ describe('DtModal Tests', () => {
139139
expect(title.text()).toEqual(MOCK_MODAL_HEADER_SLOT);
140140
});
141141

142-
it('Should display slotted banner instead of bannerTitle', () => {
142+
it('Should display slotted banner instead of bannerHeaderText', () => {
143143
mockSlots = {
144144
banner: MOCK_MODAL_BANNER_SLOT,
145145
};
@@ -219,11 +219,11 @@ describe('DtModal Tests', () => {
219219

220220
it('Should apply banner class', async () => {
221221
const bannerClass = 'banner-class';
222-
const bannerTitle = 'title';
222+
const bannerHeaderText = 'title';
223223

224224
await wrapper.setProps({
225225
open: true,
226-
bannerTitle,
226+
bannerHeaderText,
227227
bannerClass,
228228
});
229229

@@ -236,7 +236,7 @@ describe('DtModal Tests', () => {
236236
await wrapper.setProps({
237237
open: true,
238238
bannerKind: 'info',
239-
bannerTitle: 'title',
239+
bannerHeaderText: 'title',
240240
});
241241

242242
banner = wrapper.find('[data-qa="dt-modal-banner"]');
@@ -248,7 +248,7 @@ describe('DtModal Tests', () => {
248248
await wrapper.setProps({
249249
show: true,
250250
bannerKind: 'critical',
251-
bannerTitle: 'title',
251+
bannerHeaderText: 'title',
252252
});
253253

254254
banner = wrapper.find('[data-qa="dt-modal-banner"]');

0 commit comments

Comments
 (0)