Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(minimap): disable minimap for ArcGIS base map #357

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/components/debug-panel/debug-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 (
<PanelContainer layout={layout}>
Expand All @@ -84,6 +90,7 @@ export const DebugPanel = ({ onClose }: DebugPanelProps) => {
<ToggleSwitch
id={"toggle-minimap"}
checked={debugOptions.minimap}
disabled={minimapDisabled}
onChange={() =>
dispatch(setDebugOptions({ minimap: !debugOptions.minimap }))
}
Expand Down
45 changes: 32 additions & 13 deletions src/components/toogle-switch/toggle-switch.tsx
Original file line number Diff line number Diff line change
@@ -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";

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to colors.ts. I would name it dim_canvas_tertiary. Make sure it looks good on the light theme

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

const Input = styled.input`
height: 0;
Expand All @@ -22,7 +18,6 @@ const Label = styled.label<{
width: 28px;
height: 18px;
border-radius: 8px;
cursor: pointer;
${Input} {
opacity: 0;
width: 0;
Expand All @@ -32,7 +27,6 @@ const Label = styled.label<{

const Slider = styled.span`
position: absolute;
cursor: pointer;
top: 1px;
left: 0;
right: 0;
Expand Down Expand Up @@ -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 (
<Switch>
<Switch disabled={disabled}>
<Label htmlFor={id} title={title}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled button should not react on hover

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<Input
id={id}
type="checkbox"
name={name}
checked={checked}
disabled={disabled}
title={title}
onChange={onChange}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/debug-app/debug-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const DebugApp = () => {
setColoredTilesMap({});
setSelectedTile(null);
dispatch(resetDebugOptions());
dispatch(setDebugOptions({ minimap: true }));
dispatch(setDebugOptions({ minimap: !(selectedBaseMapId === "ArcGis") }));
dispatch(clearBSLStatisitcsSummary());
dispatch(setFiltersByAttrubute({ filter: null }));
}, [activeLayers, buildingExplorerOpened]);
Expand Down
Loading