diff --git a/components/controls-panel/controls-panel.tsx b/components/controls-panel/controls-panel.tsx index c3310b1ec..7d57656b6 100644 --- a/components/controls-panel/controls-panel.tsx +++ b/components/controls-panel/controls-panel.tsx @@ -2,18 +2,14 @@ import styled from 'styles' import React, { useRef } from 'react' import state, { useSelector } from 'state' -import { X, Code } from 'react-feather' +import { X } from 'react-feather' import { breakpoints, IconButton } from 'components/shared' import * as Panel from '../panel' import Control from './control' import { deepCompareArrays } from 'utils' -function openCodePanel() { - state.send('CLOSED_CODE_PANEL') -} - -function closeCodePanel() { - state.send('OPENED_CODE_PANEL') +function handleClose() { + state.send('CLOSED_CONTROLS') } const stopKeyboardPropagation = (e: KeyboardEvent | React.KeyboardEvent) => @@ -22,11 +18,16 @@ const stopKeyboardPropagation = (e: KeyboardEvent | React.KeyboardEvent) => export default function ControlPanel(): JSX.Element { const rContainer = useRef(null) const isOpen = useSelector((s) => Object.keys(s.data.codeControls).length > 0) + const codeControls = useSelector( (state) => Object.keys(state.data.codeControls), deepCompareArrays ) + if (codeControls.length === 0) { + return null + } + return ( - {isOpen ? ( - - - - - -

Controls

-
- - {codeControls.map((id) => ( - - ))} - -
- ) : ( - - - - )} + + + + + +

Controls

+
+ + {codeControls.map((id) => ( + + ))} + +
) }