import React from 'react' import { ToolbarItem, ToolbarItemView } from '../wrapper' import { Tooltip } from '@planview/pv-uikit' import { LogoContainer, StrippedAnchor } from '../navigation-bar/styles' import { useIsFocusVisible } from '@planview/pv-utilities' import { useMergeRefs } from '../utils/refs' import styled from 'styled-components' export type MainNavigationLogoProps = { /** * url to navigate to when clicking on the logotype. Using this prop will wrap the logo in an -element */ url?: string /** * descriptive label */ label?: string } & React.HTMLAttributes const StyledLogo = styled.svg` height: 31px; ` export function asProductLogo(Logo: React.ElementType) { const Component: React.FC = ({ url, label, ...rest }) => { const { innerRef: _innerRef, focusVisible, ...focusProps } = useIsFocusVisible() const anchorRef = React.useRef(null) const mergedRef = useMergeRefs([anchorRef, focusProps.ref]) return url !== undefined ? ( refOverride={anchorRef}> {( ref, { toolbarItemProps: { focused: _focused, ...toolbarItemProps }, } ) => ( { toolbarItemProps.onClick(ev) rest.onClick?.(ev) }} onKeyDown={(ev) => { toolbarItemProps.onKeyDown(ev) rest.onKeyDown?.(ev) }} ref={mergedRef} href={url} aria-label={label} > )} ) : ( ) } return Component }