@dialpad/dialtone-css 8.80.0-next.2 → 8.80.0-next.4
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/lib/build/js/dialtone_migrate_link_rendering/button-nav-test-examples.vue +92 -0
- package/lib/build/js/dialtone_migrate_link_rendering/button-nav.test.mjs +272 -0
- package/lib/build/js/dialtone_migrate_link_rendering/helpers.mjs +25 -0
- package/lib/build/js/dialtone_migrate_link_rendering/index.mjs +1041 -0
- package/lib/build/js/dialtone_migrate_link_rendering/link-nav-test-examples.vue +97 -0
- package/lib/build/js/dialtone_migrate_link_rendering/link-nav.test.mjs +194 -0
- package/lib/build/js/dialtone_migrate_link_rendering/underline-test-examples.vue +57 -0
- package/lib/build/js/dialtone_migrate_link_rendering/underline.test.mjs +161 -0
- package/lib/build/js/dialtone_migrate_props/index.mjs +794 -0
- package/lib/build/js/dialtone_migrate_props/test.mjs +959 -0
- package/lib/build/js/dialtone_migration_helper/configs/base-to-semantic.mjs +8 -8
- package/lib/build/js/dialtone_migration_helper/configs/size-to-layout.mjs +10 -0
- package/lib/build/js/dialtone_migration_helper/configs/success-to-positive.mjs +73 -0
- package/lib/build/js/dialtone_migration_helper/configs/utility-class-to-token-stops.mjs +92 -12
- package/lib/build/js/dialtone_migration_helper/tests/base-to-semantic-test-examples.vue +10 -10
- package/lib/build/js/dialtone_migration_helper/tests/base-to-semantic.test.mjs +8 -8
- package/lib/build/js/dialtone_migration_helper/tests/size-to-layout-test-examples.vue +16 -0
- package/lib/build/js/dialtone_migration_helper/tests/size-to-layout.test.mjs +87 -0
- package/lib/build/js/dialtone_migration_helper/tests/success-to-positive-test-examples.vue +166 -0
- package/lib/build/js/dialtone_migration_helper/tests/success-to-positive.test.mjs +287 -0
- package/lib/build/js/dialtone_migration_helper/tests/utility-class-to-token-stops-radius-examples.vue +66 -0
- package/lib/build/js/dialtone_migration_helper/tests/utility-class-to-token-stops.test.mjs +170 -0
- package/lib/build/less/components/badge.less +1 -1
- package/lib/build/less/components/banner.less +1 -1
- package/lib/build/less/components/box.less +9 -22
- package/lib/build/less/components/description-list.less +4 -0
- package/lib/build/less/components/forms.less +4 -2
- package/lib/build/less/components/input.less +2 -2
- package/lib/build/less/components/link.less +18 -4
- package/lib/build/less/components/modal.less +1 -1
- package/lib/build/less/components/notice.less +3 -3
- package/lib/build/less/components/progress_circle.less +10 -2
- package/lib/build/less/components/prose.less +512 -0
- package/lib/build/less/components/rich-text-editor.less +31 -0
- package/lib/build/less/components/selects.less +1 -1
- package/lib/build/less/components/text.less +2 -0
- package/lib/build/less/components/toast.less +1 -1
- package/lib/build/less/dialtone.less +1 -0
- package/lib/build/less/recipes/leftbar_row.less +2 -2
- package/lib/build/less/recipes/settings_menu_button.less +1 -1
- package/lib/build/less/recipes/top_banner_info.less +1 -1
- package/lib/build/less/utilities/backgrounds.less +12 -0
- package/lib/build/less/utilities/borders.less +56 -89
- package/lib/build/less/utilities/colors.less +8 -0
- package/lib/build/less/utilities/effects.less +1 -0
- package/lib/build/less/utilities/flex.less +145 -18
- package/lib/build/less/utilities/grid.less +40 -152
- package/lib/build/less/utilities/layout.less +19 -7
- package/lib/build/less/utilities/sizing.less +148 -143
- package/lib/build/less/variables/visual-styles.less +2 -1
- package/lib/dist/dialtone-default-theme.css +2840 -1807
- package/lib/dist/dialtone-default-theme.min.css +1 -1
- package/lib/dist/dialtone-docs.json +1 -1
- package/lib/dist/dialtone.css +2747 -1756
- package/lib/dist/dialtone.min.css +1 -1
- package/lib/dist/js/dialtone_migrate_link_rendering/button-nav-test-examples.vue +92 -0
- package/lib/dist/js/dialtone_migrate_link_rendering/button-nav.test.mjs +272 -0
- package/lib/dist/js/dialtone_migrate_link_rendering/helpers.mjs +25 -0
- package/lib/dist/js/dialtone_migrate_link_rendering/index.mjs +1041 -0
- package/lib/dist/js/dialtone_migrate_link_rendering/link-nav-test-examples.vue +97 -0
- package/lib/dist/js/dialtone_migrate_link_rendering/link-nav.test.mjs +194 -0
- package/lib/dist/js/dialtone_migrate_link_rendering/underline-test-examples.vue +57 -0
- package/lib/dist/js/dialtone_migrate_link_rendering/underline.test.mjs +161 -0
- package/lib/dist/js/dialtone_migrate_props/index.mjs +794 -0
- package/lib/dist/js/dialtone_migrate_props/test.mjs +959 -0
- package/lib/dist/js/dialtone_migration_helper/configs/base-to-semantic.mjs +8 -8
- package/lib/dist/js/dialtone_migration_helper/configs/size-to-layout.mjs +10 -0
- package/lib/dist/js/dialtone_migration_helper/configs/success-to-positive.mjs +73 -0
- package/lib/dist/js/dialtone_migration_helper/configs/utility-class-to-token-stops.mjs +92 -12
- package/lib/dist/js/dialtone_migration_helper/tests/base-to-semantic-test-examples.vue +10 -10
- package/lib/dist/js/dialtone_migration_helper/tests/base-to-semantic.test.mjs +8 -8
- package/lib/dist/js/dialtone_migration_helper/tests/size-to-layout-test-examples.vue +16 -0
- package/lib/dist/js/dialtone_migration_helper/tests/size-to-layout.test.mjs +87 -0
- package/lib/dist/js/dialtone_migration_helper/tests/success-to-positive-test-examples.vue +166 -0
- package/lib/dist/js/dialtone_migration_helper/tests/success-to-positive.test.mjs +287 -0
- package/lib/dist/js/dialtone_migration_helper/tests/utility-class-to-token-stops-radius-examples.vue +66 -0
- package/lib/dist/js/dialtone_migration_helper/tests/utility-class-to-token-stops.test.mjs +170 -0
- package/lib/dist/tokens/tokens-101-dark.css +81 -45
- package/lib/dist/tokens/tokens-101-light.css +75 -39
- package/lib/dist/tokens/tokens-102-dark.css +81 -45
- package/lib/dist/tokens/tokens-102-light.css +75 -39
- package/lib/dist/tokens/tokens-103-dark.css +81 -45
- package/lib/dist/tokens/tokens-103-light.css +75 -39
- package/lib/dist/tokens/tokens-104-dark.css +81 -45
- package/lib/dist/tokens/tokens-104-light.css +75 -39
- package/lib/dist/tokens/tokens-105-dark.css +81 -45
- package/lib/dist/tokens/tokens-105-light.css +75 -39
- package/lib/dist/tokens/tokens-106-dark.css +81 -45
- package/lib/dist/tokens/tokens-106-light.css +75 -39
- package/lib/dist/tokens/tokens-107-dark.css +81 -45
- package/lib/dist/tokens/tokens-107-light.css +75 -39
- package/lib/dist/tokens/tokens-108-dark.css +81 -45
- package/lib/dist/tokens/tokens-108-light.css +75 -39
- package/lib/dist/tokens/tokens-109-dark.css +81 -45
- package/lib/dist/tokens/tokens-109-light.css +75 -39
- package/lib/dist/tokens/tokens-110-dark.css +81 -45
- package/lib/dist/tokens/tokens-110-light.css +75 -39
- package/lib/dist/tokens/tokens-111-dark.css +81 -45
- package/lib/dist/tokens/tokens-111-light.css +75 -39
- package/lib/dist/tokens/tokens-112-dark.css +81 -45
- package/lib/dist/tokens/tokens-112-light.css +75 -39
- package/lib/dist/tokens/tokens-113-dark.css +81 -45
- package/lib/dist/tokens/tokens-113-light.css +75 -39
- package/lib/dist/tokens/tokens-114-dark.css +81 -45
- package/lib/dist/tokens/tokens-114-light.css +75 -39
- package/lib/dist/tokens/tokens-115-dark.css +81 -45
- package/lib/dist/tokens/tokens-115-light.css +75 -39
- package/lib/dist/tokens/tokens-116-dark.css +81 -45
- package/lib/dist/tokens/tokens-116-light.css +75 -39
- package/lib/dist/tokens/tokens-117-dark.css +81 -45
- package/lib/dist/tokens/tokens-117-light.css +75 -39
- package/lib/dist/tokens/tokens-118-dark.css +81 -45
- package/lib/dist/tokens/tokens-118-light.css +75 -39
- package/lib/dist/tokens/tokens-119-dark.css +81 -45
- package/lib/dist/tokens/tokens-119-light.css +75 -39
- package/lib/dist/tokens/tokens-120-dark.css +81 -45
- package/lib/dist/tokens/tokens-120-light.css +75 -39
- package/lib/dist/tokens/tokens-121-dark.css +81 -45
- package/lib/dist/tokens/tokens-121-light.css +75 -39
- package/lib/dist/tokens/tokens-122-dark.css +81 -45
- package/lib/dist/tokens/tokens-122-light.css +75 -39
- package/lib/dist/tokens/tokens-123-dark.css +81 -45
- package/lib/dist/tokens/tokens-123-light.css +75 -39
- package/lib/dist/tokens/tokens-124-dark.css +81 -45
- package/lib/dist/tokens/tokens-124-light.css +75 -39
- package/lib/dist/tokens/tokens-125-dark.css +81 -45
- package/lib/dist/tokens/tokens-125-light.css +75 -39
- package/lib/dist/tokens/tokens-126-dark.css +81 -45
- package/lib/dist/tokens/tokens-126-light.css +75 -39
- package/lib/dist/tokens/tokens-127-dark.css +81 -45
- package/lib/dist/tokens/tokens-127-light.css +75 -39
- package/lib/dist/tokens/tokens-128-dark.css +81 -45
- package/lib/dist/tokens/tokens-128-light.css +75 -39
- package/lib/dist/tokens/tokens-129-dark.css +81 -45
- package/lib/dist/tokens/tokens-129-light.css +75 -39
- package/lib/dist/tokens/tokens-130-dark.css +81 -45
- package/lib/dist/tokens/tokens-130-light.css +75 -39
- package/lib/dist/tokens/tokens-131-dark.css +81 -45
- package/lib/dist/tokens/tokens-131-light.css +75 -39
- package/lib/dist/tokens/tokens-132-dark.css +81 -45
- package/lib/dist/tokens/tokens-132-light.css +75 -39
- package/lib/dist/tokens/tokens-133-dark.css +81 -45
- package/lib/dist/tokens/tokens-133-light.css +75 -39
- package/lib/dist/tokens/tokens-134-dark.css +81 -45
- package/lib/dist/tokens/tokens-134-light.css +75 -39
- package/lib/dist/tokens/tokens-135-dark.css +81 -45
- package/lib/dist/tokens/tokens-135-light.css +75 -39
- package/lib/dist/tokens/tokens-136-dark.css +81 -45
- package/lib/dist/tokens/tokens-136-light.css +75 -39
- package/lib/dist/tokens/tokens-137-dark.css +81 -45
- package/lib/dist/tokens/tokens-137-light.css +75 -39
- package/lib/dist/tokens/tokens-aegean-dark.css +81 -45
- package/lib/dist/tokens/tokens-aegean-light.css +75 -39
- package/lib/dist/tokens/tokens-base-dark.css +18 -12
- package/lib/dist/tokens/tokens-base-light.css +18 -12
- package/lib/dist/tokens/tokens-botany-dark.css +81 -45
- package/lib/dist/tokens/tokens-botany-light.css +75 -39
- package/lib/dist/tokens/tokens-buttercream-dark.css +81 -45
- package/lib/dist/tokens/tokens-buttercream-light.css +75 -39
- package/lib/dist/tokens/tokens-ceruleo-dark.css +81 -45
- package/lib/dist/tokens/tokens-ceruleo-light.css +75 -39
- package/lib/dist/tokens/tokens-debug-base.css +6 -0
- package/lib/dist/tokens/tokens-debug-dp.css +39 -3
- package/lib/dist/tokens/tokens-dp-dark.css +81 -45
- package/lib/dist/tokens/tokens-dp-light.css +75 -39
- package/lib/dist/tokens/tokens-expressive-dark.css +81 -45
- package/lib/dist/tokens/tokens-expressive-light.css +75 -39
- package/lib/dist/tokens/tokens-expressive-sm-dark.css +81 -45
- package/lib/dist/tokens/tokens-expressive-sm-light.css +75 -39
- package/lib/dist/tokens/tokens-high-desert-dark.css +81 -45
- package/lib/dist/tokens/tokens-high-desert-light.css +75 -39
- package/lib/dist/tokens/tokens-melon-dark.css +81 -45
- package/lib/dist/tokens/tokens-melon-light.css +75 -39
- package/lib/dist/tokens/tokens-plum-dark.css +81 -45
- package/lib/dist/tokens/tokens-plum-light.css +75 -39
- package/lib/dist/tokens/tokens-prota-deuter-dark.css +79 -43
- package/lib/dist/tokens/tokens-prota-deuter-light.css +74 -38
- package/lib/dist/tokens/tokens-sunflower-dark.css +81 -45
- package/lib/dist/tokens/tokens-sunflower-light.css +75 -39
- package/lib/dist/tokens/tokens-tmo-dark.css +81 -45
- package/lib/dist/tokens/tokens-tmo-light.css +75 -39
- package/lib/dist/tokens/tokens-trita-dark.css +81 -45
- package/lib/dist/tokens/tokens-trita-light.css +75 -39
- package/lib/dist/tokens/tokens-verdant-haze-dark.css +81 -45
- package/lib/dist/tokens/tokens-verdant-haze-light.css +75 -39
- package/lib/dist/tokens-docs.json +1 -1
- package/package.json +10 -5
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
TEST FILE FOR button-nav MIGRATION (DLT-3033)
|
|
4
|
+
|
|
5
|
+
Each example shows a legacy pattern the codemod recognizes and the expected
|
|
6
|
+
rewritten form. The fixture doubles as a `npx dialtone-migrate-link-rendering
|
|
7
|
+
--dry-run --cwd <this-folder>` demo target.
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
<!-- ============================================ -->
|
|
11
|
+
<!-- 1. <a class="d-btn"> → <dt-button href> -->
|
|
12
|
+
<!-- ============================================ -->
|
|
13
|
+
|
|
14
|
+
<!-- Plain anchor -->
|
|
15
|
+
<a class="d-btn" href="/settings">Settings</a>
|
|
16
|
+
|
|
17
|
+
<!-- Anchor with size modifier -->
|
|
18
|
+
<a class="d-btn d-btn--lg" href="/settings">Large CTA</a>
|
|
19
|
+
|
|
20
|
+
<!-- Anchor with importance modifier -->
|
|
21
|
+
<a class="d-btn d-btn--outlined" href="/cancel">Cancel</a>
|
|
22
|
+
|
|
23
|
+
<!-- Anchor with kind modifier -->
|
|
24
|
+
<a class="d-btn d-btn--critical" href="/delete">Delete</a>
|
|
25
|
+
|
|
26
|
+
<!-- Anchor with renamed kind (danger → critical) -->
|
|
27
|
+
<a class="d-btn d-btn--danger" href="/delete">Delete</a>
|
|
28
|
+
|
|
29
|
+
<!-- Anchor with circle modifier (icon button) -->
|
|
30
|
+
<a class="d-btn d-btn--circle" href="/avatar">A</a>
|
|
31
|
+
|
|
32
|
+
<!-- Stacked modifiers -->
|
|
33
|
+
<a class="d-btn d-btn--lg d-btn--outlined d-btn--critical" href="/delete">Delete</a>
|
|
34
|
+
|
|
35
|
+
<!-- Anchor with target / rel (preserved via $attrs fallthrough) -->
|
|
36
|
+
<a
|
|
37
|
+
class="d-btn"
|
|
38
|
+
href="https://example.com"
|
|
39
|
+
target="_blank"
|
|
40
|
+
rel="noopener noreferrer"
|
|
41
|
+
>
|
|
42
|
+
External link
|
|
43
|
+
</a>
|
|
44
|
+
|
|
45
|
+
<!-- ============================================ -->
|
|
46
|
+
<!-- 2. <router-link class="d-btn"> → <dt-button :to> -->
|
|
47
|
+
<!-- ============================================ -->
|
|
48
|
+
|
|
49
|
+
<!-- Static `to` -->
|
|
50
|
+
<router-link class="d-btn" to="/dashboard">Dashboard</router-link>
|
|
51
|
+
|
|
52
|
+
<!-- Bound `:to` -->
|
|
53
|
+
<router-link class="d-btn" :to="{ name: 'dashboard' }">Dashboard</router-link>
|
|
54
|
+
|
|
55
|
+
<!-- Bound `:to` with modifiers -->
|
|
56
|
+
<router-link
|
|
57
|
+
class="d-btn d-btn--lg d-btn--critical"
|
|
58
|
+
:to="route"
|
|
59
|
+
>
|
|
60
|
+
Delete
|
|
61
|
+
</router-link>
|
|
62
|
+
|
|
63
|
+
<!-- ============================================ -->
|
|
64
|
+
<!-- 3. Vendor & BEM modifiers preserved on class -->
|
|
65
|
+
<!-- ============================================ -->
|
|
66
|
+
|
|
67
|
+
<a class="d-btn d-btn--google" href="/auth/google">Sign in with Google</a>
|
|
68
|
+
|
|
69
|
+
<!-- Custom user class preserved -->
|
|
70
|
+
<a class="d-btn my-cta-class" href="/upgrade">Upgrade</a>
|
|
71
|
+
|
|
72
|
+
<!-- ============================================ -->
|
|
73
|
+
<!-- 4. Patterns that warn (not transformed) -->
|
|
74
|
+
<!-- ============================================ -->
|
|
75
|
+
|
|
76
|
+
<!-- Dynamic :href — warn, skip -->
|
|
77
|
+
<a class="d-btn" :href="dynamicUrl">Dynamic</a>
|
|
78
|
+
|
|
79
|
+
<!-- Dynamic :class alongside static class — warn, skip -->
|
|
80
|
+
<a class="d-btn" :class="extraClasses" href="/x">Mixed</a>
|
|
81
|
+
|
|
82
|
+
<!-- <router-link custom> wrapping <dt-button> — warn, manual review -->
|
|
83
|
+
<router-link
|
|
84
|
+
custom
|
|
85
|
+
v-slot="{ navigate, isActive }"
|
|
86
|
+
:to="{ name: 'profile' }"
|
|
87
|
+
>
|
|
88
|
+
<dt-button :class="{ 'is-active': isActive }" @click="navigate">
|
|
89
|
+
Profile
|
|
90
|
+
</dt-button>
|
|
91
|
+
</router-link>
|
|
92
|
+
</template>
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DLT-3033 — button-nav transform tests.
|
|
3
|
+
*
|
|
4
|
+
* One assertion per test; data-driven via for..of where multiple cases share a concept.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, it } from 'node:test';
|
|
8
|
+
import assert from 'node:assert/strict';
|
|
9
|
+
import { runTransform, runTransformVerbose } from './helpers.mjs';
|
|
10
|
+
|
|
11
|
+
describe('button-nav: <a class="d-btn"> → <dt-button href>', () => {
|
|
12
|
+
const cases = [
|
|
13
|
+
[
|
|
14
|
+
'plain anchor',
|
|
15
|
+
'<a class="d-btn" href="/x">Go</a>',
|
|
16
|
+
'<dt-button href="/x">Go</dt-button>',
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
'anchor with target and rel preserved as fallthrough',
|
|
20
|
+
'<a class="d-btn" href="/x" target="_blank" rel="noopener">Go</a>',
|
|
21
|
+
'<dt-button target="_blank" rel="noopener" href="/x">Go</dt-button>',
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
'anchor with size modifier',
|
|
25
|
+
'<a class="d-btn d-btn--lg" href="/x">Go</a>',
|
|
26
|
+
'<dt-button href="/x" :size="400">Go</dt-button>',
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
'anchor with importance modifier',
|
|
30
|
+
'<a class="d-btn d-btn--outlined" href="/x">Go</a>',
|
|
31
|
+
'<dt-button href="/x" importance="outlined">Go</dt-button>',
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
'anchor with kind modifier',
|
|
35
|
+
'<a class="d-btn d-btn--critical" href="/x">Go</a>',
|
|
36
|
+
'<dt-button href="/x" kind="critical">Go</dt-button>',
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
'anchor with d-btn--danger renames to kind=critical',
|
|
40
|
+
'<a class="d-btn d-btn--danger" href="/x">Go</a>',
|
|
41
|
+
'<dt-button href="/x" kind="critical">Go</dt-button>',
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
'anchor with d-btn--success renames to kind=positive',
|
|
45
|
+
'<a class="d-btn d-btn--success" href="/x">Go</a>',
|
|
46
|
+
'<dt-button href="/x" kind="positive">Go</dt-button>',
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
'anchor with circle modifier',
|
|
50
|
+
'<a class="d-btn d-btn--circle" href="/x">Go</a>',
|
|
51
|
+
'<dt-button href="/x" circle>Go</dt-button>',
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
'anchor with active modifier',
|
|
55
|
+
'<a class="d-btn d-btn--active" href="/x">Go</a>',
|
|
56
|
+
'<dt-button href="/x" active>Go</dt-button>',
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
'anchor with loading modifier',
|
|
60
|
+
'<a class="d-btn d-btn--loading" href="/x">Go</a>',
|
|
61
|
+
'<dt-button href="/x" loading>Go</dt-button>',
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
'anchor with multiple modifiers (size + importance + kind)',
|
|
65
|
+
'<a class="d-btn d-btn--lg d-btn--outlined d-btn--critical" href="/x">Go</a>',
|
|
66
|
+
'<dt-button href="/x" :size="400" importance="outlined" kind="critical">Go</dt-button>',
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
'd-btn--md is the default size — stripped silently',
|
|
70
|
+
'<a class="d-btn d-btn--md" href="/x">Go</a>',
|
|
71
|
+
'<dt-button href="/x">Go</dt-button>',
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
'd-btn--primary is the default importance — stripped silently',
|
|
75
|
+
'<a class="d-btn d-btn--primary" href="/x">Go</a>',
|
|
76
|
+
'<dt-button href="/x">Go</dt-button>',
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
'vendor class preserved on resulting class attr',
|
|
80
|
+
'<a class="d-btn d-btn--google" href="/x">Sign in</a>',
|
|
81
|
+
'<dt-button href="/x" class="d-btn--google">Sign in</dt-button>',
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
'BEM internal preserved on class attr',
|
|
85
|
+
'<a class="d-btn d-btn__icon-only" href="/x">i</a>',
|
|
86
|
+
'<dt-button href="/x" class="d-btn__icon-only">i</dt-button>',
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
'arbitrary user class preserved',
|
|
90
|
+
'<a class="d-btn my-cta-class" href="/x">Go</a>',
|
|
91
|
+
'<dt-button href="/x" class="my-cta-class">Go</dt-button>',
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
'multiline tag content preserved',
|
|
95
|
+
'<a class="d-btn" href="/x">\n <span>Go</span>\n</a>',
|
|
96
|
+
'<dt-button href="/x">\n <span>Go</span>\n</dt-button>',
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
'self-closing anchor (rare but legal in templates)',
|
|
100
|
+
'<a class="d-btn" href="/x" />',
|
|
101
|
+
'<dt-button href="/x" />',
|
|
102
|
+
],
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
for (const [label, input, expected] of cases) {
|
|
106
|
+
it(label, () => {
|
|
107
|
+
assert.equal(runTransform(input), expected);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('button-nav: <router-link class="d-btn"> → <dt-button :to>', () => {
|
|
113
|
+
const cases = [
|
|
114
|
+
[
|
|
115
|
+
'router-link with static to',
|
|
116
|
+
'<router-link class="d-btn" to="/x">Go</router-link>',
|
|
117
|
+
'<dt-button to="/x">Go</dt-button>',
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
'router-link with bound :to',
|
|
121
|
+
'<router-link class="d-btn" :to="route">Go</router-link>',
|
|
122
|
+
'<dt-button :to="route">Go</dt-button>',
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
'router-link with size and kind modifiers',
|
|
126
|
+
'<router-link class="d-btn d-btn--lg d-btn--critical" to="/x">Go</router-link>',
|
|
127
|
+
'<dt-button to="/x" :size="400" kind="critical">Go</dt-button>',
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
'router-link with bound :to and circle',
|
|
131
|
+
'<router-link class="d-btn d-btn--circle" :to="route">x</router-link>',
|
|
132
|
+
'<dt-button :to="route" circle>x</dt-button>',
|
|
133
|
+
],
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
for (const [label, input, expected] of cases) {
|
|
137
|
+
it(label, () => {
|
|
138
|
+
assert.equal(runTransform(input), expected);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('button-nav: warning paths', () => {
|
|
144
|
+
it('dynamic :href on <a class="d-btn"> is lifted to :href on the output', () => {
|
|
145
|
+
assert.equal(
|
|
146
|
+
runTransform('<a class="d-btn" :href="url">Go</a>'),
|
|
147
|
+
'<dt-button :href="url">Go</dt-button>',
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('dynamic :class alongside static class warns and skips transform', () => {
|
|
152
|
+
const { transformed, warnings } = runTransformVerbose(
|
|
153
|
+
'<a class="d-btn" :class="extraClass" href="/x">Go</a>',
|
|
154
|
+
{ filePath: 'fixture.vue' },
|
|
155
|
+
);
|
|
156
|
+
assert.equal(transformed, '<a class="d-btn" :class="extraClass" href="/x">Go</a>');
|
|
157
|
+
assert.equal(warnings.length, 1);
|
|
158
|
+
assert.match(warnings[0], /dynamic :class/);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('<router-link custom> wrapping <dt-button> warns', () => {
|
|
162
|
+
const input = '<router-link custom v-slot="{ navigate }" to="/x"><dt-button @click="navigate">Go</dt-button></router-link>';
|
|
163
|
+
const { warnings } = runTransformVerbose(input, { filePath: 'fixture.vue' });
|
|
164
|
+
const customWarn = warnings.find(w => /router-link custom.*dt-button/.test(w));
|
|
165
|
+
assert.ok(customWarn, 'expected warning about <router-link custom> wrapper');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('<router-link custom class="d-btn"> on the source tag itself warns and skips', () => {
|
|
169
|
+
const input = '<router-link custom v-slot="{ navigate }" to="/x" class="d-btn">Go</router-link>';
|
|
170
|
+
const { transformed, warnings } = runTransformVerbose(input, { filePath: 'fixture.vue' });
|
|
171
|
+
assert.equal(transformed, input);
|
|
172
|
+
assert.ok(warnings.some(w => /router-link custom.*don't transfer/.test(w)));
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('<router-link class="d-btn"> without `to` warns and skips', () => {
|
|
176
|
+
const { transformed, warnings } = runTransformVerbose(
|
|
177
|
+
'<router-link class="d-btn">Go</router-link>',
|
|
178
|
+
{ filePath: 'fixture.vue' },
|
|
179
|
+
);
|
|
180
|
+
assert.equal(transformed, '<router-link class="d-btn">Go</router-link>');
|
|
181
|
+
assert.ok(warnings.some(w => /without a `to`/.test(w)));
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe('button-nav: PascalCase tags accepted, kebab-case emitted', () => {
|
|
186
|
+
it('<RouterLink class="d-btn" :to="..."> → <dt-button :to="...">', () => {
|
|
187
|
+
assert.equal(
|
|
188
|
+
runTransform('<RouterLink class="d-btn" :to="route">Go</RouterLink>'),
|
|
189
|
+
'<dt-button :to="route">Go</dt-button>',
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe('button-nav: quote-aware tag matching survives `>` inside Vue bindings', () => {
|
|
195
|
+
it('<router-link v-if="count > 0" class="d-btn" :to="route">', () => {
|
|
196
|
+
assert.equal(
|
|
197
|
+
runTransform('<router-link v-if="count > 0" class="d-btn" :to="route">Go</router-link>'),
|
|
198
|
+
'<dt-button v-if="count > 0" :to="route">Go</dt-button>',
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('<a class="d-btn" :data-x="`a > b`" href="/x"> — `>` inside binding preserved', () => {
|
|
203
|
+
assert.equal(
|
|
204
|
+
runTransform('<a class="d-btn" :data-x="`a > b`" href="/x">Go</a>'),
|
|
205
|
+
'<dt-button :data-x="`a > b`" href="/x">Go</dt-button>',
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('button-nav: whitespace inside quoted attribute values is preserved', () => {
|
|
211
|
+
it('<a class="d-btn" title="Hello world"> keeps multi-space title verbatim', () => {
|
|
212
|
+
assert.equal(
|
|
213
|
+
runTransform('<a class="d-btn" title="Hello world" href="/x">Go</a>'),
|
|
214
|
+
'<dt-button title="Hello world" href="/x">Go</dt-button>',
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe('button-nav: <router-link custom> wrapper warn is scoped to the wrapper body', () => {
|
|
220
|
+
it('<router-link custom> with a sibling <dt-button> later in the file does not warn', () => {
|
|
221
|
+
const input =
|
|
222
|
+
'<router-link custom v-slot="{ navigate }" to="/x"><span @click="navigate">Go</span></router-link>\n' +
|
|
223
|
+
'<dt-button href="/elsewhere">Unrelated</dt-button>';
|
|
224
|
+
const { warnings } = runTransformVerbose(input, { filePath: 'fixture.vue' });
|
|
225
|
+
assert.equal(warnings.filter(w => /router-link custom/.test(w)).length, 0);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe('button-nav: requires base d-btn token, not just a modifier', () => {
|
|
230
|
+
it('<a class="d-btn--lg"> without base d-btn is not transformed', () => {
|
|
231
|
+
const input = '<a class="d-btn--lg" href="/x">Go</a>';
|
|
232
|
+
assert.equal(runTransform(input), input);
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
describe('button-nav: idempotency', () => {
|
|
237
|
+
it('already-migrated <dt-button href> is a no-op', () => {
|
|
238
|
+
const input = '<dt-button href="/x" :size="400">Go</dt-button>';
|
|
239
|
+
assert.equal(runTransform(input), input);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('mixed: one already-migrated and one legacy in same content', () => {
|
|
243
|
+
const input =
|
|
244
|
+
'<dt-button href="/already">A</dt-button>\n' +
|
|
245
|
+
'<a class="d-btn" href="/legacy">B</a>';
|
|
246
|
+
const expected =
|
|
247
|
+
'<dt-button href="/already">A</dt-button>\n' +
|
|
248
|
+
'<dt-button href="/legacy">B</dt-button>';
|
|
249
|
+
assert.equal(runTransform(input), expected);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('running the transform twice produces no further changes', () => {
|
|
253
|
+
const input = '<a class="d-btn d-btn--lg" href="/x">Go</a>';
|
|
254
|
+
const once = runTransform(input);
|
|
255
|
+
const twice = runTransform(once);
|
|
256
|
+
assert.equal(once, twice);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
describe('button-nav: --only respects transform selection', () => {
|
|
261
|
+
it('--only=link-nav skips button-nav transform', () => {
|
|
262
|
+
const input = '<a class="d-btn" href="/x">Go</a>';
|
|
263
|
+
const { transformed } = runTransformVerbose(input, { only: ['link-nav'] });
|
|
264
|
+
assert.equal(transformed, input);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('--only=button-nav runs only button-nav', () => {
|
|
268
|
+
const input = '<a class="d-btn" href="/x">Go</a>';
|
|
269
|
+
const { transformed } = runTransformVerbose(input, { only: ['button-nav'] });
|
|
270
|
+
assert.equal(transformed, '<dt-button href="/x">Go</dt-button>');
|
|
271
|
+
});
|
|
272
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared test helpers for dialtone-migrate-link-rendering.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the pattern from dialtone_migration_helper/tests/helpers.mjs:
|
|
5
|
+
* a small surface that test files can rely on without re-importing the CLI internals.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { transformContent } from './index.mjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Run the transform on a single string of content and return the rewritten output.
|
|
12
|
+
* Useful for one-input/one-expected-output assertion tests.
|
|
13
|
+
*/
|
|
14
|
+
export function runTransform (input, opts = {}) {
|
|
15
|
+
const { transformed } = transformContent(input, opts);
|
|
16
|
+
return transformed;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Run the transform and return the full result, including warnings and notes.
|
|
21
|
+
* Useful for tests that assert on warnings or notes.
|
|
22
|
+
*/
|
|
23
|
+
export function runTransformVerbose (input, opts = {}) {
|
|
24
|
+
return transformContent(input, opts);
|
|
25
|
+
}
|