Accessibility fixes: add missing labels, dynamically scale home header (#1516)
* Improve labels * Dynanically adjust home header to account for font scalingzio/stable
parent
88b95df200
commit
b7697f08d6
|
@ -203,9 +203,9 @@ export const FeedItem = observer(function FeedItemImpl({
|
||||||
<Link
|
<Link
|
||||||
style={styles.includeReason}
|
style={styles.includeReason}
|
||||||
href={makeProfileLink(item.reasonRepost.by)}
|
href={makeProfileLink(item.reasonRepost.by)}
|
||||||
title={sanitizeDisplayName(
|
title={`Reposted by ${sanitizeDisplayName(
|
||||||
item.reasonRepost.by.displayName || item.reasonRepost.by.handle,
|
item.reasonRepost.by.displayName || item.reasonRepost.by.handle,
|
||||||
)}>
|
)}`}>
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon="retweet"
|
icon="retweet"
|
||||||
style={{
|
style={{
|
||||||
|
|
|
@ -454,7 +454,9 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({
|
||||||
{dropdownItems?.length ? (
|
{dropdownItems?.length ? (
|
||||||
<NativeDropdown
|
<NativeDropdown
|
||||||
testID="profileHeaderDropdownBtn"
|
testID="profileHeaderDropdownBtn"
|
||||||
items={dropdownItems}>
|
items={dropdownItems}
|
||||||
|
accessibilityLabel="More options"
|
||||||
|
accessibilityHint="">
|
||||||
<View style={[styles.btn, styles.secondaryBtn, pal.btn]}>
|
<View style={[styles.btn, styles.secondaryBtn, pal.btn]}>
|
||||||
<FontAwesomeIcon icon="ellipsis" size={20} style={[pal.text]} />
|
<FontAwesomeIcon icon="ellipsis" size={20} style={[pal.text]} />
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -142,6 +142,7 @@ export const TextLink = observer(function TextLink({
|
||||||
dataSet,
|
dataSet,
|
||||||
title,
|
title,
|
||||||
onPress,
|
onPress,
|
||||||
|
...orgProps
|
||||||
}: {
|
}: {
|
||||||
testID?: string
|
testID?: string
|
||||||
type?: TypographyVariant
|
type?: TypographyVariant
|
||||||
|
@ -190,7 +191,8 @@ export const TextLink = observer(function TextLink({
|
||||||
title={title}
|
title={title}
|
||||||
// @ts-ignore web only -prf
|
// @ts-ignore web only -prf
|
||||||
hrefAttrs={hrefAttrs} // hack to get open in new tab to work on safari. without this, safari will open in a new window
|
hrefAttrs={hrefAttrs} // hack to get open in new tab to work on safari. without this, safari will open in a new window
|
||||||
{...props}>
|
{...props}
|
||||||
|
{...orgProps}>
|
||||||
{text}
|
{text}
|
||||||
</Text>
|
</Text>
|
||||||
)
|
)
|
||||||
|
|
|
@ -230,7 +230,11 @@ export function UserAvatar({
|
||||||
|
|
||||||
// onSelectNewAvatar is only passed as prop on the EditProfile component
|
// onSelectNewAvatar is only passed as prop on the EditProfile component
|
||||||
return onSelectNewAvatar ? (
|
return onSelectNewAvatar ? (
|
||||||
<NativeDropdown testID="changeAvatarBtn" items={dropdownItems}>
|
<NativeDropdown
|
||||||
|
testID="changeAvatarBtn"
|
||||||
|
items={dropdownItems}
|
||||||
|
accessibilityLabel="Image options"
|
||||||
|
accessibilityHint="">
|
||||||
{avatar ? (
|
{avatar ? (
|
||||||
<HighPriorityImage
|
<HighPriorityImage
|
||||||
testID="userAvatarImage"
|
testID="userAvatarImage"
|
||||||
|
|
|
@ -106,7 +106,11 @@ export function UserBanner({
|
||||||
|
|
||||||
// setUserBanner is only passed as prop on the EditProfile component
|
// setUserBanner is only passed as prop on the EditProfile component
|
||||||
return onSelectNewBanner ? (
|
return onSelectNewBanner ? (
|
||||||
<NativeDropdown testID="changeBannerBtn" items={dropdownItems}>
|
<NativeDropdown
|
||||||
|
testID="changeBannerBtn"
|
||||||
|
items={dropdownItems}
|
||||||
|
accessibilityLabel="Image options"
|
||||||
|
accessibilityHint="">
|
||||||
{banner ? (
|
{banner ? (
|
||||||
<Image
|
<Image
|
||||||
testID="userBannerImage"
|
testID="userBannerImage"
|
||||||
|
|
|
@ -405,7 +405,11 @@ export const CustomFeedScreenInner = observer(
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
<NativeDropdown testID="feedHeaderDropdownBtn" items={dropdownItems}>
|
<NativeDropdown
|
||||||
|
testID="feedHeaderDropdownBtn"
|
||||||
|
items={dropdownItems}
|
||||||
|
accessibilityLabel="More options"
|
||||||
|
accessibilityHint="">
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
paddingLeft: 12,
|
paddingLeft: 12,
|
||||||
|
|
|
@ -120,7 +120,10 @@ export const FeedsScreen = withAuthRequired(
|
||||||
<Text type="title-lg" style={[pal.text, s.bold]}>
|
<Text type="title-lg" style={[pal.text, s.bold]}>
|
||||||
My Feeds
|
My Feeds
|
||||||
</Text>
|
</Text>
|
||||||
<Link href="/settings/saved-feeds">
|
<Link
|
||||||
|
href="/settings/saved-feeds"
|
||||||
|
accessibilityLabel="Edit My Feeds"
|
||||||
|
accessibilityHint="">
|
||||||
<CogIcon strokeWidth={1.5} style={pal.icon} size={28} />
|
<CogIcon strokeWidth={1.5} style={pal.icon} size={28} />
|
||||||
</Link>
|
</Link>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {FlatList, View} from 'react-native'
|
import {FlatList, View, useWindowDimensions} from 'react-native'
|
||||||
import {useFocusEffect, useIsFocused} from '@react-navigation/native'
|
import {useFocusEffect, useIsFocused} from '@react-navigation/native'
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {FontAwesomeIconStyle} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIconStyle} from '@fortawesome/react-native-fontawesome'
|
||||||
|
@ -26,9 +26,6 @@ import {useAnalytics} from 'lib/analytics/analytics'
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
import {ComposeIcon2} from 'lib/icons'
|
import {ComposeIcon2} from 'lib/icons'
|
||||||
|
|
||||||
const HEADER_OFFSET_MOBILE = 78
|
|
||||||
const HEADER_OFFSET_TABLET = 50
|
|
||||||
const HEADER_OFFSET_DESKTOP = 0
|
|
||||||
const POLL_FREQ = 30e3 // 30sec
|
const POLL_FREQ = 30e3 // 30sec
|
||||||
|
|
||||||
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
|
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
|
||||||
|
@ -160,16 +157,10 @@ const FeedPage = observer(function FeedPageImpl({
|
||||||
}) {
|
}) {
|
||||||
const store = useStores()
|
const store = useStores()
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {isMobile, isTablet, isDesktop} = useWebMediaQueries()
|
const {isDesktop} = useWebMediaQueries()
|
||||||
const [onMainScroll, isScrolledDown, resetMainScroll] = useOnMainScroll(store)
|
const [onMainScroll, isScrolledDown, resetMainScroll] = useOnMainScroll(store)
|
||||||
const {screen, track} = useAnalytics()
|
const {screen, track} = useAnalytics()
|
||||||
const [headerOffset, setHeaderOffset] = React.useState(
|
const headerOffset = useHeaderOffset()
|
||||||
isMobile
|
|
||||||
? HEADER_OFFSET_MOBILE
|
|
||||||
: isTablet
|
|
||||||
? HEADER_OFFSET_TABLET
|
|
||||||
: HEADER_OFFSET_DESKTOP,
|
|
||||||
)
|
|
||||||
const scrollElRef = React.useRef<FlatList>(null)
|
const scrollElRef = React.useRef<FlatList>(null)
|
||||||
const {appState} = useAppState({
|
const {appState} = useAppState({
|
||||||
onForeground: () => doPoll(true),
|
onForeground: () => doPoll(true),
|
||||||
|
@ -214,17 +205,6 @@ const FeedPage = observer(function FeedPageImpl({
|
||||||
}
|
}
|
||||||
}, [isPageFocused, scrollToTop, feed])
|
}, [isPageFocused, scrollToTop, feed])
|
||||||
|
|
||||||
// listens for resize events
|
|
||||||
React.useEffect(() => {
|
|
||||||
setHeaderOffset(
|
|
||||||
isMobile
|
|
||||||
? HEADER_OFFSET_MOBILE
|
|
||||||
: isTablet
|
|
||||||
? HEADER_OFFSET_TABLET
|
|
||||||
: HEADER_OFFSET_DESKTOP,
|
|
||||||
)
|
|
||||||
}, [isMobile, isTablet])
|
|
||||||
|
|
||||||
// fires when page within screen is activated/deactivated
|
// fires when page within screen is activated/deactivated
|
||||||
// - check for latest
|
// - check for latest
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
@ -301,6 +281,8 @@ const FeedPage = observer(function FeedPageImpl({
|
||||||
type="title-lg"
|
type="title-lg"
|
||||||
href="/settings/home-feed"
|
href="/settings/home-feed"
|
||||||
style={{fontWeight: 'bold'}}
|
style={{fontWeight: 'bold'}}
|
||||||
|
accessibilityLabel="Feed Preferences"
|
||||||
|
accessibilityHint=""
|
||||||
text={
|
text={
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon="sliders"
|
icon="sliders"
|
||||||
|
@ -347,3 +329,17 @@ const FeedPage = observer(function FeedPageImpl({
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function useHeaderOffset() {
|
||||||
|
const {isDesktop, isTablet} = useWebMediaQueries()
|
||||||
|
const {fontScale} = useWindowDimensions()
|
||||||
|
if (isDesktop) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if (isTablet) {
|
||||||
|
return 50
|
||||||
|
}
|
||||||
|
// default text takes 44px, plus 34px of pad
|
||||||
|
// scale the 44px by the font scale
|
||||||
|
return 34 + 44 * fontScale
|
||||||
|
}
|
||||||
|
|
|
@ -651,7 +651,11 @@ function AccountDropdownBtn({handle}: {handle: string}) {
|
||||||
]
|
]
|
||||||
return (
|
return (
|
||||||
<Pressable accessibilityRole="button" style={s.pl10}>
|
<Pressable accessibilityRole="button" style={s.pl10}>
|
||||||
<NativeDropdown testID="accountSettingsDropdownBtn" items={items}>
|
<NativeDropdown
|
||||||
|
testID="accountSettingsDropdownBtn"
|
||||||
|
items={items}
|
||||||
|
accessibilityLabel="Account options"
|
||||||
|
accessibilityHint="">
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon="ellipsis-h"
|
icon="ellipsis-h"
|
||||||
style={pal.textLight as FontAwesomeIconStyle}
|
style={pal.textLight as FontAwesomeIconStyle}
|
||||||
|
|
|
@ -47,6 +47,7 @@ const ProfileCard = observer(function ProfileCardImpl() {
|
||||||
<Link
|
<Link
|
||||||
href={makeProfileLink(store.me)}
|
href={makeProfileLink(store.me)}
|
||||||
style={[styles.profileCard, !isDesktop && styles.profileCardTablet]}
|
style={[styles.profileCard, !isDesktop && styles.profileCardTablet]}
|
||||||
|
title="My Profile"
|
||||||
asAnchor>
|
asAnchor>
|
||||||
<UserAvatar avatar={store.me.avatar} size={size} />
|
<UserAvatar avatar={store.me.avatar} size={size} />
|
||||||
</Link>
|
</Link>
|
||||||
|
|
Loading…
Reference in New Issue