Skip to content

Commit

Permalink
feat(frontend): update help menu (#2689)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc authored and mathnogueira committed Jun 13, 2023
1 parent 5a1ede1 commit 09ff862
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 96 deletions.
10 changes: 10 additions & 0 deletions web/src/assets/discord.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 2 additions & 22 deletions web/src/components/Header/Header.styled.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {QuestionCircleOutlined} from '@ant-design/icons';
import {Layout, Menu, Typography} from 'antd';
import {Layout, Typography} from 'antd';
import styled from 'styled-components';

export const Header = styled(Layout.Header)`
Expand Down Expand Up @@ -31,30 +31,10 @@ export const Logo = styled.img`
margin-right: 24px;
`;

export const NavMenu = styled(Menu).attrs({
mode: 'horizontal',
disabledOverflow: true,
})`
&& {
align-items: center;
}
.ant-menu-submenu.ant-menu-submenu-horizontal {
padding-right: 0;
}
.ant-menu-item > span > a {
color: ${({theme}) => theme.color.primary};
}
`;

export const QuestionIcon = styled(QuestionCircleOutlined)`
color: ${({theme}) => theme.color.primary};
font-size: ${({theme}) => theme.size.lg};
`;

export const AppVersionContainer = styled.div`
border-top: ${({theme}) => `1px solid ${theme.color.borderLight}`};
margin: 0 24px;
`;

export const AppVersion = styled(Typography.Text)`
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Logo from 'assets/Logo.svg';
import EnvironmentSelector from 'components/EnvironmentSelector';
import NoTracingPopover from 'components/NoTracingPopover';
import * as S from './Header.styled';
import Menu from './Menu';
import HelpMenu from './HelpMenu';

interface IProps {
hasLogo?: boolean;
Expand All @@ -25,7 +25,7 @@ const Header = ({hasLogo = false, isNoTracingMode}: IProps) => (
<Space>
{isNoTracingMode && <NoTracingPopover />}
<EnvironmentSelector />
<Menu />
<HelpMenu />
</Space>
</S.Header>
);
Expand Down
90 changes: 90 additions & 0 deletions web/src/components/Header/HelpMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import {BulbOutlined, GithubOutlined, ReadOutlined} from '@ant-design/icons';
import {Dropdown, Menu, MenuProps, Space} from 'antd';
import {useMemo} from 'react';
import {useLocation} from 'react-router-dom';

import discordIcon from 'assets/discord.svg';
import {DISCORD_URL, DOCUMENTATION_URL, GITHUB_URL} from 'constants/Common.constants';
import {useGuidedTour} from 'providers/GuidedTour/GuidedTour.provider';
import GuidedTourService from 'services/GuidedTour.service';
import Env from 'utils/Env';
import * as S from './Header.styled';

const appVersion = Env.get('appVersion');

function getMenuItems({
isOnboardingActive,
onClickOnboarding,
}: {
isOnboardingActive: boolean;
onClickOnboarding: () => void;
}) {
const items: MenuProps['items'] = [
{
key: '1',
label: (
<a target="_blank" href={GITHUB_URL}>
GitHub
</a>
),
icon: <GithubOutlined />,
},
{
key: '2',
label: (
<a target="_blank" href={DOCUMENTATION_URL}>
Documentation
</a>
),
icon: <ReadOutlined />,
},
{
key: '3',
label: (
<a target="_blank" href={DISCORD_URL}>
Join our Discord community
</a>
),
icon: <img src={discordIcon} width={12} />,
},
{
key: '4',
label: <a onClick={onClickOnboarding}>Show Onboarding</a>,
icon: <BulbOutlined />,
disabled: !isOnboardingActive,
},
{
type: 'divider',
},
{
key: '5',
label: <S.AppVersion>App version: {appVersion}</S.AppVersion>,
disabled: true,
},
];

return items;
}

const HelpMenu = () => {
const pathname = useLocation().pathname;
const tourByPathname = GuidedTourService.getByPathName(pathname);
const isOnboardingActive = !!tourByPathname;
const {onStart} = useGuidedTour();
const items = useMemo(
() => getMenuItems({isOnboardingActive, onClickOnboarding: onStart}),
[isOnboardingActive, onStart]
);

return (
<Dropdown overlay={<Menu items={items} />}>
<a onClick={e => e.preventDefault()}>
<Space>
<S.QuestionIcon data-cy="menu-link" />
</Space>
</a>
</Dropdown>
);
};

export default HelpMenu;
72 changes: 0 additions & 72 deletions web/src/components/Header/Menu.tsx

This file was deleted.

0 comments on commit 09ff862

Please sign in to comment.