From fa924650f24b218a39202dd71ea5291be2d62bee Mon Sep 17 00:00:00 2001 From: Mumtahin Farabi Date: Wed, 13 Nov 2024 23:53:42 -0500 Subject: [PATCH] refactor: reorganize libs with feature sliced design and bulletproof react --- .gitignore | 2 +- .../custom-viewports.ts | 0 .../ui/.storybook => .storybook}/main.ts | 23 +++++- .../ui/.storybook => .storybook}/preview.tsx | 3 +- .../themes-storybook-ui.ts | 0 .../ui => .storybook}/tsconfig.storybook.json | 7 +- apps/website/app/root.tsx | 2 +- apps/website/app/routes/_index.tsx | 4 +- apps/website/tailwind.config.ts | 2 +- components.json | 9 ++- libs/{shared/ui => external/shadcn}/README.md | 0 .../shadcn/components/ui}/accordion.tsx | 4 +- .../shadcn/components/ui}/button.stories.tsx | 0 .../shadcn/components/ui}/button.tsx | 4 +- .../shadcn/components/ui}/calendar.tsx | 4 +- .../shadcn/components/ui}/colors.mdx | 0 .../shadcn/components/ui}/docs.mdx | 0 .../shadcn/components/ui}/introduction.tsx | 4 +- .../components/ui}/typography/typography.tsx | 2 +- .../ui => external/shadcn}/eslint.config.js | 0 .../.storybook => external/shadcn}/global.css | 0 libs/external/shadcn/hooks/hook.tsx | 0 libs/external/shadcn/index.ts | 1 + .../src => external/shadcn/lib/utils}/cn.ts | 0 .../shadcn/lib/utils}/index.ts | 0 .../ui => external/shadcn}/postcss.config.js | 0 .../ui => external/shadcn}/project.json | 8 +- .../shadcn}/public/cuhacking-logo.svg | 0 libs/external/shadcn/tailwind.config.ts | 74 +++++++++++++++++++ .../utils => external/shadcn}/tsconfig.json | 0 .../ui => external/shadcn}/tsconfig.lib.json | 0 libs/shared/assets/cuhacking-logo.svg | 6 ++ libs/shared/components/component.tsx | 0 libs/shared/config/eslint/antfu.js | 10 +++ libs/shared/config/eslint/base.js | 42 ----------- libs/shared/config/eslint/default.js | 31 ++++++++ libs/shared/config/eslint/playwright.js | 13 ---- .../config/tailwind/{base.js => base.ts} | 0 .../tailwind/shadcn.ts} | 0 libs/shared/config/typescript/base.json | 2 +- .../features/awesome-feature/api/endpoint.ts | 0 .../awesome-feature/assets/cuhacking-logo.svg | 6 ++ .../awesome-feature/components/component.tsx | 0 .../features/awesome-feature/hooks/hook.tsx | 0 libs/shared/features/awesome-feature/index.ts | 1 + .../features/awesome-feature/routes/route.tsx | 0 .../features/awesome-feature/stores/store.tsx | 0 .../features/awesome-feature/types/type.ts | 0 .../features/awesome-feature/utils/utils.ts | 0 libs/shared/{utils => }/project.json | 5 +- libs/shared/providers/provider.tsx | 0 libs/shared/routes/route.tsx | 0 libs/shared/test/test.spec.ts | 0 libs/shared/{ui => }/tsconfig.json | 3 - libs/shared/{utils => }/tsconfig.lib.json | 4 +- libs/shared/types/type.ts | 0 libs/shared/ui/.babelrc | 12 --- libs/shared/ui/component.tsx | 0 libs/shared/{utils/src => ui}/global.css | 0 libs/shared/ui/package.json | 12 --- libs/shared/ui/tailwind.config.ts | 17 ----- libs/shared/utils/.babelrc | 12 --- libs/shared/utils/README.md | 7 -- libs/shared/utils/cn.ts | 6 ++ libs/shared/utils/eslint.config.js | 37 ---------- package.json | 1 + pnpm-lock.yaml | 3 + postcss.config.js | 6 ++ tailwind.config.ts | 66 +++++++++++++++++ tsconfig.base.json | 10 +-- 70 files changed, 265 insertions(+), 200 deletions(-) rename {libs/shared/ui/.storybook => .storybook}/custom-viewports.ts (100%) rename {libs/shared/ui/.storybook => .storybook}/main.ts (83%) rename {libs/shared/ui/.storybook => .storybook}/preview.tsx (98%) rename {libs/shared/ui/.storybook => .storybook}/themes-storybook-ui.ts (100%) rename {libs/shared/ui => .storybook}/tsconfig.storybook.json (58%) rename libs/{shared/ui => external/shadcn}/README.md (100%) rename libs/{shared/ui/src/shadcn => external/shadcn/components/ui}/accordion.tsx (98%) rename libs/{shared/ui/src/shadcn => external/shadcn/components/ui}/button.stories.tsx (100%) rename libs/{shared/ui/src/shadcn => external/shadcn/components/ui}/button.tsx (97%) rename libs/{shared/ui/src/shadcn => external/shadcn/components/ui}/calendar.tsx (96%) rename libs/{shared/ui/src/shadcn => external/shadcn/components/ui}/colors.mdx (100%) rename libs/{shared/ui/src/shadcn => external/shadcn/components/ui}/docs.mdx (100%) rename libs/{shared/ui/src/shadcn => external/shadcn/components/ui}/introduction.tsx (98%) rename libs/{shared/ui/src/shadcn => external/shadcn/components/ui}/typography/typography.tsx (99%) rename libs/{shared/ui => external/shadcn}/eslint.config.js (100%) rename libs/{shared/ui/.storybook => external/shadcn}/global.css (100%) create mode 100644 libs/external/shadcn/hooks/hook.tsx create mode 100644 libs/external/shadcn/index.ts rename libs/{shared/utils/src => external/shadcn/lib/utils}/cn.ts (100%) rename libs/{shared/utils/src => external/shadcn/lib/utils}/index.ts (100%) rename libs/{shared/ui => external/shadcn}/postcss.config.js (100%) rename libs/{shared/ui => external/shadcn}/project.json (50%) rename libs/{shared/ui => external/shadcn}/public/cuhacking-logo.svg (100%) create mode 100644 libs/external/shadcn/tailwind.config.ts rename libs/{shared/utils => external/shadcn}/tsconfig.json (100%) rename libs/{shared/ui => external/shadcn}/tsconfig.lib.json (100%) create mode 100644 libs/shared/assets/cuhacking-logo.svg create mode 100644 libs/shared/components/component.tsx create mode 100644 libs/shared/config/eslint/antfu.js delete mode 100644 libs/shared/config/eslint/base.js create mode 100644 libs/shared/config/eslint/default.js rename libs/shared/config/tailwind/{base.js => base.ts} (100%) rename libs/shared/{utils/src/tailwind.config.ts => config/tailwind/shadcn.ts} (100%) create mode 100644 libs/shared/features/awesome-feature/api/endpoint.ts create mode 100644 libs/shared/features/awesome-feature/assets/cuhacking-logo.svg create mode 100644 libs/shared/features/awesome-feature/components/component.tsx create mode 100644 libs/shared/features/awesome-feature/hooks/hook.tsx create mode 100644 libs/shared/features/awesome-feature/index.ts create mode 100644 libs/shared/features/awesome-feature/routes/route.tsx create mode 100644 libs/shared/features/awesome-feature/stores/store.tsx create mode 100644 libs/shared/features/awesome-feature/types/type.ts create mode 100644 libs/shared/features/awesome-feature/utils/utils.ts rename libs/shared/{utils => }/project.json (50%) create mode 100644 libs/shared/providers/provider.tsx create mode 100644 libs/shared/routes/route.tsx create mode 100644 libs/shared/test/test.spec.ts rename libs/shared/{ui => }/tsconfig.json (84%) rename libs/shared/{utils => }/tsconfig.lib.json (87%) create mode 100644 libs/shared/types/type.ts delete mode 100644 libs/shared/ui/.babelrc create mode 100644 libs/shared/ui/component.tsx rename libs/shared/{utils/src => ui}/global.css (100%) delete mode 100644 libs/shared/ui/package.json delete mode 100644 libs/shared/ui/tailwind.config.ts delete mode 100644 libs/shared/utils/.babelrc delete mode 100644 libs/shared/utils/README.md create mode 100644 libs/shared/utils/cn.ts delete mode 100644 libs/shared/utils/eslint.config.js create mode 100644 postcss.config.js create mode 100644 tailwind.config.ts diff --git a/.gitignore b/.gitignore index ef5f1208..a9a29ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -79,5 +79,5 @@ yarn-error.log* .vercel next-env.d.ts -storybook-static +**/*/storybook-static build-storybook.log diff --git a/libs/shared/ui/.storybook/custom-viewports.ts b/.storybook/custom-viewports.ts similarity index 100% rename from libs/shared/ui/.storybook/custom-viewports.ts rename to .storybook/custom-viewports.ts diff --git a/libs/shared/ui/.storybook/main.ts b/.storybook/main.ts similarity index 83% rename from libs/shared/ui/.storybook/main.ts rename to .storybook/main.ts index 591837ab..7daedae2 100644 --- a/libs/shared/ui/.storybook/main.ts +++ b/.storybook/main.ts @@ -1,7 +1,12 @@ import type { StorybookConfig } from '@storybook/nextjs' -const config: StorybookConfig = { - stories: ['../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'], +// import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin' + +export default { + stories: [ + '../libs/external/shadcn/**/*.@(mdx|stories.@(js|jsx|ts|tsx))', + '../libs/shared/ui/**/*.@(mdx|stories.@(js|jsx|ts|tsx))', + ], framework: { name: '@storybook/nextjs', options: {}, @@ -84,5 +89,15 @@ const config: StorybookConfig = { // https://github.com/whitespace-se/storybook-addon-html '@whitespace/storybook-addon-html', ], -} -export default config + // webpackFinal: async (config) => { + // if (config.resolve) { + // config.resolve.plugins = [ + // ...(config.resolve.plugins || []), + // new TsconfigPathsPlugin({ + // configFile: './tsconfig.storybook.json', + // }), + // ] + // } + // return config + // }, +} satisfies StorybookConfig diff --git a/libs/shared/ui/.storybook/preview.tsx b/.storybook/preview.tsx similarity index 98% rename from libs/shared/ui/.storybook/preview.tsx rename to .storybook/preview.tsx index 10897421..c6c0de81 100644 --- a/libs/shared/ui/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -10,8 +10,7 @@ import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode' import { customViewports } from './custom-viewports' import { commonTheme, darkUIStorybook, lightUIStorybook } from './themes-storybook-ui' -/* import '../../utils/src/global.css' */ -import './global.css' +import '../libs/shared/ui/global.css' const preview: Preview = { parameters: { diff --git a/libs/shared/ui/.storybook/themes-storybook-ui.ts b/.storybook/themes-storybook-ui.ts similarity index 100% rename from libs/shared/ui/.storybook/themes-storybook-ui.ts rename to .storybook/themes-storybook-ui.ts diff --git a/libs/shared/ui/tsconfig.storybook.json b/.storybook/tsconfig.storybook.json similarity index 58% rename from libs/shared/ui/tsconfig.storybook.json rename to .storybook/tsconfig.storybook.json index e575d335..e0596410 100644 --- a/libs/shared/ui/tsconfig.storybook.json +++ b/.storybook/tsconfig.storybook.json @@ -1,14 +1,9 @@ { - "extends": "./tsconfig.json", + "extends": "../tsconfig.base.json", "compilerOptions": { "emitDecoratorMetadata": true }, "include": [ - "src/**/*.stories.ts", - "src/**/*.stories.js", - "src/**/*.stories.jsx", - "src/**/*.stories.tsx", - "src/**/*.stories.mdx", ".storybook/*.js", ".storybook/*.ts", "tailwind.config.ts", diff --git a/apps/website/app/root.tsx b/apps/website/app/root.tsx index 50cef72f..af2cbfa0 100644 --- a/apps/website/app/root.tsx +++ b/apps/website/app/root.tsx @@ -8,7 +8,7 @@ import { ScrollRestoration, } from '@remix-run/react' -import '@cuhacking/utils/global.css' +import '@cuhacking/shared/ui/global.css' export const links: LinksFunction = () => [ { rel: 'preconnect', href: 'https://fonts.googleapis.com' }, diff --git a/apps/website/app/routes/_index.tsx b/apps/website/app/routes/_index.tsx index c6f26866..cfb1fa0d 100644 --- a/apps/website/app/routes/_index.tsx +++ b/apps/website/app/routes/_index.tsx @@ -4,8 +4,8 @@ import { AccordionContent, AccordionItem, AccordionTrigger, -} from '@shadcn/ui/accordion' -import { Calendar } from '@shadcn/ui/calendar' +} from '@shadcn/components/ui/accordion' +import { Calendar } from '@shadcn/components/ui/calendar' import { useState } from 'react' diff --git a/apps/website/tailwind.config.ts b/apps/website/tailwind.config.ts index 46485177..2ff7d0c9 100644 --- a/apps/website/tailwind.config.ts +++ b/apps/website/tailwind.config.ts @@ -12,6 +12,6 @@ // plugins: [], // } satisfies Config -import { buildConfig } from '../../libs/shared/utils/src/tailwind.config' +import { buildConfig } from '../../libs/shared/config/tailwind/shadcn' export default buildConfig(__dirname) diff --git a/components.json b/components.json index 976bb15e..a22f4828 100644 --- a/components.json +++ b/components.json @@ -3,13 +3,14 @@ "style": "default", "rsc": false, "tailwind": { - "config": "libs/shared/utils/tailwind.config.js", - "css": "libs/shared/utils/global.css", + "config": "libs/shared/external/shadcn/tailwind.config.ts", + "css": "libs/shared/external/shadcn/global.css", "baseColor": "neutral", "cssVariables": true }, "aliases": { - "components": "@shadcn", - "utils": "@cuhacking/utils" + "utils": "@shadcn/lib/utils", + "components": "@shadcn/components", + "hooks": "@shadcn/hooks" } } diff --git a/libs/shared/ui/README.md b/libs/external/shadcn/README.md similarity index 100% rename from libs/shared/ui/README.md rename to libs/external/shadcn/README.md diff --git a/libs/shared/ui/src/shadcn/accordion.tsx b/libs/external/shadcn/components/ui/accordion.tsx similarity index 98% rename from libs/shared/ui/src/shadcn/accordion.tsx rename to libs/external/shadcn/components/ui/accordion.tsx index 866da154..531dbdb3 100644 --- a/libs/shared/ui/src/shadcn/accordion.tsx +++ b/libs/external/shadcn/components/ui/accordion.tsx @@ -1,9 +1,9 @@ -import { cn } from '@cuhacking/utils' import * as AccordionPrimitive from '@radix-ui/react-accordion' import { ChevronDown } from 'lucide-react' - import * as React from 'react' +import { cn } from '../../lib/utils' + const Accordion = AccordionPrimitive.Root const AccordionItem = React.forwardRef< diff --git a/libs/shared/ui/src/shadcn/button.stories.tsx b/libs/external/shadcn/components/ui/button.stories.tsx similarity index 100% rename from libs/shared/ui/src/shadcn/button.stories.tsx rename to libs/external/shadcn/components/ui/button.stories.tsx diff --git a/libs/shared/ui/src/shadcn/button.tsx b/libs/external/shadcn/components/ui/button.tsx similarity index 97% rename from libs/shared/ui/src/shadcn/button.tsx rename to libs/external/shadcn/components/ui/button.tsx index 45fa7c99..6c638faf 100644 --- a/libs/shared/ui/src/shadcn/button.tsx +++ b/libs/external/shadcn/components/ui/button.tsx @@ -1,9 +1,9 @@ -import { cn } from '@cuhacking/utils' import { Slot } from '@radix-ui/react-slot' import { cva, type VariantProps } from 'class-variance-authority' - import * as React from 'react' +import { cn } from '../../lib/utils' + const buttonVariants = cva( 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', { diff --git a/libs/shared/ui/src/shadcn/calendar.tsx b/libs/external/shadcn/components/ui/calendar.tsx similarity index 96% rename from libs/shared/ui/src/shadcn/calendar.tsx rename to libs/external/shadcn/components/ui/calendar.tsx index 3dc490de..6e545e2d 100644 --- a/libs/shared/ui/src/shadcn/calendar.tsx +++ b/libs/external/shadcn/components/ui/calendar.tsx @@ -1,5 +1,5 @@ -import { cn } from '@cuhacking/utils' -import { buttonVariants } from '@shadcn/ui/button' +import { buttonVariants } from '@shadcn/components/ui/button' +import { cn } from '@shadcn/lib/utils' import { ChevronLeft, ChevronRight } from 'lucide-react' import * as React from 'react' diff --git a/libs/shared/ui/src/shadcn/colors.mdx b/libs/external/shadcn/components/ui/colors.mdx similarity index 100% rename from libs/shared/ui/src/shadcn/colors.mdx rename to libs/external/shadcn/components/ui/colors.mdx diff --git a/libs/shared/ui/src/shadcn/docs.mdx b/libs/external/shadcn/components/ui/docs.mdx similarity index 100% rename from libs/shared/ui/src/shadcn/docs.mdx rename to libs/external/shadcn/components/ui/docs.mdx diff --git a/libs/shared/ui/src/shadcn/introduction.tsx b/libs/external/shadcn/components/ui/introduction.tsx similarity index 98% rename from libs/shared/ui/src/shadcn/introduction.tsx rename to libs/external/shadcn/components/ui/introduction.tsx index 1e301d0d..dc6d8864 100644 --- a/libs/shared/ui/src/shadcn/introduction.tsx +++ b/libs/external/shadcn/components/ui/introduction.tsx @@ -3,14 +3,14 @@ import { AccordionContent, AccordionItem, AccordionTrigger, -} from '@shadcn/ui/accordion' +} from './accordion' import { TypographyH1, TypographyH2, TypographyMuted, TypographyP, TypographySmall, -} from '@shadcn/ui/typography/typography' +} from './typography/typography' function Introduction() { return ( diff --git a/libs/shared/ui/src/shadcn/typography/typography.tsx b/libs/external/shadcn/components/ui/typography/typography.tsx similarity index 99% rename from libs/shared/ui/src/shadcn/typography/typography.tsx rename to libs/external/shadcn/components/ui/typography/typography.tsx index 838f4bcf..c10cb484 100644 --- a/libs/shared/ui/src/shadcn/typography/typography.tsx +++ b/libs/external/shadcn/components/ui/typography/typography.tsx @@ -1,5 +1,5 @@ /* eslint-disable unused-imports/no-unused-vars */ -import { cn } from '@cuhacking/utils' +import { cn } from '../../../lib/utils' export function TypographyH1({ className, diff --git a/libs/shared/ui/eslint.config.js b/libs/external/shadcn/eslint.config.js similarity index 100% rename from libs/shared/ui/eslint.config.js rename to libs/external/shadcn/eslint.config.js diff --git a/libs/shared/ui/.storybook/global.css b/libs/external/shadcn/global.css similarity index 100% rename from libs/shared/ui/.storybook/global.css rename to libs/external/shadcn/global.css diff --git a/libs/external/shadcn/hooks/hook.tsx b/libs/external/shadcn/hooks/hook.tsx new file mode 100644 index 00000000..e69de29b diff --git a/libs/external/shadcn/index.ts b/libs/external/shadcn/index.ts new file mode 100644 index 00000000..ceaee8cb --- /dev/null +++ b/libs/external/shadcn/index.ts @@ -0,0 +1 @@ +export * from './components/ui' diff --git a/libs/shared/utils/src/cn.ts b/libs/external/shadcn/lib/utils/cn.ts similarity index 100% rename from libs/shared/utils/src/cn.ts rename to libs/external/shadcn/lib/utils/cn.ts diff --git a/libs/shared/utils/src/index.ts b/libs/external/shadcn/lib/utils/index.ts similarity index 100% rename from libs/shared/utils/src/index.ts rename to libs/external/shadcn/lib/utils/index.ts diff --git a/libs/shared/ui/postcss.config.js b/libs/external/shadcn/postcss.config.js similarity index 100% rename from libs/shared/ui/postcss.config.js rename to libs/external/shadcn/postcss.config.js diff --git a/libs/shared/ui/project.json b/libs/external/shadcn/project.json similarity index 50% rename from libs/shared/ui/project.json rename to libs/external/shadcn/project.json index 3c607c68..0cb8dbb4 100644 --- a/libs/shared/ui/project.json +++ b/libs/external/shadcn/project.json @@ -1,14 +1,14 @@ { - "name": "ui", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/shared/ui/src", + "name": "shadcn", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/external/shadcn", "projectType": "library", "tags": [], "targets": { "add-component": { "executor": "@nx-extend/shadcn-ui:add", "options": { - "cwd": "libs/shared/ui/src/shadcn" + "cwd": "libs/external/shadcn" } } } diff --git a/libs/shared/ui/public/cuhacking-logo.svg b/libs/external/shadcn/public/cuhacking-logo.svg similarity index 100% rename from libs/shared/ui/public/cuhacking-logo.svg rename to libs/external/shadcn/public/cuhacking-logo.svg diff --git a/libs/external/shadcn/tailwind.config.ts b/libs/external/shadcn/tailwind.config.ts new file mode 100644 index 00000000..add04cba --- /dev/null +++ b/libs/external/shadcn/tailwind.config.ts @@ -0,0 +1,74 @@ +import type { Config } from 'tailwindcss' +import { join } from 'node:path' +import { createGlobPatternsForDependencies } from '@nx/react/tailwind' + +import TailwindAnimate from 'tailwindcss-animate' + +export default { + content: [ + __dirname, + join( + '{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}', + ), + ...createGlobPatternsForDependencies(__dirname), + ], + theme: { + extend: { + colors: { + border: 'hsl(var(--border))', + input: 'hsl(var(--input))', + ring: 'hsl(var(--ring))', + background: 'hsl(var(--background))', + foreground: 'hsl(var(--foreground))', + primary: { + DEFAULT: 'hsl(var(--primary))', + foreground: 'hsl(var(--primary-foreground))', + }, + secondary: { + DEFAULT: 'hsl(var(--secondary))', + foreground: 'hsl(var(--secondary-foreground))', + }, + destructive: { + DEFAULT: 'hsl(var(--destructive))', + foreground: 'hsl(var(--destructive-foreground))', + }, + muted: { + DEFAULT: 'hsl(var(--muted))', + foreground: 'hsl(var(--muted-foreground))', + }, + accent: { + DEFAULT: 'hsl(var(--accent))', + foreground: 'hsl(var(--accent-foreground))', + }, + popover: { + DEFAULT: 'hsl(var(--popover))', + foreground: 'hsl(var(--popover-foreground))', + }, + card: { + DEFAULT: 'hsl(var(--card))', + foreground: 'hsl(var(--card-foreground))', + }, + }, + borderRadius: { + lg: `var(--radius)`, + md: `calc(var(--radius) - 2px)`, + sm: 'calc(var(--radius) - 4px)', + }, + keyframes: { + 'accordion-down': { + from: { height: '0' }, + to: { height: 'var(--radix-accordion-content-height)' }, + }, + 'accordion-up': { + from: { height: 'var(--radix-accordion-content-height)' }, + to: { height: '0' }, + }, + }, + animation: { + 'accordion-down': 'accordion-down 0.2s ease-out', + 'accordion-up': 'accordion-up 0.2s ease-out', + }, + }, + }, + plugins: [TailwindAnimate], +} satisfies Config diff --git a/libs/shared/utils/tsconfig.json b/libs/external/shadcn/tsconfig.json similarity index 100% rename from libs/shared/utils/tsconfig.json rename to libs/external/shadcn/tsconfig.json diff --git a/libs/shared/ui/tsconfig.lib.json b/libs/external/shadcn/tsconfig.lib.json similarity index 100% rename from libs/shared/ui/tsconfig.lib.json rename to libs/external/shadcn/tsconfig.lib.json diff --git a/libs/shared/assets/cuhacking-logo.svg b/libs/shared/assets/cuhacking-logo.svg new file mode 100644 index 00000000..15de75d4 --- /dev/null +++ b/libs/shared/assets/cuhacking-logo.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/libs/shared/components/component.tsx b/libs/shared/components/component.tsx new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/config/eslint/antfu.js b/libs/shared/config/eslint/antfu.js new file mode 100644 index 00000000..e74cc2f8 --- /dev/null +++ b/libs/shared/config/eslint/antfu.js @@ -0,0 +1,10 @@ +import antfu from '@antfu/eslint-config' + +export default antfu({ + formatters: true, + // unocss: true, + react: true, + slidev: true, +}, +// {} +) diff --git a/libs/shared/config/eslint/base.js b/libs/shared/config/eslint/base.js deleted file mode 100644 index 66d90e21..00000000 --- a/libs/shared/config/eslint/base.js +++ /dev/null @@ -1,42 +0,0 @@ -import antfu from '@antfu/eslint-config' - -export default antfu({ - formatters: true, - // unocss: true, - react: true, - slidev: true, -}, -// {} -) - -// export default [ -// ...nx.configs['flat/base'], -// ...nx.configs['flat/typescript'], -// ...nx.configs['flat/javascript'], -// { -// ignores: ['**/dist'], -// }, -// { -// files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], -// rules: { -// '@nx/enforce-module-boundaries': [ -// 'error', -// { -// enforceBuildableLibDependency: true, -// allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'], -// depConstraints: [ -// { -// sourceTag: '*', -// onlyDependOnLibsWithTags: ['*'], -// }, -// ], -// }, -// ], -// }, -// }, -// { -// files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], -// // Override or add rules here -// rules: {}, -// }, -// ]; diff --git a/libs/shared/config/eslint/default.js b/libs/shared/config/eslint/default.js new file mode 100644 index 00000000..5d943a6c --- /dev/null +++ b/libs/shared/config/eslint/default.js @@ -0,0 +1,31 @@ +export default [ + ...nx.configs['flat/base'], + ...nx.configs['flat/typescript'], + ...nx.configs['flat/javascript'], + { + ignores: ['**/dist'], + }, + { + files: ['**.ts', '**.tsx', '**.js', '**.jsx'], + rules: { + '@nx/enforce-module-boundaries': [ + 'error', + { + enforceBuildableLibDependency: true, + allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'], + depConstraints: [ + { + sourceTag: '*', + onlyDependOnLibsWithTags: ['*'], + }, + ], + }, + ], + }, + }, + { + files: ['**.ts', '**.tsx', '**.js', '**.jsx'], + // Override or add rules here + rules: {}, + }, +]; diff --git a/libs/shared/config/eslint/playwright.js b/libs/shared/config/eslint/playwright.js index 0c1f89fb..f1b5b355 100644 --- a/libs/shared/config/eslint/playwright.js +++ b/libs/shared/config/eslint/playwright.js @@ -1,16 +1,3 @@ -// const playwright = require('eslint-plugin-playwright'); -// const baseConfig = require('../../eslint.config.js'); - -// module.exports = [ -// playwright.configs['flat/recommended'], -// ...baseConfig, -// { -// files: ['**/*.ts', '**/*.js'], -// // Override or add rules here -// rules: {}, -// }, -// ] - import playwright from 'eslint-plugin-playwright' import baseConfigPromise from '../../eslint.config.js' diff --git a/libs/shared/config/tailwind/base.js b/libs/shared/config/tailwind/base.ts similarity index 100% rename from libs/shared/config/tailwind/base.js rename to libs/shared/config/tailwind/base.ts diff --git a/libs/shared/utils/src/tailwind.config.ts b/libs/shared/config/tailwind/shadcn.ts similarity index 100% rename from libs/shared/utils/src/tailwind.config.ts rename to libs/shared/config/tailwind/shadcn.ts diff --git a/libs/shared/config/typescript/base.json b/libs/shared/config/typescript/base.json index a9943fd6..4e001c72 100644 --- a/libs/shared/config/typescript/base.json +++ b/libs/shared/config/typescript/base.json @@ -17,7 +17,7 @@ "moduleResolution": "node", // "---------- EMIT ---------": "", "paths": { - "@cuhacking/ui": ["libs/shared/ui/src/index.ts"] + "@cuhacking/*": ["libs/shared/*"] }, "declaration": false, "importHelpers": true, diff --git a/libs/shared/features/awesome-feature/api/endpoint.ts b/libs/shared/features/awesome-feature/api/endpoint.ts new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/features/awesome-feature/assets/cuhacking-logo.svg b/libs/shared/features/awesome-feature/assets/cuhacking-logo.svg new file mode 100644 index 00000000..15de75d4 --- /dev/null +++ b/libs/shared/features/awesome-feature/assets/cuhacking-logo.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/libs/shared/features/awesome-feature/components/component.tsx b/libs/shared/features/awesome-feature/components/component.tsx new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/features/awesome-feature/hooks/hook.tsx b/libs/shared/features/awesome-feature/hooks/hook.tsx new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/features/awesome-feature/index.ts b/libs/shared/features/awesome-feature/index.ts new file mode 100644 index 00000000..0089656f --- /dev/null +++ b/libs/shared/features/awesome-feature/index.ts @@ -0,0 +1 @@ +// entry point for the feature, it should serve as the public API of the given feature and exports everything that should be used outside the feature diff --git a/libs/shared/features/awesome-feature/routes/route.tsx b/libs/shared/features/awesome-feature/routes/route.tsx new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/features/awesome-feature/stores/store.tsx b/libs/shared/features/awesome-feature/stores/store.tsx new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/features/awesome-feature/types/type.ts b/libs/shared/features/awesome-feature/types/type.ts new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/features/awesome-feature/utils/utils.ts b/libs/shared/features/awesome-feature/utils/utils.ts new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/utils/project.json b/libs/shared/project.json similarity index 50% rename from libs/shared/utils/project.json rename to libs/shared/project.json index 39f7d2f0..55a0c0cc 100644 --- a/libs/shared/utils/project.json +++ b/libs/shared/project.json @@ -1,9 +1,8 @@ { - "name": "utils", + "name": "shared", "$schema": "../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/shared/utils/src", + "sourceRoot": "libs/shared/", "projectType": "library", "tags": [], - "// targets": "to see all targets run: nx show project utils --web", "targets": {} } diff --git a/libs/shared/providers/provider.tsx b/libs/shared/providers/provider.tsx new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/routes/route.tsx b/libs/shared/routes/route.tsx new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/test/test.spec.ts b/libs/shared/test/test.spec.ts new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/ui/tsconfig.json b/libs/shared/tsconfig.json similarity index 84% rename from libs/shared/ui/tsconfig.json rename to libs/shared/tsconfig.json index 45cb3d93..74d69d3d 100644 --- a/libs/shared/ui/tsconfig.json +++ b/libs/shared/tsconfig.json @@ -9,9 +9,6 @@ "references": [ { "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.storybook.json" } ], "files": [], diff --git a/libs/shared/utils/tsconfig.lib.json b/libs/shared/tsconfig.lib.json similarity index 87% rename from libs/shared/utils/tsconfig.lib.json rename to libs/shared/tsconfig.lib.json index 02bd7508..7081c64a 100644 --- a/libs/shared/utils/tsconfig.lib.json +++ b/libs/shared/tsconfig.lib.json @@ -18,6 +18,8 @@ "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", - "src/**/*.test.jsx" + "src/**/*.test.jsx", + "**/*.stories.ts", + "**/*.stories.js" ] } diff --git a/libs/shared/types/type.ts b/libs/shared/types/type.ts new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/ui/.babelrc b/libs/shared/ui/.babelrc deleted file mode 100644 index 1ea870ea..00000000 --- a/libs/shared/ui/.babelrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "presets": [ - [ - "@nx/react/babel", - { - "runtime": "automatic", - "useBuiltIns": "usage" - } - ] - ], - "plugins": [] -} diff --git a/libs/shared/ui/component.tsx b/libs/shared/ui/component.tsx new file mode 100644 index 00000000..e69de29b diff --git a/libs/shared/utils/src/global.css b/libs/shared/ui/global.css similarity index 100% rename from libs/shared/utils/src/global.css rename to libs/shared/ui/global.css diff --git a/libs/shared/ui/package.json b/libs/shared/ui/package.json deleted file mode 100644 index b8c2ea03..00000000 --- a/libs/shared/ui/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "ui", - "version": "1.0.0", - "description": "", - "author": "", - "license": "ISC", - "keywords": [], - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - } -} diff --git a/libs/shared/ui/tailwind.config.ts b/libs/shared/ui/tailwind.config.ts deleted file mode 100644 index 64596833..00000000 --- a/libs/shared/ui/tailwind.config.ts +++ /dev/null @@ -1,17 +0,0 @@ -// import type { Config } from 'tailwindcss' -// import { createGlobPatternsForDependencies } from '@nx/react/tailwind' - -// export default { -// content: [ -// './app/**/*.{js,jsx,ts,tsx}', -// ...createGlobPatternsForDependencies(__dirname), -// ], -// theme: { -// extend: {}, -// }, -// plugins: [], -// } satisfies Config - -import { buildConfig } from '../utils/src/tailwind.config' - -export default buildConfig(__dirname) diff --git a/libs/shared/utils/.babelrc b/libs/shared/utils/.babelrc deleted file mode 100644 index 1ea870ea..00000000 --- a/libs/shared/utils/.babelrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "presets": [ - [ - "@nx/react/babel", - { - "runtime": "automatic", - "useBuiltIns": "usage" - } - ] - ], - "plugins": [] -} diff --git a/libs/shared/utils/README.md b/libs/shared/utils/README.md deleted file mode 100644 index cafd71d0..00000000 --- a/libs/shared/utils/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# utils - -This library was generated with [Nx](https://nx.dev). - -## Running unit tests - -Run `nx test utils` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/shared/utils/cn.ts b/libs/shared/utils/cn.ts new file mode 100644 index 00000000..a92a0dfc --- /dev/null +++ b/libs/shared/utils/cn.ts @@ -0,0 +1,6 @@ +import { type ClassValue, clsx } from 'clsx' +import { twMerge } from 'tailwind-merge' + +export const cn = function cn(...inputs: ClassValue[]) { + return twMerge(clsx(inputs)) +} diff --git a/libs/shared/utils/eslint.config.js b/libs/shared/utils/eslint.config.js deleted file mode 100644 index 236d2911..00000000 --- a/libs/shared/utils/eslint.config.js +++ /dev/null @@ -1,37 +0,0 @@ -// const nx = require("@nx/eslint-plugin"); -// const baseConfig = require("../../eslint.config.js"); - -// module.exports = [ -// ...baseConfig, -// ...nx.configs["flat/react"], -// { -// files: [ -// "**/*.ts", -// "**/*.tsx", -// "**/*.js", -// "**/*.jsx" -// ], -// // Override or add rules here -// rules: {} -// } -// ]; - -import baseConfigPromise from '../../../eslint.config.js' - -export default (async () => { - const baseConfig = await baseConfigPromise - - return [ - ...baseConfig, - { - files: [ - '**/*.ts', - '**/*.tsx', - '**/*.js', - '**/*.jsx', - ], - // Override or add rules here - rules: {}, - }, - ] -})() diff --git a/package.json b/package.json index db3d3ae9..7187fb8f 100644 --- a/package.json +++ b/package.json @@ -149,6 +149,7 @@ "tailwindcss": "^3.4.14", "tailwindcss-animate": "^1.0.7", "ts-node": "10.9.1", + "tsconfig-paths-webpack-plugin": "^4.1.0", "tslib": "^2.8.1", "typescript": "^5.6.3", "typescript-eslint": "^8.14.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 54478a2d..40882caf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -363,6 +363,9 @@ importers: ts-node: specifier: 10.9.1 version: 10.9.1(@swc/core@1.5.29(@swc/helpers@0.5.15))(@types/node@22.8.6)(typescript@5.6.3) + tsconfig-paths-webpack-plugin: + specifier: ^4.1.0 + version: 4.1.0 tslib: specifier: ^2.8.1 version: 2.8.1 diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 00000000..2e7af2b7 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/tailwind.config.ts b/tailwind.config.ts new file mode 100644 index 00000000..ca920fa8 --- /dev/null +++ b/tailwind.config.ts @@ -0,0 +1,66 @@ +import TailwindAnimate from 'tailwindcss-animate' + +export default { + content: [ + '{libs,apps}/**/*!(*.stories|*.spec).{ts,tsx,html}', + ], + theme: { + extend: { + colors: { + border: 'hsl(var(--border))', + input: 'hsl(var(--input))', + ring: 'hsl(var(--ring))', + background: 'hsl(var(--background))', + foreground: 'hsl(var(--foreground))', + primary: { + DEFAULT: 'hsl(var(--primary))', + foreground: 'hsl(var(--primary-foreground))', + }, + secondary: { + DEFAULT: 'hsl(var(--secondary))', + foreground: 'hsl(var(--secondary-foreground))', + }, + destructive: { + DEFAULT: 'hsl(var(--destructive))', + foreground: 'hsl(var(--destructive-foreground))', + }, + muted: { + DEFAULT: 'hsl(var(--muted))', + foreground: 'hsl(var(--muted-foreground))', + }, + accent: { + DEFAULT: 'hsl(var(--accent))', + foreground: 'hsl(var(--accent-foreground))', + }, + popover: { + DEFAULT: 'hsl(var(--popover))', + foreground: 'hsl(var(--popover-foreground))', + }, + card: { + DEFAULT: 'hsl(var(--card))', + foreground: 'hsl(var(--card-foreground))', + }, + }, + borderRadius: { + lg: `var(--radius)`, + md: `calc(var(--radius) - 2px)`, + sm: 'calc(var(--radius) - 4px)', + }, + keyframes: { + 'accordion-down': { + from: { height: '0' }, + to: { height: 'var(--radix-accordion-content-height)' }, + }, + 'accordion-up': { + from: { height: 'var(--radix-accordion-content-height)' }, + to: { height: '0' }, + }, + }, + animation: { + 'accordion-down': 'accordion-down 0.2s ease-out', + 'accordion-up': 'accordion-up 0.2s ease-out', + }, + }, + }, + plugins: [TailwindAnimate], +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 9e5193bc..28c50415 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -9,12 +9,10 @@ "module": "esnext", "moduleResolution": "node", "paths": { - "@cuhacking/utils": ["libs/shared/utils/src/index.ts"], - "@cuhacking/utils/*": ["libs/shared/utils/src/*"], - "@shadcn/ui": ["libs/shared/ui/src/shadcn/index.ts"], - "@shadcn/ui/*": ["libs/shared/ui/src/shadcn/*"], - "@cuhacking/ui": ["libs/shared/ui/src/cuhacking/index.ts"], - "@cuhacking/ui/*": ["libs/shared/ui/src/cuhacking/*"] + "@shadcn": ["libs/external/shadcn/index.ts"], + "@shadcn/*": ["libs/external/shadcn/*"], + "@cuhacking/": ["libs/shared/index.ts"], + "@cuhacking/shared/*": ["libs/shared/*"] }, "declaration": false, "importHelpers": true,