Skip to content

Commit

Permalink
Add chevron for dropdown, pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbyul-here committed Aug 6, 2024
1 parent eac10bd commit fdede4a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/scripts/components/common/google-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ButtonAsNavLink = styled(Button)`
`}
`;

function GoogleForm(props: { title: string, src: string}) {
const GoogleForm: React.FC<{ title: string, src: string }> = (props) => {
const { title, src } = props;
const { isRevealed, show, hide } = useFeedbackModal();

Expand Down Expand Up @@ -78,6 +78,6 @@ function GoogleForm(props: { title: string, src: string}) {
/>
</>
);
}
};

export default GoogleForm;
1 change: 0 additions & 1 deletion app/scripts/components/common/page-header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ const GlobalMenu = styled.ul`
`}
`;


export const MODAL_TYPE = 'modal';
export const INTERNAL_LINK_TYPE = 'internalLink';
export const EXTERNAL_LINK_TYPE = 'externalLink';
Expand Down
26 changes: 11 additions & 15 deletions app/scripts/components/common/page-header/nav-menu-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import {
themeVal
} from '@devseed-ui/theme-provider';
import { Button } from '@devseed-ui/button';
import { CollecticonChevronDownSmall } from '@devseed-ui/collecticons';
import { DropMenu, DropMenuItem } from '@devseed-ui/dropdown';

import DropdownScrollable from '../dropdown-scrollable';
import GoogleForm from '../google-form';
import { AlignmentEnum, InternalNavLink, ExternalNavLink, NavLinkItem, DropdownNavLink, ModalNavLink, NavItem } from './types';

import { MODAL_TYPE, INTERNAL_LINK_TYPE, EXTERNAL_LINK_TYPE, DROPDOWN_TYPE } from './';
import GlobalMenuLinkCSS from '$styles/menu-link';
import { useMediaQuery } from '$utils/use-media-query';

Expand Down Expand Up @@ -58,13 +60,8 @@ const DropMenuNavItem = styled(DropMenuItem)`
`}
`;

export const MODAL_TYPE = 'modal';
export const INTERNAL_LINK_TYPE = 'internalLink';
export const EXTERNAL_LINK_TYPE = 'externalLink';
export const DROPDOWN_TYPE = 'dropdown';


function ChildItem({ child, onClick }: { child: NavLinkItem, onClick?:() => void}) {
function LinkDropMenuNavItem({ child, onClick }: { child: NavLinkItem, onClick?:() => void}) {
const { title, type, ...rest } = child;
if (type === INTERNAL_LINK_TYPE) {
return (
Expand Down Expand Up @@ -117,38 +114,37 @@ export default function NavMenuItem({ item, alignment, onClick }: {item: NavItem
);
} else if (type === MODAL_TYPE) {
return (<li><GoogleForm title={title} src={(item as ModalNavLink).src} /></li>);
} else {// if (item.type === DROPDOWN_TYPE

} else if (type === DROPDOWN_TYPE) {
const { title } = item as DropdownNavLink;
// Mobile view
if (isMediumDown) {
return (
<>
<li><GlobalMenuItem>{title} </GlobalMenuItem></li>
{item.children.map((child) => {
return <ChildItem key={`${title}-dropdown-menu`} child={child} onClick={onClick} />;
return <LinkDropMenuNavItem key={`${title}-dropdown-menu`} child={child} onClick={onClick} />;
})}
</>
);
// In case a user inputs a wrong type
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
} else if (type === DROPDOWN_TYPE) {
} else {
return (<li>
<DropdownScrollable
alignment={alignment?? 'left'}
triggerElement={(props) => (
// @ts-expect-error achromic text exists
<GlobalMenuButton {...props} variation='achromic-text' fitting='skinny'>
{title}
{title} <CollecticonChevronDownSmall size='small' />
</GlobalMenuButton>
)}
>
<DropMenu>
{(item as DropdownNavLink).children.map((child) => {
return <ChildItem key={`${title}-dropdown-menu`} child={child} />;
return <LinkDropMenuNavItem key={`${title}-dropdown-menu`} child={child} />;
})}
</DropMenu>
</DropdownScrollable>
</li>);
} else throw Error('Invalid type for Nav Items');
}
}
} else throw Error('Invalid type for Nav Items');
}
2 changes: 1 addition & 1 deletion mock/veda.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function checkEnvFlag(value) {

let mainNavItems = [
{
title: 'test',
title: 'Test',
type: 'dropdown',
children: [
{
Expand Down

0 comments on commit fdede4a

Please sign in to comment.