From 9e3d2eb7cdcf370d4ce54ca2af3fb2b3cc4fb16f Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Tue, 29 Jun 2021 15:58:27 +0100 Subject: [PATCH] Only show controls when present --- components/controls-panel/controls-panel.tsx | 47 +++++++++----------- 1 file changed, 21 insertions(+), 26 deletions(-) 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) => ( + + ))} + +
) }