implemented header and dark theme.

This commit is contained in:
Md Asif 2024-09-29 12:22:08 +05:30
commit dc36a9c094
24 changed files with 6189 additions and 0 deletions

24
.gitignore vendored Normal file
View File

@ -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?

8
README.md Normal file
View File

@ -0,0 +1,8 @@
# React + 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

38
eslint.config.js Normal file
View File

@ -0,0 +1,38 @@
import js from '@eslint/js'
import globals from 'globals'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
export default [
{ ignores: ['dist'] },
{
files: ['**/*.{js,jsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
settings: { react: { version: '18.3' } },
plugins: {
react,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...js.configs.recommended.rules,
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
...reactHooks.configs.recommended.rules,
'react/jsx-no-target-blank': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
]

13
index.html Normal file
View File

@ -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</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>

5686
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

34
package.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "my-project",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"lucide-react": "^0.446.0",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.2"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
"eslint": "^9.9.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.9.0",
"postcss": "^8.4.47",
"tailwindcss": "^3.4.13",
"vite": "^5.4.1"
}
}

6
postcss.config.js Normal file
View File

@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

1
public/vite.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

13
src/App.jsx Normal file
View File

@ -0,0 +1,13 @@
import { Outlet } from "react-router-dom"
import Header from "./components/Header"
function App() {
return <div className="flex flex-col min-h-screen">
<Header />
<main className="transition-color-mode px-7 flex-grow bg-surface dark:bg-surface-dark">
<Outlet />
</main>
</div>
}
export default App

21
src/assets/ipks_logo.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.5 KiB

3
src/assets/triangle.svg Normal file
View File

@ -0,0 +1,3 @@
<svg width="16" height="13" viewBox="0 0 16 13" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.26795 1C7.03775 -0.333332 8.96225 -0.333334 9.73205 0.999999L14.9282 10C15.698 11.3333 14.7358 13 13.1962 13H2.80385C1.26425 13 0.301996 11.3333 1.0718 10L6.26795 1Z" fill="#008C46"/>
</svg>

After

Width:  |  Height:  |  Size: 303 B

View File

@ -0,0 +1,16 @@
import IpksLogo from '../assets/ipks_logo.svg';
import DarkModeToggle from './DarkModeToggle';
function AppTitle() {
return (
<div className='flex items-center justify-between pt-3 pb-5'>
<div className='flex gap-5 items-center'>
<img src={IpksLogo} alt="IPKS Logo" className="h-16" />
<h1 className="text-title font-display font-bold">Integrated PACS Kisan Solution</h1>
</div>
<DarkModeToggle />
</div>
);
}
export default AppTitle;

View File

@ -0,0 +1,21 @@
import PropTypes from "prop-types";
import BannerInfoElement from "./BannerInfoElement";
function BannerInfo({info}) {
const date = new Date().toLocaleDateString('en-IN', {month: 'long', day: '2-digit', year: 'numeric'}).split(" ");
const infoElements = Object.keys(info).map((key) => (
<BannerInfoElement key={key} title={key} description={info[key]} />
))
infoElements.push(<BannerInfoElement key="date" title="Date" description={date.join(" ")} />);
return (
<div className="flex justify-between pb-1">
{infoElements}
</div>
)
}
BannerInfo.propTypes = {
info: PropTypes.object.isRequired
}
export default BannerInfo;

View File

@ -0,0 +1,17 @@
import PropTypes from 'prop-types';
function BannerInfoElement({ title, description }) {
return (
<div className='font-body'>
<div className='text-base '>{title}</div>
<div className='text-[18px] font-medium'>{description}</div>
</div>
);
}
BannerInfoElement.propTypes = {
title: PropTypes.string.isRequired,
description: PropTypes.string.isRequired
};
export default BannerInfoElement;

View File

@ -0,0 +1,35 @@
import { useState, useEffect } from 'react';
import { Sun, Moon } from 'lucide-react';
const DarkModeToggle = () => {
const [darkMode, setDarkMode] = useState(() => {
const savedMode = localStorage.getItem('darkMode');
return savedMode ? JSON.parse(savedMode) : false;
});
useEffect(() => {
localStorage.setItem('darkMode', JSON.stringify(darkMode));
if (darkMode) {
document.documentElement.setAttribute('class', 'dark');
} else {
document.documentElement.removeAttribute('class');
}
}, [darkMode]);
const toggleDarkMode = () => {
setDarkMode(prevMode => !prevMode);
};
return (
<button
onClick={toggleDarkMode}
className="p-2 rounded-full bg-gray-200 text-gray-800 transition-colors duration-200"
data-theme={darkMode ? 'dark' : 'light'}
aria-label={darkMode ? 'Switch to light mode' : 'Switch to dark mode'}
>
{darkMode ? <Sun className="w-5 h-5" /> : <Moon className="w-5 h-5" />}
</button>
);
};
export default DarkModeToggle;

64
src/components/Header.jsx Normal file
View File

@ -0,0 +1,64 @@
import { getUserInfoFromSession } from "../util/util";
import AppTitle from "./AppTitle";
import BannerInfo from "./BannerInfo";
import MenuBar from "./MenuBar";
import Separator from "./Separator";
function Header() {
const userInfo = getUserInfoFromSession();
const menuItems = [
{ name: "Home", submenu: [], path: "/" },
{
name: "Module List",
submenu: [
{name: "KCC", path: "kcc"},
{name: "Trading", path: "trading"},
{name: "Asset", path: "asset"},
{name: "Self Help Group", path: "shg"},
{name: "Deposit", path: "deposit"},
{name: "Loan", path: "loan"},
{name: "Share", path: "share"},
],
},
{ name: "Enquiry", submenu: [{name: "Locker Enquiry", path: "locker-enquiry"}, {name: "Account Enquiry", path: "account-enquiry"}] },
{
name: "Locker Operation",
submenu: [
{name: "Account Creation", path: "account-creation"},
{name: "Cabinet Maintenance", path: "cabinet-maintenance"},
{name: "Locker Maintenance", path: "locker-maintenance"},
{name: "Rent/Penalty Collection", path: "rent-collection"},
{name: "Charge Management", path: "charge-management"},
{name: "Check in/out Management", path: "check-in-out"},
{name: "Account Surrender", path: "account-surrender"}
],
},
{
name: "Reports",
submenu: [
{name: "Deposit Report", path: "deposit-report"},
{name: "Trial Balance Report", path: "trial-report"},
{name: "Deposit Return Report", path: "deposit-return-report"},
{name: "Account Statement Reports", path: "account-statement-report"},
{name: "Audit Reports", path: "audit-reports"}
],
},
{ name: "Worklist", submenu: [{name:"My Intimation", path: "my-intimation"}] },
{
name: "User Management",
submenu: [{name: "Reset Loggen In Status", path: "reset-login"}, {name: "Change Password", path: "change-password"}],
},
{ name: "Log Out", submenu: [] },
];
return (
<div className="transition-color-mode px-7 bg-secondary dark:bg-secondary-dark text-primary dark:text-primary-dark">
<AppTitle />
<BannerInfo info={userInfo} />
<Separator />
<MenuBar menuItems={menuItems} />
</div>
)
}
export default Header;

View File

@ -0,0 +1,59 @@
import { Link } from "react-router-dom";
import PropTypes from "prop-types";
const SubMenu = ({ items }) => {
return (
<div className="
hidden absolute top-full left-0 border-t-3 border-primary dark:border-primary-dark bg-secondary
dark:bg-secondary-dark rounded-2xl shadow-sm shadow-surface-variant-dark dark:shadow-primary group-hover:block z-10"
>
{items.map((subItem, index) => (
<div key={index} className="px-6 py-2 text-nowrap hover:bg-white dark:hover:bg-secondary-variant-dark cursor-pointer first:rounded-t-2xl last:rounded-b-2xl first:pt-4 last:pb-4">
<Link to={subItem.path}>{subItem.name}</Link>
</div>
))}
<svg className="absolute top-0 left-6 mt-[-13px] fill-primary dark:fill-primary-dark" width="16" height="13" viewBox="0 0 16 13" xmlns="http://www.w3.org/2000/svg">
<path d="M6.26795 1C7.03775 -0.333332 8.96225 -0.333334 9.73205 0.999999L14.9282 10C15.698 11.3333 14.7358 13 13.1962 13H2.80385C1.26425 13 0.301996 11.3333 1.0718 10L6.26795 1Z" />
</svg>
</div>
);
};
function MenuBar({ menuItems }) {
return (
<div className="flex justify-between text-base pt-5 pb-2 font-body">
{menuItems.map((item, index) =>
<div key={index} className="group relative pb-3 cursor-pointer">
{item.name}
{item.submenu.length > 0 && <SubMenu items={item.submenu} />}
</div>
)}
</div>
);
}
MenuBar.propTypes = {
menuItems: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string.isRequired,
submenu: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string.isRequired,
path: PropTypes.string.isRequired,
})
),
path: PropTypes.string
})
).isRequired
};
SubMenu.propTypes = {
items: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string.isRequired,
path: PropTypes.string.isRequired
})
).isRequired
};
export default MenuBar;

