Move combobox to right | Move "Search only in language" into separate row

This commit is contained in:
infinite-persistence 2021-08-05 21:16:10 +08:00
parent 99c7b28712
commit c539e4e10d
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
6 changed files with 36 additions and 39 deletions

View file

@ -1610,7 +1610,7 @@
"None selected": "None selected", "None selected": "None selected",
"Secondary Language": "Secondary Language", "Secondary Language": "Secondary Language",
"Your other content language": "Your other content language", "Your other content language": "Your other content language",
"Search only in this language by default": "Search only in this language by default", "Search only in the selected language by default": "Search only in the selected language by default",
"This link leads to an external website.": "This link leads to an external website.", "This link leads to an external website.": "This link leads to an external website.",
"No Content Found": "No Content Found", "No Content Found": "No Content Found",
"No Lists Found": "No Lists Found", "No Lists Found": "No Lists Found",

View file

@ -22,12 +22,7 @@ function SelectHomepage(props: Props) {
return null; return null;
} }
return ( return (
<div className="section__actions--between"> <React.Fragment>
<div>
<p>{__('Homepage')}</p>
<p className="help">{__('Tailor your experience.')}</p>
</div>
<FormField <FormField
name="homepage_select" name="homepage_select"
type="select" type="select"
@ -40,7 +35,7 @@ function SelectHomepage(props: Props) {
</option> </option>
))} ))}
</FormField> </FormField>
</div> </React.Fragment>
); );
} }

View file

@ -6,10 +6,12 @@ import SettingAppearance from './view';
const select = (state) => ({ const select = (state) => ({
clock24h: makeSelectClientSetting(SETTINGS.CLOCK_24H)(state), clock24h: makeSelectClientSetting(SETTINGS.CLOCK_24H)(state),
searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state),
}); });
const perform = (dispatch) => ({ const perform = (dispatch) => ({
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setSearchInLanguage: (value) => dispatch(doSetClientSetting(SETTINGS.SEARCH_IN_LANGUAGE, value)),
}); });
export default connect(select, perform)(SettingAppearance); export default connect(select, perform)(SettingAppearance);

View file

