diff options
author | Paul Frazee <pfrazee@gmail.com> | 2024-04-12 14:13:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-12 14:13:13 -0700 |
commit | ec5c4929c1c5677d22c923193ce04f3d69b72711 (patch) | |
tree | ccc097ea1565ae506e522a76a019bfeb6a63faf3 /src/components/AppLanguageDropdown.web.tsx | |
parent | 44039c68d678e99f9dc712f1a6dae87aed970ca3 (diff) | |
download | voidsky-ec5c4929c1c5677d22c923193ce04f3d69b72711.tar.zst |
PWI improvements (#3489)
* Enable home and feeds on the PWI * Add global SigninDialog to drive useRequireAuth() * Tweak desktop styles * Make the logo in leftnav PWI a clickable home link * Add label * Improve dialog on web * Fix query key * Go to home after signout from settings screen * Filter out feeds from the discover listing for logged out users which are known to break without auth * Update profile header follow/subscribe to give signin prompt * Show profile feeds tabs on pwi * Add language selector to account creation footer and pwi left nav desktop --------- Co-authored-by: dan <dan.abramov@gmail.com>
Diffstat (limited to 'src/components/AppLanguageDropdown.web.tsx')
-rw-r--r-- | src/components/AppLanguageDropdown.web.tsx | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/components/AppLanguageDropdown.web.tsx b/src/components/AppLanguageDropdown.web.tsx new file mode 100644 index 000000000..302a30ca6 --- /dev/null +++ b/src/components/AppLanguageDropdown.web.tsx @@ -0,0 +1,62 @@ +import React from 'react' +import {View} from 'react-native' + +import {sanitizeAppLanguageSetting} from '#/locale/helpers' +import {APP_LANGUAGES} from '#/locale/languages' +import {useLanguagePrefs, useLanguagePrefsApi} from '#/state/preferences' +import {atoms as a, useTheme} from '#/alf' +import {ChevronBottom_Stroke2_Corner0_Rounded as ChevronDown} from '#/components/icons/Chevron' +import {Text} from '#/components/Typography' + +export function AppLanguageDropdown() { + const t = useTheme() + + const langPrefs = useLanguagePrefs() + const setLangPrefs = useLanguagePrefsApi() + + const sanitizedLang = sanitizeAppLanguageSetting(langPrefs.appLanguage) + + const onChangeAppLanguage = React.useCallback( + (ev: React.ChangeEvent<HTMLSelectElement>) => { + const value = ev.target.value + + if (!value) return + if (sanitizedLang !== value) { + setLangPrefs.setAppLanguage(sanitizeAppLanguageSetting(value)) + } + }, + [sanitizedLang, setLangPrefs], + ) + + return ( + <View style={[a.flex_row, a.gap_sm, a.align_center, a.flex_shrink]}> + <Text aria-hidden={true} style={t.atoms.text_contrast_medium}> + {APP_LANGUAGES.find(l => l.code2 === sanitizedLang)?.name} + </Text> + <ChevronDown fill={t.atoms.text.color} size="xs" style={a.flex_shrink} /> + + <select + value={sanitizedLang} + onChange={onChangeAppLanguage} + style={{ + cursor: 'pointer', + MozAppearance: 'none', + WebkitAppearance: 'none', + appearance: 'none', + position: 'absolute', + inset: 0, + width: '100%', + color: 'transparent', + background: 'transparent', + border: 0, + padding: 0, + }}> + {APP_LANGUAGES.filter(l => Boolean(l.code2)).map(l => ( + <option key={l.code2} value={l.code2}> + {l.name} + </option> + ))} + </select> + </View> + ) +} |