Updated language menu.

This commit is contained in:
Mike Cao 2020-10-02 12:15:42 -07:00
parent dd651e3c77
commit 561491c2aa
6 changed files with 19 additions and 3 deletions

View File

@ -1,4 +1,5 @@
.menu { .menu {
background: var(--gray50);
border: 1px solid var(--gray500); border: 1px solid var(--gray500);
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;

View File

@ -9,6 +9,7 @@ export default function MenuButton({
icon, icon,
value, value,
options, options,
menuClassname,
menuPosition = 'bottom', menuPosition = 'bottom',
menuAlign = 'right', menuAlign = 'right',
onSelect, onSelect,
@ -45,7 +46,7 @@ export default function MenuButton({
</Button> </Button>
{showMenu && ( {showMenu && (
<Menu <Menu
className={styles.menu} className={classNames(styles.menu, menuClassname)}
options={options} options={options}
selectedOption={selectedOption} selectedOption={selectedOption}
onSelect={handleSelect} onSelect={handleSelect}

View File

@ -4,6 +4,7 @@ import { menuOptions } from 'lib/lang';
import useLocale from 'hooks/useLocale'; import useLocale from 'hooks/useLocale';
import MenuButton from 'components/common/MenuButton'; import MenuButton from 'components/common/MenuButton';
import Globe from 'assets/globe.svg'; import Globe from 'assets/globe.svg';
import styles from './LanguageButton.module.css';
export default function LanguageButton() { export default function LanguageButton() {
const [locale, setLocale] = useLocale(); const [locale, setLocale] = useLocale();
@ -32,6 +33,7 @@ export default function LanguageButton() {
icon={<Globe />} icon={<Globe />}
options={menuOptions} options={menuOptions}
value={locale} value={locale}
menuClassname={styles.menu}
renderValue={option => option?.display} renderValue={option => option?.display}
onSelect={handleSelect} onSelect={handleSelect}
/> />

View File

@ -0,0 +1,12 @@
.menu {
display: flex;
flex-flow: row wrap;
min-width: 500px;
max-width: 100vw;
padding: 10px;
}
.menu div {
border-radius: 5px;
min-width: 33%;
}

View File

@ -59,10 +59,10 @@ export const dateLocales = {
}; };
export const menuOptions = [ export const menuOptions = [
{ label: 'English', value: 'en-US', display: 'en' },
{ label: '中文', value: 'zh-CN', display: 'cn' }, { label: '中文', value: 'zh-CN', display: 'cn' },
{ label: 'Dansk', value: 'da-DK', display: 'da' }, { label: 'Dansk', value: 'da-DK', display: 'da' },
{ label: 'Deutsch', value: 'de-DE', display: 'de' }, { label: 'Deutsch', value: 'de-DE', display: 'de' },
{ label: 'English', value: 'en-US', display: 'en' },
{ label: 'Español', value: 'es-MX', display: 'es' }, { label: 'Español', value: 'es-MX', display: 'es' },
{ label: 'Føroyskt', value: 'fo-FO', display: 'fo' }, { label: 'Føroyskt', value: 'fo-FO', display: 'fo' },
{ label: 'Français', value: 'fr-FR', display: 'fr' }, { label: 'Français', value: 'fr-FR', display: 'fr' },

View File

@ -1,6 +1,6 @@
{ {
"name": "umami", "name": "umami",
"version": "0.70.0", "version": "0.71.0",
"description": "A simple, fast, website analytics alternative to Google Analytics. ", "description": "A simple, fast, website analytics alternative to Google Analytics. ",
"author": "Mike Cao <mike@mikecao.com>", "author": "Mike Cao <mike@mikecao.com>",
"license": "MIT", "license": "MIT",