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 14, 2024
1 parent 4c4d94c commit 09eccc3
Show file tree
Hide file tree
Showing 64 changed files with 230 additions and 185 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.
File renamed without changes.
5 changes: 4 additions & 1 deletion libs/shared/ui/.storybook/main.ts → .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { StorybookConfig } from '@storybook/nextjs'

const config: StorybookConfig = {
stories: ['../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
stories: [
'../libs/external/shadcn/ui/**/*.@(mdx|stories.@(js|jsx|ts|tsx))',
'../libs/shared/ui/**/*.@(mdx|stories.@(js|jsx|ts|tsx))',
],
framework: {
name: '@storybook/nextjs',
options: {},
Expand Down
File renamed without changes.
File renamed without changes.
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/ui/global.css'

export const links: LinksFunction = () => [
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
Expand Down
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,5 +1,5 @@
import { cn } from '@cuhacking/utils'
import * as AccordionPrimitive from '@radix-ui/react-accordion'
import { cn } from '@shadcn/lib/utils'
import { ChevronDown } from 'lucide-react'

import * as React from 'react'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
EnvelopeOpenIcon,
ReloadIcon,
} from '@radix-ui/react-icons'
import { Button } from '@shadcn/components/ui/button'
import { fn } from '@storybook/test'
import { Button } from './button'

const meta = {
title: 'Shadcn-ui/Button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cn } from '@cuhacking/utils'
import { Slot } from '@radix-ui/react-slot'
import { cn } from '@shadcn/lib/utils'
import { cva, type VariantProps } from 'class-variance-authority'

import * as React from 'react'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from '@cuhacking/utils'
import { cn } from '@shadcn/lib/utils'
import { buttonVariants } from '@shadcn/ui/button'
import { ChevronLeft, ChevronRight } from 'lucide-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 '@shadcn/components/ui/accordion'
import {
TypographyH1,
TypographyH2,
TypographyMuted,
TypographyP,
TypographySmall,
} from '@shadcn/ui/typography/typography'
} from '@shadcn/components/ui/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 '@shadcn/lib/utils'

export function TypographyH1({
className,
Expand Down
File renamed without changes.
File renamed without changes.
Empty file.
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
File renamed without changes.
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.
5 changes: 2 additions & 3 deletions libs/shared/utils/project.json → libs/shared/project.json
Original file line number Diff line number Diff line change
@@ -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": {}
}
Empty file.
Empty file added libs/shared/routes/route.tsx
Empty file.
Empty file added libs/shared/test/test.spec.ts
Empty file.
3 changes: 0 additions & 3 deletions libs/shared/ui/tsconfig.json → libs/shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.storybook.json"
}
],
"files": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
"src/**/*.test.jsx",
"**/*.stories.ts",
"**/*.stories.js"
]
}
Empty file added libs/shared/types/type.ts
Empty file.
12 changes: 0 additions & 12 deletions libs/shared/ui/.babelrc

This file was deleted.

Empty file added libs/shared/ui/component.tsx
Empty file.
Loading

0 comments on commit 09eccc3

Please sign in to comment.