From 78087b37d25ba0b0f955c0f8a13d73f3014f707e Mon Sep 17 00:00:00 2001 From: soryu Date: Tue, 3 Feb 2026 22:29:44 +0000 Subject: Reorganize makima navbar --- makima/frontend/src/components/NavStrip.tsx | 2 +- .../frontend/src/components/chains/ChainEditor.tsx | 22 ++- .../frontend/src/components/chains/ChainList.tsx | 187 ++++++++++----------- 3 files changed, 97 insertions(+), 114 deletions(-) (limited to 'makima/frontend/src/components') diff --git a/makima/frontend/src/components/NavStrip.tsx b/makima/frontend/src/components/NavStrip.tsx index 5937982..4f6cf32 100644 --- a/makima/frontend/src/components/NavStrip.tsx +++ b/makima/frontend/src/components/NavStrip.tsx @@ -10,8 +10,8 @@ interface NavLink { const NAV_LINKS: NavLink[] = [ { label: "Listen", href: "/listen" }, - { label: "Contracts", href: "/contracts", requiresAuth: true }, { label: "Chains", href: "/chains", requiresAuth: true }, + { label: "Contracts", href: "/contracts", requiresAuth: true }, { label: "Board", href: "/workflow", requiresAuth: true }, { label: "Mesh", href: "/mesh", requiresAuth: true }, { label: "History", href: "/history", requiresAuth: true }, diff --git a/makima/frontend/src/components/chains/ChainEditor.tsx b/makima/frontend/src/components/chains/ChainEditor.tsx index 9077d19..92bd496 100644 --- a/makima/frontend/src/components/chains/ChainEditor.tsx +++ b/makima/frontend/src/components/chains/ChainEditor.tsx @@ -5,6 +5,12 @@ import type { ChainContractDetail, } from "../../lib/api"; +const statusColors: Record = { + active: "text-green-400", + completed: "text-blue-400", + archived: "text-[#555]", +}; + interface ChainEditorProps { chain: ChainWithContracts; graph: ChainGraphResponse | null; @@ -116,12 +122,8 @@ export function ChainEditor({
{chain.chain.status} @@ -371,12 +373,8 @@ function ContractDetailPanel({ Status {contract.contractStatus} diff --git a/makima/frontend/src/components/chains/ChainList.tsx b/makima/frontend/src/components/chains/ChainList.tsx index eda79d7..befccd2 100644 --- a/makima/frontend/src/components/chains/ChainList.tsx +++ b/makima/frontend/src/components/chains/ChainList.tsx @@ -10,6 +10,12 @@ interface ChainListProps { onArchive: (chain: ChainSummary) => void; } +const statusColors: Record = { + active: "text-green-400", + completed: "text-blue-400", + archived: "text-[#555]", +}; + export function ChainList({ chains, loading, @@ -18,101 +24,74 @@ export function ChainList({ selectedId, onArchive, }: ChainListProps) { - const [statusFilter, setStatusFilter] = useState("all"); - const [contextMenu, setContextMenu] = useState<{ - chain: ChainSummary; - x: number; - y: number; - } | null>(null); + const [filter, setFilter] = useState("all"); + const [contextMenuPosition, setContextMenuPosition] = useState<{ x: number; y: number } | null>(null); + const [contextMenuChain, setContextMenuChain] = useState(null); - const filteredChains = chains.filter((chain) => - statusFilter === "all" ? true : chain.status === statusFilter - ); + const filteredChains = + filter === "all" + ? chains + : chains.filter((c) => c.status === filter); const handleContextMenu = useCallback( (e: React.MouseEvent, chain: ChainSummary) => { e.preventDefault(); - setContextMenu({ chain, x: e.clientX, y: e.clientY }); + setContextMenuPosition({ x: e.clientX, y: e.clientY }); + setContextMenuChain(chain); }, [] ); const closeContextMenu = useCallback(() => { - setContextMenu(null); + setContextMenuPosition(null); + setContextMenuChain(null); }, []); const handleArchive = useCallback(() => { - if (contextMenu) { - onArchive(contextMenu.chain); - setContextMenu(null); - } - }, [contextMenu, onArchive]); - - const getStatusColor = (status: ChainStatus) => { - switch (status) { - case "active": - return "text-[#4ade80] bg-[#4ade80]/10"; - case "completed": - return "text-[#60a5fa] bg-[#60a5fa]/10"; - case "archived": - return "text-[#6b7280] bg-[#6b7280]/10"; - default: - return "text-[#8b949e] bg-[#8b949e]/10"; + if (contextMenuChain) { + onArchive(contextMenuChain); + closeContextMenu(); } - }; + }, [contextMenuChain, onArchive, closeContextMenu]); - const getStatusIcon = (status: ChainStatus) => { - switch (status) { - case "active": - return ( - - - - ); - case "completed": - return ( - - - - ); - case "archived": - return ( - - - - - - ); - default: - return null; - } - }; + if (loading) { + return ( +
+
Loading...
+
+ ); + } return (
{/* Header */} -
+
-

Chains

+

+ Chains +

- {/* Status filter */} + {/* Filter tabs */}
{(["all", "active", "completed", "archived"] as const).map((status) => ( @@ -122,78 +101,84 @@ export function ChainList({ {/* Chain list */}
- {loading ? ( -
-

Loading chains...

-
- ) : filteredChains.length === 0 ? ( -
-

- {statusFilter === "all" ? "No chains yet" : `No ${statusFilter} chains`} + {filteredChains.length === 0 ? ( +

+

+ {filter === "all" + ? "No chains yet" + : `No ${filter} chains`}

) : ( -
+
{filteredChains.map((chain) => ( -
onSelect(chain.id)} onContextMenu={(e) => handleContextMenu(e, chain)} - className={`p-3 cursor-pointer transition-colors ${ - selectedId === chain.id - ? "bg-[rgba(117,170,252,0.15)]" - : "hover:bg-[rgba(117,170,252,0.05)]" - }`} + className={` + w-full text-left p-4 transition-colors + ${ + selectedId === chain.id + ? "bg-[rgba(117,170,252,0.1)]" + : "hover:bg-[rgba(117,170,252,0.05)]" + } + `} > -
- +
+

{chain.name} - +

- {getStatusIcon(chain.status)} {chain.status}
+ {chain.description && ( -

+

{chain.description}

)} -
+ +
{chain.contractCount} contracts - - {new Date(chain.updatedAt).toLocaleDateString()} - + {chain.completedContractCount} completed + {chain.loopEnabled && ( + + loop {chain.loopCurrentIteration || 0}/{chain.loopMaxIterations || "∞"} + + )}
-
+ ))}
)}
- {/* Context menu */} - {contextMenu && ( + {/* Context Menu */} + {contextMenuPosition && contextMenuChain && (
e.stopPropagation()} > - {contextMenu.chain.status !== "archived" && ( + {contextMenuChain.status !== "archived" && ( -- cgit v1.2.3