Skip to content

Commit 1f3e8a6

Browse files
authored
refactor: bump uno (#4576)
Nothing critical. Api is not asynchronous. Oklch is used by default though I opt out into legacy color space which is supported by our parser.
1 parent a02e9d1 commit 1f3e8a6

File tree

3 files changed

+67
-50
lines changed

3 files changed

+67
-50
lines changed

packages/css-data/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
"private": true,
3636
"sideEffects": false,
3737
"dependencies": {
38-
"@unocss/core": "^0.61.2",
39-
"@unocss/preset-uno": "^0.61.2",
38+
"@unocss/core": "^0.65.1",
39+
"@unocss/preset-legacy-compat": "^0.65.1",
40+
"@unocss/preset-uno": "^0.65.1",
4041
"@webstudio-is/css-engine": "workspace:*",
4142
"change-case": "^5.4.4",
4243
"colord": "^2.9.3",

packages/css-data/src/tailwind-parser/parse.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { UnoGenerator, createGenerator } from "@unocss/core";
22
import { type Theme, presetUno } from "@unocss/preset-uno";
3+
import { presetLegacyCompat } from "@unocss/preset-legacy-compat";
34
import warnOnce from "warn-once";
45
import { substituteVariables } from "./substitute";
56
import { parseCss, type ParsedStyleDecl } from "../parse-css";
@@ -8,9 +9,13 @@ type Warn = (condition: boolean, message: string) => void;
89

910
let unoLazy: UnoGenerator<Theme> | undefined = undefined;
1011

11-
const uno = () => {
12-
unoLazy = createGenerator({
13-
presets: [presetUno()],
12+
const createUnoGenerator = async () => {
13+
unoLazy = await createGenerator({
14+
presets: [
15+
presetUno(),
16+
// until we support oklch natively
17+
presetLegacyCompat({ legacyColorSpace: true }),
18+
],
1419
});
1520
return unoLazy;
1621
};
@@ -22,7 +27,8 @@ export const parseTailwindToCss = async (
2227
classes: string,
2328
warn: Warn = warnOnce
2429
): Promise<string> => {
25-
const generated = await uno().generate(classes, {
30+
const generator = unoLazy ?? (await createUnoGenerator());
31+
const generated = await generator.generate(classes, {
2632
preflights: true,
2733
});
2834

pnpm-lock.yaml

Lines changed: 54 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)