Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,55 @@ import {
useCommandCenterStore,
} from "../stores/commandCenterStore";

const LAYOUT_OPTIONS: { value: LayoutPreset; label: string }[] = [
{ value: "1x1", label: "1x1" },
{ value: "2x1", label: "2x1" },
{ value: "1x2", label: "1x2" },
{ value: "2x2", label: "2x2" },
{ value: "3x2", label: "3x2" },
{ value: "3x3", label: "3x3" },
function LayoutIcon({ cols, rows }: { cols: number; rows: number }) {
const size = 14;
const gap = 1.5;
const cellW = (size - gap * (cols - 1)) / cols;
const cellH = (size - gap * (rows - 1)) / rows;

const rects: React.ReactElement[] = [];
for (let r = 0; r < rows; r++) {
for (let c = 0; c < cols; c++) {
rects.push(
<rect
key={`${r}-${c}`}
x={c * (cellW + gap)}
y={r * (cellH + gap)}
width={cellW}
height={cellH}
rx={1}
fill="currentColor"
opacity={0.5}
/>,
);
}
}

return (
<svg
width={size}
height={size}
viewBox={`0 0 ${size} ${size}`}
role="img"
aria-label={`${cols} by ${rows} grid`}
>
{rects}
</svg>
);
}

const LAYOUT_OPTIONS: {
value: LayoutPreset;
label: string;
cols: number;
rows: number;
}[] = [
{ value: "1x1", label: "1x1", cols: 1, rows: 1 },
{ value: "2x1", label: "2x1", cols: 2, rows: 1 },
{ value: "1x2", label: "1x2", cols: 1, rows: 2 },
{ value: "2x2", label: "2x2", cols: 2, rows: 2 },
{ value: "3x2", label: "3x2", cols: 3, rows: 2 },
{ value: "3x3", label: "3x3", cols: 3, rows: 3 },
];

interface CommandCenterToolbarProps {
Expand Down Expand Up @@ -86,7 +128,10 @@ export function CommandCenterToolbar({
<Select.Content>
{LAYOUT_OPTIONS.map((opt) => (
<Select.Item key={opt.value} value={opt.value}>
{opt.label}
<Flex align="center" gap="2">
<LayoutIcon cols={opt.cols} rows={opt.rows} />
{opt.label}
</Flex>
</Select.Item>
))}
</Select.Content>
Expand Down
Loading