From bf18256a519f89a3b77e11ab5fd3ac074eb7feb8 Mon Sep 17 00:00:00 2001 From: Nat Hillard Date: Tue, 29 Jun 2021 19:12:08 -0400 Subject: [PATCH] Creating constants file and moving property there, using Score D --- client/src/components/mapPopup.tsx | 3 ++- client/src/components/mapWrapper.tsx | 2 ++ client/src/data/constants.tsx | 1 + client/src/data/mapStyle.tsx | 13 +++++++------ 4 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 client/src/data/constants.tsx diff --git a/client/src/components/mapPopup.tsx b/client/src/components/mapPopup.tsx index 5aede0a5..8b7fbb52 100644 --- a/client/src/components/mapPopup.tsx +++ b/client/src/components/mapPopup.tsx @@ -5,6 +5,7 @@ import {Table} from '@trussworks/react-uswds'; import {Coordinate} from 'ol/Coordinate'; import Map from 'ol/Map'; import {FeatureLike} from 'ol/Feature'; +import * as constants from '../data/constants'; interface IMapPopupProps { map: Map, @@ -62,7 +63,7 @@ const MapPopup = ({map, selectedFeature, position}: IMapPopupProps) => { const getTitleContent = () => { const properties = selectedFeature.getProperties(); const blockGroup = properties['GEOID10']; - const score = properties['Score C (percentile)']; + const score = properties[constants.SCORE_PROPERTY]; return ( diff --git a/client/src/components/mapWrapper.tsx b/client/src/components/mapWrapper.tsx index 41c9b28d..30c4bff9 100644 --- a/client/src/components/mapWrapper.tsx +++ b/client/src/components/mapWrapper.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import {useFlags} from '../contexts/FlagContext'; import MapboxMap from './mapboxMap'; import OpenLayersMap from './openlayersMap'; +import * as constants from '../data/constants'; const MapWrapper = () => { const flags = useFlags(); @@ -12,6 +13,7 @@ const MapWrapper = () => { : } +

Current Score Property: {constants.SCORE_PROPERTY}

); }; diff --git a/client/src/data/constants.tsx b/client/src/data/constants.tsx new file mode 100644 index 00000000..fcf3bc76 --- /dev/null +++ b/client/src/data/constants.tsx @@ -0,0 +1 @@ +export const SCORE_PROPERTY = 'Score D (percentile)'; diff --git a/client/src/data/mapStyle.tsx b/client/src/data/mapStyle.tsx index aa16859a..e23eb030 100644 --- a/client/src/data/mapStyle.tsx +++ b/client/src/data/mapStyle.tsx @@ -1,5 +1,6 @@ import {Style, FillPaint} from 'mapbox-gl'; import chroma from 'chroma-js'; +import * as constants from '../data/constants'; // eslint-disable-next-line require-jsdoc function hexToHSLA(hex:string, alpha:number) { @@ -98,7 +99,7 @@ const mapStyle : Style = { 'custom': { 'type': 'vector', 'tiles': [ - 'https://d2zjid6n5ja2pt.cloudfront.net/0624_demo/{z}/{x}/{y}.pbf', + 'https://d2zjid6n5ja2pt.cloudfront.net/0629_demo/{z}/{x}/{y}.pbf', // For local development, use: // 'http://localhost:8080/data/tl_2010_bg_with_data/{z}/{x}/{y}.pbf', ], @@ -138,11 +139,11 @@ const mapStyle : Style = { 'source-layer': 'blocks', 'type': 'fill', 'filter': ['all', - ['>', 'Score C (percentile)', 0.6], + ['>', constants.SCORE_PROPERTY, 0.6], // ['in', 'STATEFP10', '01', '30', '34', '35', '36'], ], 'paint': makePaint({ - field: 'Score C (percentile)', + field: constants.SCORE_PROPERTY, minRamp: 0, medRamp: 0.6, maxRamp: 0.75, @@ -155,11 +156,11 @@ const mapStyle : Style = { 'source-layer': 'blocks', 'type': 'fill', 'filter': ['all', - ['>', 'Score C (percentile)', 0.6], - ['in', 'STATEFP10', '01', '30', '34', '35', '36'], + ['>', constants.SCORE_PROPERTY, 0.6], + // ['in', 'STATEFP10', '01', '30', '34', '35', '36'], ], 'paint': makePaint({ - field: 'Score C (percentile)', + field: constants.SCORE_PROPERTY, minRamp: 0, medRamp: 0.6, maxRamp: 1.0,