From a30c651c65510325c6e4dc6d5224b3d7955631e8 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 20 Nov 2024 09:33:24 +0100 Subject: [PATCH] update css --- packages/html-reporter/src/links.tsx | 11 ++++++++++- packages/html-reporter/src/treeItem.css | 2 +- packages/html-reporter/src/treeItem.tsx | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/html-reporter/src/links.tsx b/packages/html-reporter/src/links.tsx index e72c1ef98f..be1bc7ced8 100644 --- a/packages/html-reporter/src/links.tsx +++ b/packages/html-reporter/src/links.tsx @@ -72,6 +72,7 @@ export const AttachmentLink: React.FunctionComponent<{ linkName?: string, openInNewTab?: boolean, }> = ({ attachment, href, linkName, openInNewTab }) => { + const isAnchored = useIsAnchored('attachment-' + attachment.name); return {attachment.contentType === kMissingContentType ? icons.warning() : icons.attachment()} {attachment.path && {linkName || attachment.name}} @@ -82,7 +83,7 @@ export const AttachmentLink: React.FunctionComponent<{ )} } loadChildren={attachment.body ? () => { return [
{linkifyText(attachment.body!)}
]; - } : undefined} depth={0} style={{ lineHeight: '32px' }}>
; + } : undefined} depth={0} style={{ lineHeight: '32px' }} selected={isAnchored}>; }; export const SearchParamsContext = React.createContext(new URLSearchParams(window.location.hash.slice(1))); @@ -135,6 +136,14 @@ export function useAnchor(id: AnchorID, onReveal: () => void) { }, [id, onReveal]); } +export function useIsAnchored(id: AnchorID) { + const searchParams = React.useContext(SearchParamsContext); + if (!searchParams.has('anchor')) + return false; + const anchor = searchParams.get('anchor'); + return typeof id === 'function' ? id(anchor!) : anchor === id; +} + export function Anchor({ id, children }: React.PropsWithChildren<{ id: AnchorID }>) { const ref = React.useRef(null); const onAnchorReveal = React.useCallback(() => { diff --git a/packages/html-reporter/src/treeItem.css b/packages/html-reporter/src/treeItem.css index b111b543a1..f37a759c2d 100644 --- a/packages/html-reporter/src/treeItem.css +++ b/packages/html-reporter/src/treeItem.css @@ -25,7 +25,7 @@ cursor: pointer; } -.tree-item:target > .tree-item-title { +.tree-item-title.selected { text-decoration: underline var(--color-underlinenav-icon); text-decoration-thickness: 1.5px; } diff --git a/packages/html-reporter/src/treeItem.tsx b/packages/html-reporter/src/treeItem.tsx index 507a9c0e71..926a398a05 100644 --- a/packages/html-reporter/src/treeItem.tsx +++ b/packages/html-reporter/src/treeItem.tsx @@ -17,6 +17,7 @@ import * as React from 'react'; import './treeItem.css'; import * as icons from './icons'; +import { clsx } from '@web/uiUtils'; export const TreeItem: React.FunctionComponent<{ title: JSX.Element, @@ -28,9 +29,8 @@ export const TreeItem: React.FunctionComponent<{ style?: React.CSSProperties, }> = ({ title, loadChildren, onClick, expandByDefault, depth, selected, style }) => { const [expanded, setExpanded] = React.useState(expandByDefault || false); - const className = selected ? 'tree-item-title selected' : 'tree-item-title'; return
- { onClick?.(); setExpanded(!expanded); }} > + { onClick?.(); setExpanded(!expanded); }} > {loadChildren && !!expanded && icons.downArrow()} {loadChildren && !expanded && icons.rightArrow()} {!loadChildren && {icons.rightArrow()}}