@@ -15,13 +15,55 @@ import {
1515 useCommandCenterStore ,
1616} from "../stores/commandCenterStore" ;
1717
18- const LAYOUT_OPTIONS : { value : LayoutPreset ; label : string } [ ] = [
19- { value : "1x1" , label : "1x1" } ,
20- { value : "2x1" , label : "2x1" } ,
21- { value : "1x2" , label : "1x2" } ,
22- { value : "2x2" , label : "2x2" } ,
23- { value : "3x2" , label : "3x2" } ,
24- { value : "3x3" , label : "3x3" } ,
18+ function LayoutIcon ( { cols, rows } : { cols : number ; rows : number } ) {
19+ const size = 14 ;
20+ const gap = 1.5 ;
21+ const cellW = ( size - gap * ( cols - 1 ) ) / cols ;
22+ const cellH = ( size - gap * ( rows - 1 ) ) / rows ;
23+
24+ const rects : React . ReactElement [ ] = [ ] ;
25+ for ( let r = 0 ; r < rows ; r ++ ) {
26+ for ( let c = 0 ; c < cols ; c ++ ) {
27+ rects . push (
28+ < rect
29+ key = { `${ r } -${ c } ` }
30+ x = { c * ( cellW + gap ) }
31+ y = { r * ( cellH + gap ) }
32+ width = { cellW }
33+ height = { cellH }
34+ rx = { 1 }
35+ fill = "currentColor"
36+ opacity = { 0.5 }
37+ /> ,
38+ ) ;
39+ }
40+ }
41+
42+ return (
43+ < svg
44+ width = { size }
45+ height = { size }
46+ viewBox = { `0 0 ${ size } ${ size } ` }
47+ role = "img"
48+ aria-label = { `${ cols } by ${ rows } grid` }
49+ >
50+ { rects }
51+ </ svg >
52+ ) ;
53+ }
54+
55+ const LAYOUT_OPTIONS : {
56+ value : LayoutPreset ;
57+ label : string ;
58+ cols : number ;
59+ rows : number ;
60+ } [ ] = [
61+ { value : "1x1" , label : "1x1" , cols : 1 , rows : 1 } ,
62+ { value : "2x1" , label : "2x1" , cols : 2 , rows : 1 } ,
63+ { value : "1x2" , label : "1x2" , cols : 1 , rows : 2 } ,
64+ { value : "2x2" , label : "2x2" , cols : 2 , rows : 2 } ,
65+ { value : "3x2" , label : "3x2" , cols : 3 , rows : 2 } ,
66+ { value : "3x3" , label : "3x3" , cols : 3 , rows : 3 } ,
2567] ;
2668
2769interface CommandCenterToolbarProps {
@@ -86,7 +128,10 @@ export function CommandCenterToolbar({
86128 < Select . Content >
87129 { LAYOUT_OPTIONS . map ( ( opt ) => (
88130 < Select . Item key = { opt . value } value = { opt . value } >
89- { opt . label }
131+ < Flex align = "center" gap = "2" >
132+ < LayoutIcon cols = { opt . cols } rows = { opt . rows } />
133+ { opt . label }
134+ </ Flex >
90135 </ Select . Item >
91136 ) ) }
92137 </ Select . Content >
0 commit comments