Skip to content

Commit ee89198

Browse files
authored
refactor: drop tailwind from radix package (#4704)
All styles use our css parser, no need to additional abstraction any more. Theme is handwritten and contains only used stuff. ```diff - 880 MB + 859 MB ```
1 parent 42f5760 commit ee89198

15 files changed

+96
-2467
lines changed

packages/sdk-components-react-radix/package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"scripts": {
4343
"build": "vite build --config ../../vite.sdk-components.config.ts",
4444
"build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/*.tsx !./src/*.stories.tsx !./src/*.ws.ts !./src/*.test.{ts,tsx}' -e asChild -e modal -e defaultOpen -e defaultChecked && prettier --write \"**/*.props.ts\"",
45-
"build:tailwind": "tsx --conditions=webstudio scripts/generate-tailwind-theme.ts && prettier --write src/theme/__generated__",
4645
"build:stories": "webstudio-sdk generate-stories && prettier --write \"src/__generated__/*.stories.tsx\"",
4746
"dts": "tsc --project tsconfig.dts.json",
4847
"typecheck": "tsc"
@@ -81,7 +80,6 @@
8180
"@webstudio-is/template": "workspace:*",
8281
"@webstudio-is/tsconfig": "workspace:*",
8382
"react": "18.3.0-canary-14898b6a9-20240318",
84-
"react-dom": "18.3.0-canary-14898b6a9-20240318",
85-
"tailwindcss": "^3.3.3"
83+
"react-dom": "18.3.0-canary-14898b6a9-20240318"
8684
}
8785
}

packages/sdk-components-react-radix/scripts/generate-tailwind-theme.ts

-216
This file was deleted.

packages/sdk-components-react-radix/src/accordion.ws.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import {
1212
type WsComponentPropsMeta,
1313
} from "@webstudio-is/react-sdk";
1414
import { div, h3, button } from "@webstudio-is/sdk/normalize.css";
15-
import * as tc from "./theme/tailwind-classes";
16-
import { buttonReset } from "./theme/styles";
15+
import { buttonReset } from "./shared/preset-styles";
1716
import {
1817
propsAccordion,
1918
propsAccordionItem,
@@ -75,7 +74,17 @@ export const metaAccordionHeader: WsComponentMeta = {
7574
},
7675
],
7776
presetStyle: {
78-
h3: [h3, tc.my(0)].flat(),
77+
h3: [
78+
...h3,
79+
{
80+
property: "marginTop",
81+
value: { type: "unit", unit: "px", value: 0 },
82+
},
83+
{
84+
property: "marginBottom",
85+
value: { type: "unit", unit: "px", value: 0 },
86+
},
87+
],
7988
},
8089
};
8190

packages/sdk-components-react-radix/src/checkbox.ws.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
type WsComponentPropsMeta,
66
} from "@webstudio-is/react-sdk";
77
import { button, span } from "@webstudio-is/sdk/normalize.css";
8-
import { buttonReset } from "./theme/styles";
8+
import { buttonReset } from "./shared/preset-styles";
99
import {
1010
propsCheckbox,
1111
propsCheckboxIndicator,

packages/sdk-components-react-radix/src/dialog.ws.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
propsDialogTitle,
2424
propsDialogDescription,
2525
} from "./__generated__/dialog.props";
26-
import { buttonReset } from "./theme/styles";
26+
import { buttonReset } from "./shared/preset-styles";
2727

2828
const presetStyle = {
2929
div,

packages/sdk-components-react-radix/src/radio-group.ws.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
type WsComponentPropsMeta,
66
} from "@webstudio-is/react-sdk";
77
import { button, div, span } from "@webstudio-is/sdk/normalize.css";
8-
import { buttonReset } from "./theme/styles";
8+
import { buttonReset } from "./shared/preset-styles";
99
import {
1010
propsRadioGroup,
1111
propsRadioGroupIndicator,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// this module should not rely on "template" and other unpublished packages
2+
import type { StyleProperty, Unit } from "@webstudio-is/css-engine";
3+
import type { EmbedTemplateStyleDecl } from "@webstudio-is/react-sdk";
4+
5+
const unit = (property: StyleProperty, value: number, unit: Unit) => ({
6+
property,
7+
value: { type: "unit", unit, value } as const,
8+
});
9+
10+
const keyword = (property: StyleProperty, value: string) => ({
11+
property,
12+
value: { type: "keyword", value } as const,
13+
});
14+
15+
const rgb = (property: StyleProperty, r: number, g: number, b: number) => ({
16+
property,
17+
value: { type: "rgb", alpha: 1, r, g, b } as const,
18+
});
19+
20+
export const buttonReset: EmbedTemplateStyleDecl[] = [
21+
{
22+
property: "backgroundColor",
23+
value: { type: "keyword", value: "transparent" },
24+
},
25+
{
26+
property: "backgroundImage",
27+
value: { type: "keyword", value: "none" },
28+
},
29+
30+
unit("borderTopWidth", 0, "px"),
31+
unit("borderRightWidth", 0, "px"),
32+
unit("borderBottomWidth", 0, "px"),
33+
unit("borderLeftWidth", 0, "px"),
34+
keyword("borderTopStyle", "solid"),
35+
keyword("borderRightStyle", "solid"),
36+
keyword("borderBottomStyle", "solid"),
37+
keyword("borderLeftStyle", "solid"),
38+
rgb("borderTopColor", 226, 232, 240),
39+
rgb("borderRightColor", 226, 232, 240),
40+
rgb("borderBottomColor", 226, 232, 240),
41+
rgb("borderLeftColor", 226, 232, 240),
42+
43+
unit("paddingTop", 0, "px"),
44+
unit("paddingRight", 0, "px"),
45+
unit("paddingBottom", 0, "px"),
46+
unit("paddingLeft", 0, "px"),
47+
];

0 commit comments

Comments
 (0)