refactor(ui): replace middle-dot separators with clearer hierarchy (#6087)
* refactor(ui): replace middle-dot separators with clearer hierarchy * refactor(ui): use layout instead of punctuation separators
This commit is contained in:
1 parent
d6ddceed99
commit
7cb396788c
82 files changed
+433
-462
No files matched your search
@@ -12,6 +12,8 @@ export interface ActivityStepProps {
|
||||
marker?: ReactNode;
|
||||
showMarker?: boolean;
|
||||
label: ReactNode;
|
||||
detail?: string;
|
||||
detailClassName?: string;
|
||||
tooltipContent?: ReactNode;
|
||||
ariaLabel?: string;
|
||||
active?: boolean;
|
||||
@@ -29,6 +31,8 @@ export function ActivityStep({
|
||||
marker,
|
||||
showMarker = true,
|
||||
label,
|
||||
detail,
|
||||
detailClassName,
|
||||
tooltipContent,
|
||||
ariaLabel,
|
||||
active = false,
|
||||
@@ -42,11 +46,13 @@ export function ActivityStep({
|
||||
}: ActivityStepProps) {
|
||||
const lineRef = useRef<HTMLDivElement>(null);
|
||||
const [hintOpen, setHintOpen] = useState(false);
|
||||
const textLabel = typeof label === "string" ? [label, detail].filter(Boolean).join("\n") : undefined;
|
||||
const line = (
|
||||
<div
|
||||
ref={lineRef}
|
||||
data-testid="activity-line"
|
||||
tabIndex={typeof label === "string" ? 0 : undefined}
|
||||
aria-label={detail && typeof label === "string" ? `${label}, ${detail}` : undefined}
|
||||
className="flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap"
|
||||
>
|
||||
<StreamingLabelSheen
|
||||
@@ -57,7 +63,12 @@ export function ActivityStep({
|
||||
labelClassName,
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
{detail ? (
|
||||
<span className="flex min-w-0 items-baseline gap-2">
|
||||
<span className="max-w-[70%] shrink-0 truncate">{label}</span>{" "}
|
||||
<span className={cn("min-w-0 flex-1 truncate font-normal text-muted-foreground", detailClassName)}>{detail}</span>
|
||||
</span>
|
||||
) : label}
|
||||
</StreamingLabelSheen>
|
||||
</div>
|
||||
);
|
||||
@@ -99,11 +110,11 @@ export function ActivityStep({
|
||||
<Tooltip open={hintOpen} onOpenChange={(open) => {
|
||||
const truncated = Array.from(lineRef.current?.querySelectorAll<HTMLElement>(".truncate") ?? [])
|
||||
.some((element) => element.scrollWidth > element.clientWidth);
|
||||
setHintOpen(open && (truncated || tooltipContent !== undefined && tooltipContent !== label));
|
||||
setHintOpen(open && (truncated || tooltipContent !== undefined && tooltipContent !== textLabel));
|
||||
}}>
|
||||
<TooltipTrigger asChild>{line}</TooltipTrigger>
|
||||
<TooltipContent side="top" className="max-w-[min(32rem,calc(100vw-2rem))] whitespace-pre-wrap break-words">
|
||||
{tooltipContent ?? label}
|
||||
{tooltipContent ?? textLabel}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
|
||||
Reference in new issue
Block a user