Skip to content

Commit

Permalink
feat(home): enhance view actions presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AXeL-dev committed Sep 19, 2022
1 parent 6faeb8e commit 19432d1
Show file tree
Hide file tree
Showing 28 changed files with 692 additions and 547 deletions.
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './useGrid';
export * from './useDidMountEffect';
export * from './useTimeout';
export * from './useInterval';
export * from './useForwardedRef';
16 changes: 16 additions & 0 deletions src/hooks/useForwardedRef.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useRef, useEffect, ForwardedRef } from 'react';

export function useForwardedRef<T>(ref: ForwardedRef<T>) {
const innerRef = useRef<T>(null);

useEffect(() => {
if (!ref) return;
if (typeof ref === 'function') {
ref(innerRef.current);
} else {
ref.current = innerRef.current;
}
});

return innerRef;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import NotificationsOffOutlinedIcon from '@mui/icons-material/NotificationsOffOu
import VisibilityOutlinedIcon from '@mui/icons-material/VisibilityOutlined';
import VisibilityOffOutlinedIcon from '@mui/icons-material/VisibilityOffOutlined';
import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined';
import FilterListIcon from '@mui/icons-material/FilterList';
import FilterAltIcon from '@mui/icons-material/FilterAlt';
import { Channel, Nullable } from 'types';
import ChannelDialogs from '../ChannelDialogs';

Expand Down Expand Up @@ -80,7 +80,7 @@ const ChannelActions = React.forwardRef<HTMLButtonElement, ChannelActionsProps>(
)}
</MenuItem>
<MenuItem onClick={handleFiltersClick} disableRipple>
<FilterListIcon />
<FilterAltIcon />
Filters
</MenuItem>
<Divider sx={{ my: 0.5 }} />
Expand Down
1 change: 0 additions & 1 deletion src/ui/components/pages/Channels/ChannelCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const ChannelCard = React.forwardRef(
<Card elevation={0} sx={{ flexGrow: 1, bgcolor: 'transparent' }}>
<CardHeader
sx={{
pt: 2.5,
pl: 0,
pr: 1,
'& .MuiCardHeader-title': {
Expand Down
3 changes: 0 additions & 3 deletions src/ui/components/pages/Channels/ChannelList/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,10 @@ function ChannelListActions(props: ChannelListActionsProps) {
id="more-menu"
MenuListProps={{
'aria-labelledby': 'more-button',
dense: true,
}}
anchorEl={anchorEl}
open={open}
onClose={handleClose}
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
>
{channels.length > 1 ? (
<MenuItem onClick={toggleDragHandles}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default function PickChannelCard(props: PickChannelCardProps) {
>
<CardHeader
sx={{
pt: 2.5,
pl: 0,
pr: 1,
'& .MuiCardHeader-title': {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/pages/Channels/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function Channels(props: ChannelsProps) {
alignItems: 'center',
borderBottom: 1,
borderColor: 'divider',
padding: (theme) => theme.spacing(1.5, 3),
padding: (theme) => theme.spacing(1.25, 3),
gap: 2,
}}
>
Expand Down
14 changes: 14 additions & 0 deletions src/ui/components/pages/Home/StyledTabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { styled } from '@mui/material/styles';
import Tabs, { TabsProps } from '@mui/material/Tabs';

const StyledTabs = styled((props: TabsProps) => <Tabs {...props} />)(
({ theme }) => ({
flexGrow: 1,
'& .MuiTabs-flexContainer': {
paddingTop: theme.spacing(1),
paddingBottom: theme.spacing(0.5),
},
}),
);

export default StyledTabs;
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, { useRef, useState } from 'react';
import {
IconButton,
MenuItem,
ListItemIcon,
ListItemText,
} from '@mui/material';
import { StyledMenu } from 'ui/components/shared';
import MoreVertIcon from '@mui/icons-material/MoreVert';
import SortIcon from '@mui/icons-material/Sort';
import { HomeView, Nullable } from 'types';
import { NestedMenuRef } from 'ui/components/shared/StyledMenu/NestedMenu';
import ViewSorting from '../common/ViewSorting';

interface AllViewOptionsProps {}

function AllViewOptions(props: AllViewOptionsProps) {
const [anchorEl, setAnchorEl] = useState<Nullable<HTMLElement>>(null);
const open = Boolean(anchorEl);
const menusRef = useRef<{ [key: string]: NestedMenuRef | null }>({
sorting: null,
});

const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};

const handleClose = () => {
setAnchorEl(null);
};

return (
<>
<IconButton
id="more-button"
aria-label="more"
aria-controls={open ? 'more-menu' : undefined}
aria-expanded={open ? 'true' : undefined}
aria-haspopup="true"
onClick={handleClick}
>
<MoreVertIcon />
</IconButton>
<StyledMenu
id="more-menu"
MenuListProps={{
'aria-labelledby': 'more-button',
}}
anchorEl={anchorEl}
open={open}
onClose={handleClose}
>
<MenuItem onClick={menusRef.current['sorting']?.open}>
<ListItemIcon>
<SortIcon />
</ListItemIcon>
<ListItemText>Sort by</ListItemText>
</MenuItem>
</StyledMenu>
<ViewSorting
ref={(ref) => (menusRef.current['sorting'] = ref)}
view={HomeView.All}
/>
</>
);
}

export default AllViewOptions;
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { Box } from '@mui/material';
import { HomeView } from 'types';
import ViewSorting from '../ViewSorting';
import AllViewOptions from './AllViewOptions';

interface AllViewActionsProps {}

Expand All @@ -14,7 +13,7 @@ function AllViewActions(props: AllViewActionsProps) {
gap: 2,
}}
>
<ViewSorting view={HomeView.All} />
<AllViewOptions />
</Box>
);
}
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 19432d1

Please sign in to comment.