-
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) add tabs for mail domain page
Currently, it is complicated to understand the navigation between mailbox management and role management for an email domain. This is why we add tabs with explicit naming
- Loading branch information
1 parent
30229e1
commit cc81368
Showing
16 changed files
with
360 additions
and
183 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
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
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,54 @@ | ||
import * as React from 'react'; | ||
import { ReactNode } from 'react'; | ||
import { Tab, TabList, TabPanel, Tabs } from 'react-aria-components'; | ||
|
||
import { Box } from '@/components'; | ||
|
||
import style from './custom-tabs.module.scss'; | ||
|
||
type TabsOption = { | ||
ariaLabel?: string; | ||
label: string; | ||
iconName?: string; | ||
id?: string; | ||
content: ReactNode; | ||
}; | ||
|
||
type Props = { | ||
tabs: TabsOption[]; | ||
}; | ||
|
||
export const CustomTabs = ({ tabs }: Props) => { | ||
return ( | ||
<div className={style.customTabsContainer}> | ||
<Tabs> | ||
<TabList> | ||
{tabs.map((tab) => { | ||
const id = tab.id ?? tab.label; | ||
return ( | ||
<Tab key={id} aria-label={tab.ariaLabel} id={id}> | ||
<Box $direction="row" $align="center" $gap="5px"> | ||
{tab.iconName && ( | ||
<span className="material-icons" aria-hidden="true"> | ||
{tab.iconName} | ||
</span> | ||
)} | ||
{tab.label} | ||
</Box> | ||
</Tab> | ||
); | ||
})} | ||
</TabList> | ||
|
||
{tabs.map((tab) => { | ||
const id = tab.id ?? tab.label; | ||
return ( | ||
<TabPanel key={id} id={id}> | ||
{tab.content} | ||
</TabPanel> | ||
); | ||
})} | ||
</Tabs> | ||
</div> | ||
); | ||
}; |
63 changes: 63 additions & 0 deletions
63
src/frontend/apps/desk/src/components/tabs/custom-tabs.module.scss
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,63 @@ | ||
.customTabsContainer { | ||
:global { | ||
.react-aria-TabList { | ||
display: flex; | ||
|
||
&[data-orientation='horizontal'] { | ||
.react-aria-Tab { | ||
border-bottom: 2px solid var(--c--theme--colors--greyscale-500); | ||
} | ||
} | ||
} | ||
|
||
.react-aria-Tab { | ||
padding: 10px; | ||
cursor: pointer; | ||
outline: none; | ||
position: relative; | ||
color: var(--c--theme--colors--greyscale-700); | ||
transition: color 200ms; | ||
|
||
--border-color: transparent; | ||
|
||
forced-color-adjust: none; | ||
|
||
&[data-hovered], | ||
&[data-focused] { | ||
color: var(--c--theme--colors--greyscale-900); | ||
} | ||
|
||
&[data-selected] { | ||
border-bottom: 2px solid var(--c--theme--colors--primary-600) !important; | ||
color: var(--c--theme--colors--primary-600); | ||
} | ||
|
||
&[data-disabled] { | ||
color: var(--c--theme--colors--greyscale-500); | ||
|
||
&[data-selected] { | ||
--border-color: var(--c--theme--colors--greyscale-200); | ||
} | ||
} | ||
|
||
&[data-focus-visible]::after { | ||
content: ''; | ||
position: absolute; | ||
inset: 4px; | ||
border-radius: 4px; | ||
border: 1px solid var(--c--theme--colors--primary-600); | ||
} | ||
} | ||
|
||
.react-aria-TabPanel { | ||
margin-top: 4px; | ||
padding: 10px; | ||
border-radius: 4px; | ||
outline: none; | ||
|
||
&[data-focus-visible] { | ||
outline: 2px solid var(--c--theme--colors--primary-600); | ||
} | ||
} | ||
} | ||
} |
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
68 changes: 68 additions & 0 deletions
68
src/frontend/apps/desk/src/features/mail-domains/domains/components/MailDomainView.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,68 @@ | ||
import * as React from 'react'; | ||
import { useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { Box, Text } from '@/components'; | ||
import { CustomTabs } from '@/components/tabs/CustomTabs'; | ||
import { AccessesContent } from '@/features/mail-domains/access-management'; | ||
import MailDomainsLogo from '@/features/mail-domains/assets/mail-domains-logo.svg'; | ||
import { MailDomain, Role } from '@/features/mail-domains/domains'; | ||
import { MailDomainsContent } from '@/features/mail-domains/mailboxes'; | ||
|
||
type Props = { | ||
mailDomain: MailDomain; | ||
}; | ||
export const MailDomainView = ({ mailDomain }: Props) => { | ||
const { t } = useTranslation(); | ||
const currentRole = mailDomain.abilities.delete | ||
? Role.OWNER | ||
: mailDomain.abilities.manage_accesses | ||
? Role.ADMIN | ||
: Role.VIEWER; | ||
|
||
const tabs = useMemo(() => { | ||
return [ | ||
{ | ||
ariaLabel: t('Go to mailbox management'), | ||
id: 'mails', | ||
iconName: 'mail', | ||
label: t('Mailbox management'), | ||
content: <MailDomainsContent mailDomain={mailDomain} />, | ||
}, | ||
{ | ||
ariaLabel: t('Go to accesses management'), | ||
id: 'accesses', | ||
iconName: 'people', | ||
label: t('Access management'), | ||
content: ( | ||
<AccessesContent mailDomain={mailDomain} currentRole={currentRole} /> | ||
), | ||
}, | ||
]; | ||
}, [t, currentRole, mailDomain]); | ||
|
||
return ( | ||
<Box $padding="big"> | ||
<Box | ||
$width="100%" | ||
$direction="row" | ||
$align="center" | ||
$gap="2.25rem" | ||
$justify="center" | ||
> | ||
<Box | ||
$direction="row" | ||
$justify="center" | ||
$margin={{ bottom: 'big' }} | ||
$gap="0.5rem" | ||
> | ||
<MailDomainsLogo aria-hidden="true" /> | ||
<Text $margin="none" as="h3" $size="h3"> | ||
{mailDomain?.name} | ||
</Text> | ||
</Box> | ||
</Box> | ||
<CustomTabs tabs={tabs} /> | ||
</Box> | ||
); | ||
}; |
Oops, something went wrong.