Skip to content

Commit d0ea131

Browse files
committed
feat: Add drag handle to SectionHeader, fix theme borders
Grip icon on hover. DragHandleProps typed. Theme-aware borders.
1 parent c4ecc14 commit d0ea131

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

packages/app/src/components/SectionHeader.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,29 @@ import {
66
IconDotsVertical,
77
IconEye,
88
IconEyeOff,
9+
IconGripVertical,
910
IconPlus,
1011
IconTrash,
1112
} from '@tabler/icons-react';
1213

14+
import { type DragHandleProps } from '@/components/DashboardDndContext';
15+
1316
export default function SectionHeader({
1417
section,
1518
tileCount,
1619
onToggle,
1720
onRename,
1821
onDelete,
1922
onAddTile,
23+
dragHandleProps,
2024
}: {
2125
section: DashboardContainer;
2226
tileCount: number;
2327
onToggle: () => void;
2428
onRename?: (newTitle: string) => void;
2529
onDelete?: () => void;
2630
onAddTile?: () => void;
31+
dragHandleProps?: DragHandleProps;
2732
}) {
2833
const [editing, setEditing] = useState(false);
2934
const [editedTitle, setEditedTitle] = useState(section.title);
@@ -59,11 +64,32 @@ export default function SectionHeader({
5964
onMouseEnter={() => setHovered(true)}
6065
onMouseLeave={() => setHovered(false)}
6166
style={{
62-
borderBottom: '1px solid var(--mantine-color-dark-4)',
67+
borderBottom: '1px solid var(--mantine-color-default-border)',
6368
userSelect: 'none',
6469
}}
6570
data-testid={`section-header-${section.id}`}
6671
>
72+
{dragHandleProps && (
73+
<div
74+
{...dragHandleProps}
75+
style={{
76+
cursor: 'grab',
77+
display: 'flex',
78+
alignItems: 'center',
79+
padding: 2,
80+
flexShrink: 0,
81+
opacity: showControls ? 1 : 0,
82+
transition: 'opacity 150ms',
83+
}}
84+
title="Drag to reorder sections"
85+
data-testid={`section-drag-handle-${section.id}`}
86+
>
87+
<IconGripVertical
88+
size={14}
89+
style={{ color: 'var(--mantine-color-dimmed)' }}
90+
/>
91+
</div>
92+
)}
6793
<Flex
6894
align="center"
6995
gap="xs"

0 commit comments

Comments
 (0)