-
-
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: move recent videos seniority setting to recent view actions
- Loading branch information
Showing
8 changed files
with
134 additions
and
43 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
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
93 changes: 93 additions & 0 deletions
93
src/ui/components/pages/Home/TabActions/RecentViewActions/RecentVideosSeniority.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,93 @@ | ||
import React, { useState } from 'react'; | ||
import { IconButton } from '@mui/material'; | ||
import { StyledMenu, CheckableMenuItem } from 'ui/components/shared'; | ||
import { useAppDispatch, useAppSelector } from 'store'; | ||
import HistoryIcon from '@mui/icons-material/History'; | ||
import { selectRecentVideosSeniority } from 'store/selectors/settings'; | ||
import { setSettings } from 'store/reducers/settings'; | ||
import { Nullable, VideosSeniority } from 'types'; | ||
|
||
interface RecentVideosSeniorityProps {} | ||
|
||
const options = [ | ||
{ | ||
label: '1 day', | ||
value: VideosSeniority.OneDay, | ||
}, | ||
{ | ||
label: '3 days', | ||
value: VideosSeniority.ThreeDays, | ||
}, | ||
{ | ||
label: '7 days', | ||
value: VideosSeniority.SevenDays, | ||
}, | ||
{ | ||
label: '2 weeks', | ||
value: VideosSeniority.TwoWeeks, | ||
}, | ||
{ | ||
label: '1 month', | ||
value: VideosSeniority.OneMonth, | ||
}, | ||
]; | ||
|
||
function RecentVideosSeniority(props: RecentVideosSeniorityProps) { | ||
const seniority = useAppSelector(selectRecentVideosSeniority); | ||
const dispatch = useAppDispatch(); | ||
const [anchorEl, setAnchorEl] = useState<Nullable<HTMLElement>>(null); | ||
const open = Boolean(anchorEl); | ||
|
||
const handleClick = (event: React.MouseEvent<HTMLElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
|
||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
const handleChange = (recentVideosSeniority: VideosSeniority) => { | ||
dispatch(setSettings({ recentVideosSeniority })); | ||
}; | ||
|
||
return ( | ||
<> | ||
<IconButton | ||
id="seniority-button" | ||
aria-label="seniority" | ||
aria-controls={open ? 'seniority-menu' : undefined} | ||
aria-expanded={open ? 'true' : undefined} | ||
aria-haspopup="true" | ||
onClick={handleClick} | ||
> | ||
<HistoryIcon /> | ||
</IconButton> | ||
<StyledMenu | ||
id="seniority-menu" | ||
style={{ | ||
minWidth: 160, | ||
}} | ||
MenuListProps={{ | ||
'aria-labelledby': 'seniority-button', | ||
dense: true, | ||
}} | ||
anchorEl={anchorEl} | ||
open={open} | ||
onClose={handleClose} | ||
transformOrigin={{ horizontal: 'right', vertical: 'top' }} | ||
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }} | ||
> | ||
{options.map(({ label, value }) => ( | ||
<CheckableMenuItem | ||
checked={seniority === value} | ||
onClick={() => handleChange(value)} | ||
> | ||
{label} | ||
</CheckableMenuItem> | ||
))} | ||
</StyledMenu> | ||
</> | ||
); | ||
} | ||
|
||
export default RecentVideosSeniority; |
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
23 changes: 23 additions & 0 deletions
23
src/ui/components/pages/Home/TabActions/RecentViewActions/index.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,23 @@ | ||
import React from 'react'; | ||
import { Box } from '@mui/material'; | ||
import RecentViewFilters from './RecentViewFilters'; | ||
import RecentVideosSeniority from './RecentVideosSeniority'; | ||
|
||
interface RecentViewActionsProps {} | ||
|
||
function RecentViewActions(props: RecentViewActionsProps) { | ||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: 2, | ||
}} | ||
> | ||
<RecentViewFilters /> | ||
<RecentVideosSeniority /> | ||
</Box> | ||
); | ||
} | ||
|
||
export default RecentViewActions; |
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