Skip to content

Commit 2da8818

Browse files
committed
Resolve issue where leading 0 was being stripped from CSS variables in tailwind v4 alpha
1 parent dd8b0fc commit 2da8818

File tree

4 files changed

+172
-154
lines changed

4 files changed

+172
-154
lines changed

lib/ui/utils/CSSVariables.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { isEmpty } from 'es-toolkit/compat';
33
const CSSVariable = (variableName) => {
44
if (document.readyState !== 'complete') {
55
// eslint-disable-next-line no-console
6-
// console.error('You attempted to read the value of a CSS variable before all app resources were loaded! Move calls to getCSSVariableAs* outside of the top level scope of your components.');
6+
// console.error(
7+
// 'You attempted to read the value of a CSS variable before all app resources were loaded! Move calls to getCSSVariableAs* outside of the top level scope of your components.',
8+
// );
79
}
810

911
const variable = getComputedStyle(document.body)
@@ -20,8 +22,9 @@ const CSSVariable = (variableName) => {
2022
export const getCSSVariableAsString = (variableName) =>
2123
CSSVariable(variableName);
2224

25+
// Coerce the CSS variable to a number
2326
export const getCSSVariableAsNumber = (variableName) =>
24-
parseInt(CSSVariable(variableName), 10);
27+
parseFloat(CSSVariable(variableName));
2528

2629
export const getCSSVariableAsObject = (variableName) =>
2730
JSON.parse(CSSVariable(variableName));

next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let commitHash = 'Unknown commit hash';
77
try {
88
commitHash = ChildProcess.execSync('git log --pretty=format:"%h" -n1')
99
.toString()
10-
.trim()
10+
.trim();
1111
} catch (error) {
1212
// eslint-disable-next-line no-console
1313
console.info('Error getting commit hash:', error.message ?? 'Unknown error');

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"@tailwindcss/aspect-ratio": "^0.4.2",
112112
"@tailwindcss/container-queries": "^0.1.1",
113113
"@tailwindcss/forms": "^0.5.9",
114-
"@tailwindcss/postcss": "4.0.0-beta.3",
114+
"@tailwindcss/postcss": "4.0.0-beta.9",
115115
"@tailwindcss/typography": "^0.5.15",
116116
"@total-typescript/ts-reset": "^0.6.1",
117117
"@types/archiver": "^6.0.3",
@@ -139,7 +139,7 @@
139139
"prettier-plugin-tailwindcss": "^0.6.9",
140140
"prisma": "^5.22.0",
141141
"sass": "^1.81.0",
142-
"tailwindcss": "4.0.0-beta.3",
142+
"tailwindcss": "4.0.0-beta.9",
143143
"tailwindcss-animate": "^1.0.7",
144144
"typescript": "5.6.3",
145145
"vite-tsconfig-paths": "^5.1.2",

0 commit comments

Comments
 (0)