Skip to content

Commit 38c383a

Browse files
authored
fix(components): dlt-3408 components clean up (#1264)
1 parent a5427e8 commit 38c383a

101 files changed

Lines changed: 354 additions & 140 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -175,30 +175,20 @@ describe('DtAvatar Tests', () => {
175175
expect(count.exists()).toBe(false);
176176
});
177177

178-
it('applies correct digit modifiers at boundaries', async () => {
179-
// 9 -> no group shown, no digit modifiers
180-
await wrapper.setProps({ group: 9 });
181-
expect(wrapper.classes('d-avatar--group')).toBe(true);
182-
expect(wrapper.classes('d-avatar--group-digits-2')).toBe(false);
183-
expect(wrapper.classes('d-avatar--group-digits-3')).toBe(false);
184-
185-
// 10 -> base + digits-2
186-
await wrapper.setProps({ group: 10 });
187-
expect(wrapper.classes('d-avatar--group')).toBe(true);
188-
expect(wrapper.classes('d-avatar--group-digits-2')).toBe(true);
189-
expect(wrapper.classes('d-avatar--group-digits-3')).toBe(false);
190-
191-
// 99 -> base + digits-2
192-
await wrapper.setProps({ group: 99 });
193-
expect(wrapper.classes('d-avatar--group')).toBe(true);
194-
expect(wrapper.classes('d-avatar--group-digits-2')).toBe(true);
195-
expect(wrapper.classes('d-avatar--group-digits-3')).toBe(false);
196-
197-
// 100 -> base + digits-3 and count shows 99+
178+
it.each([
179+
[9, true, false, false],
180+
[10, true, true, false],
181+
[99, true, true, false],
182+
[100, true, false, true],
183+
])('group %i applies d-avatar--group=%s, digits-2=%s, digits-3=%s', async (group, hasGroup, hasDigits2, hasDigits3) => {
184+
await wrapper.setProps({ group });
185+
expect(wrapper.classes('d-avatar--group')).toBe(hasGroup);
186+
expect(wrapper.classes('d-avatar--group-digits-2')).toBe(hasDigits2);
187+
expect(wrapper.classes('d-avatar--group-digits-3')).toBe(hasDigits3);
188+
});
189+
190+
it('shows 99+ when group is 100 or more', async () => {
198191
await wrapper.setProps({ group: 100 });
199-
expect(wrapper.classes('d-avatar--group')).toBe(true);
200-
expect(wrapper.classes('d-avatar--group-digits-2')).toBe(false);
201-
expect(wrapper.classes('d-avatar--group-digits-3')).toBe(true);
202192
const count = wrapper.find('[data-qa="dt-avatar-count"]');
203193
expect(count.text()).toBe('99+');
204194
});

packages/dialtone-vue/components/Avatar/Avatar.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ const supportsOklch = typeof CSS !== 'undefined' && CSS.supports?.('background',
105105
* @see https://dialtone.dialpad.com/components/avatar.html
106106
*/
107107
export default {
108-
compatConfig: { MODE: 3 },
109108
name: 'DtAvatar',
110109
components: { DtPresence },
111110

packages/dialtone-vue/components/Avatar/AvatarDefault.story.vue

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
<dt-avatar
33
:id="$attrs.id"
44
:full-name="$attrs.fullName"
5-
:icon-name="$attrs.iconName"
65
:image-src="$attrs.imageSrc"
76
:image-alt="$attrs.imageAlt"
8-
:icon-size="$attrs.iconSize"
97
:size="$attrs.size"
108
:presence="$attrs.presence"
119
:avatar-class="$attrs.avatarClass"
@@ -14,19 +12,38 @@
1412
:seed="$attrs.seed"
1513
:group="$attrs.group"
1614
:color="$attrs.color"
17-
:overlay-icon="$attrs.overlayIcon"
1815
:overlay-text="$attrs.overlayText"
1916
:overlay-class="$attrs.overlayClass"
2017
:interactive="$attrs.interactive"
2118
@click="$attrs.onClick"
22-
/>
19+
>
20+
<template
21+
v-if="$attrs.iconName"
22+
#icon
23+
>
24+
<dt-icon
25+
:name="$attrs.iconName"
26+
:size="$attrs.iconSize"
27+
/>
28+
</template>
29+
<template
30+
v-if="$attrs.overlayIcon"
31+
#overlayIcon
32+
>
33+
<dt-icon
34+
:name="$attrs.overlayIcon"
35+
size="300"
36+
/>
37+
</template>
38+
</dt-avatar>
2339
</template>
2440

2541
<script>
2642
import DtAvatar from './Avatar.vue';
43+
import { DtIcon } from '@/components/Icon';
2744
2845
export default {
2946
name: 'DtAvatarDefault',
30-
components: { DtAvatar },
47+
components: { DtAvatar, DtIcon },
3148
};
3249
</script>

packages/dialtone-vue/components/Avatar/AvatarVariants.story.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,20 @@
191191
</dt-stack>
192192
</div>
193193
<div>
194-
<h2>Clickable</h2>
194+
<h2>Interactive</h2>
195195
<dt-stack
196196
direction="row"
197197
gap="200"
198198
>
199199
<dt-avatar
200200
:seed="$attrs.seed"
201201
full-name="Person avatar"
202-
clickable
202+
interactive
203203
/>
204204
<dt-avatar
205205
:seed="$attrs.seed"
206206
icon-aria-label="user icon"
207-
clickable
207+
interactive
208208
>
209209
<template #icon>
210210
<dt-icon-user />
@@ -215,7 +215,7 @@
215215
full-name="Person avatar"
216216
:image-src="$attrs.imageSrc"
217217
:image-alt="$attrs.imageAlt"
218-
clickable
218+
interactive
219219
/>
220220
</dt-stack>
221221
</div>

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
BADGE_KIND_MODIFIERS,
99
BADGE_DECORATION_MODIFIERS,
1010
} from './BadgeConstants';
11+
import { ICON_SIZE_MODIFIERS } from '@/components/Icon';
1112

1213
const iconsList = getIconNames();
1314

@@ -91,6 +92,37 @@ export const argTypesData = {
9192
// TODO: Find a way to add conditions on more than one argument
9293
},
9394

95+
iconSize: {
96+
options: Object.keys(ICON_SIZE_MODIFIERS),
97+
control: {
98+
type: 'select',
99+
},
100+
},
101+
102+
text: {
103+
control: { type: 'text' },
104+
},
105+
106+
startIconClass: {
107+
description: 'Pass through classes. Used to customize the start icon container',
108+
},
109+
110+
endIconClass: {
111+
description: 'Pass through classes. Used to customize the end icon container',
112+
},
113+
114+
subtle: {
115+
control: {
116+
type: 'boolean',
117+
},
118+
},
119+
120+
outlined: {
121+
control: {
122+
type: 'boolean',
123+
},
124+
},
125+
94126
labelClass: {
95127
description: 'Pass through classes. Used to customize the label container',
96128
},

packages/dialtone-vue/components/Badge/Badge.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ import { hasSlotContent } from '@/common/utils/index.js';
6868
* @see https://dialtone.dialpad.com/components/badge.html
6969
*/
7070
export default {
71-
compatConfig: { MODE: 3 },
7271
name: 'DtBadge',
7372
7473
props: {
@@ -113,7 +112,7 @@ export default {
113112
/**
114113
* Decoration for the badge. This can be only used with kind: label and type: default
115114
* with no left and right icons
116-
* @values default, black-400, black-500, black-900, red-200, red-300, red-400, purple-200,
115+
* @values black-400, black-500, black-900, red-200, red-300, red-400, purple-200,
117116
* purple-300, purple-400, purple-500, blue-200, blue-300, blue-400, green-300, green-400,
118117
* green-500, gold-300, gold-400, gold-500, magenta-200, magenta-300, magenta-400
119118
*/
@@ -187,6 +186,10 @@ export default {
187186
},
188187
},
189188
189+
mounted () {
190+
this.validateProps();
191+
},
192+
190193
updated () {
191194
this.validateProps();
192195
},

packages/dialtone-vue/components/Badge/BadgeDefault.story.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
:outlined="$attrs.outlined"
1010
>
1111
<template
12+
v-if="$attrs.startIcon"
1213
#startIcon="{ iconSize }"
1314
>
1415
<dt-icon
15-
v-if="$attrs.startIcon"
1616
:name="$attrs.startIcon"
1717
:size="iconSize"
1818
/>
@@ -21,10 +21,10 @@
2121
{{ defaultSlot }}
2222
</template>
2323
<template
24+
v-if="$attrs.endIcon"
2425
#endIcon="{ iconSize }"
2526
>
2627
<dt-icon
27-
v-if="$attrs.endIcon"
2828
:name="$attrs.endIcon"
2929
:size="iconSize"
3030
/>

packages/dialtone-vue/components/Badge/BadgeVariants.story.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
:type="type.value"
1414
/>
1515
<dt-badge
16-
v-for="type in types.slice(0, types.length - 1)"
16+
v-for="type in types.filter(t => t.value !== 'ai')"
1717
:key="`${type.value}-count`"
1818
text="1"
1919
:type="type.value"

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,28 @@ export const argTypesData = {
102102
},
103103
},
104104

105+
dialogClass: {
106+
description: 'Inner dialog class',
107+
},
108+
backgroundImage: {
109+
control: { type: 'text' },
110+
},
111+
backgroundSize: {
112+
control: { type: 'text' },
113+
},
114+
iconClass: {
115+
description: 'Additional class name for the icon wrapper element.',
116+
},
117+
headerClass: {
118+
description: 'Additional class name for the header wrapper element.',
119+
},
120+
contentClass: {
121+
description: 'Additional class name for the content wrapper element.',
122+
},
123+
actionClass: {
124+
description: 'Additional class name for the action wrapper element.',
125+
},
126+
105127
// Action Event Handlers
106128
onClick: {
107129
table: {

packages/dialtone-vue/components/Banner/Banner.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
class="d-banner__dialog"
1010
:class="dialogClass"
1111
:role="role"
12-
:aria-labelledby="headerId"
12+
:aria-modal="important || undefined"
13+
:aria-labelledby="hasHeader ? headerId : undefined"
1314
:aria-describedby="contentId"
1415
>
1516
<dt-notice-icon
@@ -59,7 +60,6 @@ import utils from '@/common/utils';
5960
* @see https://dialtone.dialpad.com/components/banner.html
6061
*/
6162
export default {
62-
compatConfig: { MODE: 3 },
6363
name: 'DtBanner',
6464
6565
components: {
@@ -230,6 +230,10 @@ export default {
230230
return this.important ? 'alertdialog' : 'status';
231231
},
232232
233+
hasHeader () {
234+
return !!this.headerText || !!this.$slots.header;
235+
},
236+
233237
bannerClass () {
234238
const kindClasses = {
235239
critical: 'd-banner--critical',

0 commit comments

Comments
 (0)