Skip to content

Commit

Permalink
feat: [skip ci] Add goal icon and functionality to calendar title
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed Dec 9, 2023
1 parent 1b1eb0c commit 63a980e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
25 changes: 24 additions & 1 deletion src/Agenda3/components/MainArea.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { LeftOutlined, RightOutlined } from '@ant-design/icons'
import { Button, Segmented } from 'antd'
import dayjs from 'dayjs'
import { useAtom, useAtomValue } from 'jotai'
import { useRef, useState } from 'react'
import { FiSettings, FiXCircle } from 'react-icons/fi'
import { GoGoal } from 'react-icons/go'
import { LuCalendarDays, LuKanbanSquare } from 'react-icons/lu'

import { track } from '@/Agenda3/helpers/umami'
Expand Down Expand Up @@ -61,6 +63,20 @@ const MultipleView = ({ className }: { className?: string }) => {
})
track('View Change', { view: view })
}
const onClickGoal = () => {
const type = calendarRef.current?.getView() === 'dayGridMonth' ? 'month' : 'week'
const date = calendarRef.current?.getDate()
const day = dayjs(date)
setApp((_app) => ({
..._app,
sidebarType: 'objective',
objectivePeriod: {
type,
number: type === 'month' ? day.month() + 1 : day.week(),
year: day.year(),
},
}))
}

return (
<div className={cn('relative z-0 flex w-0 flex-1 flex-col py-1 pl-2', className)}>
Expand Down Expand Up @@ -92,7 +108,14 @@ const MultipleView = ({ className }: { className?: string }) => {
<Button className="!bg-transparent" shape="round" onClick={onClickToday}>
Today
</Button>
{app.view === 'calendar' ? <h1 className="ml-3 text-xl font-medium">{calendarTitle}</h1> : null}
{app.view === 'calendar' ? (
<h1 className="ml-3 flex items-center gap-1 text-xl font-medium">
{calendarTitle}
<div className="cursor-pointer text-gray-400 hover:text-gray-700" onClick={onClickGoal}>
<GoGoal />
</div>
</h1>
) : null}
</div>
<div className="flex items-center gap-3">
{app.view === 'calendar' ? (
Expand Down
8 changes: 8 additions & 0 deletions src/Agenda3/components/calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ const Calendar = ({ onCalendarTitleChange }: CalendarProps, ref) => {
changeView: (view: CalendarView) => {
calendarApi?.changeView(view)
},
getView: () => {
return calendarApi?.view.type
},
getDate: () => {
return calendarApi?.getDate()
},
navToday: () => {
calendarApi?.today()
},
Expand Down Expand Up @@ -297,6 +303,8 @@ const Calendar = ({ onCalendarTitleChange }: CalendarProps, ref) => {
export type CalendarHandle = {
prev: () => void
next: () => void
getView: () => CalendarView
getDate: () => Date
changeView: (view: CalendarView) => void
navToday: () => void
}
Expand Down
5 changes: 4 additions & 1 deletion src/Agenda3/components/calendar/WeekNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const WeekNumber = ({ weekNumber, date }: { weekNumber: number; date: Date }) =>
}))
}
return (
<div onClick={onClick} className="faiz-week-number flex cursor-pointer items-center gap-1 text-xs">
<div
onClick={onClick}
className="faiz-week-number flex cursor-pointer items-center gap-1 text-xs hover:text-gray-900"
>
W{weekNumber}
<GoGoal />
</div>
Expand Down

0 comments on commit 63a980e

Please sign in to comment.