mirror of
https://github.com/chrisbenincasa/tunarr.git
synced 2026-04-18 09:03:35 -04:00
* fix: improve user experience of channel overview on mobile Added: - Scrollable tabs to view media - Changed heading sizes - Scrollable tabs on program details - Fixed bullet being added to end incorrectly - Improved program info ux - Fixed an issue with `useState` inside of `useEffect` * fix: stack channel icon, name and number --------- Co-authored-by: Corey Vaillancourt <coreyjv@gmail.com>
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import type { channelListOptions } from '@/types/index.ts';
|
|
import { Settings } from '@mui/icons-material';
|
|
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
|
import { Button, IconButton, useMediaQuery, useTheme } from '@mui/material';
|
|
import type { Channel } from '@tunarr/types';
|
|
import { isNull } from 'lodash-es';
|
|
import { useState } from 'react';
|
|
import { ChannelOptionsMenu } from './ChannelOptionsMenu.tsx';
|
|
|
|
type Props = {
|
|
channel: Channel;
|
|
hideItems?: channelListOptions[];
|
|
};
|
|
|
|
export const ChannelOptionsButton = ({ channel, hideItems }: Props) => {
|
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
const [channelMenu, setChannelMenu] = useState<Channel>();
|
|
const open = !isNull(anchorEl);
|
|
const theme = useTheme();
|
|
const smallViewport = useMediaQuery(theme.breakpoints.down('sm'));
|
|
|
|
const handleClick = (
|
|
event: React.MouseEvent<HTMLElement>,
|
|
channel: Channel,
|
|
) => {
|
|
setAnchorEl(event.currentTarget);
|
|
setChannelMenu(channel);
|
|
};
|
|
|
|
const handleClose = () => {
|
|
setAnchorEl(null);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
{smallViewport ? (
|
|
<IconButton
|
|
aria-controls={open ? 'channel-nav-menu' : undefined}
|
|
aria-haspopup="true"
|
|
aria-expanded={open ? 'true' : undefined}
|
|
onClick={(event) => handleClick(event, channel)}
|
|
>
|
|
<Settings />
|
|
</IconButton>
|
|
) : (
|
|
<Button
|
|
variant="outlined"
|
|
startIcon={<Settings />}
|
|
aria-controls={open ? 'channel-nav-menu' : undefined}
|
|
aria-haspopup="true"
|
|
aria-expanded={open ? 'true' : undefined}
|
|
disableRipple
|
|
disableElevation
|
|
onClick={(event) => handleClick(event, channel)}
|
|
endIcon={<KeyboardArrowDownIcon />}
|
|
>
|
|
Options
|
|
</Button>
|
|
)}
|
|
{channelMenu && (
|
|
<ChannelOptionsMenu
|
|
anchorEl={anchorEl}
|
|
open={open}
|
|
onClose={handleClose}
|
|
row={channelMenu}
|
|
hideItems={hideItems}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
};
|