Skip to content

Commit

Permalink
Landcover legend [HE-813] (#652)
Browse files Browse the repository at this point in the history
* remove log

* remove basemap selector from non necesary pages

* add legend

* import colors from settings

* add responsive to legend

* fix max width on tablet

* fix responsive width
  • Loading branch information
anamontiaga authored Nov 16, 2023
1 parent 56110d0 commit 1edc0fe
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 24 deletions.
38 changes: 38 additions & 0 deletions src/containers/legend/landcover-legend/component.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';

import COLORS from 'styles/settings.scss';

import styles from './styles.module';

function LandcoverLegend() {
const LEGEND_ITEMS = [
{ label: 'Water', color: COLORS.water },
{ label: 'Trees', color: COLORS.trees },
{ label: 'Flooded Vegetation', color: COLORS['flooded-vegetation'] },
{ label: 'Crops', color: COLORS.crops },
{ label: 'Built area', color: COLORS['built-area'] },
{ label: 'Bare ground', color: COLORS['bare-ground'] },
{ label: 'Snow/Ice', color: COLORS['snow-ice'] },
{ label: 'Clouds', color: COLORS.clouds },
{ label: 'Rangeland', color: COLORS.rangeland },
];

return (
<div className={styles.legendContainer}>
<p className={styles.legendTitle}>Land cover types</p>
<div className={styles.legendItems}>
{LEGEND_ITEMS.map((item) => (
<div key={item.label} className={styles.legendItem}>
<div
className={styles.legendColor}
style={{ backgroundColor: item.color }}
/>
<p className={styles.legendItemLabel}>{item.label}</p>
</div>
))}
</div>
</div>
);
}

export default LandcoverLegend;
3 changes: 3 additions & 0 deletions src/containers/legend/landcover-legend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Component from './component';

export default Component;
73 changes: 73 additions & 0 deletions src/containers/legend/landcover-legend/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
@import 'styles/settings';
@import 'styles/typography-extends';

.legendContainer {
bottom: 28px;
display: flex;
flex-direction: column;
height: 64px;
position: absolute;
left: $sidebar-width;
margin-left: 46px;
z-index: $default-z-index;
max-width: 500px;
@media #{$tablet-portrait} {
bottom: 50px;
max-width: 250px;
}

@media #{$tablet-landscape} {
max-width: 400px;
}


@media #{$desktop} {
bottom: 16px;
max-width: none;
}


.legendTitle {
@extend %annotation;
color: $white;
text-transform: uppercase;
}

.legendItems {
display: flex;
max-width: 550px;
flex-wrap: wrap;
height: 12px;

@media #{$desktop} {
max-width: 900px;
}


.legendItem {
display: flex;
align-items: center;
margin-right: 10px;
height: 12px;
margin-bottom: 6px;

@media #{$desktop} {
margin-bottom: 0;
}

.legendColor {
border-radius: 1px;
opacity: 70%;
width: 8px;
height: 8px;
margin-right: 4px;
}
.legendItemLabel {
@extend %annotation;
color: $white;
white-space: nowrap;
}
}
}
}

