Skip to content

Commit 5b56ad0

Browse files
committed
Chore: Seperate vanilla extract API to ./compat
1 parent e770e4c commit 5b56ad0

File tree

9 files changed

+37
-39
lines changed

9 files changed

+37
-39
lines changed

examples/react-swc/src/App.css.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { globalStyle, keyframes, style } from "@mincho-js/css"
1+
import { globalCss, keyframes, css } from "@mincho-js/css"
22

3-
globalStyle("#root", {
3+
globalCss("#root", {
44
maxWidth: "1280px",
55
margin: "0 auto",
66
padding: "2rem",
77
textAlign: "center",
88
});
99

10-
export const react = style({
10+
export const react = css({
1111
});
1212
const logoSpin = keyframes({
1313
"from": {
@@ -18,7 +18,7 @@ const logoSpin = keyframes({
1818
},
1919
});
2020

21-
export const logo = style({
21+
export const logo = css({
2222
height: "6em",
2323
padding: "1.5em",
2424
willChange: "filter",
@@ -40,11 +40,11 @@ export const logo = style({
4040
},
4141
});
4242

43-
export const card = style({
43+
export const card = css({
4444
padding: "2em",
4545
});
4646

47-
export const readTheDocs = style({
47+
export const readTheDocs = css({
4848
color: "#888",
4949
});
5050

examples/react-swc/src/index.css.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { globalStyle } from "@mincho-js/css"
1+
import { globalCss } from "@mincho-js/css"
22

3-
globalStyle(":root", {
3+
globalCss(":root", {
44
fontFamily: "Inter , system-ui , Avenir , Helvetica , Arial , sans-serif",
55
lineHeight: "1.5",
66
fontWeight: "400",
@@ -20,32 +20,32 @@ globalStyle(":root", {
2020
},
2121
});
2222

23-
globalStyle("a", {
23+
globalCss("a", {
2424
fontWeight: "500",
2525
color: "#646cff",
2626
textDecoration: "inherit",
2727
});
28-
globalStyle("a:hover", {
28+
globalCss("a:hover", {
2929
color: "#535bf2",
3030
"@media (prefers-color-scheme: light)": {
3131
color: "#747bff",
3232
},
3333
});
3434

35-
globalStyle("body", {
35+
globalCss("body", {
3636
margin: "0",
3737
display: "flex",
3838
placeItems: "center",
3939
minWidth: "320px",
4040
minHeight: "100vh",
4141
});
4242

43-
globalStyle("h1", {
43+
globalCss("h1", {
4444
fontSize: "3.2em",
4545
lineHeight: "1.1",
4646
});
4747

48-
globalStyle("button", {
48+
globalCss("button", {
4949
borderRadius: "8px",
5050
border: "1px solid transparent",
5151
padding: "0.6em 1.2em",
@@ -60,11 +60,11 @@ globalStyle("button", {
6060
},
6161
});
6262

63-
globalStyle("button:hover", {
63+
globalCss("button:hover", {
6464
borderColor: "#646cff",
6565
});
6666

67-
globalStyle("button:focus, button:focus-visible", {
67+
globalCss("button:focus, button:focus-visible", {
6868
outline: "4px auto -webkit-focus-ring-color",
6969
});
7070

packages/babel/src/styled.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function styledComponentPlugin(): PluginObj<PluginState> {
5555

5656
const recipeIdentifier = registerImportMethod(
5757
callPath,
58-
"recipe",
58+
"rules",
5959
"@mincho-js/css"
6060
);
6161

packages/babel/src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ export function getNearestIdentifier(path: NodePath<t.Node>) {
7070
export const extractionAPIs = [
7171
// @mincho-js/css
7272
"mincho$",
73+
"css",
74+
"cssVariants",
75+
"globalCss",
76+
"rules",
7377
// @vanilla-extract/css
7478
"style",
7579
"styleVariants",

packages/css/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@
4242
"default": "./dist/cjs/index.cjs"
4343
}
4444
},
45+
"./compat": {
46+
"import": {
47+
"types": "./dist/esm/compat.d.ts",
48+
"default": "./dist/esm/compat.mjs"
49+
},
50+
"require": {
51+
"types": "./dist/cjs/compat.d.cts",
52+
"default": "./dist/cjs/compat.cjs"
53+
}
54+
},
4555
"./rules/createRuntimeFn": {
4656
"import": {
4757
"types": "./dist/esm/rules/createRuntimeFn.d.ts",

packages/css/src/css/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export function globalCss(selector: string, rule: GlobalCSSRule) {
3838
});
3939
}
4040
}
41-
export const globalStyle = globalCss;
4241

4342
// TODO: Make more type-safe
4443
type UnknownObject = Record<string, unknown>;
@@ -105,7 +104,6 @@ function hoistSelectors(input: CSSRule): HoistResult {
105104
export function css(style: ComplexCSSRule, debugId?: string) {
106105
return vStyle(transform(style), debugId);
107106
}
108-
export const style = css;
109107

110108
// == CSS Variants =============================================================
111109
// TODO: Need to optimize
@@ -138,7 +136,6 @@ export function cssVariants<
138136
return processVariants(styleMap, (style) => style, debugId);
139137
}
140138
}
141-
export const styleVariants = cssVariants;
142139

143140
function isMapDataFunction<
144141
Data extends Record<string | number, unknown>,
@@ -203,7 +200,7 @@ if (import.meta.vitest) {
203200
});
204201

205202
it("composition", () => {
206-
const base = style({ padding: 12 }, "base");
203+
const base = css({ padding: 12 }, "base");
207204
const result = css([base, { color: "red" }], debugId);
208205

209206
assert.isString(result);
@@ -244,7 +241,7 @@ if (import.meta.vitest) {
244241
});
245242

246243
it("Mapping Variants with composition", () => {
247-
const base = style({ padding: 12 }, "base");
244+
const base = css({ padding: 12 }, "base");
248245
const result = cssVariants(
249246
{
250247
primary: "blue",

packages/css/src/index.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {
1+
export type {
22
CSSProperties,
33
ComplexCSSRule,
44
GlobalCSSRule,
@@ -25,16 +25,8 @@ export {
2525
layer
2626
} from "@vanilla-extract/css";
2727

28-
export {
29-
globalCss,
30-
globalStyle,
31-
css,
32-
style,
33-
cssVariants,
34-
styleVariants
35-
} from "./css/index.js";
36-
export { rules, recipe } from "./rules/index.js";
37-
export { createRuntimeFn } from "./rules/createRuntimeFn.js";
28+
export { globalCss, css, cssVariants } from "./css/index.js";
29+
export { rules } from "./rules/index.js";
3830
export type {
3931
VariantStyle,
4032
RulesVariants,
@@ -50,8 +42,3 @@ export type {
5042
VariantObjectSelection,
5143
ResolveComplex
5244
} from "./rules/types.js";
53-
54-
export type { CSSProperties, ComplexCSSRule, GlobalCSSRule, CSSRule };
55-
export type ComplexStyleRule = ComplexCSSRule;
56-
export type GlobalStyleRule = GlobalCSSRule | ComplexCSSRule;
57-
export type StyleRule = CSSRule;

packages/css/src/rules/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ export function rules<
184184
}
185185
);
186186
}
187-
export const recipe = rules;
188187

189188
function processPropObject<Target extends PropTarget>(
190189
props: PropDefinition<Target>,

packages/css/vite.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export default (viteConfigEnv: ConfigEnv) => {
1010
build: {
1111
lib: {
1212
entry: {
13-
// index: join(packageDir, "src", "index.ts"),
13+
index: join(packageDir, "src", "index.ts"),
14+
compat: join(packageDir, "src", "compat.ts"),
1415
"rules/createRuntimeFn": join(
1516
packageDir,
1617
"src",

0 commit comments

Comments
 (0)