From 9f0ca1c17dc6df3ed9f915a05792139495781779 Mon Sep 17 00:00:00 2001 From: Vim <86254807+vim-usds@users.noreply.github.com> Date: Fri, 3 Jun 2022 12:35:28 -0400 Subject: [PATCH] Add address to search placeholder and add "at or above" to category copy for low income (#1665) * Add address to search placeholder text * Adds "at or above" to category copy * Updates map search placeholder text - Update es and en.json files - adds mobile search placeholder text - udpates desktop search placeholder text * Update logic to determine mobile for search text * Update search error message - update to Spanish text as well * Adjust spacing between search and territory btns * Modify mobile detection logic - remove cypress tests for faster deploys * Add placeholder text to state variable - wrap state variable in useEffect() --- .github/workflows/deploy_fe_staging.yml | 14 ++++++------ .../__snapshots__/Categories.test.tsx.snap | 14 ++++++------ .../__snapshots__/CategoryCard.test.tsx.snap | 2 +- client/src/components/MapSearch/MapSearch.tsx | 22 +++++++++++++++++-- .../__snapshots__/MapSearch.test.tsx.snap | 4 ++-- .../MapSearchMessage.test.tsx.snap | 2 +- .../territoryFocusControl.module.scss | 9 ++++---- client/src/data/copy/explore.tsx | 9 ++++++-- client/src/data/copy/methodology.tsx | 2 +- client/src/intl/en.json | 10 ++++++--- client/src/intl/es.json | 7 +++--- .../__snapshots__/methodology.test.tsx.snap | 14 ++++++------ 12 files changed, 69 insertions(+), 40 deletions(-) diff --git a/.github/workflows/deploy_fe_staging.yml b/.github/workflows/deploy_fe_staging.yml index 58d8ea9d..54e8492c 100644 --- a/.github/workflows/deploy_fe_staging.yml +++ b/.github/workflows/deploy_fe_staging.yml @@ -49,13 +49,13 @@ jobs: run: npm test - name: Check for security vulnerabilities run: npm audit --production - - name: Cypress / Gherkin integration tests 🌃 - uses: cypress-io/github-action@v2 - with: - working-directory: ${{env.WORKING_DIRECTORY}} - browser: chrome - start: npm start - wait-on: "http://localhost:8000/en" + # - name: Cypress / Gherkin integration tests 🌃 + # uses: cypress-io/github-action@v2 + # with: + # working-directory: ${{env.WORKING_DIRECTORY}} + # browser: chrome + # start: npm start + # wait-on: "http://localhost:8000/en" - name: Upload Artifact uses: actions/upload-artifact@v2 with: diff --git a/client/src/components/Categories/__snapshots__/Categories.test.tsx.snap b/client/src/components/Categories/__snapshots__/Categories.test.tsx.snap index e52c4f0a..d414c3da 100644 --- a/client/src/components/Categories/__snapshots__/Categories.test.tsx.snap +++ b/client/src/components/Categories/__snapshots__/Categories.test.tsx.snap @@ -66,7 +66,7 @@ exports[`rendering of the Categories checks if component renders 1`] = ` AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -119,7 +119,7 @@ exports[`rendering of the Categories checks if component renders 1`] = ` AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -176,7 +176,7 @@ exports[`rendering of the Categories checks if component renders 1`] = ` AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -235,7 +235,7 @@ exports[`rendering of the Categories checks if component renders 1`] = ` AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -294,7 +294,7 @@ exports[`rendering of the Categories checks if component renders 1`] = ` AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -341,7 +341,7 @@ exports[`rendering of the Categories checks if component renders 1`] = ` AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -406,7 +406,7 @@ exports[`rendering of the Categories checks if component renders 1`] = ` AND - is above the 65th percentile for + is at or above the 65th percentile for diff --git a/client/src/components/CategoryCard/__snapshots__/CategoryCard.test.tsx.snap b/client/src/components/CategoryCard/__snapshots__/CategoryCard.test.tsx.snap index 4c983640..38c8bc95 100644 --- a/client/src/components/CategoryCard/__snapshots__/CategoryCard.test.tsx.snap +++ b/client/src/components/CategoryCard/__snapshots__/CategoryCard.test.tsx.snap @@ -44,7 +44,7 @@ exports[`rendering of the CategoryCard checks if component renders 1`] = ` AND - is above the 65th percentile for + is at or above the 65th percentile for diff --git a/client/src/components/MapSearch/MapSearch.tsx b/client/src/components/MapSearch/MapSearch.tsx index a4d96795..4fc4e808 100644 --- a/client/src/components/MapSearch/MapSearch.tsx +++ b/client/src/components/MapSearch/MapSearch.tsx @@ -1,7 +1,9 @@ -import React, {useState} from 'react'; +/* eslint-disable max-len */ +import React, {useEffect, useState} from 'react'; import {LngLatBoundsLike} from 'maplibre-gl'; import {useIntl} from 'gatsby-plugin-intl'; import {Search} from '@trussworks/react-uswds'; +import {useWindowSize} from 'react-use'; import MapSearchMessage from '../MapSearchMessage'; @@ -17,6 +19,22 @@ const MapSearch = ({goToPlace}:IMapSearch) => { const [isSearchResultsNull, setIsSearchResultsNull] = useState(false); const intl = useIntl(); + /** + * At compile-time, the width/height returned by useWindowSize will be X. When the client requests the + * app on run-time from CDN, and the app hydrates, reconcilation no longer occurs and the client is forced + * to use X. + * + * To avoid this, we set the placeholder text as a state variable. We also create a useEffect that updates + * that state whenenver the width changes. + * + */ + const {width, height} = useWindowSize(); + const [placeholderText, setPlaceholderText]= useState(EXPLORE_COPY.MAP.SEARCH_PLACEHOLDER); + + useEffect( () => { + width > height ? setPlaceholderText(EXPLORE_COPY.MAP.SEARCH_PLACEHOLDER): setPlaceholderText(EXPLORE_COPY.MAP.SEARCH_PLACEHOLDER_MOBILE); + }, [width]); + /* onSearchHandler will 1. extract the search term from the input field @@ -61,7 +79,7 @@ const MapSearch = ({goToPlace}:IMapSearch) => { onSearchHandler(e)} /> diff --git a/client/src/components/MapSearch/__snapshots__/MapSearch.test.tsx.snap b/client/src/components/MapSearch/__snapshots__/MapSearch.test.tsx.snap index b8b4dc9c..6a56e2de 100644 --- a/client/src/components/MapSearch/__snapshots__/MapSearch.test.tsx.snap +++ b/client/src/components/MapSearch/__snapshots__/MapSearch.test.tsx.snap @@ -4,7 +4,7 @@ exports[`rendering of the MapSearch checks if component renders 1`] = ` - No location found. Please try again. + Location not found or unknown. Please try a different search. - No location found. Please try again. + Location not found or unknown. Please try a different search. `; diff --git a/client/src/components/territoryFocusControl.module.scss b/client/src/components/territoryFocusControl.module.scss index fc368920..4f47ce39 100644 --- a/client/src/components/territoryFocusControl.module.scss +++ b/client/src/components/territoryFocusControl.module.scss @@ -7,14 +7,15 @@ } .territoryFocusContainer { - // styles for mobile-lg (480px) and greater widths + @include baseTerritoryFocus; + + // styles for mobile-lg (480px) and greater widths: @include at-media('mobile-lg') { - @include baseTerritoryFocus; top: units(card-lg); }; - @include baseTerritoryFocus; - top: units(9); + // styles for mobile-lg (480px) and smaller widths: + top: 100px; } diff --git a/client/src/data/copy/explore.tsx b/client/src/data/copy/explore.tsx index 602390c9..5f1aab38 100644 --- a/client/src/data/copy/explore.tsx +++ b/client/src/data/copy/explore.tsx @@ -63,12 +63,17 @@ export const MAP = defineMessages({ }, SEARCH_PLACEHOLDER: { id: 'explore.map.page.map.search.placeholder.text', - defaultMessage: 'Enter a city, state or ZIP', + defaultMessage: 'Search for an address, city, state or ZIP', + description: 'On the explore the map page, on the map, the placeholder text for search', + }, + SEARCH_PLACEHOLDER_MOBILE: { + id: 'explore.map.page.map.search.placeholder.mobile.text', + defaultMessage: 'Search locations', description: 'On the explore the map page, on the map, the placeholder text for search', }, SEARCH_RESULTS_EMPTY_MESSAGE: { id: 'explore.map.page.map.search.results.empty.text', - defaultMessage: 'No location found. Please try again.', + defaultMessage: 'Location not found or unknown. Please try a different search.', description: 'On the explore the map page, on the map, the text displaying message for no search results found', }, LOWER48_SHORT: { diff --git a/client/src/data/copy/methodology.tsx b/client/src/data/copy/methodology.tsx index 9fae8e93..79b624c5 100644 --- a/client/src/data/copy/methodology.tsx +++ b/client/src/data/copy/methodology.tsx @@ -95,7 +95,7 @@ export const CATEGORY_AND_CLAUSE = { LOW_INC_65_WHEN_HIGH_ED_LTE_20: AND is above the 65th percentile for low income AND 80% or more of individuals 15 or older are not enrolled in higher education + AND is at or above the 65th percentile for low income AND 80% or more of individuals 15 or older are not enrolled in higher education `} description={'Navigate to the methodology page. Navigate to the category section. This is category portion of the formula dealing with lower income and high school degree rate'} values={{ diff --git a/client/src/intl/en.json b/client/src/intl/en.json index ed305236..2a08f30d 100644 --- a/client/src/intl/en.json +++ b/client/src/intl/en.json @@ -343,12 +343,16 @@ "defaultMessage": "Communities identified as disadvantaged by the map are those that are marginalized, underserved, and overburdened by pollution. These communities are at or above the thresholds in one or more of eight categories of criteria.", "description": "On the explore the map page, the description of the legend" }, + "explore.map.page.map.search.placeholder.mobile.text": { + "defaultMessage": "Search locations", + "description": "On the explore the map page, on the map, the placeholder text for search" + }, "explore.map.page.map.search.placeholder.text": { - "defaultMessage": "Enter a city, state or ZIP", + "defaultMessage": "Search for an address, city, state or ZIP", "description": "On the explore the map page, on the map, the placeholder text for search" }, "explore.map.page.map.search.results.empty.text": { - "defaultMessage": "No location found. Please try again.", + "defaultMessage": "Location not found or unknown. Please try a different search.", "description": "On the explore the map page, on the map, the text displaying message for no search results found" }, "explore.map.page.map.territoryFocus.alaska.long": { @@ -920,7 +924,7 @@ "description": "Navigate to the methodology page. Navigate to the category section. This is the portion of the formula dealing with higher ed enrollment and high school degree rate" }, "methodology.page.category.and.clause.low.inc.hs.ed": { - "defaultMessage": "AND is above the 65th percentile for low income AND 80% or more of individuals 15 or older are not enrolled in higher education", + "defaultMessage": "AND is at or above the 65th percentile for low income AND 80% or more of individuals 15 or older are not enrolled in higher education", "description": "Navigate to the methodology page. Navigate to the category section. This is category portion of the formula dealing with lower income and high school degree rate" }, "methodology.page.category.asthma.description.text": { diff --git a/client/src/intl/es.json b/client/src/intl/es.json index 33f14118..ee15798b 100644 --- a/client/src/intl/es.json +++ b/client/src/intl/es.json @@ -87,8 +87,9 @@ "explore.map.page.heading.text": "Explore la herramienta", "explore.map.page.label.text": "Comunidad desfavorecida", "explore.map.page.legend.description.text": "Las comunidades que la herramienta identifica como desfavorecidas son las que se encuentran marginadas, desatendidas y abrumadas por la contaminación. Esas comunidades alcanzan los umbrales de una o más de ocho categorías de criterios, o los superan.", - "explore.map.page.map.search.placeholder.text": "Introduzca una ciudad, estado o código postal", - "explore.map.page.map.search.results.empty.text": "No se encontró el lugar. Vuelva a intentarlo.", + "explore.map.page.map.search.placeholder.mobile.text": "Buscar ubicaciones", + "explore.map.page.map.search.placeholder.text": "Busque una dirección, ciudad, estado o código postal", + "explore.map.page.map.search.results.empty.text": "Ubicación no encontrada o desconocida. Intente una búsqueda diferente.", "explore.map.page.map.territoryFocus.alaska.long": "Alaska", "explore.map.page.map.territoryFocus.alaska.short": "AK", "explore.map.page.map.territoryFocus.american.samoa.long": "Samoa estadounidense", @@ -232,7 +233,7 @@ "map.territoryFocus.focusOn": "Enfoque en {territory}", "methodology.page.categories.title": "Las comunidades están identificadas como desfavorecidas por la versión actual de la herramienta para los fines de la Iniciativa Justice40 si se encuentran en grupos de bloques del censo que estén en el umbral o por encima del umbral de una o más de las ocho categorías de criterios a continuación.", "methodology.page.category.and.clause.hs.ed.higher.ed": "Y 10% o más de los adultos con 25 años cumplidos no han obtenido un grado de escuela preparatoria o secundaria Y 80% o más de las personas con 15 años cumplidos no están inscritas en un programa de educación superior", - "methodology.page.category.and.clause.low.inc.hs.ed": "Y está por encima del percentil de 65 para bajos ingresos Y 80% o más de las personas con 15 años cumplidos no están inscritas en un programa de educación superior", + "methodology.page.category.and.clause.low.inc.hs.ed": "Y está en o por encima del percentil de 65 para bajos ingresos Y 80% o más de las personas con 15 años cumplidos no están inscritas en un programa de educación superior", "methodology.page.category.asthma.description.text": "Porcentaje ponderado de personas que respondan “sí” a ambas de las siguientes preguntas: “¿Alguna vez le dijo un médico, enfermero u otro profesional sanitario que tiene asma?” y “¿Aún tiene asma?\"", "methodology.page.category.card.title": "Comunidades que están identificadas como desfavorecidas", "methodology.page.category.diabetes.description.text": "Porcentaje ponderado de personas de 18 años cumplidos que informan que un médico, enfermero u otro profesional sanitario les dijo que tienen diabetes y no es diabetes gestacional.", diff --git a/client/src/pages/tests/__snapshots__/methodology.test.tsx.snap b/client/src/pages/tests/__snapshots__/methodology.test.tsx.snap index 6625e429..1594619a 100644 --- a/client/src/pages/tests/__snapshots__/methodology.test.tsx.snap +++ b/client/src/pages/tests/__snapshots__/methodology.test.tsx.snap @@ -494,7 +494,7 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -547,7 +547,7 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -604,7 +604,7 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -663,7 +663,7 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -722,7 +722,7 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -769,7 +769,7 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis AND - is above the 65th percentile for + is at or above the 65th percentile for @@ -834,7 +834,7 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis AND - is above the 65th percentile for + is at or above the 65th percentile for