mirror of
https://github.com/Zakkaus/doona.git
synced 2026-12-06 08:02:04 +00:00
feat(shell): move language and appearance into an overflow menu on phones
Below 1024px the top bar keeps search and refresh or apply, and one More options menu at the end holds language, theme, palette and wordmark. The desktop top bar is unchanged.
This commit is contained in:
1 parent
ce42ccf5e3
commit
08dd8893ff
8 files changed
+84
-19
No files matched your search
@@ -1147,6 +1147,8 @@ export const messages = {
|
||||
'wordmark.gradient': 'Gradient',
|
||||
'wordmark.plain': 'Plain',
|
||||
lang: 'Language',
|
||||
theme: 'Theme',
|
||||
moreOptions: 'More options',
|
||||
hubs: 'Sections',
|
||||
github: 'GitHub repository',
|
||||
'search.nodes': 'Nodes',
|
||||
|
||||
@@ -1121,6 +1121,8 @@ export const messages = {
|
||||
'wordmark.gradient': '渐变',
|
||||
'wordmark.plain': '纯色',
|
||||
lang: '语言',
|
||||
theme: '主题',
|
||||
moreOptions: '更多选项',
|
||||
hubs: '页面分区',
|
||||
github: 'GitHub 仓库',
|
||||
'search.nodes': '节点',
|
||||
|
||||
@@ -1120,6 +1120,8 @@ export const messages = {
|
||||
'wordmark.gradient': '漸層',
|
||||
'wordmark.plain': '純色',
|
||||
lang: '語言',
|
||||
theme: '主題',
|
||||
moreOptions: '更多選項',
|
||||
hubs: '頁面分區',
|
||||
github: 'GitHub 儲存庫',
|
||||
'search.nodes': '節點',
|
||||
|
||||
+33
-19
@@ -4,6 +4,7 @@ import {About} from './About';
|
||||
import Color from '../ui/icons/Color';
|
||||
import Contrast from '../ui/icons/Contrast';
|
||||
import Lighten from '../ui/icons/Lighten';
|
||||
import MoreVertical from '../ui/icons/MoreVertical';
|
||||
import Refresh from '../ui/icons/Refresh';
|
||||
import Search from '../ui/icons/Search';
|
||||
import Translate from '../ui/icons/Translate';
|
||||
@@ -11,7 +12,7 @@ import logo from '../logo.svg';
|
||||
import {useT, type Lang} from '../i18n';
|
||||
import {Button, ChoiceMenu} from '../ui/ui';
|
||||
import type {SettingsContext} from './preferences';
|
||||
import type {PaletteId, Wordmark} from './preferences';
|
||||
import type {PaletteId, Scheme, Wordmark} from './preferences';
|
||||
import type {AppearanceMenu, PaletteSection} from './view';
|
||||
import {languageItems} from './view';
|
||||
import {preloadSearch} from './search/load';
|
||||
@@ -65,6 +66,10 @@ export const TopBar = memo(function TopBar({
|
||||
const t = useT();
|
||||
// The language and palette icons turn in when their value changes, like the scheme icon; not on first paint.
|
||||
const [first] = useState({lang, palette: ap.palette});
|
||||
const paletteMenu = [
|
||||
...paletteSections.map(section => ({...section, value: ap.palette, onChange: (k: string) => ap.pickPalette(k as PaletteId)})),
|
||||
{title: t('wordmark'), items: menu.wordmarks, value: ap.wordmark, onChange: (k: string) => ap.pickWordmark(k as Wordmark)}
|
||||
];
|
||||
return (
|
||||
<header className="rp-top">
|
||||
<About
|
||||
@@ -96,24 +101,33 @@ export const TopBar = memo(function TopBar({
|
||||
<Refresh className="rp-refresh rp-spin-on-press" />
|
||||
{!!held && <span className="rp-held-count">{held}</span>}
|
||||
</Button>
|
||||
<Separator orientation="vertical" className="rp-vrule" />
|
||||
<ChoiceMenu quiet chevron={false} label={t('lang')} value={lang} onChange={k => pickLang(k as Lang)} items={languageItems}>
|
||||
<Translate key={lang} className={lang !== first.lang ? 'rp-icon-in' : undefined} />
|
||||
</ChoiceMenu>
|
||||
<ChoiceMenu
|
||||
quiet
|
||||
chevron={false}
|
||||
label={t('palette')}
|
||||
sections={[
|
||||
...paletteSections.map(section => ({...section, value: ap.palette, onChange: (k: string) => ap.pickPalette(k as PaletteId)})),
|
||||
{title: t('wordmark'), items: menu.wordmarks, value: ap.wordmark, onChange: (k: string) => ap.pickWordmark(k as Wordmark)}
|
||||
]}
|
||||
>
|
||||
<Color key={ap.palette} className={ap.palette !== first.palette ? 'rp-icon-in' : undefined} />
|
||||
</ChoiceMenu>
|
||||
<Button quiet icon label={menu.themeLabel} onPress={ap.toggle}>
|
||||
<SchemeIcon dark={ap.dark} />
|
||||
</Button>
|
||||
{/* Below the side navigation's breakpoint, language and appearance share one overflow menu. */}
|
||||
<span className="rp-top-wide">
|
||||
<Separator orientation="vertical" className="rp-vrule" />
|
||||
<ChoiceMenu quiet chevron={false} label={t('lang')} value={lang} onChange={k => pickLang(k as Lang)} items={languageItems}>
|
||||
<Translate key={lang} className={lang !== first.lang ? 'rp-icon-in' : undefined} />
|
||||
</ChoiceMenu>
|
||||
<ChoiceMenu quiet chevron={false} label={t('palette')} sections={paletteMenu}>
|
||||
<Color key={ap.palette} className={ap.palette !== first.palette ? 'rp-icon-in' : undefined} />
|
||||
</ChoiceMenu>
|
||||
<Button quiet icon label={menu.themeLabel} onPress={ap.toggle}>
|
||||
<SchemeIcon dark={ap.dark} />
|
||||
</Button>
|
||||
</span>
|
||||
<span className="rp-top-more">
|
||||
<ChoiceMenu
|
||||
quiet
|
||||
chevron={false}
|
||||
label={t('moreOptions')}
|
||||
sections={[
|
||||
{title: t('lang'), items: languageItems, value: lang, onChange: k => pickLang(k as Lang)},
|
||||
{title: t('theme'), items: menu.schemes, value: ap.scheme, onChange: k => ap.pickScheme(k as Scheme)},
|
||||
...paletteMenu
|
||||
]}
|
||||
>
|
||||
<MoreVertical />
|
||||
</ChoiceMenu>
|
||||
</span>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
|
||||
@@ -83,6 +83,8 @@ export const messages = defineMessages({
|
||||
'wordmark.gradient': '漸層',
|
||||
'wordmark.plain': '純色',
|
||||
lang: '語言',
|
||||
theme: '主題',
|
||||
moreOptions: '更多選項',
|
||||
hubs: '頁面分區',
|
||||
github: 'GitHub 儲存庫',
|
||||
'search.nodes': '節點',
|
||||
@@ -210,6 +212,8 @@ export const messages = defineMessages({
|
||||
'wordmark.gradient': '渐变',
|
||||
'wordmark.plain': '纯色',
|
||||
lang: '语言',
|
||||
theme: '主题',
|
||||
moreOptions: '更多选项',
|
||||
hubs: '页面分区',
|
||||
github: 'GitHub 仓库',
|
||||
'search.nodes': '节点',
|
||||
@@ -337,6 +341,8 @@ export const messages = defineMessages({
|
||||
'wordmark.gradient': 'Gradient',
|
||||
'wordmark.plain': 'Plain',
|
||||
lang: 'Language',
|
||||
theme: 'Theme',
|
||||
moreOptions: 'More options',
|
||||
hubs: 'Sections',
|
||||
github: 'GitHub repository',
|
||||
'search.nodes': 'Nodes',
|
||||
|
||||
@@ -186,6 +186,11 @@ export function appearanceMenu(t: Translator, scheme: Scheme, dark: boolean) {
|
||||
{id: 'gradient', label: t('wordmark.gradient')},
|
||||
{id: 'plain', label: t('wordmark.plain')}
|
||||
],
|
||||
schemes: [
|
||||
{id: 'system', label: t('theme.system')},
|
||||
{id: 'light', label: t('theme.light')},
|
||||
{id: 'dark', label: t('theme.dark')}
|
||||
],
|
||||
themeLabel: t('shell.theme', {theme: t(scheme === 'system' ? 'theme.system' : dark ? 'theme.dark' : 'theme.light')})
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Three stacked dots on the Spectrum 20px grid: the overflow menu of a top bar.
|
||||
import type {SVGProps} from 'react';
|
||||
import {cx} from '../cx';
|
||||
|
||||
export default function MoreVertical({className, ...props}: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={20}
|
||||
height={20}
|
||||
viewBox="0 0 20 20"
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
className={cx('rp-icon', className)}
|
||||
{...props}
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M10 3a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3m0 5.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3m0 5.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -239,6 +239,17 @@
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.rp-top-wide {
|
||||
display: none;
|
||||
}
|
||||
@media (min-width: 1024px) {
|
||||
.rp-top-wide {
|
||||
display: contents;
|
||||
}
|
||||
.rp-top-more {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.rp-vrule {
|
||||
width: 2px;
|
||||
height: 32px;
|
||||
|
||||
Reference in new issue
Block a user