Skip to content

feat: Added prop to hide toolbar #890

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

Merged
merged 3 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion react/src/demo/example-data/deckgl-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
],
"horizontal": false
},
"toolbar": {
"visible": true
},
"coordinateUnit": "m",
"resources": {
"propertyMap": "https://raw.githubusercontent.com/equinor/webviz-subsurface-components/master/react/src/demo/example-data/propertyMap.png",
Expand Down Expand Up @@ -136,7 +139,7 @@
},
{
"@@type": "DrawingLayer"
}
}
],
"editedData": {},
"views": {
Expand Down
15 changes: 15 additions & 0 deletions react/src/lib/components/DeckGLMap/DeckGLMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ interface DeckGLMapProps {
position?: number[] | null;
};
coordinateUnit?: string;
toolbar?: {
visible?: boolean | null;
};
legend?: {
visible?: boolean | null;
position?: number[] | null;
Expand All @@ -50,6 +53,7 @@ const DeckGLMap: React.FC<DeckGLMapProps> = ({
scale,
coordinateUnit,
legend,
toolbar,
colorTables,
editedData,
setProps,
Expand Down Expand Up @@ -115,6 +119,7 @@ const DeckGLMap: React.FC<DeckGLMapProps> = ({
coords={coords}
scale={scale}
coordinateUnit={coordinateUnit}
toolbar={toolbar}
legend={legend}
colorTables={colorTables}
editedData={editedData}
Expand Down Expand Up @@ -253,6 +258,16 @@ DeckGLMap.propTypes = {
*/
coordinateUnit: PropTypes.string,

/**
* Parameters to control toolbar
*/
toolbar: PropTypes.shape({
/**
* Toggle toolbar visibility
*/
visible: PropTypes.bool,
}),

/**
* Parameters for the legend
*/
Expand Down
21 changes: 17 additions & 4 deletions react/src/lib/components/DeckGLMap/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ export interface MapProps {

coordinateUnit?: string;

/**
* Parameters to control toolbar
*/
toolbar?: {
visible?: boolean | null;
};

legend?: {
visible?: boolean | null;
position?: number[] | null;
Expand Down Expand Up @@ -158,6 +165,7 @@ const Map: React.FC<MapProps> = ({
coords,
scale,
coordinateUnit,
toolbar,
legend,
colorTables,
editedData,
Expand Down Expand Up @@ -327,10 +335,12 @@ const Map: React.FC<MapProps> = ({
colorTables={colorTables}
/>
)}
<Settings
viewportId={view.id}
layerIds={view.layerIds}
/>
{toolbar?.visible && (
<Settings
viewportId={view.id}
layerIds={view.layerIds}
/>
)}
{views.showLabel && (
<ViewFooter>
{`${
Expand Down Expand Up @@ -377,6 +387,9 @@ Map.defaultProps = {
widthPerUnit: 100,
position: [10, 10],
},
toolbar: {
visible: true,
},
legend: {
visible: true,
position: [5, 10],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ KhMapMesh.args = {
...meshMapLayer,
},
],
toolbar: {
visible: false,
},
bounds: [432150, 6475800, 439400, 6481500],
views: {
layout: [1, 1],
Expand Down Expand Up @@ -335,6 +338,9 @@ GridLayer.args = {
visible: true,
},
],
toolbar: {
visible: false,
},
views: {
layout: [1, 1],
viewports: [
Expand Down