11import { useMemo } from "react" ;
2+ import { X } from "lucide-react" ;
23import { useSelector } from "react-redux" ;
34import { twMerge } from "tailwind-merge" ;
45import { dataAttributes , ids } from "@/constants" ;
6+ import { store } from "@/store" ;
7+ import { toggleControls } from "@/store/reducers/editor" ;
58import { ISTKProps } from "@/types" ;
6- import { AnimatedSwitcher } from "../core" ;
9+ import { AnimatedSwitcher , IconButton } from "../core" ;
710import { Tool } from "../toolbar/data" ;
8- import { ElementType } from "../workspace/elements" ;
911import { default as ImageControls } from "./image" ;
1012import { default as NoControls } from "./no-controls" ;
1113import { default as NoSelectedElement } from "./no-selection" ;
@@ -15,7 +17,9 @@ import { default as SeatControls } from "./seat";
1517import { default as SelectControls } from "./select" ;
1618import { default as ShapeControls } from "./shapes" ;
1719
18- const transition = "transition-all duration-500" ;
20+ const onCogClick = ( ) => store . dispatch ( toggleControls ( ) ) ;
21+
22+ const transition = "transition-all duration-500 ease-in-out" ;
1923
2024const width = "w-[22rem]" ;
2125
@@ -32,7 +36,6 @@ const Controls = ({ options, styles }: IControlProps) => {
3236 const firstElementType = document
3337 . getElementById ( selectedElementIds [ 0 ] )
3438 ?. getAttribute ?.( dataAttributes . elementType ) ;
35- if ( firstElementType === ElementType . Booth ) return NoSelectionControls ;
3639 if ( selectedElementIds . length > 1 ) {
3740 const same = selectedElementIds . every ( ( id ) => {
3841 return document . getElementById ( id ) ?. getAttribute ?.( dataAttributes . elementType ) === firstElementType ;
@@ -51,23 +54,30 @@ const Controls = ({ options, styles }: IControlProps) => {
5154 } , [ selectedTool , selectedElementIds ] ) ;
5255
5356 return (
54- < >
55- < div className = { twMerge ( "pointer-events-none grow-0 shrink-0" , transition , open ? width : "w-0" ) } />
56- < div
57- id = { ids . controls }
58- className = { twMerge (
59- "py-5 px-6 h-[calc(100%-32px)] absolute top-0 border-t border-black overflow-y-auto" ,
60- transition ,
61- width ,
62- open ? "right-0" : "-right-[22rem]"
63- ) }
64- >
65- < AnimatedSwitcher
66- key = { ControlComponent . name }
67- component = { < ControlComponent options = { options } styles = { styles } /> }
57+ < div
58+ id = { ids . controls }
59+ className = { twMerge (
60+ "h-full bg-white border-l shadow-lg border-gray-200 absolute top-0 overflow-y-auto z-10" ,
61+ transition ,
62+ width ,
63+ open ? "right-0" : "-right-[22rem]"
64+ ) }
65+ >
66+ < div className = "flex justify-between items-center gap-4 h-14 border-b border-gray-200 box-content px-5 sticky top-0 bg-white" >
67+ < h5 > Settings</ h5 >
68+ < IconButton
69+ className = "w-6 h-6 p-0 shrink-0"
70+ variant = "secondary"
71+ icon = { < X className = "w-4 h-4" /> }
72+ onClick = { onCogClick }
6873 />
6974 </ div >
70- </ >
75+ < AnimatedSwitcher
76+ key = { ControlComponent . name }
77+ component = { < ControlComponent options = { options } styles = { styles } /> }
78+ className = "py-4 px-5 h-[calc(100%-3.5rem)]"
79+ />
80+ </ div >
7181 ) ;
7282} ;
7383
0 commit comments