From 2a9081b6c2f898668edaa05ee4dc426bbf8d62c1 Mon Sep 17 00:00:00 2001 From: Jan Burzinski <156842394+janburzinski@users.noreply.github.com> Date: Fri, 26 Jun 2026 19:27:10 +0200 Subject: [PATCH] chore(tabs): remove unused tab bar --- .../renderer/lib/components/reorder-list.tsx | 53 ------ .../src/renderer/lib/ui/tab-bar.tsx | 164 ------------------ 2 files changed, 217 deletions(-) delete mode 100644 apps/emdash-desktop/src/renderer/lib/components/reorder-list.tsx delete mode 100644 apps/emdash-desktop/src/renderer/lib/ui/tab-bar.tsx diff --git a/apps/emdash-desktop/src/renderer/lib/components/reorder-list.tsx b/apps/emdash-desktop/src/renderer/lib/components/reorder-list.tsx deleted file mode 100644 index fcfb543700..0000000000 --- a/apps/emdash-desktop/src/renderer/lib/components/reorder-list.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { Reorder, type HTMLElements } from 'motion/react'; -import React from 'react'; - -type Axis = 'x' | 'y'; -type ReorderTag = keyof HTMLElements; - -interface ReorderListProps { - items: T[]; - onReorder: (items: T[]) => void; - axis?: Axis; - className?: string; - itemClassName?: string; - layoutScroll?: boolean; - as?: ReorderTag; - getKey?: (item: T, index: number) => string | number; - children: (item: T, index: number) => React.ReactNode; -} - -export function ReorderList({ - items, - onReorder, - axis = 'y', - className, - itemClassName, - layoutScroll = true, - as = 'div', - getKey, - children, -}: ReorderListProps) { - return ( - - {items.map((item, index) => ( - - key={getKey ? getKey(item, index) : index} - value={item} - className={itemClassName} - transition={{ layout: { duration: 0 } }} - > - {children(item, index)} - - ))} - - ); -} - -export default ReorderList; diff --git a/apps/emdash-desktop/src/renderer/lib/ui/tab-bar.tsx b/apps/emdash-desktop/src/renderer/lib/ui/tab-bar.tsx deleted file mode 100644 index 162252e605..0000000000 --- a/apps/emdash-desktop/src/renderer/lib/ui/tab-bar.tsx +++ /dev/null @@ -1,164 +0,0 @@ -import { X } from 'lucide-react'; -import { observer, Observer } from 'mobx-react-lite'; -import { useEffect, useRef, useState } from 'react'; -import { ReorderList } from '@renderer/lib/components/reorder-list'; -import { cn } from '@renderer/utils/utils'; -import { Separator } from './separator'; - -function InlineEditInput({ - initialValue, - onConfirm, - onCancel, -}: { - initialValue: string; - onConfirm: (value: string) => void; - onCancel: () => void; -}) { - const [value, setValue] = useState(initialValue); - const ref = useRef(null); - - useEffect(() => { - ref.current?.focus(); - ref.current?.select(); - }, []); - - return ( - setValue(e.target.value)} - onBlur={() => onConfirm(value)} - onKeyDown={(e) => { - if (e.key === 'Enter') onConfirm(value); - if (e.key === 'Escape') onCancel(); - e.stopPropagation(); - }} - onClick={(e) => e.stopPropagation()} - /> - ); -} - -export interface TabBarProps { - tabs: TEntity[]; - activeTabId: string | undefined; - getId: (entity: TEntity) => string; - getLabel: (entity: TEntity) => string; - onSelect: (id: string) => void; - onRemove?: (id: string) => void; - renderTabPrefix?: (entity: TEntity) => React.ReactNode; - renderTabSuffix?: (entity: TEntity) => React.ReactNode; - onRename?: (id: string, newName: string) => void; - onReorder?: (fromIndex: number, toIndex: number) => void; - /** Rendered in the right-side area. Caller is responsible for all buttons and their click handlers. */ - actions?: React.ReactNode; -} - -export const TabBar = observer(function TabBar({ - tabs, - activeTabId, - getId, - getLabel, - onSelect, - onRemove, - renderTabPrefix, - renderTabSuffix, - onRename, - onReorder, - actions, -}: TabBarProps) { - const [editingId, setEditingId] = useState(null); - - const renderTab = (entity: TEntity) => { - const id = getId(entity); - const label = getLabel(entity); - const isActive = activeTabId === id; - const isEditing = editingId === id; - - return ( - <> - - - )} - - - - - ); - }; - - const handleReorder = (newTabs: TEntity[]) => { - for (let toIdx = 0; toIdx < newTabs.length; toIdx++) { - const fromIdx = tabs.findIndex((t) => getId(t) === getId(newTabs[toIdx])); - if (fromIdx !== toIdx) { - onReorder?.(fromIdx, toIdx); - break; - } - } - }; - - return ( -
- {onReorder ? ( - getId(item)} - > - {(entity) => {() => renderTab(entity)}} - - ) : ( -
{tabs.map((entity) => renderTab(entity))}
- )} - {actions &&
{actions}
} -
- ); -}) as (props: TabBarProps) => React.ReactElement;