Show island low income percentiles in sidebar

This commit is contained in:
Ryon Coleman 2024-12-06 15:36:45 -05:00 committed by Carlos Felix
parent c6c9a1a1f7
commit dd43b64579
15 changed files with 158 additions and 12 deletions

View file

@ -1,8 +1,8 @@
/* eslint-disable quotes */ /* eslint-disable quotes */
// External Libs: // External Libs:
import React from "react";
import {MessageDescriptor, useIntl} from "gatsby-plugin-intl";
import {Accordion, Button} from "@trussworks/react-uswds"; import {Accordion, Button} from "@trussworks/react-uswds";
import {MessageDescriptor, useIntl} from "gatsby-plugin-intl";
import React from "react";
// Components: // Components:
import Category from "../Category"; import Category from "../Category";
@ -15,11 +15,12 @@ import TractInfo from "../TractInfo";
import TractPrioritization from "../TractPrioritization"; import TractPrioritization from "../TractPrioritization";
// Styles and constants // Styles and constants
import * as styles from "./areaDetail.module.scss";
import * as constants from "../../data/constants"; import * as constants from "../../data/constants";
import * as EXPLORE_COPY from "../../data/copy/explore"; import * as EXPLORE_COPY from "../../data/copy/explore";
import * as styles from "./areaDetail.module.scss";
// @ts-ignore // @ts-ignore
import IslandCopy from "../IslandCopy/IslandCopy";
import launchIcon from "/node_modules/uswds/dist/img/usa-icons/launch.svg"; import launchIcon from "/node_modules/uswds/dist/img/usa-icons/launch.svg";
interface IAreaDetailProps { interface IAreaDetailProps {
@ -1192,6 +1193,13 @@ const AreaDetail = ({properties}: IAreaDetailProps) => {
</div> </div>
</div> </div>
{/* Show IslandCopy if the GeoID matches an island prefix */}
{constants.TILES_ISLAND_AREA_FIPS_CODES.some((code) => {
return properties[constants.GEOID_PROPERTY].startsWith(code);
}) && (
<IslandCopy povertyPercentile={ properties[constants.CENSUS_DECENNIAL_POVERTY_LESS_THAN_200_FPL_PERCENTILE]} />
)}
{/* Only show the DonutCopy if Adjacency index is true, the total number of disadv ind == 0, {/* Only show the DonutCopy if Adjacency index is true, the total number of disadv ind == 0,
and not grandfathered. */} and not grandfathered. */}
{properties[constants.ADJACENCY_EXCEEDS_THRESH] && {properties[constants.ADJACENCY_EXCEEDS_THRESH] &&

View file

@ -0,0 +1,44 @@
@use '../../styles/design-system.scss' as *;
@import "../utils.scss";
.islandCopyContainer{
@include u-display('flex');
flex-direction: column;
@include u-padding-left(2);
@include u-padding-right(2.5);
@include u-padding-top(2);
.islandRow {
@include u-display('flex');
justify-content: space-between;
.islandRowLabel {
font-weight: bold;
}
.valueSubTextContainer {
@include u-display('flex');
flex-direction: column;
.subTextContainer{
@include indicatorValueSubTextContainer();
}
}
}
.islandRow:first-child {
@include u-padding-bottom("05");
}
.valueContainer {
@include u-text('bold');
}
.invert {
align-self: flex-end;
@include invert();
}
.noInvert {
align-self: flex-end;
}
}

View file

@ -0,0 +1,19 @@
declare namespace IslandCopyNamespace {
export interface IIslandCopyScss {
islandCopyContainer: string;
islandRow: string;
islandRowLabel: string;
invert: string;
noInvert: string;
valueSubTextContainer: string;
valueContainer: string;
subTextContainer: string;
}
}
declare const IslandCopyScssModule: IslandCopyNamespace.IIslandCopyScss & {
/** WARNING: Only available when "css-loader" is used without "style-loader" or "mini-css-extract-plugin" */
locals: IslandCopyNamespace.IIslandCopyScss;
};
export = IslandCopyScssModule;

View file

@ -0,0 +1,51 @@
import {useIntl} from 'gatsby-plugin-intl';
import React from 'react';
import {IndicatorValue, IndicatorValueSubText} from '../Indicator/Indicator';
import * as styles from './IslandCopy.module.scss';
import * as EXPLORE_COPY from '../../data/copy/explore';
export interface IIslandCopyProps {
povertyPercentile: number | null
}
const IslandCopy = ({povertyPercentile}: IIslandCopyProps) => {
const intl = useIntl();
const percentileWhole = povertyPercentile ?
parseFloat((povertyPercentile*100).toFixed()) : null;
const threshold = 65;
return (
<div className={styles.islandCopyContainer}>
<div className={styles.islandRow}>
<div className={styles.islandRowLabel}>
{intl.formatMessage(EXPLORE_COPY.ISLAND_COPY.LOW_INC)}
</div>
<div className={styles.valueSubTextContainer}>
<div className={`${styles.valueContainer}
${ percentileWhole && percentileWhole >= threshold ?
styles.invert :
styles.noInvert }
`}>
<IndicatorValue
type={'percentile'}
displayStat={percentileWhole}
/>
</div>
<div className={styles.subTextContainer}>
<IndicatorValueSubText
value={percentileWhole}
isAboveThresh={percentileWhole && percentileWhole >= threshold ? true : false}
threshold={threshold}
type={'percentile'}
/>
</div>
</div>
</div>
</div>
);
};
export default IslandCopy;

View file

@ -40,8 +40,8 @@ const PrioritizationCopy2 =
tribalCountUS, tribalCountUS,
percentTractTribal, percentTractTribal,
}:IPrioritizationCopy2) => { }:IPrioritizationCopy2) => {
let noStyles = false; let prioCopy2Rendered = <></>;
let prioCopy2Rendered;
// if 1 // if 1
if ( if (
@ -165,13 +165,10 @@ const PrioritizationCopy2 =
(tribalCountAK !== null && tribalCountAK >= 1) (tribalCountAK !== null && tribalCountAK >= 1)
) { ) {
prioCopy2Rendered = EXPLORE_COPY.getPrioANVCopy(tribalCountAK, false); prioCopy2Rendered = EXPLORE_COPY.getPrioANVCopy(tribalCountAK, false);
} else {
prioCopy2Rendered = <></>;
noStyles = true;
}; };
return ( return (
<div className={noStyles ? '' : styles.prioritizationCopy2Container}> <div className={prioCopy2Rendered !== <></> ? '' : styles.prioritizationCopy2Container}>
{prioCopy2Rendered} {prioCopy2Rendered}
</div> </div>
); );

View file

@ -2,7 +2,9 @@
exports[`rendering of PrioritizationCopy2 Component checks if component renders The lands of Federally Recognized Tribes that cover 2% of this tract are also considered disadvantaged. when totCats = 0, totBurds = 0, isAdj = true, isAdjLI = true, tribal % = 2, 1`] = ` exports[`rendering of PrioritizationCopy2 Component checks if component renders The lands of Federally Recognized Tribes that cover 2% of this tract are also considered disadvantaged. when totCats = 0, totBurds = 0, isAdj = true, isAdjLI = true, tribal % = 2, 1`] = `
<DocumentFragment> <DocumentFragment>
<div> <div
class=""
>
The lands of Federally Recognized Tribes that cover 2% of this tract are also considered disadvantaged. The lands of Federally Recognized Tribes that cover 2% of this tract are also considered disadvantaged.
</div> </div>
</DocumentFragment> </DocumentFragment>
@ -10,7 +12,9 @@ exports[`rendering of PrioritizationCopy2 Component checks if component renders
exports[`rendering of PrioritizationCopy2 Component checks if component renders The lands of Federally Recognized Tribes that cover 4% of this tract are also considered disadvantaged. when totCats = 0, totBurds = 1, isAdj = true, isAdjLI = true, tribal % = 4, 1`] = ` exports[`rendering of PrioritizationCopy2 Component checks if component renders The lands of Federally Recognized Tribes that cover 4% of this tract are also considered disadvantaged. when totCats = 0, totBurds = 1, isAdj = true, isAdjLI = true, tribal % = 4, 1`] = `
<DocumentFragment> <DocumentFragment>
<div> <div
class=""
>
The lands of Federally Recognized Tribes that cover 4% of this tract are also considered disadvantaged. The lands of Federally Recognized Tribes that cover 4% of this tract are also considered disadvantaged.
</div> </div>
</DocumentFragment> </DocumentFragment>

View file

@ -110,6 +110,8 @@ export const IS_EXCEED_BOTH_SOCIO_INDICATORS = "N_EBSI";
export const POVERTY_BELOW_200_PERCENTILE = "P200_I_PFS"; export const POVERTY_BELOW_200_PERCENTILE = "P200_I_PFS";
export const IS_FEDERAL_POVERTY_LEVEL_200 = "FPL200S"; export const IS_FEDERAL_POVERTY_LEVEL_200 = "FPL200S";
// Percentile FPL 200 for islands only
export const CENSUS_DECENNIAL_POVERTY_LESS_THAN_200_FPL_PERCENTILE = "FPL200P";
export const HIGHER_ED_PERCENTILE = "CA"; export const HIGHER_ED_PERCENTILE = "CA";
export const IS_HIGHER_ED_PERCENTILE = "CA_LT20"; export const IS_HIGHER_ED_PERCENTILE = "CA_LT20";

View file

@ -772,6 +772,13 @@ export const DONUT_COPY = defineMessages({
description: `Navigate to the explore the map page. Click on side panel, this copy may show up`, description: `Navigate to the explore the map page. Click on side panel, this copy may show up`,
}, },
}); });
export const ISLAND_COPY = defineMessages({
LOW_INC: {
id: 'explore.map.page.side.panel.island.copy.low.income',
defaultMessage: 'Low income',
description: `Navigate to the explore the map page. Click on side panel, this copy may show up`,
},
});
export const COMMUNITY = { export const COMMUNITY = {
OF_FOCUS: <FormattedMessage OF_FOCUS: <FormattedMessage
id={'explore.map.page.side.panel.community.of.focus'} id={'explore.map.page.side.panel.community.of.focus'}

View file

@ -1375,6 +1375,10 @@
"defaultMessage": "Identified as disadvantaged?", "defaultMessage": "Identified as disadvantaged?",
"description": "Navigate to the explore the map page. When the map is in view, click on the map. The side panel will show asking IF the communities is focused on" "description": "Navigate to the explore the map page. When the map is in view, click on the map. The side panel will show asking IF the communities is focused on"
}, },
"explore.map.page.side.panel.island.copy.low.income": {
"defaultMessage": "Low income",
"description": "Navigate to the explore the map page. Click on side panel, this copy may show up"
},
"explore.map.page.side.panel.not.community.of.focus": { "explore.map.page.side.panel.not.community.of.focus": {
"defaultMessage": "NO", "defaultMessage": "NO",
"description": "Navigate to the explore the map page. When the map is in view, click on the map. The side panel will show the communities the score currently is not focused on" "description": "Navigate to the explore the map page. When the map is in view, click on the map. The side panel will show the communities the score currently is not focused on"

View file

@ -213,6 +213,7 @@
"explore.map.page.side.panel.demo.two.or.more": "Dos o más razas", "explore.map.page.side.panel.demo.two.or.more": "Dos o más razas",
"explore.map.page.side.panel.demo.white": "Personas de raza blanca", "explore.map.page.side.panel.demo.white": "Personas de raza blanca",
"explore.map.page.side.panel.donut.copy.adj.low.income": "Bajos ingresos ajustados", "explore.map.page.side.panel.donut.copy.adj.low.income": "Bajos ingresos ajustados",
"explore.map.page.side.panel.island.copy.low.income": "Bajos ingresos",
"explore.map.page.side.panel.donut.copy.complete.surround": "completamente rodeada", "explore.map.page.side.panel.donut.copy.complete.surround": "completamente rodeada",
"explore.map.page.side.panel.exceed.burden.answer.no": "No", "explore.map.page.side.panel.exceed.burden.answer.no": "No",
"explore.map.page.side.panel.exceed.burden.answer.yes": "Sí", "explore.map.page.side.panel.exceed.burden.answer.yes": "Sí",

View file

@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
"module": "commonjs", "module": "commonjs",
"target": "es6", "target": "es6",
"jsx": "preserve", "jsx": "react",
"lib": ["dom", "es2015", "es2017", "es2019"], "lib": ["dom", "es2015", "es2017", "es2019"],
"strict": true, "strict": true,
"noEmit": true, "noEmit": true,

View file

@ -347,6 +347,8 @@ TILES_SCORE_COLUMNS = {
# These are the booleans for socioeconomic indicators # These are the booleans for socioeconomic indicators
## this measures low income boolean ## this measures low income boolean
field_names.FPL_200_SERIES_IMPUTED_AND_ADJUSTED: "FPL200S", field_names.FPL_200_SERIES_IMPUTED_AND_ADJUSTED: "FPL200S",
# Percentile FPL 200 for islands only
field_names.CENSUS_DECENNIAL_POVERTY_LESS_THAN_200_FPL_PERCENTILE: "FPL200P",
## Low high school for t&wd ## Low high school for t&wd
field_names.WORKFORCE_SOCIO_INDICATORS_EXCEEDED: "N_WKFC_EBSI", field_names.WORKFORCE_SOCIO_INDICATORS_EXCEEDED: "N_WKFC_EBSI",
field_names.DOT_BURDEN_PCTILE_THRESHOLD: "TD_ET", field_names.DOT_BURDEN_PCTILE_THRESHOLD: "TD_ET",

View file

@ -200,6 +200,11 @@ CENSUS_DECENNIAL_MEDIAN_INCOME_2019 = (
CENSUS_DECENNIAL_POVERTY_LESS_THAN_100_FPL_FIELD_2019 = f"Percentage households below 100% of federal poverty line in {DEC_DATA_YEAR}" CENSUS_DECENNIAL_POVERTY_LESS_THAN_100_FPL_FIELD_2019 = f"Percentage households below 100% of federal poverty line in {DEC_DATA_YEAR}"
CENSUS_DECENNIAL_POVERTY_LESS_THAN_200_FPL_FIELD_2019 = f"Percentage households below 200% of federal poverty line in {DEC_DATA_YEAR}" CENSUS_DECENNIAL_POVERTY_LESS_THAN_200_FPL_FIELD_2019 = f"Percentage households below 200% of federal poverty line in {DEC_DATA_YEAR}"
CENSUS_DECENNIAL_ADJUSTED_POVERTY_LESS_THAN_200_FPL_FIELD_2019 = f"{CENSUS_DECENNIAL_POVERTY_LESS_THAN_200_FPL_FIELD_2019}, adjusted and imputed" CENSUS_DECENNIAL_ADJUSTED_POVERTY_LESS_THAN_200_FPL_FIELD_2019 = f"{CENSUS_DECENNIAL_POVERTY_LESS_THAN_200_FPL_FIELD_2019}, adjusted and imputed"
CENSUS_DECENNIAL_POVERTY_LESS_THAN_200_FPL_PERCENTILE = (
CENSUS_DECENNIAL_ADJUSTED_POVERTY_LESS_THAN_200_FPL_FIELD_2019
+ ISLAND_AREAS_PERCENTILE_ADJUSTMENT_FIELD
+ PERCENTILE_FIELD_SUFFIX
)
CENSUS_DECENNIAL_HIGH_SCHOOL_ED_FIELD_2019 = f"Percent individuals age 25 or over with less than high school degree in {DEC_DATA_YEAR}" CENSUS_DECENNIAL_HIGH_SCHOOL_ED_FIELD_2019 = f"Percent individuals age 25 or over with less than high school degree in {DEC_DATA_YEAR}"
CENSUS_DECENNIAL_UNEMPLOYMENT_FIELD_2019 = ( CENSUS_DECENNIAL_UNEMPLOYMENT_FIELD_2019 = (
f"Unemployment (percent) in {DEC_DATA_YEAR}" f"Unemployment (percent) in {DEC_DATA_YEAR}"

View file

@ -1053,6 +1053,8 @@ class ScoreNarwhal(Score):
# Now we set the low income flag only for territories, but we need to rank them # Now we set the low income flag only for territories, but we need to rank them
# with all other tracts. # with all other tracts.
# Note: This specific method call will generate the
# CENSUS_DECENNIAL_POVERTY_LESS_THAN_200_FPL_PERCENTILE column in the score.
( (
self.df, self.df,
island_areas_poverty_200_criteria_field_name, island_areas_poverty_200_criteria_field_name,