Skip to content
Open
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
25,682 changes: 7,882 additions & 17,800 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@
"private": true,
"dependencies": {
"@date-io/date-fns": "^1.3.13",
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-fontawesome": "^0.1.18",
"@fortawesome/fontawesome-svg-core": "^7.3.0",
"@fortawesome/free-regular-svg-icons": "^6.7.2",
"@fortawesome/free-solid-svg-icons": "^6.7.2",
"@fortawesome/react-fontawesome": "^0.1.19",
"@material-ui/core": "^4.12.4",
"@material-ui/pickers": "^3.3.10",
"@material-ui/pickers": "^3.3.11",
"@reduxjs/toolkit": "^1.5.1",
"@types/emoji-mart": "^3.0.5",
"@types/node": "^17.0.41",
"@types/react": "^16.9.0",
"@types/react": "^16.14.70",
"@types/react-redux": "^7.1.7",
"axios": "^0.27.2",
"axios": "^1.18.1",
"css-in-js-media": "^2.0.1",
"date-fns": "^2.28.0",
"date-fns": "^2.30.0",
"emoji-mart": "^3.0.1",
"file-loader": "^6.2.0",
"prettier": "^2.6.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.0",
"react-scripts": "5.0.1",
"react-scripts": "^5.0.1",
"sass": "^1.52.3",
"styled-components": "^5.3.5",
"styled-components": "^5.3.11",
"typescript": "^4.7.3",
"web-vitals": "^2.1.4"
},
Expand Down Expand Up @@ -55,8 +55,8 @@
]
},
"devDependencies": {
"@types/emoji-mart": "^3.0.9",
"@types/react-dom": "^18.0.5",
"@types/styled-components": "^5.1.25"
"@types/emoji-mart": "^3.0.14",
"@types/react-dom": "^18.3.7",
"@types/styled-components": "^5.1.36"
}
}
}
1 change: 1 addition & 0 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface Goal {
accountId: string
transactionIds: string[]
tagIds: string[]
icon: string | null;
}

