Feat: Add notifications menu

This commit is contained in:
MangoPig
2026-06-16 17:00:51 +01:00
parent fd429bdcdd
commit 248a0b1828
8 changed files with 543 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
import type { JSX } from "solid-js";
import { Bell } from "../../../lib/icons";
import { unreadNotificationCount } from "../data/shell.data";
import styles from "./NotificationsButton.module.scss";
type NotificationsButtonProps = {
isOpen: boolean;
menuId: string;
onToggle: () => void;
};
export const NotificationsButton = (props: NotificationsButtonProps): JSX.Element => {
const hasUnread = unreadNotificationCount > 0;
const unreadLabel = hasUnread ? `, ${unreadNotificationCount} unread` : "";
return (
<button
classList={{
[styles.button]: true,
[styles.buttonOpen]: props.isOpen,
}}
type="button"
aria-label={`${props.isOpen ? "Close" : "Open"} notifications${unreadLabel}`}
title={`${props.isOpen ? "Close" : "Open"} notifications`}
aria-haspopup="menu"
aria-controls={props.menuId}
aria-expanded={props.isOpen}
onClick={props.onToggle}
>
<span class={styles.iconWrap} aria-hidden="true">
<Bell size={18} strokeWidth={2} />
{hasUnread ? <span class={styles.badge}>{unreadNotificationCount}</span> : null}
</span>
</button>
);
};