From 7cf7a9529a99658c4e5cc0d59279a36f9dac2b28 Mon Sep 17 00:00:00 2001 From: LeandraH Date: Mon, 2 Sep 2024 16:29:45 +0200 Subject: [PATCH 01/35] 2173: Add a11y-language in categories --- native/src/components/Caption.tsx | 12 ++++++++++-- native/src/components/CategoryListItem.tsx | 2 +- native/src/components/HeaderBox.tsx | 10 ++++++++-- native/src/components/ListItem.tsx | 2 +- native/src/components/SubCategoryListItem.tsx | 2 +- native/src/components/Tile.tsx | 5 +++-- native/src/components/Tiles.tsx | 2 +- 7 files changed, 25 insertions(+), 10 deletions(-) diff --git a/native/src/components/Caption.tsx b/native/src/components/Caption.tsx index 095bd944ca..5b0ae76b1c 100644 --- a/native/src/components/Caption.tsx +++ b/native/src/components/Caption.tsx @@ -1,6 +1,7 @@ -import React, { ReactElement } from 'react' +import React, { ReactElement, useContext } from 'react' import styled from 'styled-components/native' +import { AppContext } from '../contexts/AppContextProvider' import Text from './base/Text' const H1 = styled(Text)` @@ -14,6 +15,13 @@ type CaptionProps = { title: string } -const Caption = ({ title }: CaptionProps): ReactElement =>

{title}

+const Caption = ({ title }: CaptionProps): ReactElement => { + const { languageCode } = useContext(AppContext) + return ( +

+ {title} +

+ ) +} export default Caption diff --git a/native/src/components/CategoryListItem.tsx b/native/src/components/CategoryListItem.tsx index 0204a9820f..fa942cb948 100644 --- a/native/src/components/CategoryListItem.tsx +++ b/native/src/components/CategoryListItem.tsx @@ -68,7 +68,7 @@ const CategoryListItem = ({ onItemPress, }: CategoryListItemProps): ReactElement => ( <> - onItemPress({ path: category.path })}> + onItemPress({ path: category.path })} accessibilityLanguage={language}> diff --git a/native/src/components/HeaderBox.tsx b/native/src/components/HeaderBox.tsx index 96b5954359..dabb56cccf 100644 --- a/native/src/components/HeaderBox.tsx +++ b/native/src/components/HeaderBox.tsx @@ -1,11 +1,12 @@ import { HeaderBackButton } from '@react-navigation/elements' -import React, { ReactElement } from 'react' +import React, { ReactElement, useContext } from 'react' import { useTranslation } from 'react-i18next' import { useWindowDimensions } from 'react-native' import styled, { useTheme } from 'styled-components/native' import { buildConfigAssets } from '../constants/buildConfig' import dimensions from '../constants/dimensions' +import { AppContext } from '../contexts/AppContextProvider' import Icon from './base/Icon' const HorizontalLeft = styled.View` @@ -37,6 +38,7 @@ const HeaderBox = ({ goBack, canGoBack = true, text }: HeaderBoxProps): ReactEle const deviceWidth = useWindowDimensions().width const theme = useTheme() const { t } = useTranslation('common') + const { languageCode } = useContext(AppContext) const AppIcon = buildConfigAssets().AppIcon const HeaderIcon = canGoBack ? ( @@ -49,10 +51,14 @@ const HeaderBox = ({ goBack, canGoBack = true, text }: HeaderBoxProps): ReactEle ) : ( ) + return ( {HeaderIcon} - + {text} diff --git a/native/src/components/ListItem.tsx b/native/src/components/ListItem.tsx index ebe041db06..01d8831d3b 100644 --- a/native/src/components/ListItem.tsx +++ b/native/src/components/ListItem.tsx @@ -54,7 +54,7 @@ type ListItemProps = { } const ListItem = ({ language, title, thumbnail, children, Icon, navigateTo }: ListItemProps): ReactElement => ( - + diff --git a/native/src/components/SubCategoryListItem.tsx b/native/src/components/SubCategoryListItem.tsx index cde749da2f..1fb43679d8 100644 --- a/native/src/components/SubCategoryListItem.tsx +++ b/native/src/components/SubCategoryListItem.tsx @@ -42,7 +42,7 @@ const SubCategoryListItem = ({ onItemPress, language, }: SubCategoryListItemProps): ReactElement => ( - onItemPress(subCategory)} language={language}> + onItemPress(subCategory)} language={language} accessibilityLanguage={language}> {!!subCategory.thumbnail && ( diff --git a/native/src/components/Tile.tsx b/native/src/components/Tile.tsx index 1af584a587..158a244e01 100644 --- a/native/src/components/Tile.tsx +++ b/native/src/components/Tile.tsx @@ -32,15 +32,16 @@ type TileProps = { tile: TileModel onTilePress: (tile: TileModel) => void resourceCache: PageResourceCacheStateType | undefined + language: string } -const Tile = ({ onTilePress, tile, resourceCache }: TileProps): ReactElement => { +const Tile = ({ onTilePress, tile, resourceCache, language }: TileProps): ReactElement => { const showSnackbar = useSnackbar() const openTile = () => tile.isExternalUrl ? openExternalUrl(tile.path, showSnackbar).catch(reportError) : onTilePress(tile) return ( - + {tile.title} diff --git a/native/src/components/Tiles.tsx b/native/src/components/Tiles.tsx index ac3ad9c570..08a1ffa5c8 100644 --- a/native/src/components/Tiles.tsx +++ b/native/src/components/Tiles.tsx @@ -29,7 +29,7 @@ const Tiles = ({ title, language, tiles, onTilePress, resourceCache }: TilesProp {!!title && } {tiles.map(tile => ( - + ))} From ace8a6fa467fb476434b035ee513dbc6a510f64e Mon Sep 17 00:00:00 2001 From: LeandraH Date: Mon, 2 Sep 2024 17:44:25 +0200 Subject: [PATCH 02/35] 2173: Add a11y-language elsewhere --- native/src/components/Caption.tsx | 6 ++--- native/src/components/CityEntry.tsx | 9 ++++++-- native/src/components/Header.tsx | 28 ++++++++++++++++++++++-- native/src/components/HeaderBox.tsx | 6 ++--- native/src/components/NewsListItem.tsx | 6 +++-- native/src/components/Page.tsx | 2 +- native/src/components/SearchListItem.tsx | 2 +- 7 files changed, 45 insertions(+), 14 deletions(-) diff --git a/native/src/components/Caption.tsx b/native/src/components/Caption.tsx index 5b0ae76b1c..3606f40d43 100644 --- a/native/src/components/Caption.tsx +++ b/native/src/components/Caption.tsx @@ -13,12 +13,12 @@ const H1 = styled(Text)` ` type CaptionProps = { title: string + language?: string } -const Caption = ({ title }: CaptionProps): ReactElement => { - const { languageCode } = useContext(AppContext) +const Caption = ({ title, language }: CaptionProps): ReactElement => { return ( -

+

{title}

) diff --git a/native/src/components/CityEntry.tsx b/native/src/components/CityEntry.tsx index 7e5a0d0038..87498e1251 100644 --- a/native/src/components/CityEntry.tsx +++ b/native/src/components/CityEntry.tsx @@ -1,4 +1,4 @@ -import React, { Fragment, memo, ReactElement } from 'react' +import React, { Fragment, memo, ReactElement, useContext } from 'react' import { Text } from 'react-native' import Highlighter from 'react-native-highlight-words' import styled from 'styled-components/native' @@ -6,6 +6,7 @@ import styled from 'styled-components/native' import { normalizeString } from 'shared' import { CityModel } from 'shared/api' +import { AppContext } from '../contexts/AppContextProvider' import testID from '../testing/testID' import Pressable from './base/Pressable' @@ -52,6 +53,7 @@ const CityEntry = ({ city, query, navigateToDashboard }: CityEntryProps): ReactE ? Object.keys(city.aliases).filter(alias => normalizeString(alias).includes(normalizedQuery)) : [] const aliases = matchingAliases.slice(0, MAX_NUMBER_OF_ALIASES_SHOWN) + const { languageCode } = useContext(AppContext) const Aliases = aliases.length > 0 ? ( @@ -86,7 +88,10 @@ const CityEntry = ({ city, query, navigateToDashboard }: CityEntryProps): ReactE ) : null return ( - navigateToDashboard(city)}> + navigateToDashboard(city)} + accessibilityLanguage={languageCode}> <>