@navikt/aksel 7.40.0 → 8.0.0
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 +3 -1
- package/dist/codemod/codeshift.utils.js +1 -0
- package/dist/codemod/migrations.js +13 -1
- package/dist/codemod/transforms/v8.0.0/box/box.js +1 -1
- package/dist/codemod/transforms/v8.0.0/button-variant/button-variant.js +18 -0
- package/dist/codemod/transforms/v8.0.0/link-variant/link-variant.js +17 -0
- package/dist/codemod/transforms/v8.0.0/primitives-spacing/spacing.js +4 -0
- package/dist/{darkside → codemod/v8-tokens}/config/TokenStatus.js +16 -17
- package/dist/{darkside → codemod/v8-tokens}/config/legacy.tokens.js +49 -18
- package/dist/{darkside → codemod/v8-tokens}/config/token-regex.js +2 -6
- package/dist/{darkside/config/darkside.tokens.js → codemod/v8-tokens/config/v8.tokens.js} +3 -3
- package/dist/{darkside → codemod/v8-tokens}/index.js +2 -2
- package/dist/{darkside → codemod/v8-tokens}/run-tooling.js +7 -7
- package/dist/{darkside → codemod/v8-tokens}/tasks/status.js +111 -12
- package/dist/{darkside/transforms/darkside-tokens-css.js → codemod/v8-tokens/transforms/v8-tokens-css.js} +16 -0
- package/dist/codemod/v8-tokens/transforms/v8-tokens-js.js +69 -0
- package/dist/codemod/v8-tokens/transforms/v8-tokens-less.js +28 -0
- package/dist/codemod/v8-tokens/transforms/v8-tokens-scss.js +28 -0
- package/dist/index.js +3 -3
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/dist/darkside/transforms/darkside-tokens-js.js +0 -50
- package/dist/darkside/transforms/darkside-tokens-less.js +0 -14
- package/dist/darkside/transforms/darkside-tokens-scss.js +0 -14
- /package/dist/{darkside → codemod/v8-tokens}/config/legacy-component.tokens.js +0 -0
- /package/dist/{darkside → codemod/v8-tokens}/config/token.utils.js +0 -0
- /package/dist/{darkside → codemod/v8-tokens}/tasks/print-remaining.js +0 -0
- /package/dist/{darkside/transforms/darkside-tokens-tailwind.js → codemod/v8-tokens/transforms/v8-tokens-tailwind.js} +0 -0
package/README.md
CHANGED
|
@@ -66,14 +66,16 @@ Removes deprecated props from components.
|
|
|
66
66
|
|
|
67
67
|
`npx @navikt/aksel codemod v8-list ...`
|
|
68
68
|
|
|
69
|
-
Tries to migrate List component moving 'title' and 'description' props to 'Heading' and 'BodyShort'.
|
|
69
|
+
Tries to migrate List component by wrapping it with 'Box' and moving 'title' and 'description' props to 'Heading' and 'BodyShort'.
|
|
70
70
|
|
|
71
71
|
#### Variants
|
|
72
72
|
|
|
73
|
+
`npx @navikt/aksel codemod v8-button-variant ...`
|
|
73
74
|
`npx @navikt/aksel codemod v8-tag-variant ...`
|
|
74
75
|
`npx @navikt/aksel codemod v8-toggle-group-variant ...`
|
|
75
76
|
`npx @navikt/aksel codemod v8-accordion-variant ...`
|
|
76
77
|
`npx @navikt/aksel codemod v8-chips-variant ...`
|
|
78
|
+
`npx @navikt/aksel codemod v8-link-variant ...`
|
|
77
79
|
|
|
78
80
|
Updates variant + data-color props based on current variant prop.
|
|
79
81
|
|
|
@@ -138,7 +138,7 @@ exports.migrations = {
|
|
|
138
138
|
ignoredExtensions: CSS_EXTENSIONS,
|
|
139
139
|
},
|
|
140
140
|
{
|
|
141
|
-
description: "Tries to migrate List component moving 'title' and 'description' props to 'Heading' and 'BodyShort'.",
|
|
141
|
+
description: "Tries to migrate List component by wrapping it with 'Box' and moving 'title' and 'description' props to 'Heading' and 'BodyShort'.",
|
|
142
142
|
value: "v8-list",
|
|
143
143
|
path: "v8.0.0/list/list",
|
|
144
144
|
ignoredExtensions: CSS_EXTENSIONS,
|
|
@@ -185,6 +185,18 @@ exports.migrations = {
|
|
|
185
185
|
path: "v8.0.0/chips-variant/chips-variant",
|
|
186
186
|
ignoredExtensions: CSS_EXTENSIONS,
|
|
187
187
|
},
|
|
188
|
+
{
|
|
189
|
+
description: "Updates variant + data-color props on Button based on current variant prop.",
|
|
190
|
+
value: "v8-button-variant",
|
|
191
|
+
path: "v8.0.0/button-variant/button-variant",
|
|
192
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
description: "Updates variant + data-color props on Link based on current variant prop.",
|
|
196
|
+
value: "v8-link-variant",
|
|
197
|
+
path: "v8.0.0/link-variant/link-variant",
|
|
198
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
199
|
+
},
|
|
188
200
|
],
|
|
189
201
|
};
|
|
190
202
|
/**
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = transformer;
|
|
7
|
-
const legacy_tokens_1 = require("../../../../
|
|
7
|
+
const legacy_tokens_1 = require("../../../../codemod/v8-tokens/config/legacy.tokens");
|
|
8
8
|
const ast_1 = require("../../../utils/ast");
|
|
9
9
|
const lineterminator_1 = require("../../../utils/lineterminator");
|
|
10
10
|
const box_new_1 = __importDefault(require("../box-new/box-new"));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrationConfig = void 0;
|
|
4
|
+
exports.default = transformer;
|
|
5
|
+
const move_variant_to_data_color_1 = require("../../../utils/move-variant-to-data-color");
|
|
6
|
+
exports.migrationConfig = {
|
|
7
|
+
component: "Button",
|
|
8
|
+
prop: "variant",
|
|
9
|
+
changes: {
|
|
10
|
+
"primary-neutral": { replacement: "primary", color: "neutral" },
|
|
11
|
+
"secondary-neutral": { replacement: "secondary", color: "neutral" },
|
|
12
|
+
"tertiary-neutral": { replacement: "tertiary", color: "neutral" },
|
|
13
|
+
danger: { replacement: "primary", color: "danger" },
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
function transformer(file, api) {
|
|
17
|
+
return (0, move_variant_to_data_color_1.moveVariantToDataColor)(file, api, exports.migrationConfig);
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrationConfig = void 0;
|
|
4
|
+
exports.default = transformer;
|
|
5
|
+
const move_variant_to_data_color_1 = require("../../../utils/move-variant-to-data-color");
|
|
6
|
+
exports.migrationConfig = {
|
|
7
|
+
component: "Link",
|
|
8
|
+
prop: "variant",
|
|
9
|
+
changes: {
|
|
10
|
+
action: { color: "accent" },
|
|
11
|
+
neutral: { color: "neutral" },
|
|
12
|
+
subtle: { color: "neutral" },
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
function transformer(file, api) {
|
|
16
|
+
return (0, move_variant_to_data_color_1.moveVariantToDataColor)(file, api, exports.migrationConfig);
|
|
17
|
+
}
|
|
@@ -52,6 +52,10 @@ function transformer(file, api) {
|
|
|
52
52
|
/* padding="32" */
|
|
53
53
|
attrValue.value = convertSpacingToSpace(attrValue.value);
|
|
54
54
|
}
|
|
55
|
+
else if (attrValue.type === "JSXExpressionContainer" &&
|
|
56
|
+
attrValue.expression.type === "StringLiteral") {
|
|
57
|
+
attrValue.expression.value = convertSpacingToSpace(attrValue.expression.value);
|
|
58
|
+
}
|
|
55
59
|
else if (attrValue.type === "JSXExpressionContainer") {
|
|
56
60
|
/* padding={{xs: "16", sm: "32"}} */
|
|
57
61
|
const expression = attrValue.expression;
|
|
@@ -107,27 +107,24 @@ class TokenStatus {
|
|
|
107
107
|
printMigrationHelp() {
|
|
108
108
|
const imports = {
|
|
109
109
|
css: {
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
new: `@use "@navikt/ds-tokens/css";`,
|
|
111
|
+
link: "https://cdn.jsdelivr.net/npm/@navikt/ds-tokens@7/dist/tokens.css",
|
|
112
112
|
},
|
|
113
113
|
scss: {
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
new: `@use "@navikt/ds-tokens/scss" as *;`,
|
|
115
|
+
link: "https://cdn.jsdelivr.net/npm/@navikt/ds-tokens@7/dist/tokens.scss",
|
|
116
116
|
},
|
|
117
117
|
less: {
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
new: `@import "~@navikt/ds-tokens/less";`,
|
|
119
|
+
link: "https://cdn.jsdelivr.net/npm/@navikt/ds-tokens@7/dist/tokens.less",
|
|
120
120
|
},
|
|
121
121
|
js: {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
},
|
|
125
|
-
tailwind: {
|
|
126
|
-
old: `import config from "@navikt/ds-tailwind";`,
|
|
127
|
-
new: `import config from "@navikt/ds-tailwind/darkside-tw3";`,
|
|
122
|
+
new: `import { ... } from "@navikt/ds-tokens/js";`,
|
|
123
|
+
link: "https://cdn.jsdelivr.net/npm/@navikt/ds-tokens@7/dist/tokens.js",
|
|
128
124
|
},
|
|
129
125
|
};
|
|
130
|
-
for (const
|
|
126
|
+
for (const _key of Object.keys(imports)) {
|
|
127
|
+
const key = _key;
|
|
131
128
|
const data = this.status[key];
|
|
132
129
|
const legacyNeeded = data.legacy.length > 0;
|
|
133
130
|
const foundUse = legacyNeeded || data.updated.length > 0;
|
|
@@ -136,22 +133,24 @@ class TokenStatus {
|
|
|
136
133
|
}
|
|
137
134
|
console.info(chalk_1.default.underline(`\n${key.toUpperCase()} Tokens Migration`));
|
|
138
135
|
const importStrings = imports[key];
|
|
139
|
-
|
|
136
|
+
if (key !== "css") {
|
|
137
|
+
console.info(`${chalk_1.default.blue("→")} Update import: ${chalk_1.default.green(importStrings.new)}`);
|
|
138
|
+
}
|
|
140
139
|
if (legacyNeeded) {
|
|
141
|
-
console.info(`${chalk_1.default.yellow("!")}
|
|
140
|
+
console.info(`${chalk_1.default.yellow("!")} Old tokens still needed until migration is finished. Finish migration now, or add old tokens to project manually:\n${chalk_1.default.blueBright(importStrings.link)}`);
|
|
142
141
|
}
|
|
143
142
|
}
|
|
144
143
|
const componentTokens = this.status.component.legacy.length;
|
|
145
144
|
if (componentTokens > 0) {
|
|
146
145
|
console.info(chalk_1.default.underline(`\nCOMPONENT Tokens Migration`));
|
|
147
146
|
console.info(`${chalk_1.default.yellow("!")} Found ${componentTokens} component token definition${componentTokens > 1 ? "s" : ""} that require manual migration.`);
|
|
148
|
-
console.info(`We no longer support component tokens. Please migrate to the new
|
|
147
|
+
console.info(`We no longer support component tokens. Please migrate to the new v8 tokens using theming or other methods.`);
|
|
149
148
|
}
|
|
150
149
|
const deprecatedTokens = this.status.deprecated.legacy.length;
|
|
151
150
|
if (deprecatedTokens > 0) {
|
|
152
151
|
console.info(chalk_1.default.underline(`\nLEGACY TOKEN DEFINITIONS (--a-token:)`));
|
|
153
152
|
console.info(`${chalk_1.default.yellow("!")} Found ${deprecatedTokens} legacy token definition${deprecatedTokens > 1 ? "s" : ""} that require manual migration.`);
|
|
154
|
-
console.info(`These are custom property definitions using legacy tokens that need to be updated to use new
|
|
153
|
+
console.info(`These are custom property definitions using legacy tokens that need to be updated to use new v8 tokens.`);
|
|
155
154
|
}
|
|
156
155
|
}
|
|
157
156
|
}
|
|
@@ -158,51 +158,61 @@ const colors = {
|
|
|
158
158
|
ref: "",
|
|
159
159
|
raw: "rgba(19, 72, 82, 1)",
|
|
160
160
|
replacement: "",
|
|
161
|
+
comment: "Lightblue is now info and brand-blue color. Consider using those colors.",
|
|
161
162
|
},
|
|
162
163
|
"lightblue-800": {
|
|
163
164
|
ref: "",
|
|
164
165
|
raw: "rgba(35, 107, 125, 1)",
|
|
165
166
|
replacement: "",
|
|
167
|
+
comment: "Lightblue is now info and brand-blue color. Consider using those colors.",
|
|
166
168
|
},
|
|
167
169
|
"lightblue-700": {
|
|
168
170
|
ref: "",
|
|
169
171
|
raw: "rgba(54, 141, 168, 1)",
|
|
170
172
|
replacement: "",
|
|
173
|
+
comment: "Lightblue is now info and brand-blue color. Consider using those colors.",
|
|
171
174
|
},
|
|
172
175
|
"lightblue-600": {
|
|
173
176
|
ref: "",
|
|
174
177
|
raw: "rgba(76, 173, 205, 1)",
|
|
175
178
|
replacement: "",
|
|
179
|
+
comment: "Lightblue is now info and brand-blue color. Consider using those colors.",
|
|
176
180
|
},
|
|
177
181
|
"lightblue-500": {
|
|
178
182
|
ref: "",
|
|
179
183
|
raw: "rgba(102, 203, 236, 1)",
|
|
180
184
|
replacement: "",
|
|
185
|
+
comment: "Lightblue is now info and brand-blue color. Consider using those colors.",
|
|
181
186
|
},
|
|
182
187
|
"lightblue-400": {
|
|
183
188
|
ref: "",
|
|
184
189
|
raw: "rgba(124, 218, 248, 1)",
|
|
185
190
|
replacement: "",
|
|
191
|
+
comment: "Lightblue is now info and brand-blue color. Consider using those colors.",
|
|
186
192
|
},
|
|
187
193
|
"lightblue-300": {
|
|
188
194
|
ref: "",
|
|
189
195
|
raw: "rgba(151, 230, 255, 1)",
|
|
190
196
|
replacement: "",
|
|
197
|
+
comment: "Lightblue is now info and brand-blue color. Consider using those colors.",
|
|
191
198
|
},
|
|
192
199
|
"lightblue-200": {
|
|
193
200
|
ref: "",
|
|
194
201
|
raw: "rgba(181, 241, 255, 1)",
|
|
195
202
|
replacement: "",
|
|
203
|
+
comment: "Lightblue is now info and brand-blue color. Consider using those colors.",
|
|
196
204
|
},
|
|
197
205
|
"lightblue-100": {
|
|
198
206
|
ref: "",
|
|
199
207
|
raw: "rgba(216, 249, 255, 1)",
|
|
200
208
|
replacement: "",
|
|
209
|
+
comment: "Lightblue is now info and brand-blue color. Consider using those colors.",
|
|
201
210
|
},
|
|
202
211
|
"lightblue-50": {
|
|
203
212
|
ref: "",
|
|
204
213
|
raw: "rgba(235, 252, 255, 1)",
|
|
205
214
|
replacement: "",
|
|
215
|
+
comment: "Lightblue is now info and brand-blue color. Consider using those colors.",
|
|
206
216
|
},
|
|
207
217
|
"green-900": {
|
|
208
218
|
ref: "",
|
|
@@ -408,31 +418,37 @@ const colors = {
|
|
|
408
418
|
ref: "",
|
|
409
419
|
raw: "rgba(2, 5, 9, 0.87)",
|
|
410
420
|
replacement: "",
|
|
421
|
+
comment: "No replacement available. Use neutral-1000 of you don't need opacity.",
|
|
411
422
|
},
|
|
412
423
|
"grayalpha-800": {
|
|
413
424
|
ref: "",
|
|
414
425
|
raw: "rgba(3, 11, 22, 0.75)",
|
|
415
426
|
replacement: "",
|
|
427
|
+
comment: "No replacement available. Use neutral-900 of you don't need opacity.",
|
|
416
428
|
},
|
|
417
429
|
"grayalpha-700": {
|
|
418
430
|
ref: "",
|
|
419
431
|
raw: "rgba(1, 11, 24, 0.68)",
|
|
420
432
|
replacement: "",
|
|
433
|
+
comment: "No replacement available. Use neutral-800 of you don't need opacity.",
|
|
421
434
|
},
|
|
422
435
|
"grayalpha-600": {
|
|
423
436
|
ref: "",
|
|
424
437
|
raw: "rgba(2, 15, 34, 0.6)",
|
|
425
438
|
replacement: "",
|
|
439
|
+
comment: "No replacement available. Use neutral-700 of you don't need opacity.",
|
|
426
440
|
},
|
|
427
441
|
"grayalpha-500": {
|
|
428
442
|
ref: "",
|
|
429
443
|
raw: "rgba(2, 20, 49, 0.49)",
|
|
430
444
|
replacement: "",
|
|
445
|
+
comment: "No replacement available. Use neutral-600 of you don't need opacity.",
|
|
431
446
|
},
|
|
432
447
|
"grayalpha-400": {
|
|
433
448
|
ref: "",
|
|
434
449
|
raw: "rgba(5, 23, 51, 0.34)",
|
|
435
450
|
replacement: "",
|
|
451
|
+
comment: "No replacement available. Use neutral-500 of you don't need opacity.",
|
|
436
452
|
},
|
|
437
453
|
"grayalpha-300": {
|
|
438
454
|
ref: "",
|
|
@@ -507,92 +523,95 @@ const colors = {
|
|
|
507
523
|
"data-border-6": {
|
|
508
524
|
ref: "purple-400",
|
|
509
525
|
raw: "rgba(130, 105, 162, 1)",
|
|
510
|
-
replacement: "",
|
|
526
|
+
replacement: "border-meta-purple",
|
|
511
527
|
},
|
|
512
528
|
"data-border-5": {
|
|
513
529
|
ref: "green-400",
|
|
514
530
|
raw: "rgba(42, 167, 88, 1)",
|
|
515
|
-
replacement: "",
|
|
531
|
+
replacement: "border-success",
|
|
516
532
|
},
|
|
517
533
|
"data-border-4": {
|
|
518
534
|
ref: "lightblue-700",
|
|
519
535
|
raw: "rgba(54, 141, 168, 1)",
|
|
520
536
|
replacement: "",
|
|
537
|
+
comment: "Lightblue is now info and brand-blue color.",
|
|
521
538
|
},
|
|
522
539
|
"data-border-3": {
|
|
523
540
|
ref: "orange-600",
|
|
524
541
|
raw: "rgba(199, 115, 0, 1)",
|
|
525
|
-
replacement: "",
|
|
542
|
+
replacement: "border-warning",
|
|
526
543
|
},
|
|
527
544
|
"data-border-2": {
|
|
528
545
|
ref: "deepblue-500",
|
|
529
546
|
raw: "rgba(0, 91, 130, 1)",
|
|
530
|
-
replacement: "",
|
|
547
|
+
replacement: "border-brand-blue",
|
|
531
548
|
},
|
|
532
549
|
"data-border-1": {
|
|
533
550
|
ref: "blue-400",
|
|
534
551
|
raw: "rgba(51, 134, 224, 1)",
|
|
535
|
-
replacement: "",
|
|
552
|
+
replacement: "border-accent",
|
|
536
553
|
},
|
|
537
554
|
"data-surface-6-subtle": {
|
|
538
555
|
ref: "purple-200",
|
|
539
556
|
raw: "rgba(192, 178, 210, 1)",
|
|
540
|
-
replacement: "",
|
|
557
|
+
replacement: "meta-purple-300",
|
|
541
558
|
},
|
|
542
559
|
"data-surface-6": {
|
|
543
560
|
ref: "purple-400",
|
|
544
561
|
raw: "rgba(130, 105, 162, 1)",
|
|
545
|
-
replacement: "",
|
|
562
|
+
replacement: "meta-purple-500",
|
|
546
563
|
},
|
|
547
564
|
"data-surface-5-subtle": {
|
|
548
565
|
ref: "green-200",
|
|
549
566
|
raw: "rgba(153, 222, 173, 1)",
|
|
550
|
-
replacement: "",
|
|
567
|
+
replacement: "success-300",
|
|
551
568
|
},
|
|
552
569
|
"data-surface-5": {
|
|
553
570
|
ref: "green-400",
|
|
554
571
|
raw: "rgba(42, 167, 88, 1)",
|
|
555
|
-
replacement: "",
|
|
572
|
+
replacement: "success-500",
|
|
556
573
|
},
|
|
557
574
|
"data-surface-4-subtle": {
|
|
558
575
|
ref: "lightblue-500",
|
|
559
576
|
raw: "rgba(102, 203, 236, 1)",
|
|
560
577
|
replacement: "",
|
|
578
|
+
comment: "Lightblue is now info and brand-blue color.",
|
|
561
579
|
},
|
|
562
580
|
"data-surface-4": {
|
|
563
581
|
ref: "lightblue-700",
|
|
564
582
|
raw: "rgba(54, 141, 168, 1)",
|
|
565
583
|
replacement: "",
|
|
584
|
+
comment: "Lightblue is now info and brand-blue color.",
|
|
566
585
|
},
|
|
567
586
|
"data-surface-3-subtle": {
|
|
568
587
|
ref: "orange-300",
|
|
569
588
|
raw: "rgba(255, 193, 102, 1)",
|
|
570
|
-
replacement: "",
|
|
589
|
+
replacement: "warning-400",
|
|
571
590
|
},
|
|
572
591
|
"data-surface-3": {
|
|
573
592
|
ref: "orange-600",
|
|
574
593
|
raw: "rgba(199, 115, 0, 1)",
|
|
575
|
-
replacement: "",
|
|
594
|
+
replacement: "warning-700",
|
|
576
595
|
},
|
|
577
596
|
"data-surface-2-subtle": {
|
|
578
597
|
ref: "deepblue-200",
|
|
579
598
|
raw: "rgba(153, 196, 221, 1)",
|
|
580
|
-
replacement: "",
|
|
599
|
+
replacement: "brand-blue-300",
|
|
581
600
|
},
|
|
582
601
|
"data-surface-2": {
|
|
583
602
|
ref: "deepblue-500",
|
|
584
603
|
raw: "rgba(0, 91, 130, 1)",
|
|
585
|
-
replacement: "",
|
|
604
|
+
replacement: "brand-blue-600",
|
|
586
605
|
},
|
|
587
606
|
"data-surface-1-subtle": {
|
|
588
607
|
ref: "blue-100",
|
|
589
608
|
raw: "rgba(204, 225, 255, 1)",
|
|
590
|
-
replacement: "",
|
|
609
|
+
replacement: "accent-200",
|
|
591
610
|
},
|
|
592
611
|
"data-surface-1": {
|
|
593
612
|
ref: "blue-400",
|
|
594
613
|
raw: "rgba(51, 134, 224, 1)",
|
|
595
|
-
replacement: "",
|
|
614
|
+
replacement: "accent-500",
|
|
596
615
|
},
|
|
597
616
|
"text-on-alt-3": {
|
|
598
617
|
ref: "white",
|
|
@@ -644,7 +663,6 @@ const colors = {
|
|
|
644
663
|
raw: "rgba(255, 255, 255, 1)",
|
|
645
664
|
replacement: "text-neutral-contrast",
|
|
646
665
|
},
|
|
647
|
-
/* TODO */
|
|
648
666
|
"text-action": {
|
|
649
667
|
ref: "blue-500",
|
|
650
668
|
raw: "rgba(0, 103, 197, 1)",
|
|
@@ -693,8 +711,8 @@ const colors = {
|
|
|
693
711
|
"surface-alt-3-strong": {
|
|
694
712
|
ref: "deepblue-800",
|
|
695
713
|
raw: "rgba(0, 52, 83, 1)",
|
|
696
|
-
comment: "Use 'bg-brand-blue-moderate' in theme 'dark'-mode.",
|
|
697
714
|
replacement: "",
|
|
715
|
+
comment: "Use 'bg-brand-blue-moderate' in theme 'dark'-mode.",
|
|
698
716
|
},
|
|
699
717
|
"surface-alt-3-moderate": {
|
|
700
718
|
ref: "deepblue-200",
|
|
@@ -936,6 +954,7 @@ const colors = {
|
|
|
936
954
|
"surface-inverted-active": {
|
|
937
955
|
ref: "gray-700",
|
|
938
956
|
raw: "rgba(82, 89, 98, 1)",
|
|
957
|
+
comment: "Use 'bg-neutral-strong-pressed' for similar color.",
|
|
939
958
|
replacement: "",
|
|
940
959
|
},
|
|
941
960
|
"surface-inverted-hover": {
|
|
@@ -1176,10 +1195,12 @@ const colors = {
|
|
|
1176
1195
|
ref: "",
|
|
1177
1196
|
raw: "rgba(255, 255, 255, 1)",
|
|
1178
1197
|
replacement: "",
|
|
1198
|
+
comment: "Use 'white' CSS color.",
|
|
1179
1199
|
},
|
|
1180
1200
|
transparent: {
|
|
1181
1201
|
ref: "",
|
|
1182
1202
|
raw: "rgba(255, 255, 255, 0)",
|
|
1203
|
+
comment: "Use 'transparent' CSS color.",
|
|
1183
1204
|
replacement: "",
|
|
1184
1205
|
},
|
|
1185
1206
|
};
|
|
@@ -1279,38 +1300,44 @@ const tokensWithoutRegex = Object.assign(Object.assign({}, colorWithTailwindConv
|
|
|
1279
1300
|
}, "shadow-xlarge": {
|
|
1280
1301
|
ref: "",
|
|
1281
1302
|
raw: "0px 2px 5px 0px rgba(0, 0, 0, 0.15), 0px 10px 24px 0px rgba(0, 0, 0, 0.18), 0px 0px 1px 0px rgba(0, 0, 0, 0.08)",
|
|
1282
|
-
replacement: "",
|
|
1303
|
+
replacement: "shadow-dialog",
|
|
1283
1304
|
twOld: "shadow-xlarge",
|
|
1284
1305
|
}, "shadow-large": {
|
|
1285
1306
|
ref: "",
|
|
1286
1307
|
raw: "0px 2px 5px 0px rgba(0, 0, 0, 0.15), 0px 10px 16px 0px rgba(0, 0, 0, 0.12), 0px 0px 1px 0px rgba(0, 0, 0, 0.12)",
|
|
1287
1308
|
replacement: "",
|
|
1288
1309
|
twOld: "shadow-large",
|
|
1310
|
+
comment: "New design-language has removed use of shadows besides on dialog, modal or popup elements where `shadow-dialog` is used.",
|
|
1289
1311
|
}, "shadow-medium": {
|
|
1290
1312
|
ref: "",
|
|
1291
1313
|
raw: "0px 5px 12px 0px rgba(0, 0, 0, 0.13), 0px 1px 3px 0px rgba(0, 0, 0, 0.10), 0px 0px 1px 0px rgba(0, 0, 0, 0.15)",
|
|
1292
1314
|
replacement: "",
|
|
1293
1315
|
twOld: "shadow-medium",
|
|
1316
|
+
comment: "New design-language has removed use of shadows besides on dialog, modal or popup elements where `shadow-dialog` is used.",
|
|
1294
1317
|
}, "shadow-small": {
|
|
1295
1318
|
ref: "",
|
|
1296
1319
|
raw: "0px 3px 8px 0px rgba(0, 0, 0, 0.10), 0px 1px 3px 0px rgba(0, 0, 0, 0.10), 0px 0px 1px 0px rgba(0, 0, 0, 0.18)",
|
|
1297
1320
|
replacement: "",
|
|
1298
1321
|
twOld: "shadow-small",
|
|
1322
|
+
comment: "New design-language has removed use of shadows besides on dialog, modal or popup elements where `shadow-dialog` is used.",
|
|
1299
1323
|
}, "shadow-xsmall": {
|
|
1300
1324
|
ref: "",
|
|
1301
1325
|
raw: "0px 1px 3px 0px rgba(0, 0, 0, 0.15), 0px 0px 1px 0px rgba(0, 0, 0, 0.20)",
|
|
1302
1326
|
replacement: "",
|
|
1303
1327
|
twOld: "shadow-xsmall",
|
|
1328
|
+
comment: "New design-language has removed use of shadows besides on dialog, modal or popup elements where `shadow-dialog` is used.",
|
|
1304
1329
|
}, "shadow-focus-inverted": {
|
|
1305
1330
|
ref: "",
|
|
1306
1331
|
raw: "0 0 0 3px rgba(153, 195, 255, 1)",
|
|
1307
1332
|
replacement: "",
|
|
1308
1333
|
twOld: "shadow-focus-inverted",
|
|
1334
|
+
comment: "This is now handled by light/dark theme.",
|
|
1309
1335
|
}, "shadow-focus": {
|
|
1310
1336
|
ref: "",
|
|
1311
1337
|
raw: "0 0 0 3px rgba(0, 52, 125, 1)",
|
|
1312
1338
|
replacement: "",
|
|
1313
1339
|
twOld: "shadow-focus",
|
|
1340
|
+
comment: "We now use `outline: 3px solid var(--ax-border-focus)` + `outline-offset: 3px`",
|
|
1314
1341
|
}, "border-radius-full": {
|
|
1315
1342
|
ref: "",
|
|
1316
1343
|
raw: "9999px",
|
|
@@ -1365,17 +1392,20 @@ const tokensWithoutRegex = Object.assign(Object.assign({}, colorWithTailwindConv
|
|
|
1365
1392
|
ref: "",
|
|
1366
1393
|
raw: "3000",
|
|
1367
1394
|
replacement: "",
|
|
1395
|
+
comment: "Use `z-index: 3000` as replacement",
|
|
1368
1396
|
twOld: "z-tooltip",
|
|
1369
1397
|
twNew: "z-[3000]",
|
|
1370
1398
|
}, "z-index-focus": {
|
|
1371
1399
|
ref: "",
|
|
1372
1400
|
raw: "10",
|
|
1401
|
+
comment: "Use `z-index: 10` as replacement",
|
|
1373
1402
|
replacement: "",
|
|
1374
1403
|
twOld: "z-focus",
|
|
1375
1404
|
twNew: "z-[10]",
|
|
1376
1405
|
}, "z-index-popover": {
|
|
1377
1406
|
ref: "",
|
|
1378
1407
|
raw: "1000",
|
|
1408
|
+
comment: "Use `z-index: 1000` as replacement",
|
|
1379
1409
|
replacement: "",
|
|
1380
1410
|
twOld: "z-popover",
|
|
1381
1411
|
twNew: "z-[1000]",
|
|
@@ -1515,6 +1545,7 @@ const tokensWithoutRegex = Object.assign(Object.assign({}, colorWithTailwindConv
|
|
|
1515
1545
|
ref: "",
|
|
1516
1546
|
raw: "576px",
|
|
1517
1547
|
replacement: "",
|
|
1548
|
+
comment: "Use `max-width: 576px` as replacement",
|
|
1518
1549
|
twOld: "max-w-text",
|
|
1519
1550
|
}, "breakpoint-2xl-down": {
|
|
1520
1551
|
ref: "",
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createCompositeTwRegex = createCompositeTwRegex;
|
|
4
|
-
exports.createSingleTwRegex = createSingleTwRegex;
|
|
5
4
|
exports.getFrameworkRegexes = getFrameworkRegexes;
|
|
6
5
|
exports.getTokenRegex = getTokenRegex;
|
|
7
|
-
const translate_token_1 = require("../../
|
|
6
|
+
const translate_token_1 = require("../../utils/translate-token");
|
|
8
7
|
const createTwRegexForBreakpoints = (token) => new RegExp(`(?<!:)(?<=\\s|^)${token}:(?=\\w)`, "gm");
|
|
9
8
|
function getFrameworkRegexes({ token, twString, legacy = false, }) {
|
|
10
9
|
const regexes = {
|
|
@@ -43,10 +42,7 @@ function getTokenRegex(variable, format) {
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
function createCompositeTwRegex(tokens) {
|
|
46
|
-
return new RegExp(`(?<!:)(\\s|^)?(${tokens.join("|")}|${tokens
|
|
45
|
+
return new RegExp(`(?<!-)(?<!:)(\\s|^)?(${tokens.join("|")}|${tokens
|
|
47
46
|
.map((t) => `:${t}`)
|
|
48
47
|
.join("|")})(?=\\s|$|[^\\w-])`, "gm");
|
|
49
48
|
}
|
|
50
|
-
function createSingleTwRegex(token) {
|
|
51
|
-
return new RegExp(`(?<!:)(\\s|^)?(${token})(?=\\s|$|[^\\w-])`, "gm");
|
|
52
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.v8TokenConfig = void 0;
|
|
4
4
|
const token_regex_1 = require("./token-regex");
|
|
5
5
|
const token_utils_1 = require("./token.utils");
|
|
6
6
|
const colors = [
|
|
@@ -384,7 +384,7 @@ const newTokensWithoutRegex = Object.assign(Object.assign({}, colors.reduce((acc
|
|
|
384
384
|
acc[token] = (0, token_utils_1.generateBgTwTags)(token, true);
|
|
385
385
|
return acc;
|
|
386
386
|
}, {})), { "opacity-disabled": "opacity-ax-disabled", "shadow-dialog": "shadow-ax-dialog", "font-weight-regular": "font-ax-regular", "font-weight-bold": "font-ax-bold", "font-size-small": "text-ax-small", "font-size-medium": "text-ax-medium", "font-size-large": "text-ax-large", "font-size-xlarge": "text-ax-xlarge", "font-size-heading-xsmall": "text-ax-heading-xsmall", "font-size-heading-small": "text-ax-heading-small", "font-size-heading-medium": "text-ax-heading-medium", "font-size-heading-large": "text-ax-heading-large", "font-size-heading-xlarge": "text-ax-heading-xlarge", "font-size-heading-2xlarge": "text-ax-heading-2xlarge", "font-line-height-medium": "leading-ax-medium", "font-line-height-large": "leading-ax-large", "font-line-height-xlarge": "leading-ax-xlarge", "font-line-height-heading-xsmall": "leading-ax-heading-xsmall", "font-line-height-heading-small": "leading-ax-heading-small", "font-line-height-heading-medium": "leading-ax-heading-medium", "font-line-height-heading-large": "leading-ax-heading-large", "font-line-height-heading-xlarge": "leading-ax-heading-xlarge", "font-line-height-heading-2xlarge": "leading-ax-heading-2xlarge", "font-family": "font-font-family", "breakpoint-2xl-down": null, "breakpoint-2xl": "ax-2xl", "breakpoint-xl-down": null, "breakpoint-xl": "ax-xl", "breakpoint-lg-down": null, "breakpoint-lg": "ax-lg", "breakpoint-md-down": null, "breakpoint-md": "ax-md", "breakpoint-sm-down": null, "breakpoint-sm": "ax-sm", "breakpoint-xs": null, "radius-full": (0, token_utils_1.generateRoundedTwTags)("full"), "radius-12": (0, token_utils_1.generateRoundedTwTags)("12"), "radius-8": (0, token_utils_1.generateRoundedTwTags)("8"), "radius-4": (0, token_utils_1.generateRoundedTwTags)("4"), "radius-2": (0, token_utils_1.generateRoundedTwTags)("2"), "space-128": null, "space-96": null, "space-80": null, "space-72": null, "space-64": null, "space-56": null, "space-48": null, "space-44": null, "space-40": null, "space-36": null, "space-32": null, "space-28": null, "space-24": null, "space-20": null, "space-16": null, "space-12": null, "space-8": null, "space-6": null, "space-4": null, "space-2": null, "space-1": null, "space-0": null });
|
|
387
|
-
const
|
|
387
|
+
const v8TokenConfig = Object.entries(newTokensWithoutRegex).reduce((acc, [name, tw]) => {
|
|
388
388
|
acc[name] = {
|
|
389
389
|
tw,
|
|
390
390
|
regexes: (0, token_regex_1.getFrameworkRegexes)({
|
|
@@ -395,4 +395,4 @@ const darksideTokenConfig = Object.entries(newTokensWithoutRegex).reduce((acc, [
|
|
|
395
395
|
};
|
|
396
396
|
return acc;
|
|
397
397
|
}, {});
|
|
398
|
-
exports.
|
|
398
|
+
exports.v8TokenConfig = v8TokenConfig;
|
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.v8TokensCommand = v8TokensCommand;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const commander_1 = require("commander");
|
|
9
9
|
const run_tooling_js_1 = require("./run-tooling.js");
|
|
10
10
|
const program = new commander_1.Command();
|
|
11
|
-
function
|
|
11
|
+
function v8TokensCommand() {
|
|
12
12
|
program.allowExcessArguments();
|
|
13
13
|
program.name(`${chalk_1.default.blueBright(`npx @navikt/aksel v8-tokens`)}`);
|
|
14
14
|
program
|
|
@@ -51,17 +51,17 @@ const enquirer_1 = __importDefault(require("enquirer"));
|
|
|
51
51
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
52
52
|
const jscodeshift = __importStar(require("jscodeshift/src/Runner"));
|
|
53
53
|
const node_path_1 = __importDefault(require("node:path"));
|
|
54
|
-
const codeshift_utils_1 = require("../
|
|
55
|
-
const validation_1 = require("../
|
|
54
|
+
const codeshift_utils_1 = require("../codeshift.utils");
|
|
55
|
+
const validation_1 = require("../validation");
|
|
56
56
|
const print_remaining_1 = require("./tasks/print-remaining");
|
|
57
57
|
const status_1 = require("./tasks/status");
|
|
58
58
|
// Constants
|
|
59
59
|
const TRANSFORMS = {
|
|
60
|
-
"css-tokens": "./transforms/
|
|
61
|
-
"scss-tokens": "./transforms/
|
|
62
|
-
"less-tokens": "./transforms/
|
|
63
|
-
"js-tokens": "./transforms/
|
|
64
|
-
"tailwind-tokens": "./transforms/
|
|
60
|
+
"css-tokens": "./transforms/v8-tokens-css",
|
|
61
|
+
"scss-tokens": "./transforms/v8-tokens-scss",
|
|
62
|
+
"less-tokens": "./transforms/v8-tokens-less",
|
|
63
|
+
"js-tokens": "./transforms/v8-tokens-js",
|
|
64
|
+
"tailwind-tokens": "./transforms/v8-tokens-tailwind",
|
|
65
65
|
};
|
|
66
66
|
/**
|
|
67
67
|
* Main entry point for the tooling system
|
|
@@ -8,11 +8,12 @@ exports.getCharacterPositionInFile = getCharacterPositionInFile;
|
|
|
8
8
|
exports.getLineStarts = getLineStarts;
|
|
9
9
|
const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
10
10
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
-
const translate_token_1 = require("../../
|
|
11
|
+
const translate_token_1 = require("../../utils/translate-token");
|
|
12
12
|
const TokenStatus_1 = require("../config/TokenStatus");
|
|
13
|
-
const darkside_tokens_1 = require("../config/darkside.tokens");
|
|
14
13
|
const legacy_component_tokens_1 = require("../config/legacy-component.tokens");
|
|
15
14
|
const legacy_tokens_1 = require("../config/legacy.tokens");
|
|
15
|
+
const token_regex_1 = require("../config/token-regex");
|
|
16
|
+
const v8_tokens_1 = require("../config/v8.tokens");
|
|
16
17
|
const StatusStore = new TokenStatus_1.TokenStatus();
|
|
17
18
|
/**
|
|
18
19
|
* Get the status of the tokens in the files
|
|
@@ -28,12 +29,13 @@ function getStatus(files, action = "print") {
|
|
|
28
29
|
}
|
|
29
30
|
StatusStore.initStatus();
|
|
30
31
|
/**
|
|
31
|
-
* Prepare search terms for legacy and
|
|
32
|
+
* Prepare search terms for legacy and v8 tokens.
|
|
32
33
|
* By pre-computing these sets, we save re-calculating them for each file,
|
|
33
34
|
* improving performance when processing large numbers of files.
|
|
34
35
|
*/
|
|
35
36
|
const legacySearchTerms = getLegacySearchTerms();
|
|
36
|
-
const
|
|
37
|
+
const v8TokensSearchTerms = getV8TokensSearchTerms();
|
|
38
|
+
const deprecatedAxSearchTerms = getDeprecatedAxSearchTerms();
|
|
37
39
|
const legacyComponentTokensSet = new Set(legacy_component_tokens_1.legacyComponentTokenList);
|
|
38
40
|
/**
|
|
39
41
|
* Pre-computed regex for legacy component tokens
|
|
@@ -152,13 +154,13 @@ function getStatus(files, action = "print") {
|
|
|
152
154
|
canAutoMigrate: false,
|
|
153
155
|
fileName,
|
|
154
156
|
name: definitionMatch[1],
|
|
155
|
-
comment: "Legacy token definition - requires manual migration to new
|
|
157
|
+
comment: "Legacy token definition - requires manual migration to new v8 tokens",
|
|
156
158
|
});
|
|
157
159
|
}
|
|
158
160
|
definitionMatch = legacyDefinitionRegex.exec(fileSrc);
|
|
159
161
|
}
|
|
160
|
-
for (const [newTokenName, config] of Object.entries(
|
|
161
|
-
const terms =
|
|
162
|
+
for (const [newTokenName, config] of Object.entries(v8_tokens_1.v8TokenConfig)) {
|
|
163
|
+
const terms = v8TokensSearchTerms.get(newTokenName);
|
|
162
164
|
/* Optimization: Check if any of the search terms exist in the file words set */
|
|
163
165
|
let found = false;
|
|
164
166
|
if (terms) {
|
|
@@ -191,6 +193,43 @@ function getStatus(files, action = "print") {
|
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Detect deprecated --ax-border-radius-* tokens that should be migrated to --ax-radius-*
|
|
198
|
+
*/
|
|
199
|
+
for (const [deprecatedToken, config] of Object.entries(deprecatedAxTokenConfig)) {
|
|
200
|
+
const terms = deprecatedAxSearchTerms.get(deprecatedToken);
|
|
201
|
+
let found = false;
|
|
202
|
+
if (terms) {
|
|
203
|
+
for (const term of terms) {
|
|
204
|
+
if (fileWords.has(term)) {
|
|
205
|
+
found = true;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (!found) {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
for (const [regexKey, regex] of Object.entries(config.regexes)) {
|
|
214
|
+
if (!regex) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
let match = regex.exec(fileSrc);
|
|
218
|
+
while (match) {
|
|
219
|
+
const { row, column } = getCharacterPositionInFile(match.index, getLineStartsLazy());
|
|
220
|
+
StatusStore.add({
|
|
221
|
+
isLegacy: true,
|
|
222
|
+
type: regexKey,
|
|
223
|
+
columnNumber: column,
|
|
224
|
+
lineNumber: row,
|
|
225
|
+
canAutoMigrate: true,
|
|
226
|
+
fileName,
|
|
227
|
+
name: match[0],
|
|
228
|
+
});
|
|
229
|
+
match = regex.exec(fileSrc);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
194
233
|
if (action === "print") {
|
|
195
234
|
progressBar.update(index + 1, { fileName });
|
|
196
235
|
}
|
|
@@ -223,9 +262,9 @@ function getLegacySearchTerms() {
|
|
|
223
262
|
}
|
|
224
263
|
return legacySearchTerms;
|
|
225
264
|
}
|
|
226
|
-
function
|
|
227
|
-
const
|
|
228
|
-
for (const [newTokenName, config] of Object.entries(
|
|
265
|
+
function getV8TokensSearchTerms() {
|
|
266
|
+
const v8TokensSearchTerms = new Map();
|
|
267
|
+
for (const [newTokenName, config] of Object.entries(v8_tokens_1.v8TokenConfig)) {
|
|
229
268
|
const terms = new Set();
|
|
230
269
|
const tokenName = `--ax-${newTokenName}`;
|
|
231
270
|
terms.add(tokenName);
|
|
@@ -238,9 +277,69 @@ function getDarksideSearchTerms() {
|
|
|
238
277
|
terms.add(t.trim());
|
|
239
278
|
});
|
|
240
279
|
}
|
|
241
|
-
|
|
280
|
+
v8TokensSearchTerms.set(newTokenName, terms);
|
|
281
|
+
}
|
|
282
|
+
return v8TokensSearchTerms;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Configuration for deprecated --ax-* tokens that should be migrated
|
|
286
|
+
*/
|
|
287
|
+
const deprecatedAxTokenConfig = {
|
|
288
|
+
"border-radius-full": {
|
|
289
|
+
replacement: "--ax-radius-full",
|
|
290
|
+
regexes: (0, token_regex_1.getFrameworkRegexes)({
|
|
291
|
+
legacy: false,
|
|
292
|
+
token: "--ax-border-radius-full",
|
|
293
|
+
twString: null,
|
|
294
|
+
}),
|
|
295
|
+
},
|
|
296
|
+
"border-radius-small": {
|
|
297
|
+
replacement: "--ax-radius-2",
|
|
298
|
+
regexes: (0, token_regex_1.getFrameworkRegexes)({
|
|
299
|
+
legacy: false,
|
|
300
|
+
token: "--ax-border-radius-small",
|
|
301
|
+
twString: null,
|
|
302
|
+
}),
|
|
303
|
+
},
|
|
304
|
+
"border-radius-medium": {
|
|
305
|
+
replacement: "--ax-radius-4",
|
|
306
|
+
regexes: (0, token_regex_1.getFrameworkRegexes)({
|
|
307
|
+
legacy: false,
|
|
308
|
+
token: "--ax-border-radius-medium",
|
|
309
|
+
twString: null,
|
|
310
|
+
}),
|
|
311
|
+
},
|
|
312
|
+
"border-radius-large": {
|
|
313
|
+
replacement: "--ax-radius-8",
|
|
314
|
+
regexes: (0, token_regex_1.getFrameworkRegexes)({
|
|
315
|
+
legacy: false,
|
|
316
|
+
token: "--ax-border-radius-large",
|
|
317
|
+
twString: null,
|
|
318
|
+
}),
|
|
319
|
+
},
|
|
320
|
+
"border-radius-xlarge": {
|
|
321
|
+
replacement: "--ax-radius-12",
|
|
322
|
+
regexes: (0, token_regex_1.getFrameworkRegexes)({
|
|
323
|
+
legacy: false,
|
|
324
|
+
token: "--ax-border-radius-xlarge",
|
|
325
|
+
twString: null,
|
|
326
|
+
}),
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
function getDeprecatedAxSearchTerms() {
|
|
330
|
+
const deprecatedAxSearchTerms = new Map();
|
|
331
|
+
for (const deprecatedToken of Object.keys(deprecatedAxTokenConfig)) {
|
|
332
|
+
const terms = new Set();
|
|
333
|
+
const tokenName = `--ax-${deprecatedToken}`;
|
|
334
|
+
terms.add(tokenName);
|
|
335
|
+
terms.add((0, translate_token_1.translateToken)(tokenName, "scss"));
|
|
336
|
+
terms.add((0, translate_token_1.translateToken)(tokenName, "less"));
|
|
337
|
+
/* JS tokens use Ax prefix */
|
|
338
|
+
const jsToken = (0, translate_token_1.translateToken)(tokenName, "js");
|
|
339
|
+
terms.add(jsToken);
|
|
340
|
+
deprecatedAxSearchTerms.set(deprecatedToken, terms);
|
|
242
341
|
}
|
|
243
|
-
return
|
|
342
|
+
return deprecatedAxSearchTerms;
|
|
244
343
|
}
|
|
245
344
|
/**
|
|
246
345
|
* Given the content of a file, returns an array of line start positions.
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = transformer;
|
|
4
4
|
const legacy_tokens_1 = require("../config/legacy.tokens");
|
|
5
|
+
const axBorderRadiusMap = {
|
|
6
|
+
"--ax-border-radius-full": "--ax-radius-full",
|
|
7
|
+
"--ax-border-radius-small": "--ax-radius-2",
|
|
8
|
+
"--ax-border-radius-medium": "--ax-radius-4",
|
|
9
|
+
"--ax-border-radius-large": "--ax-radius-8",
|
|
10
|
+
"--ax-border-radius-xlarge": "--ax-radius-12",
|
|
11
|
+
};
|
|
5
12
|
function transformer(file) {
|
|
6
13
|
let src = file.source;
|
|
7
14
|
/*
|
|
@@ -17,5 +24,14 @@ function transformer(file) {
|
|
|
17
24
|
}
|
|
18
25
|
return match;
|
|
19
26
|
});
|
|
27
|
+
/*
|
|
28
|
+
Replace usages: --ax-border-radius-(full|small|medium|large|xlarge) -> --ax-radius-(full|2|4|8|12)
|
|
29
|
+
Matches "--ax-border-radius-*" with word boundaries.
|
|
30
|
+
Uses negative lookahead to skip definitions (--ax-border-radius-small:)
|
|
31
|
+
*/
|
|
32
|
+
src = src.replace(/(?<![\w-])(--ax-border-radius-(?:full|small|medium|large|xlarge))(?![\w-])(?!\s*:)/g, (match, tokenName) => {
|
|
33
|
+
var _a;
|
|
34
|
+
return (_a = axBorderRadiusMap[tokenName]) !== null && _a !== void 0 ? _a : match;
|
|
35
|
+
});
|
|
20
36
|
return src;
|
|
21
37
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
const imports_1 = require("../../utils/imports");
|
|
8
|
+
const lineterminator_1 = require("../../utils/lineterminator");
|
|
9
|
+
const packageImports_1 = __importDefault(require("../../utils/packageImports"));
|
|
10
|
+
const translate_token_1 = require("../../utils/translate-token");
|
|
11
|
+
const legacy_tokens_1 = require("../config/legacy.tokens");
|
|
12
|
+
const axBorderRadiusMap = {
|
|
13
|
+
AxBorderRadiusFull: "AxRadiusFull",
|
|
14
|
+
AxBorderRadiusSmall: "AxRadius2",
|
|
15
|
+
AxBorderRadiusMedium: "AxRadius4",
|
|
16
|
+
AxBorderRadiusLarge: "AxRadius8",
|
|
17
|
+
AxBorderRadiusXlarge: "AxRadius12",
|
|
18
|
+
};
|
|
19
|
+
function transformer(file, api) {
|
|
20
|
+
let src = file.source;
|
|
21
|
+
const j = api.jscodeshift;
|
|
22
|
+
let root = j(file.source);
|
|
23
|
+
const jsImport = root.find(j.ImportDeclaration).filter((x) => {
|
|
24
|
+
return ["@navikt/ds-tokens/dist/tokens"].includes(x.node.source.value);
|
|
25
|
+
});
|
|
26
|
+
if (jsImport.size() > 0) {
|
|
27
|
+
for (const [oldToken, config] of Object.entries(legacy_tokens_1.legacyTokenConfig)) {
|
|
28
|
+
const oldCSSVar = `--a-${oldToken}`;
|
|
29
|
+
const oldJsVar = (0, translate_token_1.translateToken)(oldCSSVar, "js");
|
|
30
|
+
let foundName = null;
|
|
31
|
+
(0, imports_1.getImportSpecifier)(j, root, oldJsVar, "@navikt/ds-tokens/dist/tokens").forEach((x) => {
|
|
32
|
+
foundName = x.node.imported.name;
|
|
33
|
+
});
|
|
34
|
+
if (!foundName) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (config.replacement.length > 0) {
|
|
38
|
+
/* We remove the prefix */
|
|
39
|
+
const jsToken = (0, translate_token_1.translateToken)(`--ax-${config.replacement}`, "js").slice(2);
|
|
40
|
+
const localName = (0, packageImports_1.default)(j, root, {
|
|
41
|
+
fromImport: "@navikt/ds-tokens/dist/tokens",
|
|
42
|
+
toImport: "@navikt/ds-tokens/js",
|
|
43
|
+
fromName: foundName,
|
|
44
|
+
toName: jsToken,
|
|
45
|
+
ignoreAlias: true,
|
|
46
|
+
});
|
|
47
|
+
let code = root.toSource((0, lineterminator_1.getLineTerminator)(src));
|
|
48
|
+
const rgx = new RegExp(`(\\s|^)?(${localName})(?=\\s|$|[^\\w-])`, "gm");
|
|
49
|
+
code = code.replace(rgx, jsToken);
|
|
50
|
+
src = code;
|
|
51
|
+
root = j(code);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
let output = root.toSource((0, lineterminator_1.getLineTerminator)(src));
|
|
56
|
+
const jsV8TokenImport = root.find(j.ImportDeclaration).filter((x) => {
|
|
57
|
+
return ["@navikt/ds-tokens/js"].includes(x.node.source.value);
|
|
58
|
+
});
|
|
59
|
+
if (jsV8TokenImport.size() > 0) {
|
|
60
|
+
/*
|
|
61
|
+
Replace usages: AxBorderRadius(Full|Small|Medium|Large|Xlarge) -> AxRadius(Full|2|4|8|12)
|
|
62
|
+
*/
|
|
63
|
+
output = output.replace(/(?<!\w)(AxBorderRadius(?:Full|Small|Medium|Large|Xlarge))(?!\w)/g, (match, tokenName) => {
|
|
64
|
+
var _a;
|
|
65
|
+
return (_a = axBorderRadiusMap[tokenName]) !== null && _a !== void 0 ? _a : match;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return output;
|
|
69
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = transformer;
|
|
4
|
+
const translate_token_1 = require("../../utils/translate-token");
|
|
5
|
+
const legacy_tokens_1 = require("../config/legacy.tokens");
|
|
6
|
+
const axBorderRadiusMap = {
|
|
7
|
+
"@ax-border-radius-full": "@ax-radius-full",
|
|
8
|
+
"@ax-border-radius-small": "@ax-radius-2",
|
|
9
|
+
"@ax-border-radius-medium": "@ax-radius-4",
|
|
10
|
+
"@ax-border-radius-large": "@ax-radius-8",
|
|
11
|
+
"@ax-border-radius-xlarge": "@ax-radius-12",
|
|
12
|
+
};
|
|
13
|
+
function transformer(file) {
|
|
14
|
+
let src = file.source;
|
|
15
|
+
for (const config of Object.values(legacy_tokens_1.legacyTokenConfig)) {
|
|
16
|
+
if (config.replacement.length > 0) {
|
|
17
|
+
src = src.replace(config.regexes.less, (0, translate_token_1.translateToken)(`--ax-${config.replacement}`, "less"));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/*
|
|
21
|
+
Replace usages: @ax-border-radius-(full|small|medium|large|xlarge) -> @ax-radius-(full|2|4|8|12)
|
|
22
|
+
*/
|
|
23
|
+
src = src.replace(/(?<!\w)(@ax-border-radius-(?:full|small|medium|large|xlarge))(?!\w)/g, (match, tokenName) => {
|
|
24
|
+
var _a;
|
|
25
|
+
return (_a = axBorderRadiusMap[tokenName]) !== null && _a !== void 0 ? _a : match;
|
|
26
|
+
});
|
|
27
|
+
return src;
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = transformer;
|
|
4
|
+
const translate_token_1 = require("../../utils/translate-token");
|
|
5
|
+
const legacy_tokens_1 = require("../config/legacy.tokens");
|
|
6
|
+
const axBorderRadiusMap = {
|
|
7
|
+
"$ax-border-radius-full": "$ax-radius-full",
|
|
8
|
+
"$ax-border-radius-small": "$ax-radius-2",
|
|
9
|
+
"$ax-border-radius-medium": "$ax-radius-4",
|
|
10
|
+
"$ax-border-radius-large": "$ax-radius-8",
|
|
11
|
+
"$ax-border-radius-xlarge": "$ax-radius-12",
|
|
12
|
+
};
|
|
13
|
+
function transformer(file) {
|
|
14
|
+
let src = file.source;
|
|
15
|
+
for (const config of Object.values(legacy_tokens_1.legacyTokenConfig)) {
|
|
16
|
+
if (config.replacement.length > 0) {
|
|
17
|
+
src = src.replace(config.regexes.scss, (0, translate_token_1.translateToken)(`--ax-${config.replacement}`, "scss"));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/*
|
|
21
|
+
Replace usages: $ax-border-radius-(full|small|medium|large|xlarge) -> $ax-radius-(full|2|4|8|12)
|
|
22
|
+
*/
|
|
23
|
+
src = src.replace(/(?<!\w)(\$ax-border-radius-(?:full|small|medium|large|xlarge))(?!\w)/g, (match, tokenName) => {
|
|
24
|
+
var _a;
|
|
25
|
+
return (_a = axBorderRadiusMap[tokenName]) !== null && _a !== void 0 ? _a : match;
|
|
26
|
+
});
|
|
27
|
+
return src;
|
|
28
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
17
|
const commander_1 = require("commander");
|
|
18
18
|
const index_1 = require("./codemod/index");
|
|
19
|
-
const
|
|
19
|
+
const v8_tokens_1 = require("./codemod/v8-tokens");
|
|
20
20
|
const help_1 = require("./help");
|
|
21
21
|
const version_1 = require("./version");
|
|
22
22
|
run();
|
|
@@ -36,12 +36,12 @@ function run() {
|
|
|
36
36
|
}
|
|
37
37
|
if (args[0] === "codemod") {
|
|
38
38
|
if (args.includes("v8-tokens")) {
|
|
39
|
-
(0,
|
|
39
|
+
(0, v8_tokens_1.v8TokensCommand)();
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
(0, index_1.codemodCommand)((migration) => {
|
|
43
43
|
if (migration === "v8-tokens") {
|
|
44
|
-
(0,
|
|
44
|
+
(0, v8_tokens_1.v8TokensCommand)();
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
return;
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/aksel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Aksel command line interface. Codemods and other utilities for Aksel users.",
|
|
5
5
|
"author": "Aksel | Nav designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"url": "https://github.com/navikt/aksel/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@navikt/ds-css": "^
|
|
37
|
-
"@navikt/ds-tokens": "^
|
|
36
|
+
"@navikt/ds-css": "^8.0.0",
|
|
37
|
+
"@navikt/ds-tokens": "^8.0.0",
|
|
38
38
|
"chalk": "5.6.2",
|
|
39
39
|
"cli-progress": "3.12.0",
|
|
40
40
|
"clipboardy": "5.0.1",
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = transformer;
|
|
7
|
-
const imports_1 = require("../../codemod/utils/imports");
|
|
8
|
-
const lineterminator_1 = require("../../codemod/utils/lineterminator");
|
|
9
|
-
const packageImports_1 = __importDefault(require("../../codemod/utils/packageImports"));
|
|
10
|
-
const translate_token_1 = require("../../codemod/utils/translate-token");
|
|
11
|
-
const legacy_tokens_1 = require("../config/legacy.tokens");
|
|
12
|
-
function transformer(file, api) {
|
|
13
|
-
let src = file.source;
|
|
14
|
-
const j = api.jscodeshift;
|
|
15
|
-
let root = j(file.source);
|
|
16
|
-
const jsImport = root.find(j.ImportDeclaration).filter((x) => {
|
|
17
|
-
return ["@navikt/ds-tokens/dist/tokens"].includes(x.node.source.value);
|
|
18
|
-
});
|
|
19
|
-
if (jsImport.size() === 0) {
|
|
20
|
-
return src;
|
|
21
|
-
}
|
|
22
|
-
for (const [oldToken, config] of Object.entries(legacy_tokens_1.legacyTokenConfig)) {
|
|
23
|
-
const oldCSSVar = `--a-${oldToken}`;
|
|
24
|
-
const oldJsVar = (0, translate_token_1.translateToken)(oldCSSVar, "js");
|
|
25
|
-
let foundName = null;
|
|
26
|
-
(0, imports_1.getImportSpecifier)(j, root, oldJsVar, "@navikt/ds-tokens/dist/tokens").forEach((x) => {
|
|
27
|
-
foundName = x.node.imported.name;
|
|
28
|
-
});
|
|
29
|
-
if (!foundName) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (config.replacement.length > 0) {
|
|
33
|
-
/* We remove the prefix */
|
|
34
|
-
const jsToken = (0, translate_token_1.translateToken)(`--ax-${config.replacement}`, "js").slice(2);
|
|
35
|
-
const localName = (0, packageImports_1.default)(j, root, {
|
|
36
|
-
fromImport: "@navikt/ds-tokens/dist/tokens",
|
|
37
|
-
toImport: "@navikt/ds-tokens/darkside-js",
|
|
38
|
-
fromName: foundName,
|
|
39
|
-
toName: jsToken,
|
|
40
|
-
ignoreAlias: true,
|
|
41
|
-
});
|
|
42
|
-
let code = root.toSource((0, lineterminator_1.getLineTerminator)(src));
|
|
43
|
-
const rgx = new RegExp(`(\\s|^)?(${localName})(?=\\s|$|[^\\w-])`, "gm");
|
|
44
|
-
code = code.replace(rgx, jsToken);
|
|
45
|
-
src = code;
|
|
46
|
-
root = j(code);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return root.toSource((0, lineterminator_1.getLineTerminator)(src));
|
|
50
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = transformer;
|
|
4
|
-
const translate_token_1 = require("../../codemod/utils/translate-token");
|
|
5
|
-
const legacy_tokens_1 = require("../config/legacy.tokens");
|
|
6
|
-
function transformer(file) {
|
|
7
|
-
let src = file.source;
|
|
8
|
-
for (const config of Object.values(legacy_tokens_1.legacyTokenConfig)) {
|
|
9
|
-
if (config.replacement.length > 0) {
|
|
10
|
-
src = src.replace(config.regexes.less, (0, translate_token_1.translateToken)(`--ax-${config.replacement}`, "less"));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return src;
|
|
14
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = transformer;
|
|
4
|
-
const translate_token_1 = require("../../codemod/utils/translate-token");
|
|
5
|
-
const legacy_tokens_1 = require("../config/legacy.tokens");
|
|
6
|
-
function transformer(file) {
|
|
7
|
-
let src = file.source;
|
|
8
|
-
for (const config of Object.values(legacy_tokens_1.legacyTokenConfig)) {
|
|
9
|
-
if (config.replacement.length > 0) {
|
|
10
|
-
src = src.replace(config.regexes.scss, (0, translate_token_1.translateToken)(`--ax-${config.replacement}`, "scss"));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return src;
|
|
14
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|