From a237b4e7825318cec309829a37cb5f9a0f90e53d Mon Sep 17 00:00:00 2001 From: Jonathan Brennan Date: Wed, 15 Apr 2026 17:59:09 -0500 Subject: [PATCH] fix wonky SubgraphChip and associated tooltip styling (#7985) --- .../target/explorer/super-graph-metadata.tsx | 41 +++++++++---------- .../web/app/src/components/v2/tooltip.tsx | 2 +- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/packages/web/app/src/components/target/explorer/super-graph-metadata.tsx b/packages/web/app/src/components/target/explorer/super-graph-metadata.tsx index 93efe279a..3c8fdf93a 100644 --- a/packages/web/app/src/components/target/explorer/super-graph-metadata.tsx +++ b/packages/web/app/src/components/target/explorer/super-graph-metadata.tsx @@ -1,18 +1,24 @@ import { Fragment, useMemo } from 'react'; +import { useTheme } from '@/components/theme/theme-provider'; import { PackageIcon } from '@/components/ui/icon'; import { Tooltip } from '@/components/v2'; import { FragmentType, graphql, useFragment } from '@/gql'; import { LayersIcon as MetadataIcon } from '@radix-ui/react-icons'; import { Link } from '@tanstack/react-router'; -function stringToHslColor(str: string, s = 30, l = 80) { +function stringToHue(str: string) { let hash = 0; for (let i = 0; i < str.length; i++) { hash = str.charCodeAt(i) + ((hash << 5) - hash); } + return hash % 360; +} - const h = hash % 360; - return 'hsl(' + h + ', ' + s + '%, ' + l + '%)'; +function subgraphChipColors(str: string, theme: 'light' | 'dark') { + const h = stringToHue(str); + return theme === 'dark' + ? { backgroundColor: `hsl(${h}, 45%, 32%)`, color: '#f2f2f2' } + : { backgroundColor: `hsl(${h}, 30%, 80%)`, color: '#4f4f4f' }; } function Metadata(props: { supergraphMetadata: Array<{ name: string; content: string }> }) { @@ -44,6 +50,8 @@ function SubgraphChip(props: { targetSlug: string; metadata?: Array<{ name: string; content: string }>; }): React.ReactElement { + const { resolvedTheme } = useTheme(); + const inner = ( - {props.text} - - {props.metadata?.length && *} + {props.text} + + {props.metadata?.length && *} ); @@ -98,7 +106,6 @@ const SupergraphMetadataList_SupergraphMetadataFragment = graphql(` } `); -const tooltipColor = 'rgb(36, 39, 46)'; const DEFAULT_PREVIEW_THRESHOLD = 3; export function SupergraphMetadataList(props: { @@ -193,24 +200,16 @@ export function SupergraphMetadataList(props: { const [previewItems, allItems] = items ?? [null, null]; return ( -
+
{meta} - {previewItems}{' '} + {previewItems} {allItems && (
All Subgraphs
-
-
- {allItems} -
-
+
+ {allItems}
} diff --git a/packages/web/app/src/components/v2/tooltip.tsx b/packages/web/app/src/components/v2/tooltip.tsx index 3c2451275..a411dc3a9 100644 --- a/packages/web/app/src/components/v2/tooltip.tsx +++ b/packages/web/app/src/components/v2/tooltip.tsx @@ -26,7 +26,7 @@ function Wrapper({ contentProps.className, )} > - + {content} );