Skip to content

Commit 547dffb

Browse files
authored
Merge pull request #13347 from TylerAPfledderer/feat/shadcn-extend-initialization
feat: extend ShadCN initialization
2 parents 6fa37bc + 4fcc57c commit 547dffb

24 files changed

+962
-488
lines changed

.prettierrc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"semi": false,
44
"singleQuote": false,
55
"tabWidth": 2,
6-
"trailingComma": "es5"
7-
}
6+
"trailingComma": "es5",
7+
"plugins": [
8+
"prettier-plugin-tailwindcss"
9+
]
10+
}

.storybook/ChakraDecorator.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useEffect, useMemo, useState } from "react"
12
import {
23
ChakraBaseProvider,
34
extendBaseTheme,
@@ -6,7 +7,7 @@ import {
67
import type { Decorator } from "@storybook/react"
78

89
import theme from "../src/@chakra-ui/theme"
9-
import { useEffect, useMemo, useState } from "react"
10+
1011
import i18n from "./i18next"
1112

1213
type DecoratorProps = Parameters<Decorator>

.storybook/main.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ import type { StorybookConfig } from "@storybook/nextjs"
1515
*/
1616

1717
const config: StorybookConfig = {
18-
stories: ["../src/components/**/*.stories.{ts,tsx}"],
18+
stories: ["../src/components/**/*.stories.tsx"],
1919
addons: [
2020
"@storybook/addon-links",
21-
"@storybook/addon-essentials",
21+
{
22+
name: "@storybook/addon-essentials",
23+
options: {
24+
backgrounds: false
25+
}
26+
},
2227
"@storybook/addon-interactions",
2328
"storybook-react-i18next",
29+
"@storybook/addon-themes",
2430
"@chromatic-com/storybook"
2531
],
2632
staticDirs: ["../public"],

.storybook/modes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { baseLocales } from "./i18next"
2-
import { chakraBreakpointArray } from "./preview"
2+
import { breakpointSet } from "./preview"
33

4-
export const viewportModes = chakraBreakpointArray.reduce<{
4+
export const viewportModes = breakpointSet.reduce<{
55
[mode: string]: { viewport: string }
66
}>((arr, [token]) => {
77
return {

.storybook/preview-head.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
<style type="text/css">
2-
3-
:root {
4-
--font-inter: 'Inter', sans-serif;
5-
}
6-
7-
</style>
81

92
<link rel="preload" href="/fonts/inter/latin.woff2" as="font" type="font/woff2" crossorigin="anonymous" />

.storybook/preview.ts

Lines changed: 0 additions & 95 deletions
This file was deleted.

.storybook/preview.tsx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import isChromatic from "chromatic/isChromatic"
2+
import { MotionGlobalConfig } from "framer-motion"
3+
import { withThemeByDataAttribute } from "@storybook/addon-themes"
4+
import type { Preview } from "@storybook/react"
5+
6+
import ThemeProvider from "@/components/ThemeProvider"
7+
8+
import i18n, { baseLocales } from "./i18next"
9+
10+
import "../src/styles/global.css"
11+
import "../src/styles/fonts.css"
12+
13+
MotionGlobalConfig.skipAnimations = isChromatic()
14+
15+
export const breakpointSet: [token: string, value: string][] = [
16+
["base", "375px"],
17+
["sm", "640px"],
18+
["md", "768px"],
19+
["lg", "1024px"],
20+
["xl", "1280px"],
21+
["2xl", "1536px"],
22+
]
23+
24+
const preview: Preview = {
25+
globals: {
26+
locale: "en",
27+
locales: baseLocales,
28+
},
29+
decorators: [
30+
withThemeByDataAttribute({
31+
themes: {
32+
light: "light",
33+
dark: "dark",
34+
},
35+
defaultTheme: "light",
36+
}),
37+
(Story) => (
38+
<ThemeProvider>
39+
<Story />
40+
</ThemeProvider>
41+
),
42+
],
43+
parameters: {
44+
i18n,
45+
actions: { argTypesRegex: "^on[A-Z].*" },
46+
controls: {
47+
matchers: {
48+
color: /(background|color)$/i,
49+
date: /Date$/i,
50+
},
51+
},
52+
chromatic: {
53+
prefersReducedMotion: "reduce",
54+
},
55+
options: {
56+
storySort: {
57+
order: ["Atoms", "Molecules", "Organisms", "Templates", "Pages"],
58+
},
59+
},
60+
layout: "centered",
61+
// Modify viewport selection to match Chakra breakpoints (or custom breakpoints)
62+
viewport: {
63+
viewports: breakpointSet.reduce<{
64+
[token: string]: {
65+
name: string
66+
styles: Record<"width" | "height", string>
67+
}
68+
}>((arr, [token, value]) => {
69+
return {
70+
...arr,
71+
[token]: {
72+
name: token,
73+
styles: {
74+
width: value,
75+
height: "800px",
76+
},
77+
},
78+
}
79+
}, {}),
80+
},
81+
},
82+
}
83+
84+
export default preview

.storybook/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { ArgTypes } from "@storybook/react"
21
import type { ThemingProps } from "@chakra-ui/react"
2+
import type { ArgTypes } from "@storybook/react"
33

44
// Type declarations below pulled directly from `@chakra-ui/storybook-addon`
55
// with some alteration
@@ -49,7 +49,7 @@ export type ThemingArgTypeKey = "variant" | "size"
4949
* @param componentName component name to create the ArgTypes for
5050
*/
5151
export function getThemingArgTypes<
52-
Theme extends Record<string, any>,
52+
Theme extends Record<string, unknown>,
5353
ComponentName extends KeyOf<Theme["components"]>
5454
>(theme: Theme, componentName: ComponentName) {
5555
const component = theme.components[componentName]

components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"tsx": true,
66
"tailwind": {
77
"config": "tailwind.config.ts",
8-
"css": "src/styles/main.css",
8+
"css": "src/styles/global.css",
99
"baseColor": "neutral",
1010
"cssVariables": true,
1111
"prefix": ""

package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"preversion": "bash ./src/scripts/updatePublishDate.sh",
1515
"crowdin-contributors": "ts-node -O '{ \"module\": \"commonjs\" }' src/scripts/crowdin/getCrowdinContributors.ts",
1616
"storybook": "storybook dev -p 6006",
17+
"storybook:tw": "storybook dev -p 6007 -c ./tailwind/.storybook",
1718
"build-storybook": "storybook build",
1819
"build-storybook:chromatic": "storybook build --test",
1920
"chromatic": "chromatic --project-token fee8e66c9916",
@@ -32,7 +33,10 @@
3233
"@docsearch/react": "^3.5.2",
3334
"@emotion/react": "^11.11.1",
3435
"@emotion/styled": "^11.11.0",
35-
"@radix-ui/react-navigation-menu": "^1.1.4",
36+
"@hookform/resolvers": "^3.8.0",
37+
"@radix-ui/react-accordion": "^1.2.0",
38+
"@radix-ui/react-navigation-menu": "^1.2.0",
39+
"@radix-ui/react-slot": "^1.1.0",
3640
"@socialgouv/matomo-next": "^1.8.0",
3741
"chart.js": "^4.4.2",
3842
"chartjs-plugin-datalabels": "^2.2.0",
@@ -47,6 +51,7 @@
4751
"lodash.merge": "^4.6.2",
4852
"lodash.shuffle": "^4.2.0",
4953
"lodash.union": "^4.6.0",
54+
"lucide-react": "^0.400.0",
5055
"next": "^14.2.3",
5156
"next-i18next": "^14.0.3",
5257
"next-mdx-remote": "^3.0.8",
@@ -58,6 +63,7 @@
5863
"react-chartjs-2": "^5.2.0",
5964
"react-dom": "^18.2.0",
6065
"react-emoji-render": "^2.0.1",
66+
"react-hook-form": "^7.52.1",
6167
"react-i18next": "^13.3.1",
6268
"react-icons": "^4.10.1",
6369
"react-lite-youtube-embed": "^2.4.0",
@@ -75,6 +81,7 @@
7581
"@storybook/addon-essentials": "8.1.10",
7682
"@storybook/addon-interactions": "8.1.10",
7783
"@storybook/addon-links": "8.1.10",
84+
"@storybook/addon-themes": "^8.1.11",
7885
"@storybook/nextjs": "^8.1.10",
7986
"@storybook/react": "8.1.10",
8087
"@storybook/test": "8.1.10",
@@ -91,7 +98,7 @@
9198
"decompress": "^4.2.1",
9299
"eslint": "^8.45.0",
93100
"eslint-config-next": "^14.2.2",
94-
"eslint-config-prettier": "^9.0.0",
101+
"eslint-config-prettier": "9.1.0",
95102
"eslint-plugin-simple-import-sort": "^10.0.0",
96103
"eslint-plugin-storybook": "0.8.0",
97104
"eslint-plugin-unused-imports": "^3.0.0",
@@ -103,6 +110,8 @@
103110
"plaiceholder": "^3.0.0",
104111
"polished": "^4.2.2",
105112
"postcss": "^8.4.39",
113+
"prettier": "3.3.2",
114+
"prettier-plugin-tailwindcss": "^0.6.5",
106115
"raw-loader": "^4.0.2",
107116
"storybook": "8.1.10",
108117
"storybook-react-i18next": "3.1.1",

0 commit comments

Comments
 (0)