@dialpad/dialtone-css 8.78.0-next.1 → 8.78.0-next.3
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/README.md +0 -2
- package/lib/build/js/dialtone_migrate_flex_to_stack/examples-edge-cases.vue +26 -0
- package/lib/build/js/dialtone_migrate_flex_to_stack/index.mjs +56 -15
- package/lib/build/js/dialtone_migrate_tshirt_to_numeric/index.mjs +233 -0
- package/lib/build/js/dialtone_migrate_tshirt_to_numeric/test.mjs +336 -0
- package/lib/build/js/dialtone_migration_helper/configs/physical-to-logical.mjs +86 -0
- package/lib/build/js/dialtone_migration_helper/configs/size-to-layout.mjs +212 -0
- package/lib/build/js/dialtone_migration_helper/configs/space-to-spacing.mjs +48 -0
- package/lib/build/js/dialtone_migration_helper/configs/stack-gap-to-spacing.mjs +88 -0
- package/lib/build/js/dialtone_migration_helper/configs/utility-class-to-token-stops.mjs +135 -0
- package/lib/build/js/dialtone_migration_helper/tests/size-to-layout-test-examples.vue +275 -0
- package/lib/build/js/dialtone_migration_helper/tests/space-to-spacing-test-examples.vue +193 -0
- package/lib/build/less/components/avatar.less +8 -19
- package/lib/build/less/components/badge.less +22 -20
- package/lib/build/less/components/banner.less +5 -5
- package/lib/build/less/components/breadcrumbs.less +4 -4
- package/lib/build/less/components/button.less +39 -39
- package/lib/build/less/components/card.less +4 -4
- package/lib/build/less/components/chip.less +41 -51
- package/lib/build/less/components/codeblock.less +2 -2
- package/lib/build/less/components/collapsible.less +2 -2
- package/lib/build/less/components/combobox-multi-select.less +8 -8
- package/lib/build/less/components/combobox-with-popover.less +1 -1
- package/lib/build/less/components/combobox.less +5 -5
- package/lib/build/less/components/datepicker.less +6 -6
- package/lib/build/less/components/description-list.less +14 -3
- package/lib/build/less/components/dropdown.less +4 -4
- package/lib/build/less/components/emoji-picker.less +35 -35
- package/lib/build/less/components/empty-state.less +5 -5
- package/lib/build/less/components/filter-pill.less +5 -5
- package/lib/build/less/components/forms.less +10 -10
- package/lib/build/less/components/image-viewer.less +2 -2
- package/lib/build/less/components/input.less +17 -22
- package/lib/build/less/components/item-layout.less +8 -8
- package/lib/build/less/components/keyboard-shortcut.less +3 -3
- package/lib/build/less/components/link.less +5 -5
- package/lib/build/less/components/list-group.less +1 -1
- package/lib/build/less/components/list-item-group.less +1 -1
- package/lib/build/less/components/list-item.less +9 -9
- package/lib/build/less/components/modal.less +20 -20
- package/lib/build/less/components/notice.less +11 -11
- package/lib/build/less/components/pagination.less +5 -5
- package/lib/build/less/components/popover.less +5 -5
- package/lib/build/less/components/radio-checkbox.less +11 -10
- package/lib/build/less/components/rich-text-editor.less +13 -13
- package/lib/build/less/components/scrollbar.less +2 -2
- package/lib/build/less/components/segmented-control.less +6 -6
- package/lib/build/less/components/selects.less +18 -13
- package/lib/build/less/components/skeleton.less +4 -4
- package/lib/build/less/components/stack.less +24 -69
- package/lib/build/less/components/table.less +6 -7
- package/lib/build/less/components/tabs.less +24 -24
- package/lib/build/less/components/toast.less +16 -16
- package/lib/build/less/components/toggle.less +23 -23
- package/lib/build/less/components/tooltip.less +27 -27
- package/lib/build/less/dialtone-reset.less +3 -3
- package/lib/build/less/dialtone-transitions.less +4 -4
- package/lib/build/less/dialtone.less +2 -2
- package/lib/build/less/recipes/attachment_carousel.less +13 -13
- package/lib/build/less/recipes/callbar_button.less +1 -1
- package/lib/build/less/recipes/callbar_button_with_dropdown.less +7 -7
- package/lib/build/less/recipes/callbar_button_with_popover.less +8 -8
- package/lib/build/less/recipes/callbox.less +6 -6
- package/lib/build/less/recipes/contact_info.less +9 -9
- package/lib/build/less/recipes/editor.less +12 -12
- package/lib/build/less/recipes/emoji_row.less +8 -8
- package/lib/build/less/recipes/feed_item_pill.less +13 -13
- package/lib/build/less/recipes/feed_item_row.less +10 -10
- package/lib/build/less/recipes/grouped_chip.less +2 -2
- package/lib/build/less/recipes/ivr_node.less +13 -13
- package/lib/build/less/recipes/leftbar_row.less +23 -23
- package/lib/build/less/recipes/message_input.less +16 -16
- package/lib/build/less/recipes/settings_menu_button.less +10 -10
- package/lib/build/less/recipes/time_pill.less +1 -1
- package/lib/build/less/recipes/top_banner_info.less +8 -8
- package/lib/build/less/recipes/unread_pill.less +2 -2
- package/lib/build/less/themes/default.less +1 -1
- package/lib/build/less/utilities/backgrounds.less +3 -3
- package/lib/build/less/utilities/effects.less +20 -20
- package/lib/build/less/utilities/flex.less +11 -11
- package/lib/build/less/utilities/layout.less +4 -4
- package/lib/build/less/utilities/sizing.less +172 -0
- package/lib/build/less/utilities/spacing.less +49 -49
- package/lib/build/less/utilities/typography.less +2 -2
- package/lib/build/less/variables/sizes.less +8 -8
- package/lib/dist/dialtone-default-theme.css +5220 -1117
- package/lib/dist/dialtone-default-theme.min.css +1 -1
- package/lib/dist/dialtone-docs.json +1 -1
- package/lib/dist/dialtone.css +5203 -1117
- package/lib/dist/dialtone.min.css +1 -1
- package/lib/dist/js/dialtone_migrate_flex_to_stack/examples-edge-cases.vue +26 -0
- package/lib/dist/js/dialtone_migrate_flex_to_stack/index.mjs +56 -15
- package/lib/dist/js/dialtone_migrate_tshirt_to_numeric/index.mjs +233 -0
- package/lib/dist/js/dialtone_migrate_tshirt_to_numeric/test.mjs +336 -0
- package/lib/dist/js/dialtone_migration_helper/configs/physical-to-logical.mjs +86 -0
- package/lib/dist/js/dialtone_migration_helper/configs/size-to-layout.mjs +212 -0
- package/lib/dist/js/dialtone_migration_helper/configs/space-to-spacing.mjs +48 -0
- package/lib/dist/js/dialtone_migration_helper/configs/stack-gap-to-spacing.mjs +88 -0
- package/lib/dist/js/dialtone_migration_helper/configs/utility-class-to-token-stops.mjs +135 -0
- package/lib/dist/js/dialtone_migration_helper/tests/size-to-layout-test-examples.vue +275 -0
- package/lib/dist/js/dialtone_migration_helper/tests/space-to-spacing-test-examples.vue +193 -0
- package/lib/dist/tokens/tokens-base-dark.css +17 -0
- package/lib/dist/tokens/tokens-base-light.css +17 -0
- package/lib/dist/tokens/tokens-debug-base.css +17 -0
- package/lib/dist/tokens-docs.json +1 -1
- package/package.json +3 -3
- package/lib/build/js/dialtone_migration_helper/configs/space-to-size.mjs +0 -15
- package/lib/dist/js/dialtone_migration_helper/configs/space-to-size.mjs +0 -15
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Lookup table: old --dt-space-{stop} → new --dt-spacing-{suffix}
|
|
2
|
+
// Based on px value equivalence (8px base unit). Stops with no equivalent are left unchanged.
|
|
3
|
+
const MAP = {
|
|
4
|
+
0: 'spacing-0', // 0px
|
|
5
|
+
100: 'spacing-1', // 1px
|
|
6
|
+
200: 'spacing-25', // 2px
|
|
7
|
+
300: 'spacing-50', // 4px
|
|
8
|
+
350: 'spacing-75', // 6px
|
|
9
|
+
400: 'spacing-100', // 8px
|
|
10
|
+
450: 'spacing-150', // 12px
|
|
11
|
+
500: 'spacing-200', // 16px
|
|
12
|
+
525: 'spacing-250', // 20px
|
|
13
|
+
550: 'spacing-300', // 24px
|
|
14
|
+
600: 'spacing-400', // 32px
|
|
15
|
+
625: 'spacing-525', // 42px
|
|
16
|
+
650: 'spacing-600', // 48px
|
|
17
|
+
700: 'spacing-800', // 64px
|
|
18
|
+
// 720 (72px), 730 (84px), 750+ (96px+) have no --dt-spacing-* equivalent.
|
|
19
|
+
// Tokens at these sizes are better expressed as --dt-layout-* tokens.
|
|
20
|
+
// These are left unchanged for manual review — the lint rule will flag them.
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
description:
|
|
25
|
+
'Migrates --dt-space-* tokens to --dt-spacing-* tokens (8px base unit scale).\n' +
|
|
26
|
+
'This supersedes the space-to-size migration — run this instead of space-to-size.\n' +
|
|
27
|
+
'- Replaces var(--dt-space-{stop}) with var(--dt-spacing-{newSuffix})\n\t' +
|
|
28
|
+
'eg. var(--dt-space-400) → var(--dt-spacing-100)\n' +
|
|
29
|
+
'- Replaces var(--dt-space-{stop}-negative) with var(--dt-spacing-{newSuffix}-negative)\n\t' +
|
|
30
|
+
'eg. var(--dt-space-400-negative) → var(--dt-spacing-100-negative)\n' +
|
|
31
|
+
'- Replaces var(--dt-space-{stop}-percent) with var(--dt-spacing-{newSuffix}-percent)\n\t' +
|
|
32
|
+
'eg. var(--dt-space-400-percent) → var(--dt-spacing-100-percent)\n' +
|
|
33
|
+
'- Tokens with no equivalent (720, 730, 750+) are left unchanged for manual review.\n',
|
|
34
|
+
patterns: ['**/*.{css,less,scss,sass,styl,html,vue,md,js,ts,jsx,tsx}'],
|
|
35
|
+
globbyConfig: {
|
|
36
|
+
ignore: ['**/dialtone_migration_helper/tests/**'],
|
|
37
|
+
},
|
|
38
|
+
expressions: [
|
|
39
|
+
{
|
|
40
|
+
from: /var\(--dt-space-([0-9]+)(-negative|-percent)?\)/g,
|
|
41
|
+
to: (match, stop, suffix) => {
|
|
42
|
+
const newSuffix = MAP[Number(stop)];
|
|
43
|
+
if (newSuffix == null) return match;
|
|
44
|
+
return `var(--dt-${newSuffix}${suffix || ''})`;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Mapping: old DtStack/DtDescriptionList gap prop values → new spacing stop numbers
|
|
2
|
+
// The old gap values used --dt-size-* stop numbers; the new values use --dt-spacing-* stop numbers.
|
|
3
|
+
const GAP_MAP = {
|
|
4
|
+
0: '0', // 0px
|
|
5
|
+
50: '1', // 0.5px → 1px
|
|
6
|
+
100: '1', // 1px
|
|
7
|
+
200: '25', // 2px
|
|
8
|
+
300: '50', // 4px
|
|
9
|
+
350: '75', // 6px
|
|
10
|
+
400: '100', // 8px
|
|
11
|
+
450: '150', // 12px
|
|
12
|
+
500: '200', // 16px
|
|
13
|
+
525: '250', // 20px
|
|
14
|
+
550: '300', // 24px
|
|
15
|
+
600: '400', // 32px
|
|
16
|
+
625: '525', // 42px
|
|
17
|
+
650: '600', // 48px
|
|
18
|
+
700: '800', // 64px
|
|
19
|
+
// 50 (0.5px) maps to 1 (1px) — closest non-subpixel stop
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Values that only exist in the NEW system — if a file contains these,
|
|
23
|
+
// it has already been migrated. Used to detect and skip double-migration.
|
|
24
|
+
const NEW_ONLY_VALUES = new Set(['25', '75', '150', '250', '525']);
|
|
25
|
+
|
|
26
|
+
function isAlreadyMigrated (content) {
|
|
27
|
+
// Check for gap values that only exist in the new system
|
|
28
|
+
// If any are found, this file was already migrated
|
|
29
|
+
return [...NEW_ONLY_VALUES].some(v =>
|
|
30
|
+
content.includes(`gap="${v}"`) ||
|
|
31
|
+
content.includes(`gap="'${v}'"`) ||
|
|
32
|
+
content.includes(`d-stack--gap-${v}`) ||
|
|
33
|
+
content.includes(`d-description-list--gap-${v}`),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
description:
|
|
39
|
+
'Migrates DtStack and DtDescriptionList gap prop values from old size stops to new spacing stops.\n' +
|
|
40
|
+
'- Replaces gap="400" with gap="100" (8px)\n' +
|
|
41
|
+
'- Replaces :gap="\'400\'" with :gap="\'100\'" (8px)\n' +
|
|
42
|
+
'- Also handles d-stack--gap-* and d-description-list--gap-* CSS class references.\n' +
|
|
43
|
+
'- gap="50" (0.5px) maps to gap="1" (1px) — closest non-subpixel stop.\n' +
|
|
44
|
+
'- SAFE TO RE-RUN: detects already-migrated files by checking for new-only values (25, 75, 150, 250, 525).\n',
|
|
45
|
+
patterns: ['**/*.{vue,html,js,ts,jsx,tsx,md}'],
|
|
46
|
+
globbyConfig: {
|
|
47
|
+
ignore: ['**/dialtone_migration_helper/tests/**'],
|
|
48
|
+
},
|
|
49
|
+
expressions: [
|
|
50
|
+
// gap="400" → gap="100" (static prop)
|
|
51
|
+
{
|
|
52
|
+
from: /gap="([0-9]+)"/g,
|
|
53
|
+
to: (match, value) => {
|
|
54
|
+
const mapped = GAP_MAP[Number(value)];
|
|
55
|
+
return mapped != null ? `gap="${mapped}"` : match;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
// :gap="'400'" → :gap="'100'" (dynamic prop with string literal)
|
|
59
|
+
{
|
|
60
|
+
from: /:gap="'([0-9]+)'"/g,
|
|
61
|
+
to: (match, value) => {
|
|
62
|
+
const mapped = GAP_MAP[Number(value)];
|
|
63
|
+
return mapped != null ? `:gap="'${mapped}'"` : match;
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
// d-stack--gap-400 → d-stack--gap-100 (CSS class references in templates/JS)
|
|
67
|
+
{
|
|
68
|
+
from: /d-stack--gap-([0-9]+)/g,
|
|
69
|
+
to: (match, value) => {
|
|
70
|
+
const mapped = GAP_MAP[Number(value)];
|
|
71
|
+
return mapped != null ? `d-stack--gap-${mapped}` : match;
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
// d-description-list--gap-400 → d-description-list--gap-100 (CSS class references)
|
|
75
|
+
{
|
|
76
|
+
from: /d-description-list--gap-([0-9]+)/g,
|
|
77
|
+
to: (match, value) => {
|
|
78
|
+
const mapped = GAP_MAP[Number(value)];
|
|
79
|
+
return mapped != null ? `d-description-list--gap-${mapped}` : match;
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
// Called by the migration helper before processing each file.
|
|
84
|
+
// Return false to skip the file (already migrated).
|
|
85
|
+
shouldProcessFile (content) {
|
|
86
|
+
return !isAlreadyMigrated(content);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Migration: old pixel-based utility class names → new token-stop-based class names
|
|
2
|
+
// e.g. d-h16 → d-h-25, d-p8 → d-p-100, d-m8 → d-m-100
|
|
3
|
+
|
|
4
|
+
// Sizing: pixel value → layout token stop
|
|
5
|
+
// MUST STAY IN SYNC with WIDTH_HEIGHTS_LAYOUT in dialtone-css/postcss/constants.cjs
|
|
6
|
+
const SIZING_MAP = {
|
|
7
|
+
16: '25', 32: '50', 48: '75', 64: '100', 80: '125', 96: '150',
|
|
8
|
+
112: '175', 128: '200', 160: '250', 192: '300', 224: '350', 256: '400',
|
|
9
|
+
288: '450', 320: '500', 352: '550', 384: '600', 416: '650', 448: '700',
|
|
10
|
+
480: '750', 512: '800', 544: '850', 576: '900', 608: '950', 640: '1000',
|
|
11
|
+
672: '1050', 704: '1100', 736: '1150', 768: '1200', 800: '1250',
|
|
12
|
+
832: '1300', 864: '1350', 896: '1400', 928: '1450', 960: '1500',
|
|
13
|
+
992: '1550', 1024: '1600',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Small sizing values (0-12px) that map to spacing tokens, not layout tokens.
|
|
17
|
+
// These old classes (d-h0, d-h1, d-h2, etc.) don't have a layout-stop equivalent.
|
|
18
|
+
// They should be migrated to use the spacing token directly in CSS rather than a utility class,
|
|
19
|
+
// or left as-is since the old classes still work.
|
|
20
|
+
|
|
21
|
+
// Spacing: pixel value → spacing token stop
|
|
22
|
+
// MUST STAY IN SYNC with GAP_SPACES_SPACING / MARGIN_SIZES_SPACING / PADDING_SIZES_SPACING in dialtone-css/postcss/constants.cjs
|
|
23
|
+
const SPACING_MAP = {
|
|
24
|
+
0: '0', 1: '1', 2: '25', 4: '50', 6: '75', 8: '100',
|
|
25
|
+
10: '125', 12: '150', 14: '175', 16: '200', 20: '250', 24: '300',
|
|
26
|
+
32: '400', 48: '600', 64: '800',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Negative spacing: old notation (n8) → new notation (n100)
|
|
30
|
+
const NEGATIVE_SPACING_MAP = {
|
|
31
|
+
1: '1', 2: '25', 4: '50', 6: '75', 8: '100',
|
|
32
|
+
10: '125', 12: '150', 14: '175', 16: '200', 20: '250', 24: '300',
|
|
33
|
+
32: '400', 48: '600', 64: '800',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Layout sizes for margin/padding (96px, 128px use layout tokens)
|
|
37
|
+
const SPACING_LAYOUT_MAP = {
|
|
38
|
+
96: '150', 128: '200',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Helper: build regex that matches class names with word boundaries
|
|
42
|
+
// Sorted by descending key length to avoid partial matches (d-h1024 before d-h102)
|
|
43
|
+
function buildClassRegex (prefix, map) {
|
|
44
|
+
const keys = Object.keys(map).sort((a, b) => b.length - a.length || Number(b) - Number(a));
|
|
45
|
+
const pattern = keys.join('|');
|
|
46
|
+
// Match class name boundary: preceded by space, quote, or start; followed by space, quote, or end
|
|
47
|
+
return new RegExp(`((?:^|["'\\s]))${prefix}(${pattern})((?:["'\\s]|$))`, 'gm');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
description:
|
|
52
|
+
'Migrates pixel-based utility class names to token-stop-based names.\n' +
|
|
53
|
+
'- Sizing: d-h16 → d-h-25, d-w64 → d-w-100, d-hmn96 → d-hmn-150\n' +
|
|
54
|
+
'- Margin: d-m8 → d-m-100, d-mt16 → d-mt-200, d-mtn8 → d-mt-n100\n' +
|
|
55
|
+
'- Padding: d-p8 → d-p-100, d-pt16 → d-pt-200\n' +
|
|
56
|
+
'- Gap: d-g8 → d-g-100, d-rg16 → d-rg-200\n' +
|
|
57
|
+
'- Position: d-t8 → d-t-100, d-tn8 → d-t-n100\n' +
|
|
58
|
+
'- Old deprecated sizes (d-h72, d-w332, etc.) are left unchanged for manual review.\n',
|
|
59
|
+
patterns: ['**/*.{vue,html,js,ts,jsx,tsx,md,less,css}'],
|
|
60
|
+
globbyConfig: {
|
|
61
|
+
ignore: ['**/dialtone_migration_helper/tests/**', '**/node_modules/**'],
|
|
62
|
+
},
|
|
63
|
+
expressions: [
|
|
64
|
+
// ── Sizing: d-h{px} → d-h-{layout-stop} ──────────────────────────────
|
|
65
|
+
...['h', 'w', 'hmn', 'hmx', 'wmn', 'wmx'].flatMap(prefix => [
|
|
66
|
+
// Layout sizes (16px+)
|
|
67
|
+
{
|
|
68
|
+
from: buildClassRegex(`d-${prefix}`, SIZING_MAP),
|
|
69
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-${SIZING_MAP[px]}${post}`,
|
|
70
|
+
},
|
|
71
|
+
// Layout sizes for 96/128 (margin/padding also uses these for sizing)
|
|
72
|
+
{
|
|
73
|
+
from: buildClassRegex(`d-${prefix}`, SPACING_LAYOUT_MAP),
|
|
74
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-${SPACING_LAYOUT_MAP[px]}${post}`,
|
|
75
|
+
},
|
|
76
|
+
]),
|
|
77
|
+
|
|
78
|
+
// ── Margin: d-m{px} → d-m-{spacing-stop} ─────────────────────────────
|
|
79
|
+
...['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my'].flatMap(prefix => [
|
|
80
|
+
// Spacing sizes (0-64px)
|
|
81
|
+
{
|
|
82
|
+
from: buildClassRegex(`d-${prefix}`, SPACING_MAP),
|
|
83
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-${SPACING_MAP[px]}${post}`,
|
|
84
|
+
},
|
|
85
|
+
// Layout sizes (96, 128px)
|
|
86
|
+
{
|
|
87
|
+
from: buildClassRegex(`d-${prefix}`, SPACING_LAYOUT_MAP),
|
|
88
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-${SPACING_LAYOUT_MAP[px]}${post}`,
|
|
89
|
+
},
|
|
90
|
+
]),
|
|
91
|
+
|
|
92
|
+
// ── Negative margin: d-m{dir}n{px} → d-m{dir}-n{spacing-stop} ────────
|
|
93
|
+
...['mt', 'mr', 'mb', 'ml', 'mx', 'my', 'm'].map(prefix => ({
|
|
94
|
+
from: buildClassRegex(`d-${prefix}n`, NEGATIVE_SPACING_MAP),
|
|
95
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-n${NEGATIVE_SPACING_MAP[px]}${post}`,
|
|
96
|
+
})),
|
|
97
|
+
|
|
98
|
+
// ── Padding: d-p{px} → d-p-{spacing-stop} ────────────────────────────
|
|
99
|
+
...['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py'].flatMap(prefix => [
|
|
100
|
+
{
|
|
101
|
+
from: buildClassRegex(`d-${prefix}`, SPACING_MAP),
|
|
102
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-${SPACING_MAP[px]}${post}`,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
from: buildClassRegex(`d-${prefix}`, SPACING_LAYOUT_MAP),
|
|
106
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-${SPACING_LAYOUT_MAP[px]}${post}`,
|
|
107
|
+
},
|
|
108
|
+
]),
|
|
109
|
+
|
|
110
|
+
// ── Gap: d-g{px} → d-g-{spacing-stop} ────────────────────────────────
|
|
111
|
+
...['g', 'rg', 'cg'].map(prefix => ({
|
|
112
|
+
from: buildClassRegex(`d-${prefix}`, SPACING_MAP),
|
|
113
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-${SPACING_MAP[px]}${post}`,
|
|
114
|
+
})),
|
|
115
|
+
|
|
116
|
+
// ── Position: d-t{px} → d-t-{spacing-stop} ───────────────────────────
|
|
117
|
+
...['t', 'r', 'b', 'l', 'x', 'y', 'all'].flatMap(prefix => [
|
|
118
|
+
{
|
|
119
|
+
from: buildClassRegex(`d-${prefix}`, SPACING_MAP),
|
|
120
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-${SPACING_MAP[px]}${post}`,
|
|
121
|
+
},
|
|
122
|
+
// Layout position sizes (96px)
|
|
123
|
+
{
|
|
124
|
+
from: buildClassRegex(`d-${prefix}`, SPACING_LAYOUT_MAP),
|
|
125
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-${SPACING_LAYOUT_MAP[px]}${post}`,
|
|
126
|
+
},
|
|
127
|
+
]),
|
|
128
|
+
|
|
129
|
+
// ── Negative position: d-{dir}n{px} → d-{dir}-n{spacing-stop} ────────
|
|
130
|
+
...['t', 'r', 'b', 'l', 'x', 'y', 'all'].map(prefix => ({
|
|
131
|
+
from: buildClassRegex(`d-${prefix}n`, NEGATIVE_SPACING_MAP),
|
|
132
|
+
to: (match, pre, px, post) => `${pre}d-${prefix}-n${NEGATIVE_SPACING_MAP[px]}${post}`,
|
|
133
|
+
})),
|
|
134
|
+
],
|
|
135
|
+
};
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
TEST FILE FOR SIZE-TO-LAYOUT MIGRATION
|
|
4
|
+
Tests context-aware migration of --dt-size-* tokens to either:
|
|
5
|
+
--dt-spacing-* (spacing properties: padding, margin, gap, inset)
|
|
6
|
+
--dt-layout-* (layout properties: width, height, min/max, flex-basis)
|
|
7
|
+
Tokens exceeding the layout scale (>1024px) become raw rem + TODO comment.
|
|
8
|
+
Run: node packages/dialtone-css/lib/dist/js/dialtone_migration_helper/index.mjs --cwd .
|
|
9
|
+
then select "size-to-layout"
|
|
10
|
+
-->
|
|
11
|
+
|
|
12
|
+
<!-- ============================================ -->
|
|
13
|
+
<!-- VUE :style — SPACING CONTEXT -->
|
|
14
|
+
<!-- (should route to --dt-spacing-*) -->
|
|
15
|
+
<!-- ============================================ -->
|
|
16
|
+
|
|
17
|
+
<p :style="{ padding: 'var(--dt-size-400)' }">size-400 on padding → spacing-100</p>
|
|
18
|
+
<p :style="{ margin: 'var(--dt-size-500)' }">size-500 on margin → spacing-200</p>
|
|
19
|
+
<p :style="{ gap: 'var(--dt-size-550)' }">size-550 on gap → spacing-300</p>
|
|
20
|
+
|
|
21
|
+
<!-- ============================================ -->
|
|
22
|
+
<!-- VUE :style — LAYOUT CONTEXT -->
|
|
23
|
+
<!-- (should route to --dt-layout-*) -->
|
|
24
|
+
<!-- ============================================ -->
|
|
25
|
+
|
|
26
|
+
<div :style="{ width: 'var(--dt-size-700)' }">size-700 on width → layout-100</div>
|
|
27
|
+
<div :style="{ height: 'var(--dt-size-800)' }">size-800 on height → layout-200</div>
|
|
28
|
+
<div :style="{ maxWidth: 'var(--dt-size-1000)' }">size-1000 on max-width → layout-800</div>
|
|
29
|
+
|
|
30
|
+
<!-- Skip: already-migrated tokens -->
|
|
31
|
+
<div :style="{ width: 'var(--dt-layout-100)' }">already layout-100</div>
|
|
32
|
+
<p :style="{ padding: 'var(--dt-spacing-100)' }">already spacing-100</p>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<style lang="less">
|
|
36
|
+
/* ============================================ */
|
|
37
|
+
/* SPACING CONTEXT → --dt-spacing-* */
|
|
38
|
+
/* padding, margin, gap, inset and variants */
|
|
39
|
+
/* ============================================ */
|
|
40
|
+
|
|
41
|
+
/* padding: all mapped stops */
|
|
42
|
+
.test-padding-exact {
|
|
43
|
+
padding: var(--dt-size-0); /* → spacing-0 (0px) */
|
|
44
|
+
padding: var(--dt-size-100); /* → spacing-1 (1px) */
|
|
45
|
+
padding: var(--dt-size-200); /* → spacing-25 (2px) */
|
|
46
|
+
padding: var(--dt-size-300); /* → spacing-50 (4px) */
|
|
47
|
+
padding: var(--dt-size-350); /* → spacing-75 (6px) */
|
|
48
|
+
padding: var(--dt-size-400); /* → spacing-100 (8px) */
|
|
49
|
+
padding: var(--dt-size-450); /* → spacing-150 (12px) */
|
|
50
|
+
padding: var(--dt-size-500); /* → spacing-200 (16px) */
|
|
51
|
+
padding: var(--dt-size-525); /* → spacing-250 (20px) */
|
|
52
|
+
padding: var(--dt-size-550); /* → spacing-300 (24px) */
|
|
53
|
+
padding: var(--dt-size-600); /* → spacing-400 (32px) */
|
|
54
|
+
padding: var(--dt-size-625); /* → spacing-525 (42px) */
|
|
55
|
+
padding: var(--dt-size-650); /* → spacing-600 (48px) */
|
|
56
|
+
padding: var(--dt-size-700); /* → spacing-800 (64px) */
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* padding directional */
|
|
60
|
+
.test-padding-directional {
|
|
61
|
+
padding-block-start: var(--dt-size-400);
|
|
62
|
+
padding-inline: var(--dt-size-550);
|
|
63
|
+
padding-block-start: var(--dt-size-300);
|
|
64
|
+
padding-inline-end: var(--dt-size-400);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* margin */
|
|
68
|
+
.test-margin {
|
|
69
|
+
margin: var(--dt-size-400);
|
|
70
|
+
margin-block-start: var(--dt-size-550);
|
|
71
|
+
margin-inline: var(--dt-size-600);
|
|
72
|
+
margin-block-end: var(--dt-size-300);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* gap, row-gap, column-gap */
|
|
76
|
+
.test-gap {
|
|
77
|
+
gap: var(--dt-size-400);
|
|
78
|
+
row-gap: var(--dt-size-550);
|
|
79
|
+
column-gap: var(--dt-size-300);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* inset */
|
|
83
|
+
.test-inset {
|
|
84
|
+
inset: var(--dt-size-400);
|
|
85
|
+
inset-block: var(--dt-size-300);
|
|
86
|
+
inset-inline-start: var(--dt-size-550);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* shorthand with multiple size tokens */
|
|
90
|
+
.test-padding-multi {
|
|
91
|
+
padding: var(--dt-size-400) var(--dt-size-550);
|
|
92
|
+
margin: var(--dt-size-300) var(--dt-size-400) var(--dt-size-550) var(--dt-size-600);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* ============================================ */
|
|
96
|
+
/* LAYOUT CONTEXT → --dt-layout-* */
|
|
97
|
+
/* width, height, min/max, flex-basis, logical */
|
|
98
|
+
/* ============================================ */
|
|
99
|
+
|
|
100
|
+
/* width: exact matches */
|
|
101
|
+
.test-width-exact {
|
|
102
|
+
inline-size: var(--dt-size-500); /* → layout-25 (16px) */
|
|
103
|
+
inline-size: var(--dt-size-600); /* → layout-50 (32px) */
|
|
104
|
+
inline-size: var(--dt-size-650); /* → layout-75 (48px) */
|
|
105
|
+
inline-size: var(--dt-size-700); /* → layout-100 (64px) */
|
|
106
|
+
inline-size: var(--dt-size-750); /* → layout-150 (96px) */
|
|
107
|
+
inline-size: var(--dt-size-800); /* → layout-200 (128px) */
|
|
108
|
+
inline-size: var(--dt-size-850); /* → layout-300 (192px) */
|
|
109
|
+
inline-size: var(--dt-size-900); /* → layout-400 (256px) */
|
|
110
|
+
inline-size: var(--dt-size-950); /* → layout-600 (384px) */
|
|
111
|
+
inline-size: var(--dt-size-1000); /* → layout-800 (512px) */
|
|
112
|
+
inline-size: var(--dt-size-1050); /* → layout-1200 (768px) */
|
|
113
|
+
inline-size: var(--dt-size-1100); /* → layout-1600 (1024px) */
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* height */
|
|
117
|
+
.test-height {
|
|
118
|
+
block-size: var(--dt-size-700);
|
|
119
|
+
min-block-size: var(--dt-size-800);
|
|
120
|
+
max-block-size: var(--dt-size-1000);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* min/max width */
|
|
124
|
+
.test-minmax {
|
|
125
|
+
min-inline-size: var(--dt-size-650);
|
|
126
|
+
max-inline-size: var(--dt-size-900);
|
|
127
|
+
min-inline-size: var(--dt-size-1000);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* flex-basis */
|
|
131
|
+
.test-flex-basis {
|
|
132
|
+
flex-basis: var(--dt-size-700);
|
|
133
|
+
flex-basis: var(--dt-size-800);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* logical layout properties */
|
|
137
|
+
.test-logical-layout {
|
|
138
|
+
inline-size: var(--dt-size-700);
|
|
139
|
+
block-size: var(--dt-size-800);
|
|
140
|
+
min-inline-size: var(--dt-size-650);
|
|
141
|
+
max-inline-size: var(--dt-size-1000);
|
|
142
|
+
max-block-size: var(--dt-size-950);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* ============================================ */
|
|
146
|
+
/* NEAREST-NEIGHBOR MAPPINGS */
|
|
147
|
+
/* No exact match — mapped to closest stop */
|
|
148
|
+
/* ============================================ */
|
|
149
|
+
|
|
150
|
+
.test-nearest-neighbor {
|
|
151
|
+
inline-size: var(--dt-size-825); /* 164px → layout-250 (160px, Δ4px) */
|
|
152
|
+
inline-size: var(--dt-size-875); /* 216px → layout-350 (224px, Δ8px) */
|
|
153
|
+
inline-size: var(--dt-size-905); /* 264px → layout-400 (256px, Δ8px) */
|
|
154
|
+
inline-size: var(--dt-size-925); /* 332px → layout-500 (320px, Δ12px) */
|
|
155
|
+
block-size: var(--dt-size-975); /* 464px → layout-700 (448px, Δ16px) */
|
|
156
|
+
inline-size: var(--dt-size-1020); /* 628px → layout-1000 (640px, Δ12px) */
|
|
157
|
+
max-inline-size: var(--dt-size-1040); /* 764px → layout-1200 (768px, Δ4px) */
|
|
158
|
+
max-inline-size: var(--dt-size-1060); /* 828px → layout-1300 (832px, Δ4px) */
|
|
159
|
+
max-block-size: var(--dt-size-1080); /* 912px → layout-1400 (896px, Δ16px) */
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* ============================================ */
|
|
163
|
+
/* RAW FALLBACK (exceeds layout scale >1024px) */
|
|
164
|
+
/* Converted to rem + TODO comment */
|
|
165
|
+
/* ============================================ */
|
|
166
|
+
|
|
167
|
+
.test-raw-fallback {
|
|
168
|
+
max-inline-size: var(--dt-size-1115); /* 1140px → 71.25rem + TODO comment */
|
|
169
|
+
max-inline-size: var(--dt-size-1120); /* 1268px → 79.25rem + TODO comment */
|
|
170
|
+
max-inline-size: var(--dt-size-1125); /* 1280px → 80rem + TODO comment */
|
|
171
|
+
max-inline-size: var(--dt-size-1130); /* 1340px → 83.75rem + TODO comment */
|
|
172
|
+
inline-size: var(--dt-size-1150); /* 1536px → 96rem + TODO comment */
|
|
173
|
+
inline-size: var(--dt-size-1200); /* 2048px → 128rem + TODO comment */
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* ============================================ */
|
|
177
|
+
/* CUSTOM PROPERTY DEFINITIONS */
|
|
178
|
+
/* Script routes by keyword in property name */
|
|
179
|
+
/* ============================================ */
|
|
180
|
+
|
|
181
|
+
/* Spacing keywords in custom property name → --dt-spacing-* */
|
|
182
|
+
.test-custom-spacing {
|
|
183
|
+
--badge-padding-y: var(--dt-size-400); /* "padding" → spacing-100 (8px) */
|
|
184
|
+
--badge-padding-x: var(--dt-size-550); /* "padding" → spacing-300 (24px) */
|
|
185
|
+
--badge-label-padding-x: var(--dt-size-500); /* "padding" → spacing-200 (16px) */
|
|
186
|
+
--badge-letter-spacing: var(--dt-size-100); /* "spacing" → spacing-1 (1px) */
|
|
187
|
+
--badge-gap: var(--dt-size-300); /* "gap" → spacing-50 (4px) */
|
|
188
|
+
--item-margin-start: var(--dt-size-400); /* "margin" → spacing-100 (8px) */
|
|
189
|
+
--item-inset-y: var(--dt-size-300); /* "inset" → spacing-50 (4px) */
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/* Layout keywords in custom property name → --dt-layout-* */
|
|
193
|
+
.test-custom-layout {
|
|
194
|
+
--badge-radius: var(--dt-size-700); /* "radius" → layout-100 (64px) */
|
|
195
|
+
--panel-width: var(--dt-size-1050); /* "width" → layout-1200 (768px) */
|
|
196
|
+
--sidebar-min-width: var(--dt-size-900); /* "width" → layout-400 (256px) */
|
|
197
|
+
--avatar-basis: var(--dt-size-700); /* "basis" → layout-100 (64px) */
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* Ambiguous custom property — no keyword match → default fallback (layout map) */
|
|
201
|
+
/* NOTE: "line-height" intentionally excluded from height keyword matching */
|
|
202
|
+
/* These require manual review after migration */
|
|
203
|
+
.test-custom-ambiguous {
|
|
204
|
+
--badge-line-height: var(--dt-size-500); /* no keyword match → layout-25 (default) */
|
|
205
|
+
--overlay-depth: var(--dt-size-700); /* no keyword match → layout-100 (default) */
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* ============================================ */
|
|
209
|
+
/* SKIP CASES (should NOT be modified) */
|
|
210
|
+
/* ============================================ */
|
|
211
|
+
|
|
212
|
+
/* Already using --dt-layout-* */
|
|
213
|
+
.test-skip-already-layout {
|
|
214
|
+
inline-size: var(--dt-layout-100);
|
|
215
|
+
block-size: var(--dt-layout-200);
|
|
216
|
+
max-inline-size: var(--dt-layout-800);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/* Already using --dt-spacing-* */
|
|
220
|
+
.test-skip-already-spacing {
|
|
221
|
+
padding: var(--dt-spacing-100);
|
|
222
|
+
margin: var(--dt-spacing-300);
|
|
223
|
+
gap: var(--dt-spacing-400);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* Unknown stop number (not in any map — passed through, lint will flag) */
|
|
227
|
+
.test-skip-unknown {
|
|
228
|
+
inline-size: var(--dt-size-999);
|
|
229
|
+
padding: var(--dt-size-123);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/* ============================================ */
|
|
233
|
+
/* ADDITIONAL COVERAGE (from review feedback) */
|
|
234
|
+
/* ============================================ */
|
|
235
|
+
|
|
236
|
+
/* --dt-size-50 in spacing context → spacing-1 (0.5px → 1px nearest) */
|
|
237
|
+
.test-size-50-spacing {
|
|
238
|
+
padding: var(--dt-size-50); /* → spacing-1 */
|
|
239
|
+
letter-spacing: var(--dt-size-50); /* → spacing-1 (via default) */
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* Unmapped layout stops that should now have nearest-neighbor entries */
|
|
243
|
+
.test-newly-mapped-stops {
|
|
244
|
+
inline-size: var(--dt-size-720); /* 72px → layout-100 (64px) */
|
|
245
|
+
inline-size: var(--dt-size-730); /* 84px → layout-125 (80px) */
|
|
246
|
+
inline-size: var(--dt-size-760); /* 102px → layout-150 (96px) */
|
|
247
|
+
inline-size: var(--dt-size-775); /* 114px → layout-175 (112px) */
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* Negative and percent suffixes */
|
|
251
|
+
.test-suffixes {
|
|
252
|
+
margin: var(--dt-size-400-negative); /* → spacing-100-negative */
|
|
253
|
+
inline-size: var(--dt-size-100-percent); /* → layout-100-percent */
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* calc(var(--dt-spacing-*) * -1) → negative token cleanup */
|
|
257
|
+
.test-calc-negation {
|
|
258
|
+
inset: calc(var(--dt-spacing-100) * -1); /* → var(--dt-spacing-100-negative) */
|
|
259
|
+
margin: calc(var(--dt-spacing-300) * -1); /* → var(--dt-spacing-300-negative) */
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* Border-width context → --dt-size-border-* */
|
|
263
|
+
.test-border-width {
|
|
264
|
+
border: var(--dt-size-100) solid red; /* → dt-size-border-100 */
|
|
265
|
+
border-width: var(--dt-size-200); /* → dt-size-border-200 */
|
|
266
|
+
outline: var(--dt-size-100) solid; /* → dt-size-border-100 */
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/* Border-radius context → --dt-size-radius-* */
|
|
270
|
+
.test-border-radius {
|
|
271
|
+
border-radius: var(--dt-size-300); /* → dt-size-radius-300 */
|
|
272
|
+
border-radius: var(--dt-size-400); /* → dt-size-radius-400 */
|
|
273
|
+
--badge-radius: var(--dt-size-300); /* "radius" keyword → dt-size-radius-300 */
|
|
274
|
+
}
|
|
275
|
+
</style>
|