3 changes: 3 additions & 0 deletions src/containers/scenes/aoi-scene/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import FeatureHighlightLayer from 'containers/layers/feature-highlight-layer';
import LabelsLayer from 'containers/layers/labels-layer';
import MaskAndOutlineGraphicLayer from 'containers/layers/mask-and-outline-graphic-layer';
import TerrainExaggerationLayer from 'containers/layers/terrain-exaggeration-layer';
import LandcoverLegend from 'containers/legend/landcover-legend';
import ArcgisLayerManager from 'containers/managers/arcgis-layer-manager';
import ZoomIntoGeometryManager from 'containers/managers/zoom-into-geometry-manager';
import BasemapSelector from 'containers/menus/basemap-selector';
Expand Down Expand Up @@ -34,6 +35,7 @@ function AoiSceneComponent({
onboardingStep,
waitingInteraction,
activeLayers,
landcoverBasemap,
}) {
return (
<Scene
Expand All @@ -54,6 +56,7 @@ function AoiSceneComponent({
<ZoomIntoGeometryManager localGeometry={geometry} />
<SideMenu activeLayers={activeLayers} />
{!onboardingType && <BasemapSelector />}
{landcoverBasemap && <LandcoverLegend />}

<TerrainExaggerationLayer />

Expand Down
4 changes: 0 additions & 4 deletions src/containers/scenes/data-scene/data-scene-component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import { getSidebarTabs } from 'constants/ui-params';
import animationStyles from 'styles/common-animations.module.scss';
import uiStyles from 'styles/ui.module';

import BasemapSelector from '../../menus/basemap-selector';

import styles from './data-scene-styles.module.scss';

const Spinner = loadable(() => import('components/spinner'));
Expand Down Expand Up @@ -140,8 +138,6 @@ function DataSceneComponent({
/>
)}

{!onboardingType && <BasemapSelector blur={activeGlobesMenu} />}

<GlobePageIndicator onMouseEnter={() => setActiveGlobesMenu(true)} />

<MapTooltip
Expand Down
4 changes: 0 additions & 4 deletions src/containers/scenes/nrc-landing-scene/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import { LOCAL_SPATIAL_REFERENCE } from 'constants/scenes-constants';

import uiStyles from 'styles/ui.module';

import BasemapSelector from '../../menus/basemap-selector';

import styles from './nrc-landing-scene-styles.module.scss';

const Spinner = loadable(() => import('components/spinner'));
Expand Down Expand Up @@ -117,8 +115,6 @@ function NrcLandingComponent({
/>
)}

{!onboardingType && <BasemapSelector blur={activeGlobesMenu} />}

<GlobePageIndicator onMouseEnter={() => setActiveGlobesMenu(true)} />

<CountryEntryTooltip
Expand Down
2 changes: 0 additions & 2 deletions src/pages/data-globe/data-globe-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
selectGlobeUrlState,
selectUiUrlState,
} from 'selectors/location-selectors';
import { getLandcoverBasemap } from 'selectors/ui-selectors';

import dataSceneConfig from 'scenes/data-scene/data-scene-config';

Expand Down Expand Up @@ -139,5 +138,4 @@ export default createStructuredSelector({
onboardingStep: getOnboardingStep,
waitingInteraction: getOnWaitingInteraction,
aoiId: getAOIId,
landcoverBasemap: getLandcoverBasemap,
});
3 changes: 1 addition & 2 deletions src/pages/data-globe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import mapStateToProps from './data-globe-selectors';
const actions = { ...urlActions };

function DataGlobeContainer(props) {
const { changeGlobe, landcoverBasemap, sceneSettings } = props;
const { changeGlobe, sceneSettings } = props;

const handleGlobeUpdating = (updating) =>
changeGlobe({ isGlobeUpdating: updating });
Expand All @@ -24,7 +24,6 @@ function DataGlobeContainer(props) {
setBasemap({
map,
surfaceColor: '#070710',
landcoverBasemap,
layersArray: sceneSettings.basemap.layersArray,
});
activateLayersOnLoad(map, activeLayers, layersConfig);
Expand Down
3 changes: 0 additions & 3 deletions src/pages/featured-globe/featured-globe-component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import Spinner from 'components/spinner';

import uiStyles from 'styles/ui.module';

import BasemapSelector from '../../containers/menus/basemap-selector';

const InfoModal = loadable(() => import('components/modal-metadata'));
const FeaturedPlaceCard = loadable(() =>
import('containers/sidebars/featured-place-card')
Expand Down Expand Up @@ -96,7 +94,6 @@ function FeaturedGlobe({
blur={activeGlobesMenu}
/>
)}
<BasemapSelector blur={activeGlobesMenu} />

{!selectedFeaturedPlace && (
<GlobePageIndicator onMouseEnter={() => setActiveGlobesMenu(true)} />
Expand Down
2 changes: 0 additions & 2 deletions src/pages/featured-globe/featured-globe-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
selectGlobeUrlState,
selectUiUrlState,
} from 'selectors/location-selectors';
import { getLandcoverBasemap } from 'selectors/ui-selectors';

import initialState from './featured-globe-initial-state';

Expand Down Expand Up @@ -91,5 +90,4 @@ export default createStructuredSelector({
isGlobeUpdating: getGlobeUpdating,
selectedSpecies: getSelectedSpecies,
openedModal: getHalfEarthModalOpen,
landcoverBasemap: getLandcoverBasemap,
});
2 changes: 0 additions & 2 deletions src/pages/featured-globe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const featuredGlobeContainer = (props) => {
isFeaturedPlaceCard,
isFullscreenActive,
sceneSettings,
landcoverBasemap,
} = props;

const handleMarkerClick = (viewPoint) => {
Expand Down Expand Up @@ -79,7 +78,6 @@ const featuredGlobeContainer = (props) => {
setBasemap({
map,
surfaceColor: '#070710',
landcoverBasemap,
layersArray: sceneSettings.basemap.layersArray,
});
activateLayersOnLoad(map, _activeLayers, layersConfig);
Expand Down
1 change: 0 additions & 1 deletion src/pages/landing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function LandingContainer(props) {
setBasemap({
map,
surfaceColor: '#070710',

layersArray: [],
});
activateLayersOnLoad(map, activeLayers, layersConfig);
Expand Down
3 changes: 1 addition & 2 deletions src/pages/nrc-landing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import mapStateToProps from './selectors';
const actions = { ...urlActions };

function NrcLandingContainer(props) {
const { changeGlobe, landcoverBasemap, sceneSettings } = props;
const { changeGlobe, sceneSettings } = props;

const handleGlobeUpdating = (updating) =>
changeGlobe({ isGlobeUpdating: updating });
Expand All @@ -24,7 +24,6 @@ function NrcLandingContainer(props) {
setBasemap({
map,
surfaceColor: '#070710',
landcoverBasemap,
layersArray: sceneSettings.basemap.layersArray,
});
activateLayersOnLoad(map, activeLayers, layersConfig);
Expand Down
2 changes: 0 additions & 2 deletions src/pages/nrc-landing/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
selectGlobeUrlState,
selectUiUrlState,
} from 'selectors/location-selectors';
import { getLandcoverBasemap } from 'selectors/ui-selectors';

import dataSceneConfig from 'scenes/nrc-landing-scene/scene-config';

Expand Down Expand Up @@ -92,5 +91,4 @@ export default createStructuredSelector({
onboardingStep: getOnboardingStep,
waitingInteraction: getOnWaitingInteraction,
locationRoute: getLocationRoute,
landcoverBasemap: getLandcoverBasemap,
});
23 changes: 23 additions & 0 deletions src/styles/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@
$oceania: $tango;
$south-america: $french-rose;

// Landcover legend
$water: #3972B8;
$trees: #175408;
$flooded-vegetation: #4FAB6C;
$crops: #B89B35;
$built-area: #FF0066;
$bare-ground: #5B5A48;
$snow-ice: #F2FAFF;
$clouds: #FAFAFA;
$rangeland: #EBE0D3;


// Modal
$modal-light-background: $athens-gray;

Expand Down Expand Up @@ -227,6 +239,17 @@
athens-gray: $athens-gray;
oslo-gray: $oslo-gray;

// Landcover legend
water: $water;
trees: $trees;
flooded-vegetation: $flooded-vegetation;
crops: $crops;
built-area: $built-area;
bare-ground: $bare-ground;
snow-ice: $snow-ice;
clouds: $clouds;
rangeland: $rangeland;

// FONT FAMILIES
font-family-serif: $font-family-serif;
}

0 comments on commit 1edc0fe

Please sign in to comment.