Skip to content

Commit 825cb2f

Browse files
committed
chore(*): merged latest
2 parents a8cdd9d + ce1cf0a commit 825cb2f

File tree

7 files changed

+489
-2714
lines changed

7 files changed

+489
-2714
lines changed

packages/styles/package.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,42 @@
22
"name": "@firebase-ui/styles",
33
"version": "0.0.1",
44
"type": "module",
5+
"main": "./dist/index.cjs",
6+
"module": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/index.js",
12+
"require": "./dist/index.cjs"
13+
}
14+
},
515
"files": [
616
"dist.css",
717
"src"
818
],
919
"scripts": {
1020
"prepare": "pnpm run build",
11-
"build": "npx -y @tailwindcss/cli -i ./src.css -o ./dist.css --minify",
21+
"build": "tsup && pnpm run build:css",
22+
"build:css": "npx -y @tailwindcss/cli -i ./src.css -o ./dist.css --minify",
1223
"build:local": "pnpm run build && pnpm pack",
13-
"test": "echo \"No tests specified\" && exit 0",
14-
"test:watch": "echo \"No tests specified\" && exit 0",
24+
"lint": "tsc --noEmit",
25+
"format": "prettier --write \"src/**/*.ts\"",
26+
"clean": "rimraf dist",
27+
"test": "vitest run",
28+
"test:watch": "vitest",
1529
"publish:tags": "sh -c 'TAG=\"${npm_package_name}@${npm_package_version}\"; git tag --list \"$TAG\" | grep . || git tag \"$TAG\"; git push origin \"$TAG\"'",
1630
"release": "pnpm run build && pnpm pack --pack-destination ../../releases/"
1731
},
1832
"devDependencies": {
19-
"tailwindcss": "catalog:"
33+
"prettier": "catalog:",
34+
"rimraf": "catalog:",
35+
"tailwindcss": "catalog:",
36+
"tsup": "catalog:",
37+
"typescript": "catalog:",
38+
"vitest": "catalog:"
39+
},
40+
"dependencies": {
41+
"cva": "1.0.0-beta.4"
2042
}
2143
}

packages/styles/src/index.test.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE/2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { describe, it, expect } from "vitest";
18+
import { buttonVariant, type ButtonVariant } from "./index";
19+
20+
describe("buttonVariant", () => {
21+
it("should return base class when no variant is provided", () => {
22+
const result = buttonVariant();
23+
expect(result).toBe("fui-button");
24+
});
25+
26+
it("should return base class with primary variant (default)", () => {
27+
const result = buttonVariant({ variant: "primary" });
28+
expect(result).toBe("fui-button");
29+
});
30+
31+
it("should return base class with secondary variant", () => {
32+
const result = buttonVariant({ variant: "secondary" });
33+
expect(result).toBe("fui-button fui-button--secondary");
34+
});
35+
36+
it("should handle empty variant object", () => {
37+
const result = buttonVariant({});
38+
expect(result).toBe("fui-button");
39+
});
40+
41+
it("should handle undefined variant", () => {
42+
const result = buttonVariant({ variant: undefined });
43+
expect(result).toBe("fui-button");
44+
});
45+
});
46+
47+
describe("ButtonVariant type", () => {
48+
it("should accept valid variant values", () => {
49+
const primaryVariant: ButtonVariant = "primary";
50+
const secondaryVariant: ButtonVariant = "secondary";
51+
52+
expect(primaryVariant).toBe("primary");
53+
expect(secondaryVariant).toBe("secondary");
54+
});
55+
56+
it("should work with buttonVariant function", () => {
57+
const variants: ButtonVariant[] = ["primary", "secondary"];
58+
59+
variants.forEach((variant) => {
60+
const result = buttonVariant({ variant });
61+
expect(typeof result).toBe("string");
62+
expect(result).toContain("fui-button");
63+
});
64+
});
65+
});

packages/styles/src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { cva, type VariantProps } from "cva";
2+
3+
export const buttonVariant = cva({
4+
base: "fui-button",
5+
variants: {
6+
variant: {
7+
primary: "",
8+
secondary: "fui-button--secondary",
9+
},
10+
},
11+
defaultVariants: {
12+
variant: "primary",
13+
},
14+
});
15+
16+
export type ButtonVariant = VariantProps<typeof buttonVariant>['variant'];

packages/styles/tsconfig.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"module": "ESNext",
5+
"lib": ["ES2020", "DOM"],
6+
"declaration": true,
7+
"declarationMap": true,
8+
"sourceMap": true,
9+
"outDir": "./dist",
10+
"rootDir": "./src",
11+
"strict": true,
12+
"noImplicitAny": true,
13+
"strictNullChecks": true,
14+
"strictFunctionTypes": true,
15+
"strictBindCallApply": true,
16+
"strictPropertyInitialization": true,
17+
"noImplicitThis": true,
18+
"useUnknownInCatchVariables": true,
19+
"alwaysStrict": true,
20+
"noUnusedLocals": true,
21+
"noUnusedParameters": true,
22+
"exactOptionalPropertyTypes": true,
23+
"noImplicitReturns": true,
24+
"noFallthroughCasesInSwitch": true,
25+
"noUncheckedIndexedAccess": true,
26+
"noImplicitOverride": true,
27+
"noPropertyAccessFromIndexSignature": true,
28+
"esModuleInterop": true,
29+
"forceConsistentCasingInFileNames": true,
30+
"skipLibCheck": true,
31+
"moduleResolution": "node"
32+
},
33+
"include": ["src"],
34+
"exclude": ["node_modules", "dist"]
35+
}

packages/styles/tsup.config.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { defineConfig, type Options } from "tsup";
18+
19+
const config: Options = {
20+
entry: ["src/index.ts"],
21+
format: ["cjs", "esm"],
22+
dts: true,
23+
splitting: false,
24+
sourcemap: true,
25+
clean: true,
26+
treeshake: true,
27+
minify: true,
28+
};
29+
30+
export default defineConfig(config);

packages/styles/vitest.config.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE/2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { defineConfig } from "vitest/config";
18+
19+
export default defineConfig({
20+
test: {
21+
// Use the same environment as the package
22+
environment: "jsdom",
23+
// Include TypeScript files
24+
include: ["src/**/*.{test,spec}.{js,ts}"],
25+
// Exclude build output and node_modules
26+
exclude: ["node_modules/**/*", "dist/**/*"],
27+
},
28+
});

0 commit comments

Comments
 (0)