From 248aaec7970825dc29780bce903dc30ef4def316 Mon Sep 17 00:00:00 2001 From: mspivak-actionengine Date: Wed, 28 Feb 2024 13:12:41 +0300 Subject: [PATCH] fix(minimap): disable minimap for ArcGIS base map --- src/components/debug-panel/debug-panel.tsx | 7 +++ .../toogle-switch/toggle-switch.tsx | 45 +++++++++++++------ src/pages/debug-app/debug-app.tsx | 2 +- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/components/debug-panel/debug-panel.tsx b/src/components/debug-panel/debug-panel.tsx index ef6ca86e..9674012e 100644 --- a/src/components/debug-panel/debug-panel.tsx +++ b/src/components/debug-panel/debug-panel.tsx @@ -24,6 +24,7 @@ import { setDebugOptions, selectDebugOptions, } from "../../redux/slices/debug-options-slice"; +import { selectSelectedBaseMapId } from "../../redux/slices/base-maps-slice"; const CloseButtonWrapper = styled.div` position: absolute; @@ -64,6 +65,11 @@ export const DebugPanel = ({ onClose }: DebugPanelProps) => { const layout = useAppLayout(); const dispatch = useAppDispatch(); const debugOptions = useAppSelector(selectDebugOptions); + const selectedBaseMapId = useAppSelector(selectSelectedBaseMapId); + const minimapDisabled = selectedBaseMapId === "ArcGis"; + if (minimapDisabled && debugOptions.minimap) { + dispatch(setDebugOptions({ minimap: false })); + } return ( @@ -84,6 +90,7 @@ export const DebugPanel = ({ onClose }: DebugPanelProps) => { dispatch(setDebugOptions({ minimap: !debugOptions.minimap })) } diff --git a/src/components/toogle-switch/toggle-switch.tsx b/src/components/toogle-switch/toggle-switch.tsx index 23892695..aadabb5a 100644 --- a/src/components/toogle-switch/toggle-switch.tsx +++ b/src/components/toogle-switch/toggle-switch.tsx @@ -1,11 +1,7 @@ -import styled from "styled-components"; +import styled, { css } from "styled-components"; import { color_canvas_primary_inverted } from "../../constants/colors"; -const Switch = styled.div` - position: relative; - width: 28px; - height: 18px; -`; +const color_control_disabled = "#808080"; const Input = styled.input` height: 0; @@ -22,7 +18,6 @@ const Label = styled.label<{ width: 28px; height: 18px; border-radius: 8px; - cursor: pointer; ${Input} { opacity: 0; width: 0; @@ -32,7 +27,6 @@ const Label = styled.label<{ const Slider = styled.span` position: absolute; - cursor: pointer; top: 1px; left: 0; right: 0; @@ -71,26 +65,51 @@ const Slider = styled.span` -ms-transform: translateX(11px); transform: translateX(11px); } + + ${Input}:disabled + &::before { + background-color: ${color_control_disabled}; + } `; -/** - * TODO: Add types to component - */ +const Switch = styled.div<{ disabled?: boolean }>` + position: relative; + width: 28px; + height: 18px; + ${Label} { + ${({ disabled }) => + !disabled && + css` + cursor: pointer; + `} + } +`; + +type ToggleSwitchProps = { + checked: boolean; + onChange: () => void; + name?: string; + id?: string; + title?: string; + disabled?: boolean; +}; + export const ToggleSwitch = ({ checked, onChange, name = "", id = "", title = "", -}) => { + disabled = false, +}: ToggleSwitchProps) => { return ( - +