From 776be2e02241ccdb1bc2cf0cd3ee1b49979aedb7 Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:23:23 +0100 Subject: [PATCH] fix(sidebar): high contrast styles, single option link [EE-5666] (#10485) --- app/assets/css/vendor-override.css | 5 ++ app/react/sidebar/SidebarItem/SidebarItem.tsx | 86 +++++++++++++++---- .../sidebar/SidebarItem/SidebarParent.tsx | 4 +- .../sidebar/SidebarItem/SidebarTooltip.tsx | 2 +- app/react/sidebar/SidebarItem/Wrapper.tsx | 3 +- 5 files changed, 77 insertions(+), 23 deletions(-) diff --git a/app/assets/css/vendor-override.css b/app/assets/css/vendor-override.css index 80f49191e..fc85bf7ba 100644 --- a/app/assets/css/vendor-override.css +++ b/app/assets/css/vendor-override.css @@ -364,6 +364,7 @@ input:-webkit-autofill { .sidebar.tippy-box[data-placement^='right'] > .tippy-arrow { width: 12px; height: 12px; + margin-left: -1px; } .sidebar.tippy-box[data-placement^='right'] > .tippy-arrow:before { @@ -375,6 +376,10 @@ input:-webkit-autofill { border-right: 8px solid var(--ui-gray-true-9); } +[theme='highcontrast'] .sidebar.tippy-box[data-placement^='right'] > .tippy-arrow:before { + border-right: 8px solid var(--ui-white); +} + .sidebar .tippy-content { white-space: nowrap; } diff --git a/app/react/sidebar/SidebarItem/SidebarItem.tsx b/app/react/sidebar/SidebarItem/SidebarItem.tsx index 5e16a4a7b..85f39bfba 100644 --- a/app/react/sidebar/SidebarItem/SidebarItem.tsx +++ b/app/react/sidebar/SidebarItem/SidebarItem.tsx @@ -1,5 +1,6 @@ import { Icon as IconTest } from 'lucide-react'; import clsx from 'clsx'; +import { MouseEventHandler, PropsWithChildren } from 'react'; import { AutomationTestingProps } from '@/types'; @@ -37,35 +38,84 @@ export function SidebarItem({ includePaths, }); - const anchor = ( + const sidebarAnchor = ( - {!!icon && svg]:w-4')} />} {(isOpen || isSubMenu) && {label}} - + ); - if (isOpen || isSubMenu) return anchor; + if (isOpen || isSubMenu) return sidebarAnchor; return ( - {label}}> - {anchor} + + + + {label} + + + + } + > + {sidebarAnchor} ); } + +type ItemAnchorProps = { + href?: string; + onClick: MouseEventHandler; + className: string; + isOpen: boolean; + isSubMenu: boolean; + dataCy?: string; +}; + +function ItemAnchor({ + href, + onClick, + className, + isOpen, + isSubMenu, + dataCy, + children, +}: PropsWithChildren) { + return ( + + {children} + + ); +} diff --git a/app/react/sidebar/SidebarItem/SidebarParent.tsx b/app/react/sidebar/SidebarItem/SidebarParent.tsx index 424191cc3..9a688d808 100644 --- a/app/react/sidebar/SidebarItem/SidebarParent.tsx +++ b/app/react/sidebar/SidebarItem/SidebarParent.tsx @@ -71,7 +71,7 @@ export function SidebarParent({ )} > - {isSidebarOpen && {title}} + {isSidebarOpen && {title}} {isSidebarOpen && ( @@ -123,7 +123,7 @@ export function SidebarParent({
  • {title}
  • -
    +
    {children}
    diff --git a/app/react/sidebar/SidebarItem/SidebarTooltip.tsx b/app/react/sidebar/SidebarItem/SidebarTooltip.tsx index 8ccd9e334..b9a2d11d4 100644 --- a/app/react/sidebar/SidebarItem/SidebarTooltip.tsx +++ b/app/react/sidebar/SidebarItem/SidebarTooltip.tsx @@ -8,7 +8,7 @@ type Props = { export function SidebarTooltip({ children, content }: Props) { return ( a]:text-inherit [&>a]:hover:text-inherit [&>a]:hover:no-underline' + 'flex min-h-8 text-gray-3 th-highcontrast:text-white [&>a]:text-inherit [&>a]:hover:text-inherit [&>a]:hover:no-underline' )} aria-label={label} // eslint-disable-next-line react/jsx-props-no-spreading