Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/petite-bats-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@mincho-js/css": minor
---

**theme**
- Add `theme()` base usage and reference variables
2 changes: 1 addition & 1 deletion configs/tsconfig-custom/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
"noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
"noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
Expand Down
44 changes: 23 additions & 21 deletions packages/css/src/css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
import { setFileScope } from "@vanilla-extract/css/fileScope";
import { style as vStyle, globalStyle as gStyle } from "@vanilla-extract/css";
import type { GlobalStyleRule } from "@vanilla-extract/css";
import { className, getDebugName } from "../utils.js";
import { identifierName, getDebugName } from "../utils.js";
import type { CSSRuleWith } from "./types.js";

// == Global CSS ===============================================================
Expand Down Expand Up @@ -600,15 +600,15 @@ if (import.meta.vitest) {
const result = css({ color: "red" }, debugId);

assert.isString(result);
expect(result).toMatch(className(debugId));
expect(result).toMatch(identifierName(debugId));
});

it("composition", () => {
const base = css({ padding: 12 }, "base");
const result = css([base, { color: "red" }], debugId);

assert.isString(result);
expect(result).toMatch(className(debugId, "base"));
expect(result).toMatch(identifierName(debugId, "base"));
});
});

Expand Down Expand Up @@ -640,8 +640,8 @@ if (import.meta.vitest) {
);

assert.hasAllKeys(result, ["primary", "secondary"]);
expect(result.primary).toMatch(className(`${debugId}_primary`));
expect(result.secondary).toMatch(className(`${debugId}_secondary`));
expect(result.primary).toMatch(identifierName(`${debugId}_primary`));
expect(result.secondary).toMatch(identifierName(`${debugId}_secondary`));
});

it("Mapping Variants", () => {
Expand All @@ -657,8 +657,8 @@ if (import.meta.vitest) {
);

assert.hasAllKeys(result, ["primary", "secondary"]);
expect(result.primary).toMatch(className(`${debugId}_primary`));
expect(result.secondary).toMatch(className(`${debugId}_secondary`));
expect(result.primary).toMatch(identifierName(`${debugId}_primary`));
expect(result.secondary).toMatch(identifierName(`${debugId}_secondary`));
});

it("Mapping Variants with composition", () => {
Expand All @@ -678,9 +678,11 @@ if (import.meta.vitest) {
);

assert.hasAllKeys(result, ["primary", "secondary"]);
expect(result.primary).toMatch(className(`${debugId}_primary`, "base"));
expect(result.primary).toMatch(
identifierName(`${debugId}_primary`, "base")
);
expect(result.secondary).toMatch(
className(`${debugId}_secondary`, "base")
identifierName(`${debugId}_secondary`, "base")
);
});

Expand All @@ -701,7 +703,7 @@ if (import.meta.vitest) {
);

assert.hasAllKeys(result, ["primary"]);
expect(result.primary).toMatch(className(`${debugId}_primary`));
expect(result.primary).toMatch(identifierName(`${debugId}_primary`));
});

it("Complex composition with multiple base styles", () => {
Expand All @@ -717,10 +719,10 @@ if (import.meta.vitest) {

assert.hasAllKeys(result, ["primary", "secondary"]);
expect(result.primary).toMatch(
className(`${debugId}_primary`, "base1", "base2")
identifierName(`${debugId}_primary`, "base1", "base2")
);
expect(result.secondary).toMatch(
className(`${debugId}_secondary`, "base1")
identifierName(`${debugId}_secondary`, "base1")
);
});

Expand Down Expand Up @@ -760,9 +762,9 @@ if (import.meta.vitest) {
);

assert.hasAllKeys(result, ["primary", "secondary", "accent"]);
expect(result.primary).toMatch(className(`${debugId}_primary`));
expect(result.secondary).toMatch(className(`${debugId}_secondary`));
expect(result.accent).toMatch(className(`${debugId}_accent`));
expect(result.primary).toMatch(identifierName(`${debugId}_primary`));
expect(result.secondary).toMatch(identifierName(`${debugId}_secondary`));
expect(result.accent).toMatch(identifierName(`${debugId}_accent`));
});

it("Mapping with complex transformation", async () => {
Expand Down Expand Up @@ -828,9 +830,9 @@ if (import.meta.vitest) {

// Test existing class name generation
assert.hasAllKeys(result, ["primary", "secondary", "accent"]);
expect(result.primary).toMatch(className(`${debugId}_primary`));
expect(result.secondary).toMatch(className(`${debugId}_secondary`));
expect(result.accent).toMatch(className(`${debugId}_accent`));
expect(result.primary).toMatch(identifierName(`${debugId}_primary`));
expect(result.secondary).toMatch(identifierName(`${debugId}_secondary`));
expect(result.accent).toMatch(identifierName(`${debugId}_accent`));

// Verify that each result is a valid CSS class name string
expect(typeof result.primary).toBe("string");
Expand Down Expand Up @@ -894,7 +896,7 @@ if (import.meta.vitest) {
const result = withRedBackground({ color: "blue" }, debugId);

assert.isString(result);
expect(result).toMatch(className(debugId));
expect(result).toMatch(identifierName(debugId));
});

it("css.with().raw()", () => {
Expand Down Expand Up @@ -926,8 +928,8 @@ if (import.meta.vitest) {
);

assert.hasAllKeys(result, ["primary", "secondary"]);
expect(result.primary).toMatch(className(`${debugId}_primary`));
expect(result.secondary).toMatch(className(`${debugId}_secondary`));
expect(result.primary).toMatch(identifierName(`${debugId}_primary`));
expect(result.secondary).toMatch(identifierName(`${debugId}_secondary`));
});

it("css.with() with like mixin", () => {
Expand Down
Loading