Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/df 105 light dark mode #28

Merged
merged 12 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# DoughFin_FE

## Introduction
DoughFin is a user-friendly financial management app designed to help individuals effortlessly track their income, categorize expenses, and create budgets. With DoughFin, managing your finances becomes intuitive, empowering you to make informed decisions about your money.

![alt text](<Screen Shot 2024-02-29 at 2.20.26 PM.png>)

## Features
**Income Tracking:** Automatically track your income from various sources to see how much you're earning.<br>
**Expense Categorization:** Automatically categorize your expenses for a clearer understanding of your spending habits.<br>
**Budget Creation:** Set up personalized budgets to control your spending and achieve your financial goals.<br>
**Insightful Reports:** Get detailed reports and insights into your financial health, helping you make better financial decisions.<br>
**Secure Account Linking:** Safely link your bank account(s) for real-time transaction updates.
**Light & Dark Mode** Use the toggle on the left hand navbar to toggle between light and dark mode!

### Setup & Installation

Get **DoughFin** running on your machine:
Expand Down Expand Up @@ -37,3 +50,8 @@ npm cypress open
[mui](https://www.npmjs.com/package/@mui/material)
[graphql](https://www.npmjs.com/package/graphql)
[cypress](https://www.npmjs.com/package/cypress)


## Acknowledgments
Thank you to all the contributors who have helped shape DoughFin.
Special thanks to our users for trusting us with their financial management needs.
Binary file added Screen Shot 2024-02-29 at 2.20.26 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions cypress/e2e/light_dark_mode_spec.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe('Light and Dark Mode', () => {
it('switches between light and dark mode successfully', () => {
cy.visit('http://localhost:3003');
cy.viewport(1440, 900);
cy.get('.app').should('have.attr', 'id', 'dark');

// Test for Light Mode
cy.get('.react-switch-handle').click();
cy.get('.app').should('have.attr', 'id', 'light');

// Test for Dark Mode
cy.get('.react-switch-handle').click();
cy.get('.app').should('have.attr', 'id', 'dark');
});
});
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"react-dom": "^18.2.0",
"react-query": "^3.39.3",
"react-scripts": "5.0.1",
"react-switch": "^7.0.0",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
126 changes: 126 additions & 0 deletions src/components/App/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,130 @@
align-items: center;
background: #141332;
overflow: hidden;
}

/* Light mode settings */
#light .app {
background-color: #fafafa
}
#light .navbar {
background-color: #fafafa
}
#light .cashflow {
background-color: #fafafa
}
#light .add-transx-container {
background-color: #fafafa
}
#light .transactions {
background-color: #fafafa
}
#light .transactions-table-container {
background-color: #fafafa
}
#light .table-scroll {
background-color: #fafafa
}
#light .budget {
background-color: #fafafa
}
#light .budget-header {
background-color: #fafafa
}
#light .budget-pie-chart {
background-color: #fafafa
}
#light .budget-percentage-breakdown {
background-color: #fafafa
}
#light .logo-text {
color: #141332
}
#light .user-details {
color: #141332
}
#light .cashflow-h1 {
color: #141332
}
#light .cashflow-header-text {
color: #141332
}
#light .transx-text {
color: #141332
}
#light .transx-amount {
color: #141332
}
#light .transactions-h1 {
color: #141332
}
#light .transactions-tr {
color: #141332
}
#light .budget-header {
color: #141332
}
#light .percentage-description {
color: #141332
}
#light .percentage {
color: #141332
}
#light .budget-details-h3 {
color: #141332
}
#light .budget-categories-h3 {
color: #141332
}
#light {
background-color:#8AAAE5
}

/* Dark Mode Settings */
#dark .app {
background-color: #141332
}
#dark .navbar {
background-color: #141332
}
#dark .cashflow {
background-color: #141332
}
#dark .dashboard-totals-container {
background-color: #141332
}
#dark .transactions {
background-color: #141332
}
#dark .transactions-table-container {
background-color: #141332
}
#dark .table-scroll {
background-color: #141332
}
#dark .budget {
background-color: #141332
}
#dark .budget-header {
background-color: #141332
}
#dark .budget-pie-chart {
background-color: #141332
}
#dark .budget-percentage-breakdown {
background-color: #141332
}
#dark {
background-color:#141332
}

/* Switch label */
.switch{
margin: 10px;
}
#light .switch label{
color: black;
}
#dark .switch label{
color: white;
}
34 changes: 22 additions & 12 deletions src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { useGetExpenses } from '../apollo-client/queries/getExpenses';
import { useGetTransactions } from '../apollo-client/queries/getTransactions';
import { useGetCashFlow } from '../apollo-client/queries/getCashFlow';
import { useGetBudgetsByParams } from '../apollo-client/queries/getBudgetsByParams';
import { createContext } from "react";

export const ThemeContext = createContext("null");

const App = () => {
const [transactions, setTransactions] = useState([]);
Expand Down Expand Up @@ -48,19 +51,26 @@ const App = () => {
// if (budgetsData) setBudgets(budgetsData);
}, [totalIncomeData, totalExpensesData, transactionsData, cashFlowData]);

const [theme, setTheme] = useState("dark")
const toggleTheme = () => {
setTheme((curr) => (curr == "light" ? "dark" : "light"));
}

return (
<main className='app'>
<NavBar userName={userName} />
<Dashboard
cashFlow={cashFlow}
transactions={transactions}
setTransactions={setTransactions}
totalIncome={totalIncome}
setTotalIncome={setTotalIncome}
totalExpenses={totalExpenses}
setTotalExpenses={setTotalExpenses}
/>
</main>
<ThemeContext.Provider value={{ theme, toggleTheme }}>
<main className='app' id={theme}>
<NavBar userName={userName} onToggle={toggleTheme} theme={theme} />
<Dashboard
cashFlow={cashFlow}
transactions={transactions}
setTransactions={setTransactions}
totalIncome={totalIncome}
setTotalIncome={setTotalIncome}
totalExpenses={totalExpenses}
setTotalExpenses={setTotalExpenses}
/>
</main>
</ThemeContext.Provider>
)
}

Expand Down
7 changes: 6 additions & 1 deletion src/components/NavBar/NavBar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import ReactSwitch from "react-switch";
import './NavBar.css'
import UserPic from '../../assets/icons/user-icon.png'
import BarIcon from '../../assets/icons/bar-icon.svg'
Expand All @@ -7,7 +8,7 @@ import GridIcon from '../../assets/icons/grid-icon.svg'
import SettingsIcon from '../../assets/icons/settings-icon.svg'
import UserIcon from '../../assets/icons/user-icon.svg'

const NavBar = ({userName}) => {
const NavBar = ({userName, onToggle, theme}) => {
return (
<nav className='navbar'>
<aside className='nav-button-container'>
Expand All @@ -33,6 +34,10 @@ const NavBar = ({userName}) => {
<p className='navbar-button-text'>Settings</p>
</button>
<div style={{width: '100%', height: '0%', border: '1px #8C89B4 solid'}}></div>
<div className = "switch">
<ReactSwitch onChange={onToggle} checked={theme === "dark"}/>
<label> {theme == "light" ? "Light Mode" : "Dark Mode"}</label>
</div>
</section>
</aside>
<section className='user-icon'>
Expand Down
Loading