Skip to content

Commit

Permalink
refactor: reorganize libs with feature sliced design and bulletproof …
Browse files Browse the repository at this point in the history
…react
  • Loading branch information
MFarabi619 committed Nov 19, 2024
1 parent f4142ba commit fa92465
Show file tree
Hide file tree
Showing 70 changed files with 265 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ yarn-error.log*
.vercel
next-env.d.ts

storybook-static
**/*/storybook-static
build-storybook.log
File renamed without changes.
23 changes: 19 additions & 4 deletions libs/shared/ui/.storybook/main.ts → .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -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: {},
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/website/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
4 changes: 2 additions & 2 deletions apps/website/app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion apps/website/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 5 additions & 4 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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<
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
File renamed without changes.
File renamed without changes.
Empty file.
1 change: 1 addition & 0 deletions libs/external/shadcn/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/ui'
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Expand Down
File renamed without changes
74 changes: 74 additions & 0 deletions libs/external/shadcn/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions libs/shared/assets/cuhacking-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
10 changes: 10 additions & 0 deletions libs/shared/config/eslint/antfu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import antfu from '@antfu/eslint-config'

export default antfu({
formatters: true,
// unocss: true,
react: true,
slidev: true,
},
// {}
)
42 changes: 0 additions & 42 deletions libs/shared/config/eslint/base.js

This file was deleted.

31 changes: 31 additions & 0 deletions libs/shared/config/eslint/default.js
Original file line number Diff line number Diff line change
@@ -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: {},
},
];
13 changes: 0 additions & 13 deletions libs/shared/config/eslint/playwright.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion libs/shared/config/typescript/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"moduleResolution": "node",
// "---------- EMIT ---------": "",
"paths": {
"@cuhacking/ui": ["libs/shared/ui/src/index.ts"]
"@cuhacking/*": ["libs/shared/*"]
},
"declaration": false,
"importHelpers": true,
Expand Down
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions libs/shared/features/awesome-feature/index.ts
Original file line number Diff line number Diff line change
@@ -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
Empty file.
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit fa92465

Please sign in to comment.