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,634 changes: 7,739 additions & 17,895 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"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": "^1.2.36",
"@fortawesome/free-regular-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.16",
"@material-ui/core": "^4.12.4",
"@material-ui/pickers": "^3.3.10",
"@reduxjs/toolkit": "^1.5.1",
Expand Down Expand Up @@ -59,4 +60,4 @@
"@types/react-dom": "^18.0.5",
"@types/styled-components": "^5.1.25"
}
}
}
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
2 changes: 1 addition & 1 deletion src/index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap');

@import '~emoji-mart/css/emoji-mart.css';
body {
margin: 0;
-webkit-font-smoothing: antialiased;
Expand Down
2 changes: 1 addition & 1 deletion src/store/goalsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const goalsSlice = createSlice({
reducers: {
createGoal: (state, action: PayloadAction<Goal>) => {
state.map[action.payload.id] = action.payload
state.list.push(action.payload.id)
state.list.unshift(action.payload.id)
},

updateGoal: (state, action: PayloadAction<Goal>) => {
Expand Down
7 changes: 5 additions & 2 deletions src/ui/features/goalmanager/GoalIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import React from 'react'
import styled from 'styled-components'
import { TransparentButton } from '../../components/TransparentButton'

type Props = { icon: string | null; onClick: (e: React.MouseEvent) => void }
type Props = {
icon: string
onClick: (e: React.MouseEvent) => void }

export default function GoalIcon(props: Props) {
return (
Expand All @@ -14,6 +16,7 @@ export default function GoalIcon(props: Props) {
}

const Icon = styled.h1`
font-size: 6rem;
font-size: 5.5rem;
cursor: pointer;
margin: 0;
`
73 changes: 73 additions & 0 deletions src/ui/features/goalmanager/GoalManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ 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 { Picker, EmojiData } from 'emoji-mart'
import AddIconButton from './AddIconButton'
import GoalIcon from './GoalIcon'

type Props = { goal: Goal }
export function GoalManager(props: Props) {
Expand All @@ -21,28 +24,39 @@ 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 [isEmojiPickerOpen, setIsEmojiPickerOpen] = useState(false)
const [icon, setIcon] = useState<string | null>(null)

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

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

useEffect(() => {
setIcon(goal.icon)
}, [goal.icon])

const updateNameOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const nextName = event.target.value
setName(nextName)
const updatedGoal: Goal = {
...props.goal,
name: nextName,
targetDate: targetDate ?? props.goal.targetDate,
targetAmount: targetAmount ?? props.goal.targetAmount,
icon: icon ?? props.goal.icon,
}
dispatch(updateGoalRedux(updatedGoal))
updateGoalApi(props.goal.id, updatedGoal)
Expand All @@ -56,6 +70,7 @@ export function GoalManager(props: Props) {
name: name ?? props.goal.name,
targetDate: targetDate ?? props.goal.targetDate,
targetAmount: nextTargetAmount,
icon: icon ?? props.goal.icon,
}
dispatch(updateGoalRedux(updatedGoal))
updateGoalApi(props.goal.id, updatedGoal)
Expand All @@ -69,15 +84,58 @@ export function GoalManager(props: Props) {
name: name ?? props.goal.name,
targetDate: date ?? props.goal.targetDate,
targetAmount: targetAmount ?? props.goal.targetAmount,
icon: icon ?? props.goal.icon,
}
dispatch(updateGoalRedux(updatedGoal))
updateGoalApi(props.goal.id, updatedGoal)
}
}



const selectEmoji = (emoji: EmojiData) => {
if (!('native' in emoji)) return

const nextIcon = emoji.native
setIcon(nextIcon)
setIsEmojiPickerOpen(false)

const updatedGoal: Goal = {
...props.goal,
name: name ?? props.goal.name,
targetDate: targetDate ?? props.goal.targetDate,
targetAmount: targetAmount ?? props.goal.targetAmount,
icon: nextIcon,
}

dispatch(updateGoalRedux(updatedGoal))
updateGoalApi(props.goal.id, updatedGoal)
}
const hasIcon = () => icon != null

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

return (
<GoalManagerContainer>
<NameInput value={name ?? ''} onChange={updateNameOnChange} />
<GoalIconContainer shouldShow={hasIcon()}>
{icon && <GoalIcon icon={icon} onClick={addIconOnClick} />}
</GoalIconContainer>

<AddIconButtonContainer shouldShow={!hasIcon()}>
<AddIconButton hasIcon={!!icon} onClick={addIconOnClick} />
</AddIconButtonContainer>


{isEmojiPickerOpen && (

<EmojiPickerContainer isOpen={isEmojiPickerOpen} hasIcon={!!icon}>
<Picker onSelect={selectEmoji} />
</EmojiPickerContainer>
)}

<Group>
<Field name="Target Date" icon={faCalendarAlt} />
Expand Down Expand Up @@ -182,3 +240,18 @@ const StringInput = styled.input`
const Value = styled.div`
margin-left: 2rem;
`
const GoalIconContainer = styled.div<GoalIconContainerProps>`
display: ${({ shouldShow }) => (shouldShow ? 'flex' : 'none')};
font-size: 3rem;
margin-top: 1rem;
margin-bottom: 1rem;
`

const EmojiPickerContainer = styled.div<EmojiPickerContainerProps>`
display: ${({ isOpen }) => (isOpen ? 'block' : 'none')};
margin-top: 1rem;
z-index: 10;
`
const AddIconButtonContainer = styled.div<AddIconButtonContainerProps>`
display: ${({ shouldShow }) => (shouldShow ? 'flex' : 'none')};
`
5 changes: 4 additions & 1 deletion src/ui/pages/Main/goals/GoalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
import { Card } from '../../../components/Card'

type Props = { id: string }

const Icon = styled.h1`
font-size: 5.5rem;
`
export default function GoalCard(props: Props) {
const dispatch = useAppDispatch()

Expand All @@ -27,6 +29,7 @@ export default function GoalCard(props: Props) {

return (
<Container key={goal.id} onClick={onClick}>
<Icon>{goal.icon}</Icon>
<TargetAmount>${goal.targetAmount}</TargetAmount>
<TargetDate>{asLocaleDateString(goal.targetDate)}</TargetDate>
</Container>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/surfaces/drawer/Drawer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { faChartLine, faGear, faRocket } from '@fortawesome/free-solid-svg-icons'
import { faChartLine, faCog, faRocket } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import React from 'react'
import styled from 'styled-components'
Expand Down Expand Up @@ -26,7 +26,7 @@ export default function Navbar() {

<Section>
<DrawerItem isSelected={false}>
<FontAwesomeIcon icon={faGear} size="2x" />
<FontAwesomeIcon icon={faCog} size="2x" />
<span>Settings</span>
</DrawerItem>
</Section>
Expand Down