lbry-desktop/ui/component/homepageSelector/view.jsx
infinite-persistence 17871e78c8
[Appearance] grab language and homepage
Also applied new Settings Page styling.
2021-08-23 23:45:06 +08:00

47 lines
1.1 KiB
JavaScript

// @flow
import React from 'react';
// $FlowFixMe
import homepages from 'homepages';
import LANGUAGES from 'constants/languages';
import { FormField } from 'component/common/form';
import { getDefaultHomepageKey } from 'util/default-languages';
type Props = {
homepage: string,
setHomepage: (string) => void,
};
function SelectHomepage(props: Props) {
const { homepage, setHomepage } = props;
function handleSetHomepage(e) {
const { value } = e.target;
setHomepage(value);
}
if (Object.keys(homepages).length <= 1) {
return null;
}
return (
<div className="section__actions--between">
<div>
<p>{__('Homepage')}</p>
<p className="help">{__('Tailor your experience.')}</p>
</div>
<FormField
name="homepage_select"
type="select"
onChange={handleSetHomepage}
value={homepage || getDefaultHomepageKey()}
>
{Object.keys(homepages).map((hp) => (
<option key={'hp' + hp} value={hp}>
{`${LANGUAGES[hp][1]}`}
</option>
))}
</FormField>
</div>
);
}
export default SelectHomepage;