@ -5,17 +5,20 @@ import Card from 'component/common/card';
import { FormField } from 'component/common/form'; import { FormField } from 'component/common/form';
import HomepageSelector from 'component/homepageSelector'; import HomepageSelector from 'component/homepageSelector';
import SettingLanguage from 'component/settingLanguage'; import SettingLanguage from 'component/settingLanguage';
import SettingsRow from 'component/settingsRow';
import ThemeSelector from 'component/themeSelector'; import ThemeSelector from 'component/themeSelector';
// $FlowFixMe // $FlowFixMe
import homepages from 'homepages'; import homepages from 'homepages';
type Props = { type Props = {
clock24h: boolean, clock24h: boolean,
searchInLanguage: boolean,
setClientSetting: (string, boolean | string | number) => void, setClientSetting: (string, boolean | string | number) => void,
setSearchInLanguage: (boolean) => void,
}; };
export default function SettingAppearance(props: Props) { export default function SettingAppearance(props: Props) {
const { clock24h, setClientSetting } = props; const { clock24h, searchInLanguage, setClientSetting, setSearchInLanguage } = props;
return ( return (
<Card <Card
@ -24,19 +27,26 @@ export default function SettingAppearance(props: Props) {
isBodyList isBodyList
body={ body={
<> <>
{/* --- Homepage --- */}
{homepages && Object.keys(homepages).length > 1 && ( {homepages && Object.keys(homepages).length > 1 && (
<div className="card__main-actions"> <SettingsRow title={__('Homepage')} subtitle={__('Tailor your experience.')}>
<HomepageSelector /> <HomepageSelector />
</div> </SettingsRow>
)} )}
{/* --- Language --- */} <SettingsRow title={__('Language')} subtitle={__(HELP.LANGUAGE)}>
<div className="card__main-actions">
<SettingLanguage /> <SettingLanguage />
</div> </SettingsRow>
SettingsRow title={__('Theme')}> <SettingsRow title={__('Search only in the selected language by default')}>
<FormField
name="search-in-language"
type="checkbox"
checked={searchInLanguage}
onChange={() => setSearchInLanguage(!searchInLanguage)}
/>
</SettingsRow>
<SettingsRow title={__('Theme')}>
<ThemeSelector /> <ThemeSelector />
</SettingsRow> </SettingsRow>
@ -53,3 +63,8 @@ export default function SettingAppearance(props: Props) {
/> />
); );
} }
// prettier-disable
const HELP = {
LANGUAGE: 'Multi-language support is brand new and incomplete. Switching your language may have unintended consequences, like glossolalia.',
};

View file

@ -1,17 +1,14 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { SETTINGS } from 'lbry-redux'; import { doSetLanguage } from 'redux/actions/settings';
import { doSetLanguage, doSetClientSetting } from 'redux/actions/settings'; import { selectLanguage } from 'redux/selectors/settings';
import { makeSelectClientSetting, selectLanguage } from 'redux/selectors/settings';
import SettingLanguage from './view'; import SettingLanguage from './view';
const select = state => ({ const select = (state) => ({
language: selectLanguage(state), language: selectLanguage(state),
searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state),
}); });
const perform = dispatch => ({ const perform = (dispatch) => ({
setLanguage: value => dispatch(doSetLanguage(value)), setLanguage: (value) => dispatch(doSetLanguage(value)),
setSearchInLanguage: value => dispatch(doSetClientSetting(SETTINGS.SEARCH_IN_LANGUAGE, value)),
}); });
export default connect(select, perform)(SettingLanguage); export default connect(select, perform)(SettingLanguage);

View file

@ -10,12 +10,10 @@ import { getDefaultLanguage, sortLanguageMap } from 'util/default-languages';
type Props = { type Props = {
language: string, language: string,
setLanguage: (string) => void, setLanguage: (string) => void,
searchInLanguage: boolean,
setSearchInLanguage: (boolean) => void,
}; };
function SettingLanguage(props: Props) { function SettingLanguage(props: Props) {
const { language, setLanguage, searchInLanguage, setSearchInLanguage } = props; const { language, setLanguage } = props;
const [previousLanguage, setPreviousLanguage] = useState(null); const [previousLanguage, setPreviousLanguage] = useState(null);
if (previousLanguage && language !== previousLanguage) { if (previousLanguage && language !== previousLanguage) {
@ -37,15 +35,13 @@ function SettingLanguage(props: Props) {
return ( return (
<React.Fragment> <React.Fragment>
{previousLanguage && <Spinner type="small" />}
<FormField <FormField
name="language_select" name="language_select"
type="select" type="select"
label={__('Language')}
onChange={onLanguageChange} onChange={onLanguageChange}
value={language || getDefaultLanguage()} value={language || getDefaultLanguage()}
helper={__(
'Multi-language support is brand new and incomplete. Switching your language may have unintended consequences, like glossolalia.'
)}
> >
{sortLanguageMap(SUPPORTED_LANGUAGES).map(([langKey, langName]) => ( {sortLanguageMap(SUPPORTED_LANGUAGES).map(([langKey, langName]) => (
<option key={langKey} value={langKey}> <option key={langKey} value={langKey}>
@ -53,14 +49,6 @@ function SettingLanguage(props: Props) {
</option> </option>
))} ))}
</FormField> </FormField>
{previousLanguage && <Spinner type="small" />}
<FormField
name="search-in-language"
type="checkbox"
label={__('Search only in this language by default')}
checked={searchInLanguage}
onChange={() => setSearchInLanguage(!searchInLanguage)}
/>
</React.Fragment> </React.Fragment>
); );
} }