Skip to content

Commit 93ceddb

Browse files
committed
chore: fix tests
- add `ThemeConfig` in apps/[storybook, web] - enforce schema `version` to [3,4]
1 parent 212fd22 commit 93ceddb

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

apps/storybook/.storybook/preview.ts renamed to apps/storybook/.storybook/preview.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { withThemeByClassName } from "@storybook/addon-themes";
2-
import type { Preview } from "@storybook/react";
2+
import type { Decorator, Preview } from "@storybook/react";
3+
import { ThemeConfig } from "flowbite-react";
4+
import React from "react";
5+
import config from "../.flowbite-react/config.json";
36

47
import "./style.css";
58

@@ -17,7 +20,13 @@ const preview: Preview = {
1720
},
1821
};
1922

20-
export const decorators = [
23+
export const decorators: Decorator[] = [
24+
(Story) => (
25+
<>
26+
<ThemeConfig version={config.version as 3 | 4} />
27+
<Story />
28+
</>
29+
),
2130
withThemeByClassName({
2231
themes: {
2332
light: "light",

apps/web/app/layout.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { ThemeModeScript } from "flowbite-react";
1+
import { ThemeConfig, ThemeModeScript } from "flowbite-react";
22
import { Inter as InterFont } from "next/font/google";
33
import type { Metadata, Viewport } from "next/types";
44
import type { PropsWithChildren } from "react";
5+
import config from "~/.flowbite-react/config.json";
56
import { FathomScript } from "~/components/fathom-script";
67

78
import "~/styles/globals.css";
@@ -60,6 +61,7 @@ export default function RootLayout({ children }: PropsWithChildren) {
6061
<ThemeModeScript />
6162
</head>
6263
<body className="bg-white text-gray-600 antialiased dark:bg-gray-900 dark:text-gray-400">
64+
<ThemeConfig version={config.version as 3 | 4} />
6365
{children}
6466
<FathomScript />
6567
</body>

apps/web/content/docs/customize/config.mdx

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ The configuration file follows this JSON Schema:
4040
},
4141
"prefix": {
4242
"description": "Optional prefix to apply to all Tailwind CSS classes",
43-
"type": "string"
43+
"type": "string",
44+
"default": ""
4445
},
4546
"rsc": {
4647
"description": "Whether to include the 'use client' directive for React Server Components",
@@ -55,6 +56,7 @@ The configuration file follows this JSON Schema:
5556
"version": {
5657
"description": "The version of Tailwind CSS to use",
5758
"type": "number",
59+
"enum": [3, 4],
5860
"default": 4
5961
}
6062
},
@@ -109,6 +111,7 @@ For detailed instructions on configuring and using prefixes, see the [Prefix](/d
109111
#### `version`
110112

111113
- Type: `number`
114+
- Options: `3`, `4`
112115
- Default: `4`
113116
- Description: The version of Tailwind CSS to use.
114117

packages/ui/schema.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128
},
129129
"prefix": {
130130
"description": "Optional prefix to apply to all Tailwind CSS classes. \nSee https://flowbite-react.com/docs/customize/config#prefix for more details.",
131-
"type": "string"
131+
"type": "string",
132+
"default": ""
132133
},
133134
"rsc": {
134135
"description": "Whether to include the 'use client' directive for React Server Components. \nSee https://flowbite-react.com/docs/customize/config#rsc for more details.",
@@ -143,6 +144,7 @@
143144
"version": {
144145
"description": "The version of Tailwind CSS to use. \nSee https://flowbite-react.com/docs/customize/config#version for more details.",
145146
"type": "number",
147+
"enum": [3, 4],
146148
"default": 4
147149
}
148150
},

packages/ui/scripts/generate-metadata.ts

+2
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ async function generateSchema(components: string[]): Promise<void> {
235235
description:
236236
"Optional prefix to apply to all Tailwind CSS classes. \nSee https://flowbite-react.com/docs/customize/config#prefix for more details.",
237237
type: "string",
238+
default: "",
238239
},
239240
rsc: {
240241
description:
@@ -252,6 +253,7 @@ async function generateSchema(components: string[]): Promise<void> {
252253
description:
253254
"The version of Tailwind CSS to use. \nSee https://flowbite-react.com/docs/customize/config#version for more details.",
254255
type: "number",
256+
enum: [3, 4],
255257
default: 4,
256258
},
257259
},

packages/ui/src/helpers/resolve-theme.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("resolveTheme", () => {
1818
});
1919

2020
it("should apply prefix with version 3 format", () => {
21-
setStore({ prefix: "tw-" });
21+
setStore({ prefix: "tw-", version: 3 });
2222

2323
const base = { color: "text-red-400" };
2424

0 commit comments

Comments
 (0)