export interface Tag {
Expand Down
12 changes: 8 additions & 4 deletions src/ui/components/EmojiPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { BaseEmoji, Picker } from 'emoji-mart'
// @ts-ignore
import 'emoji-mart/css/emoji-mart.css'
import React from 'react'
import { useAppSelector } from '../../store/hooks'
import { selectMode } from '../../store/themeSlice'

Expand All @@ -10,11 +12,13 @@ export default function EmojiPicker(props: Props) {

return (
<Picker
theme={theme}
theme={theme === 'dark' ? 'dark' : 'light'}
showPreview={false}
showSkinTones={false}
onClick={props.onClick}
color="primary"
onClick={(emoji: BaseEmoji, event: React.MouseEvent) => {
props.onClick(emoji, event)
}}
color="#FDD835"
/>
)
}
}
8 changes: 4 additions & 4 deletions src/ui/features/goalmanager/AddIconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { faSmile } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import 'date-fns'
import React from 'react'
import styled from 'styled-components'
import { TransparentButton } from '../../components/TransparentButton'
Expand All @@ -12,7 +11,7 @@ export default function AddIconButton(props: Props) {

return (
<Container>
<TransparentButton onClick={props.onClick}>
<TransparentButton onClick={props.onClick} type="button">
<FontAwesomeIcon icon={faSmile} size="2x" />
<Text>Add icon</Text>
</TransparentButton>
Expand All @@ -21,11 +20,12 @@ export default function AddIconButton(props: Props) {
}

const Container = styled.div`
display: flex;
flex-direction: row;
align-items: flex-end;
align-items: center;
`
const Text = styled.span`
margin-left: 0.6rem;
font-size: 1.5rem;
color: rgba(174, 174, 174, 1);
`
`
8 changes: 4 additions & 4 deletions src/ui/features/goalmanager/GoalIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'date-fns'
import React from 'react'
import styled from 'styled-components'
import { TransparentButton } from '../../components/TransparentButton'
Expand All @@ -7,13 +6,14 @@ type Props = { icon: string | null; onClick: (e: React.MouseEvent) => void }

export default function GoalIcon(props: Props) {
return (
<TransparentButton onClick={props.onClick}>
<TransparentButton onClick={props.onClick} type="button">
<Icon>{props.icon}</Icon>
</TransparentButton>
)
}

const Icon = styled.h1`
font-size: 6rem;
font-size: 4rem;
cursor: pointer;
`
margin: 0;
`
61 changes: 56 additions & 5 deletions src/ui/features/goalmanager/GoalManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { faCalendarAlt } from '@fortawesome/free-regular-svg-icons'
import { faDollarSign, IconDefinition } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { MaterialUiPickersDate } from '@material-ui/pickers/typings/date'
import { BaseEmoji } from 'emoji-mart'
import 'date-fns'
import React, { useEffect, useState } from 'react'
import styled from 'styled-components'
Expand All @@ -11,8 +12,12 @@ import { selectGoalsMap, updateGoal as updateGoalRedux } from '../../../store/go
import { useAppDispatch, useAppSelector } from '../../../store/hooks'
import DatePicker from '../../components/DatePicker'
import { Theme } from '../../components/Theme'
import AddIconButton from '../goalmanager/AddIconButton'
import GoalIcon from '../goalmanager/GoalIcon'
import EmojiPicker from '../../components/EmojiPicker'

type Props = { goal: Goal }

export function GoalManager(props: Props) {
const dispatch = useAppDispatch()

Expand All @@ -21,22 +26,28 @@ export function GoalManager(props: Props) {
const [name, setName] = useState<string | null>(null)
const [targetDate, setTargetDate] = useState<Date | null>(null)
const [targetAmount, setTargetAmount] = useState<number | null>(null)
const [icon, setIcon] = useState<string | null>(null)
const [emojiPickerIsOpen, setEmojiPickerIsOpen] = useState(false)

useEffect(() => {
setName(props.goal.name)
setTargetDate(props.goal.targetDate)
setTargetAmount(props.goal.targetAmount)
setIcon(props.goal.icon ?? null)
}, [
props.goal.id,
props.goal.name,
props.goal.targetDate,
props.goal.targetAmount,
props.goal.icon,
])

useEffect(() => {
setName(goal.name)
}, [goal.name])

const hasIcon = () => icon != null

const updateNameOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const nextName = event.target.value
setName(nextName)
Expand Down Expand Up @@ -75,10 +86,44 @@ export function GoalManager(props: Props) {
}
}

const addIconOnClick = (event: React.MouseEvent) => {
event.stopPropagation()
setEmojiPickerIsOpen(true)
}

const pickEmojiOnClick = (emoji: BaseEmoji, event: React.MouseEvent) => {
event.stopPropagation()
setIcon(emoji.native)
setEmojiPickerIsOpen(false)
const updatedGoal: Goal = {
...props.goal,
icon: emoji.native ?? null,
name: name ?? props.goal.name,
targetDate: targetDate ?? props.goal.targetDate,
targetAmount: targetAmount ?? props.goal.targetAmount,
}
dispatch(updateGoalRedux(updatedGoal))
updateGoalApi(props.goal.id, updatedGoal)
}

return (
<GoalManagerContainer>
<NameInput value={name ?? ''} onChange={updateNameOnChange} />

<AddIconButton hasIcon={hasIcon()} onClick={addIconOnClick} />

<GoalIconContainer shouldShow={hasIcon()}>
<GoalIcon icon={goal.icon ?? null} onClick={addIconOnClick} />
</GoalIconContainer>

<EmojiPickerContainer
isOpen={emojiPickerIsOpen}
hasIcon={hasIcon()}
onClick={(event) => event.stopPropagation()}
>
<EmojiPicker onClick={pickEmojiOnClick} />
</EmojiPickerContainer>

<Group>
<Field name="Target Date" icon={faCalendarAlt} />
<Value>
Expand Down Expand Up @@ -111,7 +156,6 @@ export function GoalManager(props: Props) {
}

type FieldProps = { name: string; icon: IconDefinition }
type AddIconButtonContainerProps = { shouldShow: boolean }
type GoalIconContainerProps = { shouldShow: boolean }
type EmojiPickerContainerProps = { isOpen: boolean; hasIcon: boolean }

Expand All @@ -131,7 +175,16 @@ const GoalManagerContainer = styled.div`
width: 100%;
position: relative;
`

const GoalIconContainer = styled.div<GoalIconContainerProps>`
display: ${(props) => (props.shouldShow ? 'flex' : 'none')};
`
const EmojiPickerContainer = styled.div<EmojiPickerContainerProps>`
display: ${(props) => (props.isOpen ? 'flex' : 'none')};
position: absolute;
top: ${(props) => (props.hasIcon ? '10rem' : '2rem')};
left: 0;
z-index: 100;
`
const Group = styled.div`
display: flex;
flex-direction: row;
Expand All @@ -148,7 +201,6 @@ const NameInput = styled.input`
font-weight: bold;
color: ${({ theme }: { theme: Theme }) => theme.text};
`

const FieldName = styled.h1`
font-size: 1.8rem;
margin-left: 1rem;
Expand Down Expand Up @@ -178,7 +230,6 @@ const StringInput = styled.input`
font-weight: bold;
color: ${({ theme }: { theme: Theme }) => theme.text};
`

const Value = styled.div`
margin-left: 2rem;
`
`
14 changes: 11 additions & 3 deletions src/ui/pages/Main/goals/GoalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default function GoalCard(props: Props) {

return (
<Container key={goal.id} onClick={onClick}>
{goal.icon && <Icon>{goal.icon}</Icon>}
<GoalName>{goal.name}</GoalName>
<TargetAmount>${goal.targetAmount}</TargetAmount>
<TargetDate>{asLocaleDateString(goal.targetDate)}</TargetDate>
</Container>
Expand All @@ -43,14 +45,20 @@ const Container = styled(Card)`
margin-left: 2rem;
margin-right: 2rem;
border-radius: 2rem;

align-items: center;
`
const Icon = styled.h1`
font-size: 5.5rem;
margin: 0;
`
const GoalName = styled.h3`
font-size: 1.2rem;
margin: 0.3rem 0;
`
const TargetAmount = styled.h2`
font-size: 2rem;
`

const TargetDate = styled.h4`
color: rgba(174, 174, 174, 1);
font-size: 1rem;
`
`
7 changes: 2 additions & 5 deletions src/ui/pages/Main/goals/GoalsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@ const Container = styled.div`
flex-direction: row;
justify-content: flex-start;
width: 400px;
padding: 4rem;
padding: 2rem 0;
overflow-x: auto;

${media('<tablet')} {
width: 100%;

padding-left: 0;
padding-right: 0;
}
`
`
29 changes: 19 additions & 10 deletions src/ui/pages/Main/goals/GoalsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { faPlusCircle } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import React, { useEffect } from 'react'
import React, { useEffect, useRef } from 'react'
import styled from 'styled-components'
import { createGoal as createGoalApi, getGoals } from '../../../../api/lib'
import { createGoal as createGoalRedux, selectGoalsList } from '../../../../store/goalsSlice'
Expand All @@ -17,18 +15,24 @@ import GoalsContent from './GoalsContent'
export default function GoalsSection() {
const dispatch = useAppDispatch()
const goalIds = useAppSelector(selectGoalsList)
const hasFetched = useRef(false)

useEffect(() => {
async function fetch() {
if (hasFetched.current) return
hasFetched.current = true

const fetchGoals = async () => {
const goals = await getGoals()
goals?.forEach((goal) => dispatch(createGoalRedux(goal)))
if (goals != null) {
const recentGoals = goals.slice(-10)
recentGoals.forEach((goal) => dispatch(createGoalRedux(goal)))
}
}
fetch()
fetchGoals()
}, [dispatch])

const onClick = async () => {
const goal = await createGoalApi()

if (goal != null) {
dispatch(createGoalRedux(goal))
dispatch(setContentRedux(goal))
Expand All @@ -41,11 +45,10 @@ export default function GoalsSection() {
<Container>
<TopGroup>
<SectionHeading>Goals</SectionHeading>
<Icon onClick={onClick}>
<FontAwesomeIcon icon={faPlusCircle} size="2x" className="alert" />
<Icon onClick={onClick} aria-label="Create goal">
<PlusCircleSvg />
</Icon>
</TopGroup>

<GoalsContent ids={goalIds} />
</Container>
)
Expand Down Expand Up @@ -77,3 +80,9 @@ const TopGroup = styled.div`
const Icon = styled.a`
margin-left: 1rem;
`

const PlusCircleSvg = () => (
<svg viewBox="0 0 448 512" width="20" height="20" fill="currentColor" aria-hidden="true">
<path d="M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32v112H80c-17.7 0-32 14.3-32 32s14.3 32 32 32h112v112c0 17.7 14.3 32 32 32s32-14.3 32-32V256h112c17.7 0 32-14.3 32-32s-14.3-32-32-32H256V80zM224 512C100.3 512 0 411.7 0 288S100.3 64 224 64s224 100.3 224 224-100.3 224-224 224z" />
</svg>
)
Empty file added tsc_err.txt
Empty file.
Empty file added tsc_out.txt
Empty file.
Loading