-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨(frontend) introduce a notification settings
I extended Room settings with a new tab, allowing users to toggle the sound notification they want. Their choices will be persisted.
- Loading branch information
1 parent
83914f8
commit e0021db
Showing
5 changed files
with
95 additions
and
5 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
41 changes: 41 additions & 0 deletions
41
src/frontend/src/features/settings/components/tabs/NotificationsTab.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,41 @@ | ||
import { TabPanel, TabPanelProps } from '@/primitives/Tabs' | ||
import { H, Switch } from '@/primitives' | ||
import { css } from '@/styled-system/css' | ||
import { useTranslation } from 'react-i18next' | ||
import { useSnapshot } from 'valtio' | ||
import { notificationsStore } from '@/stores/notifications' | ||
|
||
export type NotificationsTabProps = Pick<TabPanelProps, 'id'> | ||
|
||
export const NotificationsTab = ({ id }: NotificationsTabProps) => { | ||
const { t } = useTranslation('settings', { keyPrefix: 'notifications' }) | ||
const notificationsSnap = useSnapshot(notificationsStore) | ||
return ( | ||
<TabPanel padding={'md'} flex id={id}> | ||
<H lvl={2}>{t('heading')}</H> | ||
<ul | ||
className={css({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '1rem', | ||
})} | ||
> | ||
{Array.from(notificationsSnap.soundNotifications).map( | ||
([key, value]) => ( | ||
<li key={key}> | ||
<Switch | ||
aria-label={`${t(`actions.${value ? 'disable' : 'enable'}`)} ${t('label')} "${t(`items.${key}`)}"`} | ||
isSelected={value} | ||
onChange={(v) => { | ||
notificationsStore.soundNotifications.set(key, v) | ||
}} | ||
> | ||
{t(`items.${key}`)} | ||
</Switch> | ||
</li> | ||
) | ||
)} | ||
</ul> | ||
</TabPanel> | ||
) | ||
} |
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