Skip to content

Commit

Permalink
next-ui setup
Browse files Browse the repository at this point in the history
  • Loading branch information
siddg97 committed Feb 8, 2024
1 parent 68ba841 commit eea9c80
Show file tree
Hide file tree
Showing 18 changed files with 4,452 additions and 0 deletions.
18 changes: 18 additions & 0 deletions react/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions react/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
30 changes: 30 additions & 0 deletions react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
13 changes: 13 additions & 0 deletions react/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "react",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@nextui-org/react": "^2.2.9",
"clsx": "^2.1.0",
"framer-motion": "^11.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwind-merge": "^2.2.1",
"usehooks-ts": "^2.13.0"
},
"devDependencies": {
"@iconify/react": "^4.1.1",
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.17",
"eslint": "^8.55.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"typescript": "^5.2.2",
"vite": "^5.0.8"
}
}
6 changes: 6 additions & 0 deletions react/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
1 change: 1 addition & 0 deletions react/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions react/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Navigation from "./components/Navigation.tsx";

function App() {
return (
<div className="w-full">
<Navigation/>
<main className="mt-6 flex w-full flex-col items-center">
Hello
</main>
</div>
)
}

export default App
163 changes: 163 additions & 0 deletions react/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import { Icon } from "@iconify/react";
import {
Avatar,
Badge,
Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger,
Link,
Navbar,
NavbarBrand,
NavbarContent,
NavbarItem, NavbarMenu, NavbarMenuItem,
NavbarMenuToggle,
} from "@nextui-org/react";

export default function Navigation() {
return (
<Navbar
classNames={{
base: "lg:bg-transparent lg:backdrop-filter-none",
item: "data-[active=true]:text-primary",
wrapper: "px-4 sm:px-6",
}}
height="60px"
>
<NavbarBrand>
<NavbarMenuToggle className="mr-2 h-6 sm:hidden"/>
{/*<AcmeIcon/>*/}
<p className="font-bold text-inherit">ACME</p>
</NavbarBrand>
<NavbarContent
className="ml-4 hidden h-12 w-full max-w-fit gap-4 rounded-full bg-content2 px-4 dark:bg-content1 sm:flex"
justify="start"
>
<NavbarItem>
<Link className="flex gap-2 text-inherit" href="#">
Dashboard
</Link>
</NavbarItem>
<NavbarItem isActive>
<Link aria-current="page" className="flex gap-2 text-inherit" href="#">
Deployments
</Link>
</NavbarItem>
<NavbarItem>
<Link className="flex gap-2 text-inherit" href="#">
Analytics
</Link>
</NavbarItem>
<NavbarItem>
<Link className="flex gap-2 text-inherit" href="#">
Team
</Link>
</NavbarItem>
<NavbarItem>
<Link className="flex gap-2 text-inherit" href="#">
Settings
</Link>
</NavbarItem>
</NavbarContent>
<NavbarContent
className="ml-auto flex h-12 max-w-fit items-center gap-0 rounded-full p-0 lg:bg-content2 lg:px-1 lg:dark:bg-content1"
justify="end"
>
<NavbarItem className="hidden sm:flex">
<Button isIconOnly radius="full" variant="light">
<Icon className="text-default-500" icon="solar:magnifer-linear" width={22}/>
</Button>
</NavbarItem>
<NavbarItem className="hidden sm:flex">
<Button isIconOnly radius="full" variant="light">
<Icon className="text-default-500" icon="solar:sun-linear" width={24}/>
</Button>
</NavbarItem>
<NavbarItem className="hidden sm:flex">
<Button isIconOnly radius="full" variant="light">
<Icon className="text-default-500" icon="solar:settings-linear" width={24}/>
</Button>
</NavbarItem>
{/*<NavbarItem className="flex">*/}
{/* <Popover offset={12} placement="bottom-end">*/}
{/* <PopoverTrigger>*/}
{/* <Button*/}
{/* disableRipple*/}
{/* isIconOnly*/}
{/* className="overflow-visible"*/}
{/* radius="full"*/}
{/* variant="light"*/}
{/* >*/}
{/* <Badge color="danger" content="5" showOutline={false} size="md">*/}
{/* <Icon className="text-default-500" icon="solar:bell-linear" width={22}/>*/}
{/* </Badge>*/}
{/* </Button>*/}
{/* </PopoverTrigger>*/}
{/* <PopoverContent className="max-w-[90vw] p-0 sm:max-w-[380px]">*/}
{/* <NotificationsCard className="w-full shadow-none"/>*/}
{/* </PopoverContent>*/}
{/* </Popover>*/}
{/*</NavbarItem>*/}
<NavbarItem className="px-2">
<Dropdown placement="bottom-end">
<DropdownTrigger>
<button className="mt-1 h-8 w-8 outline-none transition-transform">
<Badge
className="border-transparent"
color="success"
content=""
placement="bottom-right"
shape="circle"
size="sm"
>
<Avatar size="sm" src="https://i.pravatar.cc/150?u=a04258114e29526708c"/>
</Badge>
</button>
</DropdownTrigger>
<DropdownMenu aria-label="Profile Actions" variant="flat">
<DropdownItem key="profile" className="h-14 gap-2">
<p className="font-semibold">Signed in as</p>
<p className="font-semibold">johndoe@example.com</p>
</DropdownItem>
<DropdownItem key="settings">My Settings</DropdownItem>
<DropdownItem key="team_settings">Team Settings</DropdownItem>
<DropdownItem key="analytics">Analytics</DropdownItem>
<DropdownItem key="system">System</DropdownItem>
<DropdownItem key="configurations">Configurations</DropdownItem>
<DropdownItem key="help_and_feedback">Help & Feedback</DropdownItem>
<DropdownItem key="logout" color="danger">
Log Out
</DropdownItem>
</DropdownMenu>
</Dropdown>
</NavbarItem>
</NavbarContent>

{/* Mobile Menu */}
<NavbarMenu>
<NavbarMenuItem>
<Link className="w-full" color="foreground" href="#">
Dashboard
</Link>
</NavbarMenuItem>
<NavbarMenuItem isActive>
<Link aria-current="page" className="w-full" color="primary" href="#">
Deployments
</Link>
</NavbarMenuItem>
<NavbarMenuItem>
<Link className="w-full" color="foreground" href="#">
Analytics
</Link>
</NavbarMenuItem>
<NavbarMenuItem>
<Link className="w-full" color="foreground" href="#">
Team
</Link>
</NavbarMenuItem>
<NavbarMenuItem>
<Link className="w-full" color="foreground" href="#">
Settings
</Link>
</NavbarMenuItem>
</NavbarMenu>
</Navbar>
);
}
3 changes: 3 additions & 0 deletions react/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
13 changes: 13 additions & 0 deletions react/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { NextUIProvider } from "@nextui-org/react";
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<NextUIProvider>
<App/>
</NextUIProvider>
</React.StrictMode>,
)
8 changes: 8 additions & 0 deletions react/src/utils/cn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { ClassValue } from "clsx";

import clsx from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
1 change: 1 addition & 0 deletions react/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
19 changes: 19 additions & 0 deletions react/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** @type {import('tailwindcss').Config} */

const { nextui } = require("@nextui-org/react");

export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
"./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
darkMode: "class",
plugins: [nextui({
defaultTheme: 'dark',
defaultExtendTheme: 'dark'
})],
}
25 changes: 25 additions & 0 deletions react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
Loading

0 comments on commit eea9c80

Please sign in to comment.