Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: notification settings link #2578

Merged
merged 6 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 40 additions & 21 deletions src/components/notification-center/NotificationCenter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import ButtonBase from '@mui/material/ButtonBase'
import Popover from '@mui/material/Popover'
import Paper from '@mui/material/Paper'
import Typography from '@mui/material/Typography'
import Button from '@mui/material/Button'
import IconButton from '@mui/material/IconButton'
import MuiLink from '@mui/material/Link'
import BellIcon from '@/public/images/notifications/bell.svg'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import ExpandLessIcon from '@mui/icons-material/ExpandLess'
Expand All @@ -17,6 +17,10 @@ import {
} from '@/store/notificationsSlice'
import NotificationCenterList from '@/components/notification-center/NotificationCenterList'
import UnreadBadge from '@/components/common/UnreadBadge'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { AppRoutes } from '@/config/routes'
import SettingsIcon from '@/public/images/sidebar/settings.svg'

import css from './styles.module.css'
import { trackEvent, OVERVIEW_EVENTS } from '@/services/analytics'
Expand All @@ -25,6 +29,7 @@ import SvgIcon from '@mui/icons-material/ExpandLess'
const NOTIFICATION_CENTER_LIMIT = 4

const NotificationCenter = (): ReactElement => {
const router = useRouter()
const [showAll, setShowAll] = useState<boolean>(false)
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null)
const open = Boolean(anchorEl)
Expand Down Expand Up @@ -124,32 +129,46 @@ const NotificationCenter = (): ReactElement => {
)}
</div>
{notifications.length > 0 && (
<Button variant="text" size="small" onClick={handleClear}>
<MuiLink onClick={handleClear} variant="body2" component="button" sx={{ textDecoration: 'unset' }}>
Clear all
</Button>
</MuiLink>
)}
</div>
<div>
<NotificationCenterList notifications={notificationsToShow} handleClose={handleClose} />
</div>
{canExpand && (
<div className={css.popoverFooter}>
<IconButton onClick={() => setShowAll((prev) => !prev)} disableRipple className={css.expandButton}>
<UnreadBadge
invisible={showAll || unreadCount <= NOTIFICATION_CENTER_LIMIT}
anchorOrigin={{
vertical: 'top',
horizontal: 'left',
}}
>
<ExpandIcon color="border" />
</UnreadBadge>
</IconButton>
<Typography sx={{ color: ({ palette }) => palette.border.main }}>
{showAll ? 'Hide' : `${notifications.length - NOTIFICATION_CENTER_LIMIT} other notifications`}
</Typography>
</div>
)}
<div className={css.popoverFooter}>
{canExpand && (
<>
<IconButton onClick={() => setShowAll((prev) => !prev)} disableRipple className={css.expandButton}>
<UnreadBadge
invisible={showAll || unreadCount <= NOTIFICATION_CENTER_LIMIT}
anchorOrigin={{
vertical: 'top',
horizontal: 'left',
}}
>
<ExpandIcon color="border" />
</UnreadBadge>
</IconButton>
<Typography sx={{ color: ({ palette }) => palette.border.main }}>
{showAll ? 'Hide' : `${notifications.length - NOTIFICATION_CENTER_LIMIT} other notifications`}
</Typography>
</>
)}
<Link
href={{
pathname: AppRoutes.settings.notifications,
query: router.query,
}}
passHref
legacyBehavior
>
<MuiLink className={css.settingsLink} variant="body2" onClick={handleClose}>
<SvgIcon component={SettingsIcon} inheritViewBox fontSize="small" /> Settings
</MuiLink>
</Link>
</div>
</Paper>
</Popover>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}

.popoverFooter {
padding: var(--space-2);
padding: var(--space-2) var(--space-3);
display: flex;
align-items: center;
}
Expand Down Expand Up @@ -57,3 +57,11 @@
width: 18px;
height: 18px;
}

.settingsLink {
margin-left: auto;
display: flex;
align-items: center;
text-decoration: unset;
gap: var(--space-1);
}
Loading