-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(coscrad-frontend): support a presenter for the term of the day (#…
…323) * WIP - term of the day component * WIP - changes from PR 323 * WIP - added term-of-the-day component * WIP - updated term of the day with prettier * Use term of day container in home * complete data flow for term of the day * style(coscrad-frontend): add mui styled component for term of the day * style(coscrad-frontend): update styled component from suggestions on PR --------- Co-authored-by: Aaron Plahn <[email protected]>
- Loading branch information
1 parent
25fce04
commit d7286bf
Showing
9 changed files
with
136 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
"trailingComma": "es5", | ||
"tabWidth": 4, | ||
"singleQuote": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
apps/coscrad-frontend/src/components/term-of-the-day/term-of-the-day-styled.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { styled } from '@mui/material'; | ||
|
||
export const StyledTermOfTheDay = styled('div')({ | ||
textAlign: 'center', | ||
display: 'inline-flex', | ||
flexDirection: 'column', | ||
width: '100%', | ||
padding: '20px 0 20px 0', | ||
}); |
26 changes: 26 additions & 0 deletions
26
apps/coscrad-frontend/src/components/term-of-the-day/term-of-the-day.container.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useContext } from 'react'; | ||
import { ConfigurableContentContext } from '../../configurable-front-matter/configurable-content-provider'; | ||
import { useLoadableTermById } from '../../store/slices/resources'; | ||
import { displayLoadableSearchResult } from '../higher-order-components/display-loadable-search-result'; | ||
import { TermOfTheDayPresenter } from './term-of-the-day.presenter'; | ||
import { useDate } from './use-date'; | ||
|
||
export const TermOfTheDayContainer = (): JSX.Element => { | ||
const { termOfTheDayConfig } = useContext(ConfigurableContentContext); | ||
|
||
const monthAndDate = useDate(); | ||
|
||
const termOfTheDayId = termOfTheDayConfig[monthAndDate.date.toString()]; | ||
|
||
const loadableTermSearchResult = useLoadableTermById(termOfTheDayId); | ||
|
||
const Presenter = displayLoadableSearchResult( | ||
TermOfTheDayPresenter, | ||
(loadableTermSearchResult) => ({ | ||
termProps: loadableTermSearchResult, | ||
monthAndDate, | ||
}) | ||
); | ||
|
||
return <Presenter {...loadableTermSearchResult} />; | ||
}; |
25 changes: 25 additions & 0 deletions
25
apps/coscrad-frontend/src/components/term-of-the-day/term-of-the-day.presenter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ICategorizableDetailQueryResult, ITermViewModel } from '@coscrad/api-interfaces'; | ||
import { Typography } from '@mui/material'; | ||
import { TermDetailFullViewPresenter } from '../resources/terms/term-detail.full-view.presenter'; | ||
import { StyledTermOfTheDay } from './term-of-the-day-styled'; | ||
import { MonthAndDate } from './use-date'; | ||
|
||
interface TermOfTheDayPresenterProps { | ||
termProps: ICategorizableDetailQueryResult<ITermViewModel>; | ||
monthAndDate: MonthAndDate; | ||
} | ||
|
||
export const TermOfTheDayPresenter = ({ | ||
monthAndDate: { month, date }, | ||
termProps, | ||
}: TermOfTheDayPresenterProps): JSX.Element => { | ||
return ( | ||
<StyledTermOfTheDay> | ||
<Typography variant="h3">Term of the day</Typography> | ||
<TermDetailFullViewPresenter {...termProps} /> | ||
<Typography variant="h4"> | ||
{month} {date} | ||
</Typography> | ||
</StyledTermOfTheDay> | ||
); | ||
}; |
30 changes: 30 additions & 0 deletions
30
apps/coscrad-frontend/src/components/term-of-the-day/use-date.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const months = [ | ||
'January', | ||
'February', | ||
'March', | ||
'April', | ||
'May', | ||
'June', | ||
'July', | ||
'August', | ||
'September', | ||
'October', | ||
'November', | ||
'December', | ||
] as const; | ||
|
||
export type Month = typeof months[number]; | ||
|
||
export type MonthAndDate = { | ||
month: Month; | ||
date: number; | ||
}; | ||
|
||
export function useDate(): MonthAndDate { | ||
const currentDate = new Date(); | ||
|
||
return { | ||
month: months[currentDate.getMonth()], | ||
date: currentDate.getDate(), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters