Skip to content

Commit

Permalink
feat: initialized shadcn (gitcoinco#3)
Browse files Browse the repository at this point in the history
* fix: shadcn requires src folder

* feat: initialized shadcn
  • Loading branch information
hussedev authored Oct 18, 2024
1 parent 9125bb4 commit 4989d63
Show file tree
Hide file tree
Showing 32 changed files with 62 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
stories: ["../lib/**/*.mdx", "../lib/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
Expand Down
4 changes: 2 additions & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type { Preview } from "@storybook/react";
import { withThemeByDataAttribute } from "@storybook/addon-themes";

import { initialize, mswLoader } from "msw-storybook-addon";
import { handlers } from "../lib/mocks/handlers";
import { handlers } from "../src/mocks/handlers";

initialize();

import "../lib/index.css";
import "../src/index.css";

const preview: Preview = {
parameters: {
Expand Down
20 changes: 20 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/index.css",
"baseColor": "neutral",
"cssVariables": false,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"storybook": "^8.3.5",
"tailwind-merge": "^2.5.4",
"tailwindcss": "^3.4.14",
"tailwindcss-animate": "^1.0.7",
"typescript": "^5.5.3",
"typescript-eslint": "^8.10.0",
"vite": "^5.4.8",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions lib/index.css → src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
body {
@apply dark:ui-bg-black dark:ui-text-white;
}

@layer base {
:root {
--radius: 0.5rem;
}
}
File renamed without changes.
6 changes: 6 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 9 additions & 4 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import type { Config } from "tailwindcss";
import { colors } from "./lib/tokens/colors";
import { colors } from "./src/tokens/colors";

export default {
prefix: "ui-",
content: ["./lib/**/*.{js,ts,jsx,tsx,mdx}"],
content: ["./src/**/*.{js,ts,jsx,tsx,mdx}"],
darkMode: ["class", "[data-mode='dark']"],
theme: {
extend: {
fontFamily: {
mono: ["DM Mono", "monospace"],
},
colors,
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
colors: {},
},
},
plugins: [],
plugins: [require("tailwindcss-animate")],
} satisfies Config;
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
"baseUrl": ".",
"paths": {
"@/*": ["./lib/*"]
"@/*": ["./src/*"]
},
"outDir": "./dist"
},
"include": ["lib"],
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import path, { resolve } from "path";
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, "./lib/index.ts"),
entry: resolve(__dirname, "./src/index.ts"),
name: "gitcoin-ui",
fileName: (format, filename) => {
const extension = format === "es" ? "mjs" : format;
Expand All @@ -35,7 +35,7 @@ export default defineConfig({
plugins: [react(), dts({ rollupTypes: true }), cssInjectedByJsPlugin()],
resolve: {
alias: {
"@": path.resolve(__dirname, "lib"),
"@": path.resolve(__dirname, "./src"),
},
},
css: {
Expand Down

0 comments on commit 4989d63

Please sign in to comment.