Skip to content

Commit

Permalink
Migration #9
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikkabade committed Mar 28, 2024
1 parent 5faeee8 commit 7d554c4
Show file tree
Hide file tree
Showing 17 changed files with 514 additions and 201 deletions.
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import './styles/App.css';
import './styles/Tailwind.css';
import './styles/Animations.css';
import { ProjectRoutes } from './routes/Routes';
import { NewHome } from './pages/NewHome';

function App() {
return (
<div className='bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-200'>
<ProjectRoutes />
{/* <ProjectRoutes /> */}
<NewHome />
</div>
);
}
Expand Down
35 changes: 35 additions & 0 deletions src/components/AnimatedLoader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { LoadingTransactionItem } from "./core/LoadingTransactionItem"

export const AnimatedLoader = () => {
return (
<div>
<div className="flex flex-col w-full text-4xl font-bold text-center select-none py-10 fade-in scrl">
<div>
Total:
<span className="bg-slate-200 text-slate-200 mx-2 rounded-xl animate-pulse">sum</span>
</div>
<div className="flex justify-center w-full text-4xl font-bold text-center items-center">
<div className="flex flex-row flex-wrap justify-around text-lg font-bold my-5">
<p className="bg-slate-50 text-slate-100 p-2 px-10 m-1 rounded-full hover:shadow-md cursor-pointer animate-pulse">
<i className="fa-solid fa-filter mr-2"></i>
Category
</p>
<p className="bg-slate-50 text-slate-100 p-2 px-10 m-1 rounded-full hover:shadow-md cursor-pointer animate-pulse">
<i className="fa-solid fa-filter mr-2"></i>
Account
</p>
</div>
</div>
<div className="flex flex-wrap flex-row mx-auto justify-center items-center">
<div className="flex justify-center flex-wrap slide-r">
<LoadingTransactionItem />
<LoadingTransactionItem />
<LoadingTransactionItem />
<LoadingTransactionItem />
</div>

</div>
</div>
</div>
)
}
12 changes: 5 additions & 7 deletions src/components/LoadingComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AnimatedLoader } from "./AnimatedLoader"

export const LoadingComponent = () => {

// fetch url from local storage
Expand All @@ -23,14 +25,10 @@ export const LoadingComponent = () => {
else {
return (
<div className="container my-32 flex flex-wrap flex-col mx-auto justify-center items-center text-center text-4xl font-bold">
<div id="chn1" className="flex flex-row align-center">Loading
<div id="chn1">

<div role="status" className="mx-3 mt-0.5">
<svg aria-hidden="true" className="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor" />
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill" />
</svg>
<span className="sr-only">Loading...</span>
<div className="-my-32">
<AnimatedLoader />
</div>

</div>
Expand Down
55 changes: 55 additions & 0 deletions src/components/buttons/AccountFilterButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Modal } from "flowbite-react"
import { useState } from "react";
import { AccountFilter } from "../../hooks/AccountFilter";

type accountProp = {
currentData: any;
accountC: string;
setAccountC: React.Dispatch<React.SetStateAction<string>>;
}

export const AccountFilterButton = (accountProps: accountProp) => {
const [openModal, setOpenModal] = useState<string | undefined>();
const props = { openModal, setOpenModal };

// listen to escape key
window.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
setOpenModal('false');
}
});

return (
<div>
<div
onClick={() => (
props.setOpenModal('default')
)}>
<p className="bg-slate-50 p-2 px-10 m-1 rounded-full hover:shadow-md cursor-pointer fade-in">
<i className="fa-solid fa-filter mr-2"></i>
Account
</p>
</div>

<Modal dismissible className="fade-in h-screen" show={props.openModal === 'default'} onClose={() => props.setOpenModal(undefined)}>
<Modal.Header className="bg-slate-100">
Select the Account
</Modal.Header>
<Modal.Body className="slide-up scrl2">
<div className="flex justify-between mt-5">
<AccountFilter
dataBase={accountProps.currentData}
accountC={accountProps.accountC}
setAccountC={accountProps.setAccountC} />
</div>
</Modal.Body>

<Modal.Footer className="flex justify-around items-center bg-slate-100">

<button onClick={() => setOpenModal('false')} type="button" className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800">Save</button>

</Modal.Footer>
</Modal>
</div>
)
}
56 changes: 56 additions & 0 deletions src/components/buttons/CategoryFilterButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Modal } from "flowbite-react"
import { useState } from "react";
import { CategoryFilter } from "../../hooks/CategoryFilter";

type categoryProp = {
currentData: any;
categoryC: string;
setCategoryC: React.Dispatch<React.SetStateAction<string>>;
}

export const CategoryFilterButton = (categoryProps: categoryProp) => {
const [openModal, setOpenModal] = useState<string | undefined>();
const props = { openModal, setOpenModal };

// listen to escape key
window.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
setOpenModal('false');
}
});

return (
<div>
<div
onClick={() => (
props.setOpenModal('default')
)}>
<p className="bg-slate-50 p-2 px-10 m-1 rounded-full hover:shadow-md cursor-pointer fade-in">
<i className="fa-solid fa-filter mr-2"></i>
Category
</p>
</div>

<Modal dismissible className="fade-in h-screen" show={props.openModal === 'default'} onClose={() => props.setOpenModal(undefined)}>
<Modal.Header className="bg-slate-100">
Select the Category
</Modal.Header>
<Modal.Body className="slide-up scrl2">
<div className="flex justify-between mt-5">
<CategoryFilter
dataBase={categoryProps.currentData}
categoryC={categoryProps.categoryC}
setCategoryC={categoryProps.setCategoryC} />
</div>
</Modal.Body>
<Modal.Footer className="flex justify-around items-center bg-slate-100">

<button onClick={() => setOpenModal('false')} type="button" className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800">
Close
</button>

</Modal.Footer>
</Modal>
</div>
)
}
37 changes: 37 additions & 0 deletions src/components/buttons/RemoveAccountButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { androidColorToHex } from "../../utils/AndroidColorToHex";

