Skip to content

Commit 407ef79

Browse files
authored
Merge pull request #13343 from ethereum/shadcn-initial-setup
Shadcn/Tailwind - initial setup
2 parents 787c54c + f3d4294 commit 407ef79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1376
-516
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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ const config: StorybookConfig = {
2222
],
2323
addons: [
2424
"@storybook/addon-links",
25-
"@storybook/addon-essentials",
25+
{
26+
name: "@storybook/addon-essentials",
27+
options: {
28+
backgrounds: false
29+
}
30+
},
2631
"@storybook/addon-interactions",
2732
"storybook-react-i18next",
33+
"@storybook/addon-themes",
2834
"@chromatic-com/storybook"
2935
],
3036
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: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
<style type="text/css">
2-
3-
:root {
4-
--font-inter: 'Inter', sans-serif;
5-
--font-mono: "IBM Plex Mono", Courier, monospace;
6-
}
7-
8-
</style>
91

102
<link rel="preload" href="/fonts/inter/latin.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
11-
<link rel="preload" href="/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf" as="font" type="font/ttf" crossorigin="anonymous" />
3+
<link rel="preload" href="/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf" as="font" type="font/ttf" 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import type { StyleConfig, ThemingProps } from "@chakra-ui/react"
12
import type { ArgTypes } from "@storybook/react"
2-
import type { ThemingProps } from "@chakra-ui/react"
33

44
// Type declarations below pulled directly from `@chakra-ui/storybook-addon`
55
// with some alteration
@@ -49,10 +49,10 @@ 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> & { components?: Record<string, StyleConfig> },
5353
ComponentName extends KeyOf<Theme["components"]>
5454
>(theme: Theme, componentName: ComponentName) {
55-
const component = theme.components[componentName]
55+
const component = theme.components?.[componentName]
5656
if (!component) {
5757
return undefined
5858
}

components.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.ts",
8+
"css": "src/styles/global.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils"
16+
}
17+
}

package.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@
3232
"@docsearch/react": "^3.5.2",
3333
"@emotion/react": "^11.11.1",
3434
"@emotion/styled": "^11.11.0",
35-
"@radix-ui/react-navigation-menu": "^1.1.4",
35+
"@hookform/resolvers": "^3.8.0",
36+
"@radix-ui/react-accordion": "^1.2.0",
37+
"@radix-ui/react-navigation-menu": "^1.2.0",
38+
"@radix-ui/react-slot": "^1.1.0",
3639
"@socialgouv/matomo-next": "^1.8.0",
3740
"chart.js": "^4.4.2",
3841
"chartjs-plugin-datalabels": "^2.2.0",
42+
"class-variance-authority": "^0.7.0",
43+
"clsx": "^2.1.1",
3944
"embla-carousel-react": "^7.0.0",
4045
"ethereum-blockies-base64": "^1.0.2",
4146
"framer-motion": "^10.13.0",
@@ -45,22 +50,27 @@
4550
"lodash.merge": "^4.6.2",
4651
"lodash.shuffle": "^4.2.0",
4752
"lodash.union": "^4.6.0",
53+
"lucide-react": "^0.400.0",
4854
"next": "^14.2.3",
4955
"next-i18next": "^14.0.3",
5056
"next-mdx-remote": "^3.0.8",
5157
"next-sitemap": "^4.2.3",
58+
"next-themes": "^0.3.0",
5259
"prism-react-renderer": "1.1.0",
5360
"prismjs": "^1.27.0",
5461
"react": "^18.2.0",
5562
"react-chartjs-2": "^5.2.0",
5663
"react-dom": "^18.2.0",
5764
"react-emoji-render": "^2.0.1",
65+
"react-hook-form": "^7.52.1",
5866
"react-i18next": "^13.3.1",
5967
"react-icons": "^4.10.1",
6068
"react-lite-youtube-embed": "^2.4.0",
6169
"react-select": "5.8.0",
6270
"reading-time": "^1.5.0",
6371
"remark-gfm": "^3.0.1",
72+
"tailwind-merge": "^2.3.0",
73+
"tailwindcss-animate": "^1.0.7",
6474
"yaml-loader": "^0.8.0"
6575
},
6676
"devDependencies": {
@@ -70,6 +80,7 @@
7080
"@storybook/addon-essentials": "8.1.10",
7181
"@storybook/addon-interactions": "8.1.10",
7282
"@storybook/addon-links": "8.1.10",
83+
"@storybook/addon-themes": "8.1.10",
7384
"@storybook/nextjs": "^8.1.10",
7485
"@storybook/react": "8.1.10",
7586
"@storybook/test": "8.1.10",
@@ -81,11 +92,12 @@
8192
"@types/react-dom": "18.2.19",
8293
"@typescript-eslint/eslint-plugin": "^6.19.0",
8394
"@typescript-eslint/parser": "^6.19.0",
95+
"autoprefixer": "^10.4.19",
8496
"chromatic": "10.9.6",
8597
"decompress": "^4.2.1",
8698
"eslint": "^8.45.0",
8799
"eslint-config-next": "^14.2.2",
88-
"eslint-config-prettier": "^9.0.0",
100+
"eslint-config-prettier": "9.1.0",
89101
"eslint-plugin-simple-import-sort": "^10.0.0",
90102
"eslint-plugin-storybook": "0.8.0",
91103
"eslint-plugin-unused-imports": "^3.0.0",
@@ -96,9 +108,13 @@
96108
"minimist": "^1.2.8",
97109
"plaiceholder": "^3.0.0",
98110
"polished": "^4.2.2",
111+
"postcss": "^8.4.39",
112+
"prettier": "3.3.2",
113+
"prettier-plugin-tailwindcss": "^0.6.5",
99114
"raw-loader": "^4.0.2",
100115
"storybook": "8.1.10",
101116
"storybook-react-i18next": "3.1.1",
117+
"tailwindcss": "^3.4.4",
102118
"ts-node": "^10.9.1",
103119
"tsconfig-paths-webpack-plugin": "4.1.0",
104120
"typescript": "^5.5.2",

0 commit comments

Comments
 (0)