1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-18 00:19:49 +01:00

feat: adds a new design to the header icons (#5025)

After aligning with @nicolaesocaciu, adds a new, cleaner, more
consistent design to our header icons.


![image](https://github.com/Unleash/unleash/assets/14320932/a9f0eb93-ee1f-4e63-96c8-4b2ac11cfdab)

Co-authored-by: Nicolae <nicolae@getunleash.ai>
This commit is contained in:
Nuno Góis 2023-10-13 14:31:07 +01:00 committed by GitHub
parent e663dc0960
commit 9c047e0756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 45 deletions

View File

@ -8,6 +8,7 @@ import {
ClickAwayListener, ClickAwayListener,
Button, Button,
Switch, Switch,
Tooltip,
} from '@mui/material'; } from '@mui/material';
import { useNotifications } from 'hooks/api/getters/useNotifications/useNotifications'; import { useNotifications } from 'hooks/api/getters/useNotifications/useNotifications';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
@ -170,10 +171,11 @@ export const Notifications = () => {
return ( return (
<StyledPrimaryContainerBox> <StyledPrimaryContainerBox>
<Tooltip title='Notifications' arrow>
<StyledIconButton <StyledIconButton
onClick={() => setShowNotifications(!showNotifications)} onClick={() => setShowNotifications(!showNotifications)}
data-testid='NOTIFICATIONS_BUTTON' data-testid='NOTIFICATIONS_BUTTON'
disableFocusRipple size='large'
> >
<ConditionallyRender <ConditionallyRender
condition={hasUnreadNotifications} condition={hasUnreadNotifications}
@ -181,6 +183,7 @@ export const Notifications = () => {
/> />
<NotificationsIcon /> <NotificationsIcon />
</StyledIconButton> </StyledIconButton>
</Tooltip>
<ConditionallyRender <ConditionallyRender
condition={showNotifications} condition={showNotifications}

View File

@ -100,9 +100,18 @@ const styledIconProps = (theme: Theme) => ({
const StyledLink = styled(Link)(({ theme }) => focusable(theme)); const StyledLink = styled(Link)(({ theme }) => focusable(theme));
const StyledIconButton = styled(IconButton)(({ theme }) => ({ const StyledIconButton = styled(IconButton)<{
...focusable(theme), component?: 'a' | 'button';
href?: string;
target?: string;
}>(({ theme }) => ({
borderRadius: 100, borderRadius: 100,
'&:focus-visible': {
outlineStyle: 'solid',
outlineWidth: 2,
outlineColor: theme.palette.primary.main,
borderRadius: '100%',
},
})); }));
const Header: VFC = () => { const Header: VFC = () => {
@ -210,29 +219,31 @@ const Header: VFC = () => {
} }
arrow arrow
> >
<IconButton onClick={onSetThemeMode} sx={focusable}> <StyledIconButton
onClick={onSetThemeMode}
size='large'
>
<ConditionallyRender <ConditionallyRender
condition={themeMode === 'dark'} condition={themeMode === 'dark'}
show={<DarkModeOutlined />} show={<DarkModeOutlined />}
elseShow={<LightModeOutlined />} elseShow={<LightModeOutlined />}
/> />
</IconButton> </StyledIconButton>
</Tooltip>{' '} </Tooltip>
<ConditionallyRender <ConditionallyRender
condition={!isOss() && !disableNotifications} condition={!isOss() && !disableNotifications}
show={<Notifications />} show={<Notifications />}
/> />
<Tooltip title='Documentation' arrow> <Tooltip title='Documentation' arrow>
<IconButton <StyledIconButton
component='a'
href='https://docs.getunleash.io/' href='https://docs.getunleash.io/'
target='_blank' target='_blank'
rel='noopener noreferrer' rel='noopener noreferrer'
size='large' size='large'
disableRipple
sx={focusable}
> >
<MenuBookIcon /> <MenuBookIcon />
</IconButton> </StyledIconButton>
</Tooltip> </Tooltip>
<Tooltip title='Settings' arrow> <Tooltip title='Settings' arrow>
<StyledIconButton <StyledIconButton
@ -240,10 +251,8 @@ const Header: VFC = () => {
aria-controls={adminRef ? adminId : undefined} aria-controls={adminRef ? adminId : undefined}
aria-expanded={Boolean(adminRef)} aria-expanded={Boolean(adminRef)}
size='large' size='large'
disableRipple
> >
<SettingsIcon /> <SettingsIcon />
<KeyboardArrowDown sx={styledIconProps} />
</StyledIconButton> </StyledIconButton>
</Tooltip> </Tooltip>
<NavigationMenu <NavigationMenu

View File

@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react'; import { useContext, useState } from 'react';
import { ClickAwayListener, IconButton, styled, Tooltip } from '@mui/material'; import { ClickAwayListener, IconButton, styled, Tooltip } from '@mui/material';
import { useId } from 'hooks/useId'; import { useId } from 'hooks/useId';
import { focusable } from 'themes/themeStyles'; import { focusable } from 'themes/themeStyles';
@ -14,6 +14,12 @@ const StyledContainer = styled('div')(() => ({
const StyledIconButton = styled(IconButton)(({ theme }) => ({ const StyledIconButton = styled(IconButton)(({ theme }) => ({
...focusable(theme), ...focusable(theme),
borderRadius: 100, borderRadius: 100,
'&:focus-visible': {
outlineStyle: 'solid',
outlineWidth: 2,
outlineColor: theme.palette.primary.main,
borderRadius: '100%',
},
})); }));
const InviteLinkButton = () => { const InviteLinkButton = () => {
@ -34,7 +40,6 @@ const InviteLinkButton = () => {
<StyledIconButton <StyledIconButton
onClick={() => setShowInviteLinkContent(true)} onClick={() => setShowInviteLinkContent(true)}
size='large' size='large'
disableRipple
> >
<PersonAdd /> <PersonAdd />
</StyledIconButton> </StyledIconButton>

View File

@ -1,6 +1,5 @@
import { useState } from 'react'; import { useState } from 'react';
import { Button, ClickAwayListener, styled } from '@mui/material'; import { ClickAwayListener, IconButton, Tooltip, styled } from '@mui/material';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import { UserProfileContent } from './UserProfileContent/UserProfileContent'; import { UserProfileContent } from './UserProfileContent/UserProfileContent';
import { IUser } from 'interfaces/user'; import { IUser } from 'interfaces/user';
import { HEADER_USER_AVATAR } from 'utils/testIds'; import { HEADER_USER_AVATAR } from 'utils/testIds';
@ -17,19 +16,21 @@ const StyledProfileContainer = styled('div')(({ theme }) => ({
position: 'relative', position: 'relative',
})); }));
const StyledButton = styled(Button)(({ theme }) => ({ const StyledIconButton = styled(IconButton)(({ theme }) => ({
...focusable(theme), ...focusable(theme),
...flexRow, ...flexRow,
...itemsCenter, ...itemsCenter,
color: 'inherit', color: 'inherit',
padding: theme.spacing(0.5, 2), padding: theme.spacing(1),
'&:hover': { '&:hover': {
backgroundColor: 'transparent', backgroundColor: 'transparent',
}, },
})); '&:focus-visible': {
outlineStyle: 'solid',
const StyledIcon = styled(KeyboardArrowDownIcon)(({ theme }) => ({ outlineWidth: 2,
color: theme.palette.neutral.main, outlineColor: theme.palette.primary.main,
borderRadius: '100%',
},
})); }));
interface IUserProfileProps { interface IUserProfileProps {
@ -43,19 +44,20 @@ const UserProfile = ({ profile }: IUserProfileProps) => {
return ( return (
<ClickAwayListener onClickAway={() => setShowProfile(false)}> <ClickAwayListener onClickAway={() => setShowProfile(false)}>
<StyledProfileContainer> <StyledProfileContainer>
<StyledButton <Tooltip title='Profile' arrow>
<StyledIconButton
onClick={() => setShowProfile((prev) => !prev)} onClick={() => setShowProfile((prev) => !prev)}
aria-controls={showProfile ? modalId : undefined} aria-controls={showProfile ? modalId : undefined}
aria-expanded={showProfile} aria-expanded={showProfile}
color='secondary' color='secondary'
disableRipple size='large'
> >
<StyledUserAvatar <StyledUserAvatar
user={profile} user={profile}
data-testid={HEADER_USER_AVATAR} data-testid={HEADER_USER_AVATAR}
/> />
<StyledIcon /> </StyledIconButton>
</StyledButton> </Tooltip>
<UserProfileContent <UserProfileContent
id={modalId} id={modalId}
showProfile={showProfile} showProfile={showProfile}