type removeAccountProp = {
accountC: string;
setAccountC: React.Dispatch<React.SetStateAction<string>>;
}

export const RemoveAccountButton = (props: removeAccountProp) => {

// fetch color from theData and set it to the backgroundColor
const data = () => {
const theData = localStorage.getItem('theData');
if (theData !== null) {
const parsedData = JSON.parse(theData);
console.log(parsedData)
const account = parsedData.accounts.filter((item: any) => item.name === props.accountC);
return account[0].color
}

return ''

}

// convert android color to hex
const color = androidColorToHex(data())


return (
<p
onClick={() => props.setAccountC('')}
className="p-2 px-10 m-1 rounded-full hover:shadow-md cursor-pointer fade-in"
style={{ backgroundColor: color }}>
{props.accountC}
<i className="fa-solid fa-x ml-2"></i>
</p>
)
}
37 changes: 37 additions & 0 deletions src/components/buttons/RemoveCategoryButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { androidColorToHex } from "../../utils/AndroidColorToHex";

type removeCategoryProp = {
categoryC: string;
setCategoryC: React.Dispatch<React.SetStateAction<string>>;
}

export const RemoveCategoryButton = (props: removeCategoryProp) => {

// fetch color from theData and set it to the backgroundColor
const data = () => {
const theData = localStorage.getItem('theData');
if (theData !== null) {
const parsedData = JSON.parse(theData);
const category = parsedData.categories.filter((item: any) => item.name === props.categoryC);
return category[0].color
}


return ''

}

// convert android color to hex
const color = androidColorToHex(data())


return (
<p
onClick={() => props.setCategoryC('')}
className="p-2 px-10 m-1 rounded-full hover:shadow-md cursor-pointer fade-in"
style={{ backgroundColor: color }}>
{props.categoryC}
<i className="fa-solid fa-x ml-2"></i>
</p>
)
}
57 changes: 57 additions & 0 deletions src/components/buttons/SettingsButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { useState } from "react";
import { Modal } from "flowbite-react";
import { JSONdata } from "../../services/JSONdata";
import { ClearData } from "../data/ClearData";
import DarkModeButton from "../layout/DarkModeButton";

export const SettingsButton = () => {
const [openModal, setOpenModal] = useState<string | undefined>();
const props = { openModal, setOpenModal };

// listen to escape key
window.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
setOpenModal('false');
}
});

return (
<>
<div className="flex flex-row align-middle justify-center items-center lg:w-48 max-lg:w-fit max-lg:h-fit p-5 m-1 rounded-2xl hover:shadow-sm cursor-pointer hover:brightness-95 transition duration-300 ease-in-out bg-slate-50 text-xl font-bold"
onClick={() => (
props.setOpenModal('default')
)}>
<i className='fas fa-cog mr-2 max-lg:mr-0'></i>
<div className="max-lg:hidden">
Settings
</div>
</div>

<Modal className="fade-in h-screen" show={props.openModal === 'default'} onClose={() => props.setOpenModal(undefined)}>
<Modal.Header className="bg-slate-100">
Settings
</Modal.Header>
<Modal.Body className="slide-up scrl2">
<div className="flex flex-col mt-5">
<div className="bg-sky-100 m-1 p-3 rounded-xl cursor-pointer hover:brightness-95">
<DarkModeButton />
</div>
<div className="bg-sky-100 m-1 p-3 rounded-xl">
<JSONdata />
</div>
<div className="bg-sky-100 m-1 p-3 rounded-xl">
<ClearData />
</div>
</div>
</Modal.Body>
<Modal.Footer className="flex justify-around items-center bg-slate-100">

<button onClick={() => setOpenModal('false')} type="button" className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800">
Close
</button>

</Modal.Footer>
</Modal>
</>
)
}
15 changes: 0 additions & 15 deletions src/components/core/Button.tsx

This file was deleted.

44 changes: 44 additions & 0 deletions src/components/core/LoadingTransactionItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const LoadingTransactionItem = () => {
return (
<div>
<div className="p-5 lg:w-96 md:w-72 m-5 bg-slate-100 dark:bg-slate-800 rounded-2xl hover:shadow-lg cursor-default">
<p
className="text-xl font-bold bg-slate-200 text-slate-200 mx-2 rounded-t-xl animate-pulse w-32">
March 01
</p>
<p
className="text-sm font-medium bg-slate-200 text-slate-200 mx-2 rounded-b-xl animate-pulse w-32">
Friday
</p>

<div className="flex flex-row flex-wrap justify-around text-lg font-bold my-5">
<div>
<p className="bg-green-200 text-green-200 p-2 px-10 m-1 rounded-full hover:shadow-md cursor-pointer animate-pulse">
Category
</p>
</div>
<div>
<p className="bg-sky-200 text-sky-200 p-2 px-10 m-1 rounded-full hover:shadow-md cursor-pointer animate-pulse">
Account
</p>
</div>
</div>

<p className="text-2xl font-bold my-3 bg-slate-200 text-slate-200 mx-2 rounded-xl animate-pulse">
title
</p>
<p className="bg-slate-200 text-slate-200 mx-2 rounded-xl animate-pulse my-3">
description
</p>
<p className='text-5xl font-extrabold ml-12 flex flex-wrap bg-slate-200 text-slate-200 mx-2 rounded-xl animate-pulse'>
asds
<abbr
className="font-normal ml-2">
asd
</abbr>
</p>
</div>

</div>
)
}
Loading

0 comments on commit 7d554c4

Please sign in to comment.