@frontify/fondue 12.10.2 → 13.0.0-beta.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.
@@ -1,28 +1,10 @@
1
- /**
2
- * Do not edit directly
3
- * Generated on Thu, 03 Jul 2025 07:04:18 GMT
4
- */
5
-
6
1
  import plugin from 'tailwindcss/plugin';
7
2
 
8
3
  export default {
9
- darkMode: "class",
10
- prefix: "tw-",
11
- theme: {"colors":{"base":{"DEFAULT":"var(--base-color)","alt":"var(--base-color-alt)"},"box":{"neutral":"var(--box-neutral-color)","neutral-hover":"var(--box-neutral-color-hover)","neutral-pressed":"var(--box-neutral-color-pressed)","neutral-inverse":"var(--box-neutral-inverse-color)","neutral-inverse-hover":"var(--box-neutral-inverse-color-hover)","neutral-inverse-pressed":"var(--box-neutral-inverse-color-pressed)","neutral-strong":"var(--box-neutral-strong-color)","neutral-strong-hover":"var(--box-neutral-strong-color-hover)","neutral-strong-pressed":"var(--box-neutral-strong-color-pressed)","neutral-strong-inverse":"var(--box-neutral-strong-inverse-color)","neutral-strong-inverse-hover":"var(--box-neutral-strong-inverse-color-hover)","neutral-strong-inverse-pressed":"var(--box-neutral-strong-inverse-color-pressed)","neutral-mighty":"var(--box-neutral-mighty-color)","neutral-mighty-hover":"var(--box-neutral-mighty-color-hover)","neutral-mighty-pressed":"var(--box-neutral-mighty-color-pressed)","neutral-mighty-inverse":"var(--box-neutral-mighty-inverse-color)","neutral-mighty-inverse-hover":"var(--box-neutral-mighty-inverse-color-hover)","neutral-mighty-inverse-pressed":"var(--box-neutral-mighty-inverse-color-pressed)","selected":"var(--box-selected-color)","selected-hover":"var(--box-selected-color-hover)","selected-pressed":"var(--box-selected-color-pressed)","selected-inverse":"var(--box-selected-inverse-color)","selected-inverse-hover":"var(--box-selected-inverse-color-hover)","selected-inverse-pressed":"var(--box-selected-inverse-color-pressed)","selected-strong":"var(--box-selected-strong-color)","selected-strong-hover":"var(--box-selected-strong-color-hover)","selected-strong-pressed":"var(--box-selected-strong-color-pressed)","selected-strong-inverse":"var(--box-selected-strong-inverse-color)","selected-strong-inverse-hover":"var(--box-selected-strong-inverse-color-hover)","selected-strong-inverse-pressed":"var(--box-selected-strong-inverse-color-pressed)","disabled":"var(--box-disabled-color)","disabled-inverse":"var(--box-disabled-color-inverse)","disabled-strong":"var(--box-disabled-strong-color)","disabled-strong-inverse":"var(--box-disabled-strong-color-inverse)","positive":"var(--box-positive-color)","positive-hover":"var(--box-positive-color-hover)","positive-pressed":"var(--box-positive-color-pressed)","positive-inverse":"var(--box-positive-inverse-color)","positive-inverse-hover":"var(--box-positive-inverse-color-hover)","positive-inverse-pressed":"var(--box-positive-inverse-color-pressed)","positive-strong":"var(--box-positive-strong-color)","positive-strong-hover":"var(--box-positive-strong-color-hover)","positive-strong-pressed":"var(--box-positive-strong-color-pressed)","positive-strong-inverse":"var(--box-positive-strong-inverse-color)","positive-strong-inverse-hover":"var(--box-positive-strong-inverse-color-hover)","positive-strong-inverse-pressed":"var(--box-positive-strong-inverse-color-pressed)","negative":"var(--box-negative-color)","negative-hover":"var(--box-negative-color-hover)","negative-pressed":"var(--box-negative-color-pressed)","negative-inverse":"var(--box-negative-inverse-color)","negative-inverse-hover":"var(--box-negative-inverse-color-hover)","negative-inverse-pressed":"var(--box-negative-inverse-color-pressed)","negative-strong":"var(--box-negative-strong-color)","negative-strong-hover":"var(--box-negative-strong-color-hover)","negative-strong-pressed":"var(--box-negative-strong-color-pressed)","negative-strong-inverse":"var(--box-negative-strong-inverse-color)","negative-strong-inverse-hover":"var(--box-negative-strong-inverse-color-hover)","negative-strong-inverse-pressed":"var(--box-negative-strong-inverse-color-pressed)","warning":"var(--box-warning-color)","warning-hover":"var(--box-warning-color-hover)","warning-pressed":"var(--box-warning-color-pressed)","warning-inverse":"var(--box-warning-inverse-color)","warning-inverse-hover":"var(--box-warning-inverse-color-hover)","warning-inverse-pressed":"var(--box-warning-inverse-color-pressed)","warning-strong":"var(--box-warning-strong-color)","warning-strong-hover":"var(--box-warning-strong-color-hover)","warning-strong-pressed":"var(--box-warning-strong-color-pressed)","warning-strong-inverse":"var(--box-warning-strong-inverse-color)","warning-strong-inverse-hover":"var(--box-warning-strong-inverse-color-hover)","warning-strong-inverse-pressed":"var(--box-warning-strong-inverse-color-pressed)"},"focus":{"shadow":"var(--focus-ring-color)"},"line":{"DEFAULT":"var(--line-color)","weak":"var(--line-color-weak)","strong":"var(--line-color-strong)","x-strong":"var(--line-color-x-strong)","xx-strong":"var(--line-color-xx-strong)","mighty":"var(--line-color-mighty)"},"overlay":{"shadow":"var(--overlay-color)"},"shadow":{"shadow":"var(--shadow-large-color)"},"text":{"DEFAULT":"var(--text-color)","hover":"var(--text-color-hover)","pressed":"var(--text-color-pressed)","weak":"var(--text-color-weak)","weak-hover":"var(--text-color-weak-hover)","weak-pressed":"var(--text-color-weak-pressed)","x-weak":"var(--text-color-x-weak)","disabled":"var(--text-color-disabled)","negative":"var(--text-color-negative)","negative-hover":"var(--text-color-negative-hover)","negative-pressed":"var(--text-color-negative-pressed)","positive":"var(--text-color-positive)","positive-hover":"var(--text-color-positive-hover)","positive-pressed":"var(--text-color-positive-pressed)","warning":"var(--text-color-warning)","warning-hover":"var(--text-color-warning-hover)","warning-pressed":"var(--text-color-warning-pressed)","interactive":"var(--text-color-interactive)","interactive-hover":"var(--text-color-interactive-hover)","interactive-pressed":"var(--text-color-interactive-pressed)"},"button":{"background":"var(--button-background-color)","background-hover":"var(--button-background-color-hover)","background-pressed":"var(--button-background-color-pressed)","text":"var(--button-text-color)","icon":"var(--button-icon-color)","border":"var(--button-border-color)","negative-background":"var(--button-negative-background-color)","negative-background-hover":"var(--button-negative-background-color-hover)","negative-background-pressed":"var(--button-negative-background-color-pressed)","negative-text":"var(--button-negative-text-color)","negative-icon":"var(--button-negative-icon-color)","negative-border":"var(--button-negative-border-color)","positive-background":"var(--button-positive-background-color)","positive-background-hover":"var(--button-positive-background-color-hover)","positive-background-pressed":"var(--button-positive-background-color-pressed)","positive-text":"var(--button-positive-text-color)","positive-icon":"var(--button-positive-icon-color)","positive-border":"var(--button-positive-border-color)","strong-background":"var(--button-strong-background-color)","strong-background-hover":"var(--button-strong-background-color-hover)","strong-background-pressed":"var(--button-strong-background-color-pressed)","strong-text":"var(--button-strong-text-color)","strong-icon":"var(--button-strong-icon-color)","strong-border":"var(--button-strong-border-color)","strong-negative-background":"var(--button-strong-negative-background-color)","strong-negative-background-hover":"var(--button-strong-negative-background-color-hover)","strong-negative-background-pressed":"var(--button-strong-negative-background-color-pressed)","strong-negative-text":"var(--button-strong-negative-text-color)","strong-negative-icon":"var(--button-strong-negative-icon-color)","strong-negative-border":"var(--button-strong-negative-border-color)","strong-positive-background":"var(--button-strong-positive-background-color)","strong-positive-background-hover":"var(--button-strong-positive-background-color-hover)","strong-positive-background-pressed":"var(--button-strong-positive-background-color-pressed)","strong-positive-text":"var(--button-strong-positive-text-color)","strong-positive-icon":"var(--button-strong-positive-icon-color)","strong-positive-border":"var(--button-strong-positive-border-color)","danger-background":"var(--button-danger-background-color)","danger-background-hover":"var(--button-danger-background-color-hover)","danger-background-pressed":"var(--button-danger-background-color-pressed)","danger-text":"var(--button-danger-text-color)","danger-icon":"var(--button-danger-icon-color)","danger-border":"var(--button-danger-border-color)"}},"extend":{"fontSize":{"body-x-small":["var(--body-size-x-small)","var(--body-size-x-small-line-height)"],"body-small":["var(--body-size-small)","var(--body-size-small-line-height)"],"body-medium":["var(--body-size-medium)","var(--body-size-medium-line-height)"],"body-large":["var(--body-size-large)","var(--body-size-large-line-height)"],"code-small":["var(--code-size-small)","var(--code-size-small-line-height)"],"code-medium":["var(--code-size-medium)","var(--code-size-medium-line-height)"],"code-large":["var(--code-size-large)","var(--code-size-large-line-height)"],"heading-medium":["var(--heading-size-medium)","var(--heading-size-medium-line-height)"],"heading-large":["var(--heading-size-large)","var(--heading-size-large-line-height)"],"heading-x-large":["var(--heading-size-x-large)","var(--heading-size-x-large-line-height)"],"heading-xx-large":["var(--heading-size-xx-large)","var(--heading-size-xx-large-line-height)"]},"fontFamily":{"body":"var(--body-family)","body--stack":"var(--body-family-stack)","code":"var(--code-family)","code--stack":"var(--code-family-stack)","heading":"var(--heading-family)","heading--stack":"var(--heading-family-stack)"},"boxShadow":{"matrix":"var(--shadow-matrix)","top-matrix":"var(--shadow-top-matrix)","bottom-matrix":"var(--shadow-bottom-matrix)","large-matrix":"var(--shadow-large-matrix)","inner-line":"inset 0 0 0 var(--line-width) var(--line-color)","inner-line-strong":"inset 0 0 0 var(--line-width) var(--line-color-strong)","inner-line-x-strong":"inset 0 0 0 var(--line-width) var(--line-color-x-strong)","inner-line-xx-strong":"inset 0 0 0 var(--line-width) var(--line-color-xx-strong)"},"borderWidth":{"DEFAULT":"var(--line-width)","large":"var(--line-width-large)"},"borderRadius":{"DEFAULT":"var(--radius)","small":"var(--radius-small)","large":"var(--radius-large)","x-large":"var(--radius-x-large)"},"ringColor":{"DEFAULT":"var(--focus-ring-color)"},"outline":{"violet":"1px solid var(--focus-ring-color)"},"spacing":{"xxs":"var(--space-xxs)","xs":"var(--space-xs)","s":"var(--space-s)","m":"var(--space-m)","l":"var(--space-l)","xl":"var(--space-xl)","xxl":"var(--space-xxl)"}}},
12
- plugins: [
13
- plugin(function({ addComponents, addUtilities}) {
14
- const components = {};
15
- addComponents(components);
16
- }),
17
- ]
18
- }
19
-
20
- export const fondueDiatypeTypographyUtil = plugin(({ addUtilities }) => {
21
- addUtilities({
22
- '.italic, i, em': {
23
- fontStyle: normal,
24
- fontFeatureSettings: '"ss01"',
25
- fontVariationSettings: '"slnt" -12',
26
- },
27
- });
28
- });
4
+ theme: {"colors":{"container":{"disabled":{"DEFAULT":"var(--color-container-disabled-default)","on-disabled-container":"var(--color-container-disabled-on-disabled-container)"},"error":{"active":"var(--color-container-error-active)","DEFAULT":"var(--color-container-error-default)","hover":"var(--color-container-error-hover)","on-error-container":"var(--color-container-error-on-error-container)"},"highlight":{"active":"var(--color-container-highlight-active)","DEFAULT":"var(--color-container-highlight-default)","hover":"var(--color-container-highlight-hover)","on-highlight-container":"var(--color-container-highlight-on-highlight-container)"},"secondary":{"active":"var(--color-container-secondary-active)","DEFAULT":"var(--color-container-secondary-default)","hover":"var(--color-container-secondary-hover)","on-secondary-container":"var(--color-container-secondary-on-secondary-container)","on-secondary-container-variant":"var(--color-container-secondary-on-secondary-container-variant)"},"success":{"active":"var(--color-container-success-active)","DEFAULT":"var(--color-container-success-default)","hover":"var(--color-container-success-hover)","on-success-container":"var(--color-container-success-on-success-container)"},"warning":{"active":"var(--color-container-warning-active)","DEFAULT":"var(--color-container-warning-default)","hover":"var(--color-container-warning-hover)","on-warning-container":"var(--color-container-warning-on-warning-container)"}},"disabled":{"DEFAULT":"var(--color-disabled-default)","on-disabled":"var(--color-disabled-on-disabled)"},"error":{"active":"var(--color-error-active)","DEFAULT":"var(--color-error-default)","hover":"var(--color-error-hover)","on-error":"var(--color-error-on-error)"},"focus":{"contrast":"var(--color-focus-contrast)","DEFAULT":"var(--color-focus-default)"},"highlight":{"active":"var(--color-highlight-active)","DEFAULT":"var(--color-highlight-default)","hover":"var(--color-highlight-hover)","on-highlight":"var(--color-highlight-on-highlight)"},"line":{"mid":"var(--color-line-mid)","strong":"var(--color-line-strong)","subtle":"var(--color-line-subtle)"},"overlay":"var(--color-overlay-overlay)","primary":{"active":"var(--color-primary-active)","DEFAULT":"var(--color-primary-default)","hover":"var(--color-primary-hover)","on-primary":"var(--color-primary-on-primary)","on-primary-variant":"var(--color-primary-on-primary-variant)"},"secondary":{"active":"var(--color-secondary-active)","DEFAULT":"var(--color-secondary-default)","hover":"var(--color-secondary-hover)","on-secondary":"var(--color-secondary-on-secondary)"},"shadow":{"DEFAULT":"var(--color-shadow-default)"},"success":{"active":"var(--color-success-active)","DEFAULT":"var(--color-success-default)","hover":"var(--color-success-hover)","on-success":"var(--color-success-on-success)"},"surface":{"active":"var(--color-surface-active)","DEFAULT":"var(--color-surface-default)","dim":"var(--color-surface-dim)","hover":"var(--color-surface-hover)","on-surface":"var(--color-surface-on-surface)","on-surface-variant":"var(--color-surface-on-surface-variant)"},"warning":{"active":"var(--color-warning-active)","DEFAULT":"var(--color-warning-default)","hover":"var(--color-warning-hover)","on-warning":"var(--color-warning-on-warning)"}},"fontSize":{"large":"var(--typography-font-size-large)","medium":"var(--typography-font-size-medium)","small":"var(--typography-font-size-small)","x-large":"var(--typography-font-size-x-large)","x-small":"var(--typography-font-size-x-small)","xx-large":"var(--typography-font-size-xx-large)","xx-small":"var(--typography-font-size-xx-small)"},"fontWeight":{"bold":"var(--typography-font-weight-bold)","medium":"var(--typography-font-weight-medium)","regular":"var(--typography-font-weight-regular)"},"fontFamily":{"monospace":"var(--typography-font-family-monospace)","primary":"var(--typography-font-family-primary)"},"letterSpacing":{"DEFAULT":"var(--typography-letter-spacing-default)","wide":"var(--typography-letter-spacing-wide)"},"lineHeight":{"extra-loose":"var(--typography-line-height-extra-loose)","loose":"var(--typography-line-height-loose)","medium":"var(--typography-line-height-medium)","tight":"var(--typography-line-height-tight)","wide":"var(--typography-line-height-wide)"},"borderRadius":{"large":"var(--border-radius-large)","medium":"var(--border-radius-medium)","small":"var(--border-radius-small)","x-large":"var(--border-radius-x-large)","full":"9999px"},"borderWidth":{"DEFAULT":"var(--border-width-default)","large":"var(--border-width-large)"},"ringColor":{"DEFAULT":"var(--color-focus-default)"},"outline":{"DEFAULT":"1px solid var(--color-focus-default)"},"boxShadow":{"big":"var(--shadow-big)","DEFAULT":"var(--shadow-default)","mid":"var(--shadow-mid)"},"extend":{"spacing":{"large":"var(--spacing-large)","medium":"var(--spacing-medium)","small":"var(--spacing-small)","x-large":"var(--spacing-x-large)","x-small":"var(--spacing-x-small)","xx-large":"var(--spacing-xx-large)","xx-small":"var(--spacing-xx-small)"}}},
5
+ plugins: [plugin(function({ addUtilities }) {
6
+ addUtilities({
7
+ '.body-large': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-large)", fontWeight: "var(--typography-font-weight-regular)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-wide)" }, '.body-large-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-large)", fontWeight: "var(--typography-font-weight-medium)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-wide)" }, '.body-large-x-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-large)", fontWeight: "var(--typography-font-weight-bold)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-wide)" }, '.body-medium': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-medium)", fontWeight: "var(--typography-font-weight-regular)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-medium)" }, '.body-medium-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-medium)", fontWeight: "var(--typography-font-weight-medium)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-medium)" }, '.body-medium-x-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-medium)", fontWeight: "var(--typography-font-weight-bold)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-medium)" }, '.body-small': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-small)", fontWeight: "var(--typography-font-weight-regular)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-tight)" }, '.body-small-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-small)", fontWeight: "var(--typography-font-weight-medium)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-tight)" }, '.body-small-x-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-small)", fontWeight: "var(--typography-font-weight-bold)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-tight)" }, '.body-x-small': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-x-small)", fontWeight: "var(--typography-font-weight-regular)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-tight)" }, '.body-x-small-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-x-small)", fontWeight: "var(--typography-font-weight-medium)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-tight)" }, '.body-x-small-x-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-x-small)", fontWeight: "var(--typography-font-weight-bold)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-tight)" }, '.heading-category': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-xx-small)", fontWeight: "var(--typography-font-weight-medium)", textTransform: "var(--typography-text-transform-uppercase)", letterSpacing: "var(--typography-letter-spacing-wide)", lineHeight: "var(--typography-line-height-tight)" }, '.heading-category-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-xx-small)", fontWeight: "var(--typography-font-weight-bold)", textTransform: "var(--typography-text-transform-uppercase)", letterSpacing: "var(--typography-letter-spacing-wide)", lineHeight: "var(--typography-line-height-tight)" }, '.heading-large': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-large)", fontWeight: "var(--typography-font-weight-medium)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-wide)" }, '.heading-large-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-large)", fontWeight: "var(--typography-font-weight-bold)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-wide)" }, '.heading-medium': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-medium)", fontWeight: "var(--typography-font-weight-medium)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-tight)" }, '.heading-medium-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-medium)", fontWeight: "var(--typography-font-weight-bold)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-tight)" }, '.heading-x-large': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-x-large)", fontWeight: "var(--typography-font-weight-medium)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-loose)" }, '.heading-x-large-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-x-large)", fontWeight: "var(--typography-font-weight-bold)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-loose)" }, '.heading-xx-large': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-xx-large)", fontWeight: "var(--typography-font-weight-medium)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-extra-loose)" }, '.heading-xx-large-strong': { fontFamily: "var(--typography-font-family-primary)", fontSize: "var(--typography-font-size-xx-large)", fontWeight: "var(--typography-font-weight-bold)", textTransform: "var(--typography-text-transform-default)", letterSpacing: "var(--typography-letter-spacing-default)", lineHeight: "var(--typography-line-height-extra-loose)" },
8
+ })
9
+ })],
10
+ };
@@ -0,0 +1,176 @@
1
+ /* (c) Copyright Frontify Ltd., all rights reserved. */
2
+
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+
6
+ import { cssVariableReplacements, deprecatedCssVariables, tailwindClassReplacements } from './replacements';
7
+
8
+ const deprecatedOccurrences: { filePath: string; line: number; variable: string }[] = [];
9
+
10
+ const logDeprecatedInFile = (filePath: string, deprecatedMap: Record<string, string>) => {
11
+ try {
12
+ const stats = fs.statSync(filePath);
13
+ if (!stats.isFile()) {
14
+ return;
15
+ }
16
+
17
+ const content = fs.readFileSync(filePath, 'utf8');
18
+ const lines = content.split('\n');
19
+
20
+ for (let i = 0; i < lines.length; i++) {
21
+ const line = lines[i];
22
+ for (const deprecatedVar of Object.keys(deprecatedMap)) {
23
+ if (line?.includes(deprecatedVar)) {
24
+ deprecatedOccurrences.push({
25
+ filePath,
26
+ line: i + 1,
27
+ variable: deprecatedVar,
28
+ });
29
+ }
30
+ }
31
+ }
32
+ } catch (error) {
33
+ console.error(
34
+ `Could not check for deprecated variables in file ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`,
35
+ );
36
+ }
37
+ };
38
+
39
+ const replaceInFile = (filePath: string, replacementMap: Record<string, string>, dryRun: boolean) => {
40
+ try {
41
+ const stats = fs.statSync(filePath);
42
+ if (!stats.isFile()) {
43
+ return;
44
+ }
45
+
46
+ const content = fs.readFileSync(filePath, 'utf8');
47
+
48
+ const replacementsToApply: { selector: string; replacement: string; oldValue: string; newValue: string }[] = [];
49
+ for (const [selector, value] of Object.entries(replacementMap)) {
50
+ const regexMatch = content.match(new RegExp(selector, 'g'));
51
+
52
+ for (const match of regexMatch ?? []) {
53
+ const newValue = match.replaceAll(new RegExp(selector, 'g'), value);
54
+ if (newValue !== match) {
55
+ replacementsToApply.push({
56
+ selector,
57
+ replacement: value,
58
+ oldValue: match,
59
+ newValue,
60
+ });
61
+ }
62
+ }
63
+ }
64
+
65
+ if (replacementsToApply.length === 0) {
66
+ return;
67
+ }
68
+
69
+ if (dryRun) {
70
+ console.log(`Potential changes for: ${filePath}`);
71
+ for (const { oldValue, newValue } of replacementsToApply) {
72
+ console.log(` '${oldValue}' => '${newValue}'`);
73
+ }
74
+ console.log('');
75
+ return;
76
+ }
77
+
78
+ let modifiedContent = content;
79
+ for (const { selector, newValue } of replacementsToApply) {
80
+ modifiedContent = modifiedContent.replaceAll(new RegExp(selector, 'g'), newValue);
81
+ }
82
+
83
+ fs.writeFileSync(filePath, modifiedContent, 'utf8');
84
+ console.log(`Updated: ${filePath}`);
85
+ } catch (error) {
86
+ console.error(
87
+ `Could not process file ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`,
88
+ );
89
+ }
90
+ };
91
+
92
+ const traverseDir = (
93
+ dir: string,
94
+ replacementMap: Record<string, string>,
95
+ deprecatedMap: Record<string, string>,
96
+ dryRun: boolean,
97
+ ) => {
98
+ try {
99
+ const files = fs.readdirSync(dir);
100
+
101
+ for (const file of files) {
102
+ const fullPath = path.join(dir, file);
103
+
104
+ const stat = fs.statSync(fullPath);
105
+ if (stat.isDirectory()) {
106
+ traverseDir(fullPath, replacementMap, deprecatedMap, dryRun);
107
+ } else {
108
+ replaceInFile(fullPath, replacementMap, dryRun);
109
+ logDeprecatedInFile(fullPath, deprecatedMap);
110
+ }
111
+ }
112
+ } catch (error) {
113
+ console.error(`Could not read directory ${dir}: ${error instanceof Error ? error.message : 'Unknown error'}`);
114
+ }
115
+ };
116
+
117
+ const replaceTokens = (
118
+ directory: string,
119
+ replacementMap: Record<string, string>,
120
+ deprecatedMap: Record<string, string>,
121
+ { dryRun = false }: { dryRun?: boolean } = {},
122
+ ) => {
123
+ if (dryRun) {
124
+ console.log('\n\n==================================================');
125
+ console.log('DRY RUN MODE ENABLED. NO FILES WILL BE MODIFIED.');
126
+ console.log('==================================================\n');
127
+ }
128
+
129
+ traverseDir(directory, replacementMap, deprecatedMap, dryRun);
130
+
131
+ if (deprecatedOccurrences.length > 0) {
132
+ console.log('\n\n==================================================');
133
+ console.log('🚨 DEPRECATED CSS VARIABLES WITHOUT REPLACEMENT FOUND 🚨');
134
+ console.log('==================================================\n');
135
+
136
+ const groupedByFile = deprecatedOccurrences.reduce(
137
+ (acc, { filePath, line, variable }) => {
138
+ if (!acc[filePath]) {
139
+ acc[filePath] = [];
140
+ }
141
+ acc[filePath].push(` - Line ${line}: ${variable}`);
142
+ return acc;
143
+ },
144
+ {} as Record<string, string[]>,
145
+ );
146
+
147
+ for (const [file, occurrences] of Object.entries(groupedByFile)) {
148
+ console.log(`File: ${file}`);
149
+ for (const occurrence of occurrences) {
150
+ console.log(occurrence);
151
+ }
152
+ console.log('');
153
+ }
154
+
155
+ console.log(
156
+ 'Please replace the variables listed above with their new counterparts from the design system tokens.',
157
+ );
158
+ console.log('==================================================\n');
159
+
160
+ process.exit(1);
161
+ }
162
+ };
163
+
164
+ export const replaceCssVariables = (directory: string, { dryRun = false }: { dryRun?: boolean } = {}) => {
165
+ const escapedCssVariableReplacements = Object.fromEntries(
166
+ Object.entries(cssVariableReplacements).map(([key, value]) => [
167
+ key.replaceAll(/[$()*+./?[\\\]^{|}-]/g, '\\$&'),
168
+ value,
169
+ ]),
170
+ );
171
+ replaceTokens(directory, escapedCssVariableReplacements, deprecatedCssVariables, { dryRun });
172
+ };
173
+
174
+ export const replaceTailwindClasses = (directory: string, { dryRun = false }: { dryRun?: boolean } = {}) => {
175
+ replaceTokens(directory, tailwindClassReplacements, {}, { dryRun });
176
+ };