Skip to content

Commit

Permalink
FIX: Hide rectangle, circle and freehand modes in mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
rajtoshranjan committed Jun 17, 2024
1 parent 0cf025b commit 9352e2d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/layer-panel/draw/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { IconIdentifier } from '../../components';
import { Styles } from '../../core/maplibre';
import { ModeInfo, Modes } from './types';
import { ModeInfo, OptionalModes, RequiredModes } from './types';

export const MODES: Record<Modes, ModeInfo> = {
export const MODES: Record<RequiredModes, ModeInfo> &
Partial<Record<OptionalModes, ModeInfo>> = {
select: {
iconIdentifier: IconIdentifier.Select,
},
Expand All @@ -15,16 +16,20 @@ export const MODES: Record<Modes, ModeInfo> = {
polygon: {
iconIdentifier: IconIdentifier.Polygon,
},
rectangle: {
};

// Enable rest of the modes in desktop view.
if (window.innerWidth > 768) {
MODES.rectangle = {
iconIdentifier: IconIdentifier.Rectangle,
},
circle: {
};
MODES.circle = {
iconIdentifier: IconIdentifier.Circle,
},
freehand: {
};
MODES.freehand = {
iconIdentifier: IconIdentifier.Freehand,
},
};
};
}

export const DEFAULT_STYLES: Styles = {
pointColor: '#60a5fa',
Expand Down
3 changes: 3 additions & 0 deletions src/layer-panel/draw/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export type Modes =
| 'circle'
| 'freehand';

export type RequiredModes = Exclude<Modes, 'freehand' | 'circle' | 'rectangle'>;
export type OptionalModes = Exclude<Modes, RequiredModes>;

export type ModeInfo = {
iconIdentifier: IconIdentifier;
};

0 comments on commit 9352e2d

Please sign in to comment.