View File

@ -0,0 +1,9 @@
function Separator() {
return (
<div className="h-[2px]">
<div className="h-full w-full bg-white rounded-md"></div>
</div>
)
}
export default Separator;

20
src/index.css Normal file
View File

@ -0,0 +1,20 @@
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&family=Rubik:ital,wght@0,300..900;1,300..900&display=swap');
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--transition-duration: 700ms;
}
body {
transition-property: background-color, color, border-color;
transition-duration: var(--transition-duration);
}
.transition-color-mode {
transition-property: background-color, color, border-color;
transition-duration: var(--transition-duration);
}
}

31
src/main.jsx Normal file
View File

@ -0,0 +1,31 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.jsx'
import './index.css'
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import Placeholder from './pages/Placeholder.jsx';
const router = createBrowserRouter([
{
path: "/",
element: <App/>,
children: [
{
index: true,
element: <Placeholder />
},
{
path: 'cabinet-maintenance',
element: <Placeholder />
}
]
}
]
);
createRoot(document.getElementById('root')).render(
<StrictMode>
<RouterProvider router={router} />
</StrictMode>,
)

View File

@ -0,0 +1,9 @@
function Placeholder() {
return (
<div className="h-max text-center text-2xl font-body text-primary dark:text-primary-dark">
<h1>Placeholder</h1>
</div >
);
}
export default Placeholder;

10
src/util/util.js Normal file
View File

@ -0,0 +1,10 @@
const getUserInfoFromSession = () => {
return {
"User Name": "Rajesh Kumar",
"PACS / Bank Name": "Demo SKUS Ltd.",
"User Type": "PACS Teller",
"Module Name": "Locker",
}
}
export { getUserInfoFromSession };

44
tailwind.config.js Normal file
View File

@ -0,0 +1,44 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
darkMode: 'selector',
theme: {
colors: {
white: '#FFFFFF',
black: '#000000',
transparent: 'transparent',
primary: {
DEFAULT: '#008C46',
dark: '#6affb4'
},
secondary: {
DEFAULT: '#B1E1B3',
dark: '#20542f',
variant: {DEFAULT: '#80AE82', dark: '#5F8E5F'}
},
surface: {
DEFAULT: '#F6F6F6',
dark: '#3C3C3C',
variant: {DEFAULT: '#F4FFF4', dark: '#525252'}
},
},
fontFamily: {
display: ['Montserrat', 'sans-serif'],
body: ['Rubik', 'sans-serif'],
},
extend: {
borderWidth: {
'3': '3px',
},
fontSize: {
title: '40px',
},
},
},
plugins: [],
}

7
vite.config.js Normal file
View File

@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})