From 162431c4b7301986d80d6cce76500843c25fd3ac Mon Sep 17 00:00:00 2001 From: Lars Heinemann Date: Tue, 12 Mar 2024 14:06:36 +0100 Subject: [PATCH] added a top bar menu for later use. it already contains some useful external links Signed-off-by: Lars Heinemann --- packages/ui/src/layout/TopBar.tsx | 87 +++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 11 deletions(-) diff --git a/packages/ui/src/layout/TopBar.tsx b/packages/ui/src/layout/TopBar.tsx index dd8e28d57..5567085b4 100644 --- a/packages/ui/src/layout/TopBar.tsx +++ b/packages/ui/src/layout/TopBar.tsx @@ -1,29 +1,57 @@ import { Button, + Divider, + Dropdown, + DropdownItem, Icon, Masthead, MastheadBrand, MastheadContent, MastheadMain, MastheadToggle, + MenuToggle, + MenuToggleElement, ToolbarItem, } from '@patternfly/react-core'; -import { GithubIcon } from '@patternfly/react-icons'; +import { EllipsisVIcon, ExternalLinkAltIcon, GithubIcon } from '@patternfly/react-icons'; import { BarsIcon } from '@patternfly/react-icons/dist/js/icons/bars-icon'; -import { FunctionComponent, useRef } from 'react'; -import { Link } from 'react-router-dom'; +import React, { FunctionComponent, useRef } from 'react'; import logo from '../assets/logo-kaoto.png'; import { useComponentLink } from '../hooks/ComponentLink'; -import { ExternalLinks, Links } from '../router/links.models'; +import { Links } from '../router/links.models'; interface ITopBar { navToggle: () => void; } +const DEFAULT_POPPER_PROPS = { + position: 'end', + preventOverflow: true, +} as const; + export const TopBar: FunctionComponent = (props) => { const displayObject = useRef({ default: 'inline', lg: 'stack', '2xl': 'inline' } as const); const logoLink = useComponentLink(Links.Home); + const [isOpen, setIsOpen] = React.useState(false); + + const onToggle = () => { + setIsOpen(!isOpen); + }; + + const onSelect = (event: React.MouseEvent | undefined) => { + event?.stopPropagation(); + setIsOpen(!isOpen); + const selectedItemId = event?.currentTarget?.id || ''; + if (selectedItemId === 'settings') { + // TODO: open the settings modal + } else if (selectedItemId === 'about') { + // TODO: open the about modal + } else { + // ignore unknown menu items + } + }; + return ( @@ -40,13 +68,50 @@ export const TopBar: FunctionComponent = (props) => { - - - + ) => ( + + + + )} + isOpen={isOpen} + onOpenChange={(isOpen: boolean) => setIsOpen(isOpen)} + popperProps={DEFAULT_POPPER_PROPS} + > + + + + + +  Tutorials + + + + + + + +  Help + + + + + + + +  Feedback + + + + + Settings + + + + About + +