|
1 | 1 | // Copyright 2026, Command Line Inc. |
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | | -import { getTabBadgeAtom, sortBadgesForTab } from "@/app/store/badge"; |
| 4 | +import { getTabBadgeAtom } from "@/app/store/badge"; |
5 | 5 | import { getOrefMetaKeyAtom, globalStore, recordTEvent, refocusNode } from "@/app/store/global"; |
6 | 6 | import { TabRpcClient } from "@/app/store/wshrpcutil"; |
7 | 7 | import { WaveEnv, WaveEnvSubset, useWaveEnv } from "@/app/waveenv/waveenv"; |
8 | 8 | import { Button } from "@/element/button"; |
9 | 9 | import { validateCssColor } from "@/util/color-validator"; |
10 | | -import { fireAndForget, makeIconClass } from "@/util/util"; |
| 10 | +import { fireAndForget } from "@/util/util"; |
11 | 11 | import clsx from "clsx"; |
12 | 12 | import { useAtomValue } from "jotai"; |
13 | | -import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react"; |
14 | | -import { v7 as uuidv7 } from "uuid"; |
| 13 | +import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react"; |
15 | 14 | import { makeORef } from "../store/wos"; |
| 15 | +import { TabBadges } from "./tabbadges"; |
16 | 16 | import "./tab.scss"; |
17 | 17 |
|
18 | 18 | type TabEnv = WaveEnvSubset<{ |
@@ -47,47 +47,6 @@ interface TabVProps { |
47 | 47 | renameRef?: React.RefObject<(() => void) | null>; |
48 | 48 | } |
49 | 49 |
|
50 | | -interface TabBadgesProps { |
51 | | - badges?: Badge[] | null; |
52 | | - flagColor?: string | null; |
53 | | -} |
54 | | - |
55 | | -function TabBadges({ badges, flagColor }: TabBadgesProps) { |
56 | | - const flagBadgeId = useMemo(() => uuidv7(), []); |
57 | | - const allBadges = useMemo(() => { |
58 | | - const base = badges ?? []; |
59 | | - if (!flagColor) { |
60 | | - return base; |
61 | | - } |
62 | | - const flagBadge: Badge = { icon: "flag", color: flagColor, priority: 0, badgeid: flagBadgeId }; |
63 | | - return sortBadgesForTab([...base, flagBadge]); |
64 | | - }, [badges, flagColor, flagBadgeId]); |
65 | | - if (!allBadges[0]) { |
66 | | - return null; |
67 | | - } |
68 | | - const firstBadge = allBadges[0]; |
69 | | - const extraBadges = allBadges.slice(1, 3); |
70 | | - return ( |
71 | | - <div className="pointer-events-none absolute left-[4px] top-1/2 z-[3] flex h-[20px] w-[20px] -translate-y-1/2 items-center justify-center px-[2px] py-[1px]"> |
72 | | - <i |
73 | | - className={makeIconClass(firstBadge.icon, true, { defaultIcon: "circle-small" }) + " text-[12px]"} |
74 | | - style={{ color: firstBadge.color || "#fbbf24" }} |
75 | | - /> |
76 | | - {extraBadges.length > 0 && ( |
77 | | - <div className="flex flex-col items-center justify-center gap-[2px] ml-[2px]"> |
78 | | - {extraBadges.map((badge, idx) => ( |
79 | | - <div |
80 | | - key={idx} |
81 | | - className="w-[4px] h-[4px] rounded-full" |
82 | | - style={{ backgroundColor: badge.color || "#fbbf24" }} |
83 | | - /> |
84 | | - ))} |
85 | | - </div> |
86 | | - )} |
87 | | - </div> |
88 | | - ); |
89 | | -} |
90 | | - |
91 | 50 | const TabV = forwardRef<HTMLDivElement, TabVProps>((props, ref) => { |
92 | 51 | const { |
93 | 52 | tabId, |
|
0 commit comments