Skip to content

Commit 586723f

Browse files
Rename --letter-spacing-* variables to --tracking-* (#14921)
Part of the current changes, we also want to make the `--letter-spacing-*` namespace closer to the utility name so we're renaming it to `--tracking-*`: ```diff @theme { - --letter-spacing-tighter: -0.05em; - --letter-spacing-tight: -0.025em; - --letter-spacing-normal: 0em; - --letter-spacing-wide: 0.025em; - --letter-spacing-wider: 0.05em; - --letter-spacing-widest: 0.1em; /* ... */ + --tracking-tighter: -0.05em; + --tracking-tight: -0.025em; + --tracking-normal: 0em; + --tracking-wide: 0.025em; + --tracking-wider: 0.05em; + --tracking-widest: 0.1em; /* ... */ } ``` ## Test Plan Added cases to the CSS `theme()` variable/JS plugin tests (interop layer) and the integration tests (codemod layer).
1 parent 97da59f commit 586723f

File tree

13 files changed

+77
-39
lines changed

13 files changed

+77
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5656
- Rename `--transition-timing-function-*` variables to `--ease-*` ([#14886](https://github.com/tailwindlabs/tailwindcss/pull/14886))
5757
- Rename `--width-*` variables to `--container-*` ([#14898](https://github.com/tailwindlabs/tailwindcss/pull/14898))
5858
- Rename `--font-size-*` variables to `--text-*` ([#14909](https://github.com/tailwindlabs/tailwindcss/pull/14909))
59+
- Rename `--letter-spacing-*` variables to `--tracking-*` ([#14921](https://github.com/tailwindlabs/tailwindcss/pull/14921))
5960
- Revert specificity of `*` variant to match v3 behavior ([#14920](https://github.com/tailwindlabs/tailwindcss/pull/14920))
6061

6162
## [4.0.0-alpha.31] - 2024-10-29

integrations/upgrade/js-config.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ test(
114114
'spin-clockwise': 'spin-clockwise 1s linear infinite',
115115
'spin-counterclockwise': 'spin-counterclockwise 1s linear infinite',
116116
},
117+
letterSpacing: {
118+
superWide: '0.25em',
119+
},
117120
},
118121
},
119122
plugins: [],
@@ -130,6 +133,11 @@ test(
130133
'shouldNotMigrate': !border.test + '',
131134
}
132135
`,
136+
'src/index.html': html`
137+
<div
138+
class="[letter-spacing:theme(letterSpacing.superWide)]"
139+
></div>
140+
`,
133141
'node_modules/my-external-lib/src/template.html': html`
134142
<div class="text-red-500">
135143
Hello world!
@@ -140,8 +148,13 @@ test(
140148
async ({ exec, fs }) => {
141149
await exec('npx @tailwindcss/upgrade')
142150

143-
expect(await fs.dumpFiles('src/**/*.{css,js}')).toMatchInlineSnapshot(`
151+
expect(await fs.dumpFiles('src/**/*.{css,js,html}')).toMatchInlineSnapshot(`
144152
"
153+
--- src/index.html ---
154+
<div
155+
class="[letter-spacing:var(--tracking-super-wide)]"
156+
></div>
157+
145158
--- src/input.css ---
146159
@import 'tailwindcss';
147160
@@ -223,6 +236,8 @@ test(
223236
--animate-spin-clockwise: spin-clockwise 1s linear infinite;
224237
--animate-spin-counterclockwise: spin-counterclockwise 1s linear infinite;
225238
239+
--tracking-super-wide: 0.25em;
240+
226241
@keyframes spin-clockwise {
227242
0% {
228243
transform: rotate(0deg);

packages/@tailwindcss-postcss/src/__snapshots__/index.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,12 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
349349
--font-weight-bold: 700;
350350
--font-weight-extrabold: 800;
351351
--font-weight-black: 900;
352-
--letter-spacing-tighter: -.05em;
353-
--letter-spacing-tight: -.025em;
354-
--letter-spacing-normal: 0em;
355-
--letter-spacing-wide: .025em;
356-
--letter-spacing-wider: .05em;
357-
--letter-spacing-widest: .1em;
352+
--tracking-tighter: -.05em;
353+
--tracking-tight: -.025em;
354+
--tracking-normal: 0em;
355+
--tracking-wide: .025em;
356+
--tracking-wider: .05em;
357+
--tracking-widest: .1em;
358358
--line-height-none: 1;
359359
--line-height-tight: 1.25;
360360
--line-height-snug: 1.375;

packages/tailwindcss/src/__snapshots__/index.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,12 @@ exports[`compiling CSS > \`@tailwind utilities\` is replaced by utilities using
348348
--font-weight-bold: 700;
349349
--font-weight-extrabold: 800;
350350
--font-weight-black: 900;
351-
--letter-spacing-tighter: -.05em;
352-
--letter-spacing-tight: -.025em;
353-
--letter-spacing-normal: 0em;
354-
--letter-spacing-wide: .025em;
355-
--letter-spacing-wider: .05em;
356-
--letter-spacing-widest: .1em;
351+
--tracking-tighter: -.05em;
352+
--tracking-tight: -.025em;
353+
--tracking-normal: 0em;
354+
--tracking-wide: .025em;
355+
--tracking-wider: .05em;
356+
--tracking-widest: .1em;
357357
--line-height-none: 1;
358358
--line-height-tight: 1.25;
359359
--line-height-snug: 1.375;

packages/tailwindcss/src/compat/apply-config-to-theme.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ test('config values can be merged into the theme', () => {
5050
],
5151
},
5252

53+
letterSpacing: {
54+
superWide: '0.25em',
55+
},
56+
5357
width: {
5458
// Purposely setting to something different from the default
5559
'1/2': '60%',
@@ -88,6 +92,7 @@ test('config values can be merged into the theme', () => {
8892
'1rem',
8993
{ '--line-height': '1.5' },
9094
])
95+
expect(theme.resolve('super-wide', ['--tracking'])).toEqual('0.25em')
9196
expect(theme.resolve('1/2', ['--width'])).toEqual('60%')
9297
expect(theme.resolve('0.5', ['--width'])).toEqual('60%')
9398
expect(theme.resolve('100%', ['--width'])).toEqual('100%')

packages/tailwindcss/src/compat/apply-config-to-theme.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,16 @@ const IS_VALID_KEY = /^[a-zA-Z0-9-_%/\.]+$/
130130
export function keyPathToCssProperty(path: string[]) {
131131
path = structuredClone(path)
132132

133-
if (path[0] === 'colors') path[0] = 'color'
134-
if (path[0] === 'screens') path[0] = 'breakpoint'
133+
if (path[0] === 'animation') path[0] = 'animate'
135134
if (path[0] === 'borderRadius') path[0] = 'radius'
136135
if (path[0] === 'boxShadow') path[0] = 'shadow'
137-
if (path[0] === 'animation') path[0] = 'animate'
138-
if (path[0] === 'transitionTimingFunction') path[0] = 'ease'
136+
if (path[0] === 'colors') path[0] = 'color'
139137
if (path[0] === 'fontFamily') path[0] = 'font'
140138
if (path[0] === 'fontSize') path[0] = 'text'
139+
if (path[0] === 'letterSpacing') path[0] = 'tracking'
141140
if (path[0] === 'maxWidth') path[0] = 'container'
141+
if (path[0] === 'screens') path[0] = 'breakpoint'
142+
if (path[0] === 'transitionTimingFunction') path[0] = 'ease'
142143

143144
for (let part of path) {
144145
if (!IS_VALID_KEY.test(part)) return null

packages/tailwindcss/src/compat/config.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,9 @@ test('old theme values are merged with their renamed counterparts in the CSS the
15361536
15371537
--container-a: 1;
15381538
--container-b: 2;
1539+
1540+
--tracking-a: 1;
1541+
--tracking-b: 2;
15391542
}
15401543
15411544
@plugin "./plugin.js";
@@ -1594,6 +1597,14 @@ test('old theme values are merged with their renamed counterparts in the CSS the
15941597

15951598
expect(theme('maxWidth.a')).toEqual('1')
15961599
expect(theme('maxWidth.b')).toEqual('2')
1600+
1601+
expect(theme('letterSpacing.a')).toEqual('1')
1602+
expect(theme('letterSpacing.b')).toEqual('2')
1603+
1604+
expect(theme('letterSpacing')).toMatchObject({
1605+
a: '1',
1606+
b: '2',
1607+
})
15971608
}),
15981609
}
15991610
},

packages/tailwindcss/src/compat/config/create-compat-config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export function createCompatConfig(cssTheme: Theme): UserConfig {
3434
...theme('breakpoint', {}),
3535
}),
3636

37+
letterSpacing: ({ theme }) => ({
38+
...theme('tracking', {}),
39+
}),
40+
3741
transitionDuration: {
3842
DEFAULT: cssTheme.get(['--default-transition-duration']) ?? null,
3943
},

packages/tailwindcss/src/css-functions.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ describe('theme function', () => {
639639
],
640640
['maxWidth.xs', '20rem'],
641641
['transitionTimingFunction.in-out', 'cubic-bezier(.4, 0, .2, 1)'],
642+
['letterSpacing.wide', '.025em'],
642643
['backgroundColor.red.500', 'oklch(.637 .237 25.331)'],
643644
])('theme(%s) → %s', async (value, result) => {
644645
let defaultTheme = await fs.readFile(path.join(__dirname, '..', 'theme.css'), 'utf8')

packages/tailwindcss/src/utilities.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14095,17 +14095,17 @@ test('tracking', async () => {
1409514095
await compileCss(
1409614096
css`
1409714097
@theme {
14098-
--letter-spacing-normal: 0em;
14099-
--letter-spacing-wide: 0.025em;
14098+
--tracking-normal: 0em;
14099+
--tracking-wide: 0.025em;
1410014100
}
1410114101
@tailwind utilities;
1410214102
`,
1410314103
['tracking-normal', 'tracking-wide', 'tracking-[var(--value)]', '-tracking-[var(--value)]'],
1410414104
),
1410514105
).toMatchInlineSnapshot(`
1410614106
":root {
14107-
--letter-spacing-normal: 0em;
14108-
--letter-spacing-wide: .025em;
14107+
--tracking-normal: 0em;
14108+
--tracking-wide: .025em;
1410914109
}
1411014110
1411114111
.-tracking-\\[var\\(--value\\)\\] {
@@ -14119,13 +14119,13 @@ test('tracking', async () => {
1411914119
}
1412014120
1412114121
.tracking-normal {
14122-
--tw-tracking: var(--letter-spacing-normal);
14123-
letter-spacing: var(--letter-spacing-normal);
14122+
--tw-tracking: var(--tracking-normal);
14123+
letter-spacing: var(--tracking-normal);
1412414124
}
1412514125
1412614126
.tracking-wide {
14127-
--tw-tracking: var(--letter-spacing-wide);
14128-
letter-spacing: var(--letter-spacing-wide);
14127+
--tw-tracking: var(--tracking-wide);
14128+
letter-spacing: var(--tracking-wide);
1412914129
}
1413014130
1413114131
@supports (-moz-orient: inline) {

0 commit comments

Comments
 (0)