Skip to content

Commit

Permalink
feat(lib): add ui-components library
Browse files Browse the repository at this point in the history
  • Loading branch information
kavania2002 committed Oct 5, 2024
1 parent a1b6517 commit d22c5f5
Show file tree
Hide file tree
Showing 16 changed files with 697 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ Thumbs.db

# Next.js
.next
out
out
7 changes: 7 additions & 0 deletions libs/ui-components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ui-components

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test ui-components` to execute the unit tests via [Jest](https://jestjs.io).
12 changes: 12 additions & 0 deletions libs/ui-components/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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: {},
},
];
9 changes: 9 additions & 0 deletions libs/ui-components/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "ui-components",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/ui-components/src",
"projectType": "library",
"tags": [],
"// targets": "to see all targets run: nx show project ui-components --web",
"targets": {}
}
3 changes: 3 additions & 0 deletions libs/ui-components/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Use this file to export React client components (e.g. those with 'use client' directive) or other non-server utilities

export * from './lib/ui-components';
4 changes: 4 additions & 0 deletions libs/ui-components/src/lib/hello-server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// React server components are async so you make database or API calls.
export async function HelloServer() {
return <h1>Hello Server</h1>;
}
7 changes: 7 additions & 0 deletions libs/ui-components/src/lib/ui-components.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Replace this with your own classes
*
* e.g.
* .container {
* }
*/
10 changes: 10 additions & 0 deletions libs/ui-components/src/lib/ui-components.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { render } from '@testing-library/react';

import UiComponents from './ui-components';

describe('UiComponents', () => {
it('should render successfully', () => {
const { baseElement } = render(<UiComponents />);
expect(baseElement).toBeTruthy();
});
});
11 changes: 11 additions & 0 deletions libs/ui-components/src/lib/ui-components.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import styles from './ui-components.module.css';

export function UiComponents() {
return (
<div className={styles['container']}>
<h1>Welcome to UiComponents!</h1>
</div>
);
}

export default UiComponents;
2 changes: 2 additions & 0 deletions libs/ui-components/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Use this file to export React server components
export * from './lib/hello-server';
17 changes: 17 additions & 0 deletions libs/ui-components/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
],
"extends": "../../tsconfig.base.json"
}
25 changes: 25 additions & 0 deletions libs/ui-components/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts",
"next",
"@nx/next/typings/image.d.ts"
]
},
"exclude": [
"jest.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/**/*.spec.tsx",
"src/**/*.test.tsx",
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}
3 changes: 3 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"style": "tailwind",
"linter": "eslint"
}
},
"@nx/react": {
"library": {}
}
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
"@nx/jest": "19.8.4",
"@nx/js": "19.8.4",
"@nx/next": "19.8.4",
"@nx/react": "19.8.4",
"@nx/workspace": "19.8.4",
"@swc-node/register": "~1.9.1",
"@swc/cli": "~0.3.12",
"@swc/core": "~1.5.7",
"@swc/helpers": "~0.5.11",
"@types/jest": "^29.5.12",
Expand Down
9 changes: 8 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {}
"paths": {
"@nx-monorepo-aceternity-ui-boilerplate/ui-components": [
"libs/ui-components/src/index.ts"
],
"@nx-monorepo-aceternity-ui-boilerplate/ui-components/server": [
"libs/ui-components/src/server.ts"
]
}
},
"exclude": ["node_modules", "tmp"]
}
Loading

0 comments on commit d22c5f5

Please sign in to comment.