Skip to content

Commit 725bd41

Browse files
feat(dialtone-vue): DLT-3225 migrate component size props to numeric ordinal scale (#1157)
1 parent 84da5ef commit 725bd41

File tree

81 files changed

+588
-226
lines changed

Some content is hidden

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

81 files changed

+588
-226
lines changed

.claude/rules/vue-components.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ paths:
3030

3131
## Sizes
3232

33-
- Interactive components: `xs`, `sm`, `md`, `lg`, `xl` (string).
34-
- Icons: numeric scale `100``800`.
35-
- Export from `*_constants.js`: `COMPONENT_SIZES` object + `COMPONENT_SIZE_DEFAULT`.
33+
- All component size props use a numeric ordinal scale: `100` (xs), `200` (sm), `300` (md), `400` (lg), `500` (xl).
34+
- Prop type: `[String, Number]`. Default: numeric (e.g., `default: 300`).
35+
- T-shirt aliases (`xs`, `sm`, `md`, `lg`, `xl`) remain in constants for backward compat but are deprecated.
36+
- `@values` JSDoc: list numeric only (e.g., `@values 100, 200, 300, 400, 500`). Do not list t-shirt aliases.
37+
- Text headline extends the scale: `500` (xl), `600` (2xl), `700` (3xl).
38+
- Icons: separate numeric scale `100``800` (unchanged, do not modify).
39+
- Shared scale definition: `packages/dialtone-vue/common/constants/sizes.js`.
40+
- Export from `*_constants.js`: `COMPONENT_SIZE_MODIFIERS` object with both numeric and t-shirt keys.
3641

3742
## Separation of Concerns
3843

packages/dialtone-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@dialpad/dialtone-css": "workspace:*",
2424
"@dialpad/dialtone-icons": "workspace:*",
2525
"@dialpad/dialtone-query-core": "workspace:*",
26-
"@dialpad/dialtone-vue": "workspace:^3",
26+
"@dialpad/dialtone-vue": "workspace:*",
2727
"@rollup/plugin-commonjs": "^28.0.0",
2828
"@rollup/plugin-json": "^6.0.0",
2929
"@rollup/plugin-node-resolve": "^15.2.0",

packages/dialtone-query-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"devDependencies": {
1515
"@dialpad/dialtone-css": "workspace:*",
1616
"@dialpad/dialtone-icons": "workspace:*",
17-
"@dialpad/dialtone-vue": "workspace:^3",
17+
"@dialpad/dialtone-vue": "workspace:*",
1818
"@types/node": "24.3.1",
1919
"typescript": "^5.2"
2020
},

packages/dialtone-vue/common/constants/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ export const DESCRIPTION_SIZE_TYPES = {
2222

2323
// Description size variants
2424
export const DESCRIPTION_SIZE_MODIFIERS = {
25+
// Numeric (preferred)
26+
100: 'd-description--xs',
27+
200: 'd-description--sm',
28+
300: '',
29+
400: 'd-description--lg',
30+
500: 'd-description--xl',
31+
// T-shirt aliases (deprecated)
2532
xs: 'd-description--xs',
2633
sm: 'd-description--sm',
2734
md: '',
@@ -31,6 +38,13 @@ export const DESCRIPTION_SIZE_MODIFIERS = {
3138

3239
// Label size variants
3340
export const LABEL_SIZE_MODIFIERS = {
41+
// Numeric (preferred)
42+
100: 'd-label--xs',
43+
200: 'd-label--sm',
44+
300: '',
45+
400: 'd-label--lg',
46+
500: 'd-label--xl',
47+
// T-shirt aliases (deprecated)
3448
xs: 'd-label--xs',
3549
sm: 'd-label--sm',
3650
md: '',
@@ -66,6 +80,9 @@ export const DEFAULT_VALIDATION_MESSAGE_TYPE = VALIDATION_MESSAGE_TYPES.ERROR;
6680
// Default prefix used for ids
6781
export const DEFAULT_PREFIX = 'dt';
6882

83+
// Component size scale
84+
export { COMPONENT_SIZES, TEXT_HEADLINE_SIZES } from './sizes.js';
85+
6986
export default {
7087
VALIDATION_MESSAGE_TYPES,
7188
DESCRIPTION_SIZE_TYPES,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Canonical numeric-to-t-shirt size mapping for component size props.
3+
*
4+
* Scale: 100-unit ordinal steps with 50-unit half-steps reserved for future sizes.
5+
* Convention matches Dialtone's existing token scales (dt-size-*, dt-icon-size-*, colors).
6+
*
7+
* @example
8+
* <DtButton :size="200" /> <!-- equivalent to size="sm" -->
9+
* <DtButton :size="250" /> <!-- future "smedium" -->
10+
*/
11+
12+
// Numeric → t-shirt label mapping
13+
export const COMPONENT_SIZES = {
14+
100: 'xs',
15+
200: 'sm',
16+
300: 'md',
17+
400: 'lg',
18+
500: 'xl',
19+
};
20+
21+
// Extended sizes for Text headline kind
22+
export const TEXT_HEADLINE_SIZES = {
23+
...COMPONENT_SIZES,
24+
600: '2xl',
25+
700: '3xl',
26+
};
27+
28+
export default {
29+
COMPONENT_SIZES,
30+
TEXT_HEADLINE_SIZES,
31+
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const ICONS_LIST = getIconNames();
1111

1212
export const argsData = {
1313
onClick: action('click'),
14-
size: 'md',
14+
size: 300,
1515
presence: null,
1616
fullName: 'Jaqueline Nackos',
1717
imageAlt: 'profile image',

packages/dialtone-vue/components/avatar/avatar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export default {
171171
* The size of the avatar.
172172
* T-shirt sizes (xs, sm, md, lg, xl) are deprecated and will be removed in the next major version.
173173
* Please use the numeric scale instead.
174-
* @values 100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900, xs, sm, md, lg, xl
174+
* @values 100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900
175175
*/
176176
size: {
177177
type: [String, Number],

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const argsData = {
1717
onClick: action('click'),
1818
onFocusIn: action('focusin'),
1919
onFocusOut: action('focusout'),
20-
size: 'md',
20+
size: 300,
2121
link: false,
2222
};
2323

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ describe('DtButton Tests', () => {
227227
});
228228
});
229229

230+
describe('When size is numeric', () => {
231+
it('should apply the correct size class for numeric size 200', async () => {
232+
await wrapper.setProps({
233+
size: 200,
234+
});
235+
236+
button = wrapper.find('.base-button__button');
237+
238+
expect(button.classes().includes('d-btn--sm')).toBe(true);
239+
});
240+
});
241+
230242
describe('When button has an invalid size prop', () => {
231243
it('should not have a size class', async () => {
232244
await wrapper.setProps({

packages/dialtone-vue/components/button/button.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,12 @@ export default {
281281
282282
/**
283283
* The size of the button.
284-
* @values xs, sm, md, lg, xl
284+
* @values 100, 200, 300, 400, 500
285285
*/
286286
size: {
287-
type: String,
288-
default: 'md',
289-
validator: (s) => Object.keys(BUTTON_SIZE_MODIFIERS).includes(s),
287+
type: [String, Number],
288+
default: 300,
289+
validator: (s) => Object.keys(BUTTON_SIZE_MODIFIERS).includes(String(s)),
290290
},
291291
292292
/**
@@ -508,11 +508,11 @@ export default {
508508
},
509509
510510
iconSize () {
511-
return BUTTON_ICON_SIZES[this.size];
511+
return BUTTON_ICON_SIZES[String(this.size)];
512512
},
513513
514514
loaderSize () {
515-
return BUTTON_ICON_SIZES[this.size];
515+
return BUTTON_ICON_SIZES[String(this.size)];
516516
},
517517
},
518518
@@ -547,7 +547,7 @@ export default {
547547
return [
548548
'd-link',
549549
getLinkKindModifier(this.linkKind, this.linkInverted),
550-
BUTTON_SIZE_MODIFIERS[this.size],
550+
BUTTON_SIZE_MODIFIERS[String(this.size)],
551551
{ 'd-link--no-underline': !this.resolvedUnderline },
552552
];
553553
}
@@ -558,7 +558,7 @@ export default {
558558
'd-btn',
559559
BUTTON_IMPORTANCE_MODIFIERS[this.importance],
560560
BUTTON_KIND_MODIFIERS[this.kind],
561-
BUTTON_SIZE_MODIFIERS[this.size],
561+
BUTTON_SIZE_MODIFIERS[String(this.size)],
562562
{
563563
'd-btn--circle': this.circle,
564564
'd-btn--loading': this.loading,

0 commit comments

Comments
 (0)