diff --git a/src/components/DynamicPropertiesPanel.tsx b/src/components/DynamicPropertiesPanel.tsx index 556d5f5a..e22d2b98 100644 --- a/src/components/DynamicPropertiesPanel.tsx +++ b/src/components/DynamicPropertiesPanel.tsx @@ -229,22 +229,26 @@ function DisplayModeSelector({ propKey, currentMode, autoMode, onSelect }: { className="fixed z-[12001] min-w-[130px] rounded-md border border-border bg-background py-1 shadow-md" data-testid="display-mode-menu" > - {DISPLAY_MODE_OPTIONS.map(opt => ( - - ))} + {DISPLAY_MODE_OPTIONS.map(opt => { + const OptIcon = DISPLAY_MODE_ICONS[opt.value] + return ( + + ) + })} , document.body @@ -421,8 +425,9 @@ function ReadOnlyType({ isA, customColorKey, onNavigate }: { isA?: string | null ) } -function TypeSelector({ isA, customColorKey, availableTypes, onUpdateProperty, onNavigate }: { +function TypeSelector({ isA, customColorKey, availableTypes, typeColorKeys, onUpdateProperty, onNavigate }: { isA?: string | null; customColorKey?: string | null; availableTypes: string[] + typeColorKeys: Record onUpdateProperty?: (key: string, value: FrontmatterValue) => void onNavigate?: (target: string) => void }) { @@ -448,7 +453,10 @@ function TypeSelector({ isA, customColorKey, availableTypes, onUpdateProperty, o None {options.map(type => ( - {type} + + + {type} + ))} @@ -564,9 +572,12 @@ function reconcileListUpdate( function deriveTypeInfo(entries: VaultEntry[] | undefined, entryIsA: string | null) { const typeEntries = (entries ?? []).filter(e => e.isA === 'Type') + const typeColorKeys: Record = {} + for (const e of typeEntries) { typeColorKeys[e.title] = e.color ?? null } return { availableTypes: typeEntries.map(e => e.title).sort((a, b) => a.localeCompare(b)), - customColorKey: entryIsA ? (typeEntries.find(e => e.title === entryIsA)?.color ?? null) : null, + customColorKey: entryIsA ? (typeColorKeys[entryIsA] ?? null) : null, + typeColorKeys, } } @@ -606,7 +617,7 @@ function usePropertyPanelState(deps: PropertyPanelDeps) { const [showAddDialog, setShowAddDialog] = useState(false) const [displayOverrides, setDisplayOverrides] = useState(() => loadDisplayModeOverrides()) - const { availableTypes, customColorKey } = useMemo(() => deriveTypeInfo(entries, entryIsA), [entries, entryIsA]) + const { availableTypes, customColorKey, typeColorKeys } = useMemo(() => deriveTypeInfo(entries, entryIsA), [entries, entryIsA]) const vaultStatuses = useMemo(() => collectVaultStatuses(entries), [entries]) const propertyEntries = useMemo(() => Object.entries(frontmatter).filter(isVisibleProperty), [frontmatter]) @@ -637,7 +648,7 @@ function usePropertyPanelState(deps: PropertyPanelDeps) { return { editingKey, setEditingKey, showAddDialog, setShowAddDialog, displayOverrides, - availableTypes, customColorKey, vaultStatuses, propertyEntries, + availableTypes, customColorKey, typeColorKeys, vaultStatuses, propertyEntries, handleSaveValue, handleSaveList, handleAdd, handleDisplayModeChange, } } @@ -657,7 +668,7 @@ export function DynamicPropertiesPanel({ }) { const { editingKey, setEditingKey, showAddDialog, setShowAddDialog, displayOverrides, - availableTypes, customColorKey, vaultStatuses, propertyEntries, + availableTypes, customColorKey, typeColorKeys, vaultStatuses, propertyEntries, handleSaveValue, handleSaveList, handleAdd, handleDisplayModeChange, } = usePropertyPanelState({ entries, entryIsA: entry.isA, frontmatter, onUpdateProperty, onDeleteProperty, onAddProperty }) @@ -666,7 +677,7 @@ export function DynamicPropertiesPanel({ return (
- + {propertyEntries.map(([key, value]) => (