diff --git a/src/webparts/map/components/Map.module.scss b/src/webparts/map/components/Map.module.scss index acce0bf30..4de807cc9 100644 --- a/src/webparts/map/components/Map.module.scss +++ b/src/webparts/map/components/Map.module.scss @@ -172,47 +172,6 @@ border: solid 1px $ms-color-themeDarker !important; } - .map-legend { - display: flex; - margin-top: 5px; - - &-title { - font-weight: 700; - padding-right: 4px; - font-size: 12px; - } - - &-marker-wrapper { - position: relative; - height: 36px; - float: left; - - & > div { - position: absolute; - } - - svg { - height: 18px !important; - } - - .map-icon, - .map-icon i { - font-size: 6px; - } - - .map-icon { - left: 3px; - top: 4px; - } - } - - label { - margin: 0 10px 0 16px; - padding: 1px 0; - font-size: 12px; - } - } - .panel-footer { button { margin: 0 5px; diff --git a/src/webparts/map/components/Map.tsx b/src/webparts/map/components/Map.tsx index 12e7e32f8..741bb5c6e 100644 --- a/src/webparts/map/components/Map.tsx +++ b/src/webparts/map/components/Map.tsx @@ -19,7 +19,8 @@ import { isFunction } from 'lodash'; import { MarkerIcon } from './MarkerIcon'; import MarkerClusterGroup from 'react-leaflet-markercluster'; import * as strings from 'MapWebPartStrings'; -import SearchPlugin from './plugin/SearchPlugin'; +import SearchPlugin from './plugins/search/SearchPlugin'; +import LegendPlugin from './plugins/legend/LegendPlugin'; interface IMapState { markerItems: IMarker[]; @@ -151,9 +152,10 @@ export default class Map extends React.Component { } {this.renderSearchBox()} + {this.renderLegend(isZoomControlEnabled)} - {this.renderLegend()} + {this.props.isEditMode && { ); } - private renderLegend(): JSX.Element { + private renderLegend(isZoomControlEnabled: boolean): JSX.Element { if(!getDeepOrDefault(this.props, "plugins.legend", false) || isNullOrEmpty(this.state.markerCategories)) { return (<>); } return ( -
- {strings.LegendLabel}: - {this.state.markerCategories.map((cat: IMarkerCategory): JSX.Element => { - return ( -
-
-
- -
-
- -
); - })} -
); + + ); } private renderSearchBox(): JSX.Element { diff --git a/src/webparts/map/components/plugins/legend/LegendPlugin.module.scss b/src/webparts/map/components/plugins/legend/LegendPlugin.module.scss new file mode 100644 index 000000000..aff7e9096 --- /dev/null +++ b/src/webparts/map/components/plugins/legend/LegendPlugin.module.scss @@ -0,0 +1,62 @@ +@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss'; + + +.map-plugin-legend { + display: block; + + + &-bottom { + top: 80px; + } + + button { + outline: none; + border-radius: 2px; + height: 32px; + border: 2px solid rgba(0,0,0,0.2); + background-clip: padding-box; + font-size: 1.4em; + background: #fff; + cursor: pointer; + } +} + +:global { + .map-legend { + margin: 10px; + + &-title { + font-weight: 700; + // padding-right: 4px; + // font-size: 12px; + text-align: center; + font-size: 1.5em; + } + + &-marker-item { + display: flex; + padding: 5px 10px; + align-items: center; + + &-icon { + width: 35px; + } + } + + &-marker-wrapper { + position: relative; + height: 36px; + // float: left; + + & > div { + position: absolute; + } + } + + label { + margin: 0 10px 0 16px; + padding: 1px 0; + font-size: 12px; + } + } +} \ No newline at end of file diff --git a/src/webparts/map/components/plugins/legend/LegendPlugin.tsx b/src/webparts/map/components/plugins/legend/LegendPlugin.tsx new file mode 100644 index 000000000..f8992dc7c --- /dev/null +++ b/src/webparts/map/components/plugins/legend/LegendPlugin.tsx @@ -0,0 +1,82 @@ +import { Callout } from '@microsoft/office-ui-fabric-react-bundle'; +import { randomString } from '@spfxappdev/utility'; +import * as strings from 'MapWebPartStrings'; +import { Icon, Label, Separator } from 'office-ui-fabric-react'; +import * as React from 'react'; +import { IMarkerCategory } from '../../IMapProps'; +import { MarkerIcon } from '../../MarkerIcon'; +import styles from './LegendPlugin.module.scss'; + + + +export interface ILegendPluginProps { + markerCategories: IMarkerCategory[]; + isZoomControlVisible: boolean; +} + +interface ILegendPluginState { + isCalloutVisible: boolean; +} + +export default class LegendPlugin extends React.Component { + + public state: ILegendPluginState = { + isCalloutVisible: false + }; + + private randomId: string; + + constructor(props: ILegendPluginProps) { + super(props); + this.randomId = `map_legend_${randomString(6)}`; + } + + public render(): React.ReactElement { + + let cssClass = styles['map-plugin-legend']; + if(this.props.isZoomControlVisible) { + cssClass += ' ' + styles['map-plugin-legend-bottom']; + } + + return ( +
+
+ + { this.setState({ isCalloutVisible: false }); }} + hidden={!this.state.isCalloutVisible}> +
+ + + {this.props.markerCategories.map((cat: IMarkerCategory): JSX.Element => { + return ( +
+
+
+
+ +
+
+
+ +
); + })} +
+
+
+
); + } +} \ No newline at end of file diff --git a/src/webparts/map/components/plugin/SearchPlugin.module.scss b/src/webparts/map/components/plugins/search/SearchPlugin.module.scss similarity index 100% rename from src/webparts/map/components/plugin/SearchPlugin.module.scss rename to src/webparts/map/components/plugins/search/SearchPlugin.module.scss diff --git a/src/webparts/map/components/plugin/SearchPlugin.tsx b/src/webparts/map/components/plugins/search/SearchPlugin.tsx similarity index 98% rename from src/webparts/map/components/plugin/SearchPlugin.tsx rename to src/webparts/map/components/plugins/search/SearchPlugin.tsx index 4b45b38c5..9b1aac8c0 100644 --- a/src/webparts/map/components/plugin/SearchPlugin.tsx +++ b/src/webparts/map/components/plugins/search/SearchPlugin.tsx @@ -100,7 +100,6 @@ export default class SearchPlugin extends React.Component