Skip to content

Budget Tracker is a single-page-application that assists keeping track of respective budgets and expenses.

Notifications You must be signed in to change notification settings

jsadsad/Budget-Tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Budget Tracker

This react application is a budgets and expenses tracker that is useful on the go whether it be for travel, groceries, or shopping.

Simply create a budget with a max amount, and accordingly add expenses to the budget which will indicate how close you are to your desired maximum.

Budget Tracker is built as a single-page-application using hooks and styled with react-bootstrap keeping accessibility in mind. A Dark Theme is additionally implemented using context for better accessibility.

Deployed on Netlify.

Landing New Budget Expense Details

Code Snippets

  1. hooks for state and context management
const [showAddBudgetModal, setShowAddBudgetModal] = useState(false)
const [showAddExpenseModal, setShowAddExpenseModal] = useState(false)
const [viewExpensesModalBudgetId, setViewExpensesModalBudgetId] = useState()
const [addExpenseModalBudgetId, setAddExpenseModalId] = useState()

const { budgets, getBudgetExpenses } = useBudgets()
const { theme, textColor } = useThemes()
  1. Creating a custom hook to persist values in localStorage
const useLocalStorage = (key, defaultValue) => {
  const [value, setValue] = useState(() => {
    const jsonValue = localStorage.getItem(key)
    if (jsonValue !== null) return JSON.parse(jsonValue)

    if (typeof defaultValue === 'function') return defaultValue
    else return defaultValue
  })

  useEffect(() => {
    localStorage.setItem(key, JSON.stringify(value))
  }, [key, value])

  return [value, setValue]
}
  1. Dark Theme Implementation
const Layout = ({ children }) => {
  const { theme } = useThemes()

  const background =
    theme === 'dark'
      ? 'body {background-color: #404042; color: gray;}'
      : 'body {background-color: #fff; color: #000;}'

  return (
    <>
      <style>{background}</style>
      {children}
    </>
  )
}

Resources

  1. Web Dev Simplified
  2. react-bootstrap
  3. Dark Mode

About

Budget Tracker is a single-page-application that assists keeping track of respective budgets and expenses.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published