Skip to content

Commit

Permalink
Create Tasks layout for switching view mode
Browse files Browse the repository at this point in the history
  • Loading branch information
negreirosleo committed Jan 18, 2024
1 parent bccb653 commit 6aa70e0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 3 deletions.
3 changes: 0 additions & 3 deletions frontend/src/app/tasks/DayView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const DayView = ({ projects, taskTypes, templates }: DayViewProps) => {
return (
<Box
sx={{
padding: { xs: '0 8px', sm: '0 32px' },
display: 'grid',
gridTemplateAreas: {
xs: "'select-template start-timer''divider divider''create-task-form create-task-form''task-list task-list'",
Expand All @@ -32,8 +31,6 @@ export const DayView = ({ projects, taskTypes, templates }: DayViewProps) => {
xs: '1fr',
sm: '558px 558px'
},
margin: '0 auto',
maxWidth: '1146px',
columnGap: '30px',
rowGap: '16px'
}}
Expand Down
57 changes: 57 additions & 0 deletions frontend/src/app/tasks/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use client'

import { PropsWithChildren } from 'react'
import { Tabs, TabList, Tab, Box, Divider } from '@mui/joy'
import Link from 'next/link'
import { usePathname } from 'next/navigation'

export default function TasksLayout({ children }: PropsWithChildren) {
const pathname = usePathname()

return (
<Box
sx={{
display: 'grid',
padding: { xs: '0 8px', sm: '0' },
margin: '0 auto',
maxWidth: '1146px',
rowGap: '16px'
}}
>
<Tabs
sx={{
borderRadius: '8px',
border: '1px solid #C4C6D0',
width: 'fit-content',
paddding: '1px'
}}
size="md"
value={pathname}
>
<TabList disableUnderline>
<TimeViewTab path="/tasks">Day</TimeViewTab>
<TimeViewTab path="/tasks/week">Week</TimeViewTab>
<TimeViewTab path="/tasks/month">Month</TimeViewTab>
</TabList>
</Tabs>
<Divider />
{children}
</Box>
)
}

const TimeViewTab = ({ children, path }: PropsWithChildren<{ path: string }>) => {
return (
<Link href={path}>
<Tab
sx={{ borderRadius: '7px' }}
value={path}
variant="plain"
color="primary"
disableIndicator
>
{children}
</Tab>
</Link>
)
}
3 changes: 3 additions & 0 deletions frontend/src/app/tasks/month/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function MonthView() {
return <div>Month!</div>
}
3 changes: 3 additions & 0 deletions frontend/src/app/tasks/week/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default async function WeekView() {
return <div>Week!</div>
}

0 comments on commit 6aa70e0

Please sign in to comment.