feat: consolidated app nav to settings & dropdown

This commit is contained in:
Josh Corbett 2023-07-25 23:33:02 -06:00 committed by psychedelicious
parent 3dccc4d61e
commit 6fa42cb10c
26 changed files with 97 additions and 280 deletions

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "مجتمع",
"hotkeysLabel": "مفاتيح الأختصار", "hotkeysLabel": "مفاتيح الأختصار",
"themeLabel": "الموضوع", "themeLabel": "الموضوع",
"languagePickerLabel": "منتقي اللغة", "languagePickerLabel": "منتقي اللغة",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "Gemeinschaft",
"themeLabel": "Thema", "themeLabel": "Thema",
"languagePickerLabel": "Sprachauswahl", "languagePickerLabel": "Sprachauswahl",
"reportBugLabel": "Fehler melden", "reportBugLabel": "Fehler melden",

View File

@ -23,6 +23,7 @@
"menu": "Menu" "menu": "Menu"
}, },
"common": { "common": {
"communityLabel": "Community",
"hotkeysLabel": "Hotkeys", "hotkeysLabel": "Hotkeys",
"darkMode": "Dark Mode", "darkMode": "Dark Mode",
"lightMode": "Light Mode", "lightMode": "Light Mode",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "Comunidad",
"hotkeysLabel": "Atajos de teclado", "hotkeysLabel": "Atajos de teclado",
"themeLabel": "Tema", "themeLabel": "Tema",
"languagePickerLabel": "Selector de idioma", "languagePickerLabel": "Selector de idioma",

View File

@ -22,6 +22,7 @@
"showOptionsPanel": "Näytä asetukset" "showOptionsPanel": "Näytä asetukset"
}, },
"common": { "common": {
"communityLabel": "Yhteisö",
"postProcessDesc2": "Erillinen käyttöliittymä tullaan julkaisemaan helpottaaksemme työnkulkua jälkikäsittelyssä.", "postProcessDesc2": "Erillinen käyttöliittymä tullaan julkaisemaan helpottaaksemme työnkulkua jälkikäsittelyssä.",
"training": "Kouluta", "training": "Kouluta",
"statusLoadingModel": "Ladataan mallia", "statusLoadingModel": "Ladataan mallia",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "Communauté",
"hotkeysLabel": "Raccourcis clavier", "hotkeysLabel": "Raccourcis clavier",
"themeLabel": "Thème", "themeLabel": "Thème",
"languagePickerLabel": "Sélecteur de langue", "languagePickerLabel": "Sélecteur de langue",

View File

@ -106,6 +106,7 @@
"modelMergeInterpAddDifferenceHelp": "במצב זה, מודל 3 מופחת תחילה ממודל 2. הגרסה המתקבלת משולבת עם מודל 1 עם קצב האלפא שנקבע לעיל." "modelMergeInterpAddDifferenceHelp": "במצב זה, מודל 3 מופחת תחילה ממודל 2. הגרסה המתקבלת משולבת עם מודל 1 עם קצב האלפא שנקבע לעיל."
}, },
"common": { "common": {
"communityLabel": "קהילה",
"nodesDesc": "מערכת מבוססת צמתים עבור יצירת תמונות עדיין תחת פיתוח. השארו קשובים לעדכונים עבור הפיצ׳ר המדהים הזה.", "nodesDesc": "מערכת מבוססת צמתים עבור יצירת תמונות עדיין תחת פיתוח. השארו קשובים לעדכונים עבור הפיצ׳ר המדהים הזה.",
"themeLabel": "ערכת נושא", "themeLabel": "ערכת נושא",
"languagePickerLabel": "בחירת שפה", "languagePickerLabel": "בחירת שפה",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "Comunità",
"hotkeysLabel": "Tasti di scelta rapida", "hotkeysLabel": "Tasti di scelta rapida",
"themeLabel": "Tema", "themeLabel": "Tema",
"languagePickerLabel": "Seleziona lingua", "languagePickerLabel": "Seleziona lingua",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "コミュニティ",
"themeLabel": "テーマ", "themeLabel": "テーマ",
"languagePickerLabel": "言語選択", "languagePickerLabel": "言語選択",
"reportBugLabel": "バグ報告", "reportBugLabel": "バグ報告",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "지역 사회",
"themeLabel": "테마 설정", "themeLabel": "테마 설정",
"languagePickerLabel": "언어 설정", "languagePickerLabel": "언어 설정",
"reportBugLabel": "버그 리포트", "reportBugLabel": "버그 리포트",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "Gemeenschap",
"hotkeysLabel": "Sneltoetsen", "hotkeysLabel": "Sneltoetsen",
"themeLabel": "Thema", "themeLabel": "Thema",
"languagePickerLabel": "Taalkeuze", "languagePickerLabel": "Taalkeuze",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "Wspólnota",
"hotkeysLabel": "Skróty klawiszowe", "hotkeysLabel": "Skróty klawiszowe",
"themeLabel": "Motyw", "themeLabel": "Motyw",
"languagePickerLabel": "Wybór języka", "languagePickerLabel": "Wybór języka",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "Comunidade",
"greenTheme": "Verde", "greenTheme": "Verde",
"langArabic": "العربية", "langArabic": "العربية",
"themeLabel": "Tema", "themeLabel": "Tema",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "Comunidade",
"hotkeysLabel": "Teclas de atalho", "hotkeysLabel": "Teclas de atalho",
"themeLabel": "Tema", "themeLabel": "Tema",
"languagePickerLabel": "Seletor de Idioma", "languagePickerLabel": "Seletor de Idioma",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "Сообщество",
"hotkeysLabel": "Горячие клавиши", "hotkeysLabel": "Горячие клавиши",
"themeLabel": "Тема", "themeLabel": "Тема",
"languagePickerLabel": "Язык", "languagePickerLabel": "Язык",

View File

@ -22,6 +22,7 @@
"showOptionsPanel": "Visa inställningspanelen" "showOptionsPanel": "Visa inställningspanelen"
}, },
"common": { "common": {
"communityLabel": "Gemenskap",
"hotkeysLabel": "Snabbtangenter", "hotkeysLabel": "Snabbtangenter",
"reportBugLabel": "Rapportera bugg", "reportBugLabel": "Rapportera bugg",
"githubLabel": "Github", "githubLabel": "Github",

View File

@ -23,6 +23,7 @@
"showGallery": "Galeriyi Göster" "showGallery": "Galeriyi Göster"
}, },
"common": { "common": {
"communityLabel": "Toplum",
"hotkeysLabel": "Kısayol Tuşları", "hotkeysLabel": "Kısayol Tuşları",
"themeLabel": "Tema", "themeLabel": "Tema",
"languagePickerLabel": "Dil Seçimi", "languagePickerLabel": "Dil Seçimi",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "Спільнота",
"hotkeysLabel": арячi клавіші", "hotkeysLabel": арячi клавіші",
"themeLabel": "Тема", "themeLabel": "Тема",
"languagePickerLabel": "Мова", "languagePickerLabel": "Мова",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "社区",
"hotkeysLabel": "快捷键", "hotkeysLabel": "快捷键",
"themeLabel": "主题", "themeLabel": "主题",
"languagePickerLabel": "语言", "languagePickerLabel": "语言",

View File

@ -1,5 +1,6 @@
{ {
"common": { "common": {
"communityLabel": "社區",
"nodes": "節點", "nodes": "節點",
"img2img": "圖片轉圖片", "img2img": "圖片轉圖片",
"langSimplifiedChinese": "簡體中文", "langSimplifiedChinese": "簡體中文",

View File

@ -1,32 +0,0 @@
import { useColorMode } from '@chakra-ui/react';
import IAIIconButton from 'common/components/IAIIconButton';
import { useTranslation } from 'react-i18next';
import { FaMoon, FaSun } from 'react-icons/fa';
const ColorModeButton = () => {
const { colorMode, toggleColorMode } = useColorMode();
const { t } = useTranslation();
return (
<IAIIconButton
aria-label={
colorMode === 'dark' ? t('common.lightMode') : t('common.darkMode')
}
tooltip={
colorMode === 'dark' ? t('common.lightMode') : t('common.darkMode')
}
size="sm"
icon={
colorMode === 'dark' ? (
<FaSun fontSize={19} />
) : (
<FaMoon fontSize={18} />
)
}
onClick={toggleColorMode}
variant="link"
/>
);
};
export default ColorModeButton;

View File

@ -1,50 +0,0 @@
import {
IconButton,
Menu,
MenuButton,
MenuItemOption,
MenuList,
MenuOptionGroup,
Tooltip,
} from '@chakra-ui/react';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { map } from 'lodash-es';
import { useTranslation } from 'react-i18next';
import { IoLanguage } from 'react-icons/io5';
import { LANGUAGES } from '../store/constants';
import { languageSelector } from '../store/systemSelectors';
import { languageChanged } from '../store/systemSlice';
export default function LanguagePicker() {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const language = useAppSelector(languageSelector);
return (
<Menu closeOnSelect={false}>
<Tooltip label={t('common.languagePickerLabel')} hasArrow>
<MenuButton
as={IconButton}
icon={<IoLanguage />}
variant="link"
aria-label={t('common.languagePickerLabel')}
fontSize={22}
minWidth={8}
/>
</Tooltip>
<MenuList>
<MenuOptionGroup value={language}>
{map(LANGUAGES, (languageName, l: keyof typeof LANGUAGES) => (
<MenuItemOption
key={l}
value={l}
onClick={() => dispatch(languageChanged(l))}
>
{languageName}
</MenuItemOption>
))}
</MenuOptionGroup>
</MenuList>
</Menu>
);
}

View File

@ -10,6 +10,7 @@ import {
ModalOverlay, ModalOverlay,
Text, Text,
useDisclosure, useDisclosure,
useColorMode,
} from '@chakra-ui/react'; } from '@chakra-ui/react';
import { createSelector } from '@reduxjs/toolkit'; import { createSelector } from '@reduxjs/toolkit';
import { VALID_LOG_LEVELS } from 'app/logging/logger'; import { VALID_LOG_LEVELS } from 'app/logging/logger';
@ -46,6 +47,10 @@ import SettingSwitch from './SettingSwitch';
import SettingsClearIntermediates from './SettingsClearIntermediates'; import SettingsClearIntermediates from './SettingsClearIntermediates';
import SettingsSchedulers from './SettingsSchedulers'; import SettingsSchedulers from './SettingsSchedulers';
import StyledFlex from './StyledFlex'; import StyledFlex from './StyledFlex';
import { useFeatureStatus } from '../../hooks/useFeatureStatus';
import { LANGUAGES } from '../../store/constants';
import { languageChanged } from '../../store/systemSlice';
import { languageSelector } from '../../store/systemSelectors';
const selector = createSelector( const selector = createSelector(
[stateSelector], [stateSelector],
@ -166,6 +171,13 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
[dispatch] [dispatch]
); );
const handleLanguageChanged = useCallback(
(l: string) => {
dispatch(languageChanged(l as keyof typeof LANGUAGES));
},
[dispatch]
);
const handleLogToConsoleChanged = useCallback( const handleLogToConsoleChanged = useCallback(
(e: ChangeEvent<HTMLInputElement>) => { (e: ChangeEvent<HTMLInputElement>) => {
dispatch(shouldLogToConsoleChanged(e.target.checked)); dispatch(shouldLogToConsoleChanged(e.target.checked));
@ -180,6 +192,12 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
[dispatch] [dispatch]
); );
const { colorMode, toggleColorMode } = useColorMode();
const isLocalizationEnabled =
useFeatureStatus('localization').isFeatureEnabled;
const language = useAppSelector(languageSelector);
return ( return (
<> <>
{cloneElement(children, { {cloneElement(children, {
@ -225,6 +243,11 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
<StyledFlex> <StyledFlex>
<Heading size="sm">{t('settings.ui')}</Heading> <Heading size="sm">{t('settings.ui')}</Heading>
<SettingSwitch
label={t('common.darkMode')}
isChecked={colorMode === 'dark'}
onChange={toggleColorMode}
/>
<SettingSwitch <SettingSwitch
label={t('settings.useSlidersForAll')} label={t('settings.useSlidersForAll')}
isChecked={shouldUseSliders} isChecked={shouldUseSliders}
@ -267,6 +290,16 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
onChange={handleToggleNodes} onChange={handleToggleNodes}
/> />
)} )}
<IAIMantineSelect
disabled={!isLocalizationEnabled}
label={t('common.languagePickerLabel')}
value={language}
data={Object.entries(LANGUAGES).map(([value, label]) => ({
value,
label,
}))}
onChange={handleLanguageChanged}
/>
</StyledFlex> </StyledFlex>
{shouldShowDeveloperSettings && ( {shouldShowDeveloperSettings && (

View File

@ -1,28 +1,27 @@
import { Flex, Spacer } from '@chakra-ui/react'; import { Flex, MenuGroup, Spacer } from '@chakra-ui/react';
import { memo } from 'react'; import { memo } from 'react';
import StatusIndicator from './StatusIndicator'; import StatusIndicator from './StatusIndicator';
import { Link } from '@chakra-ui/react'; import { Menu, MenuButton, MenuList, MenuItem } from '@chakra-ui/react';
import IAIIconButton from 'common/components/IAIIconButton'; import IAIIconButton from 'common/components/IAIIconButton';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { FaBug, FaDiscord, FaGithub, FaKeyboard } from 'react-icons/fa'; import { FaBug, FaDiscord, FaGithub, FaKeyboard, FaBars } from 'react-icons/fa';
import { MdSettings } from 'react-icons/md'; import { MdSettings } from 'react-icons/md';
import { useFeatureStatus } from '../hooks/useFeatureStatus'; import { useFeatureStatus } from '../hooks/useFeatureStatus';
import ColorModeButton from './ColorModeButton';
import HotkeysModal from './HotkeysModal/HotkeysModal'; import HotkeysModal from './HotkeysModal/HotkeysModal';
import InvokeAILogoComponent from './InvokeAILogoComponent'; import InvokeAILogoComponent from './InvokeAILogoComponent';
import LanguagePicker from './LanguagePicker';
import SettingsModal from './SettingsModal/SettingsModal'; import SettingsModal from './SettingsModal/SettingsModal';
const SiteHeader = () => { const SiteHeader = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const isLocalizationEnabled =
useFeatureStatus('localization').isFeatureEnabled;
const isBugLinkEnabled = useFeatureStatus('bugLink').isFeatureEnabled; const isBugLinkEnabled = useFeatureStatus('bugLink').isFeatureEnabled;
const isDiscordLinkEnabled = useFeatureStatus('discordLink').isFeatureEnabled; const isDiscordLinkEnabled = useFeatureStatus('discordLink').isFeatureEnabled;
const isGithubLinkEnabled = useFeatureStatus('githubLink').isFeatureEnabled; const isGithubLinkEnabled = useFeatureStatus('githubLink').isFeatureEnabled;
const githubLink = 'http://github.com/invoke-ai/InvokeAI';
const discordLink = 'https://discord.gg/ZmtBAhwWhy';
return ( return (
<Flex <Flex
sx={{ sx={{
@ -34,87 +33,46 @@ const SiteHeader = () => {
<Spacer /> <Spacer />
<StatusIndicator /> <StatusIndicator />
<HotkeysModal> <Menu>
<IAIIconButton <MenuButton
aria-label={t('common.hotkeysLabel')} as={IAIIconButton}
tooltip={t('common.hotkeysLabel')}
size="sm"
variant="link" variant="link"
data-variant="link" aria-label={t('accessibility.menu')}
fontSize={20} tooltip={t('accessibility.menu')}
icon={<FaKeyboard />} icon={<FaBars />}
/> />
</HotkeysModal> <MenuList>
<MenuGroup title={t('common.communityLabel')}>
{isLocalizationEnabled && <LanguagePicker />} {isGithubLinkEnabled && (
<MenuItem as="a" href={githubLink} icon={<FaGithub />}>
{isBugLinkEnabled && ( {t('common.githubLabel')}
<Link </MenuItem>
isExternal )}
href="http://github.com/invoke-ai/InvokeAI/issues" {isBugLinkEnabled && (
marginBottom="-0.25rem" <MenuItem as="a" href={`${githubLink}/issues}`} icon={<FaBug />}>
> {t('common.reportBugLabel')}
<IAIIconButton </MenuItem>
aria-label={t('common.reportBugLabel')} )}
tooltip={t('common.reportBugLabel')} {isDiscordLinkEnabled && (
variant="link" <MenuItem as="a" href={discordLink} icon={<FaDiscord />}>
data-variant="link" {t('common.discordLabel')}
fontSize={20} </MenuItem>
size="sm" )}
icon={<FaBug />} </MenuGroup>
/> <MenuGroup title={t('common.settingsLabel')}>
</Link> <HotkeysModal>
)} <MenuItem as="button" icon={<FaKeyboard />}>
{t('common.hotkeysLabel')}
{isGithubLinkEnabled && ( </MenuItem>
<Link </HotkeysModal>
isExternal <SettingsModal>
href="http://github.com/invoke-ai/InvokeAI" <MenuItem as="button" icon={<MdSettings />}>
marginBottom="-0.25rem" {t('common.settingsLabel')}
> </MenuItem>
<IAIIconButton </SettingsModal>
aria-label={t('common.githubLabel')} </MenuGroup>
tooltip={t('common.githubLabel')} </MenuList>
variant="link" </Menu>
data-variant="link"
fontSize={20}
size="sm"
icon={<FaGithub />}
/>
</Link>
)}
{isDiscordLinkEnabled && (
<Link
isExternal
href="https://discord.gg/ZmtBAhwWhy"
marginBottom="-0.25rem"
>
<IAIIconButton
aria-label={t('common.discordLabel')}
tooltip={t('common.discordLabel')}
variant="link"
data-variant="link"
fontSize={20}
size="sm"
icon={<FaDiscord />}
/>
</Link>
)}
<ColorModeButton />
<SettingsModal>
<IAIIconButton
aria-label={t('common.settingsLabel')}
tooltip={t('common.settingsLabel')}
variant="link"
data-variant="link"
fontSize={22}
size="sm"
icon={<MdSettings />}
/>
</SettingsModal>
</Flex> </Flex>
); );
}; };

View File

@ -1,111 +0,0 @@
import { Flex, Link } from '@chakra-ui/react';
import { useTranslation } from 'react-i18next';
import { FaBug, FaDiscord, FaGithub, FaKeyboard } from 'react-icons/fa';
import { MdSettings } from 'react-icons/md';
import HotkeysModal from './HotkeysModal/HotkeysModal';
import LanguagePicker from './LanguagePicker';
import SettingsModal from './SettingsModal/SettingsModal';
import IAIIconButton from 'common/components/IAIIconButton';
import { useFeatureStatus } from '../hooks/useFeatureStatus';
const SiteHeaderMenu = () => {
const { t } = useTranslation();
const isLocalizationEnabled =
useFeatureStatus('localization').isFeatureEnabled;
const isBugLinkEnabled = useFeatureStatus('bugLink').isFeatureEnabled;
const isDiscordLinkEnabled = useFeatureStatus('discordLink').isFeatureEnabled;
const isGithubLinkEnabled = useFeatureStatus('githubLink').isFeatureEnabled;
return (
<Flex
alignItems="center"
flexDirection={{ base: 'column', xl: 'row' }}
gap={{ base: 4, xl: 1 }}
>
<HotkeysModal>
<IAIIconButton
aria-label={t('common.hotkeysLabel')}
tooltip={t('common.hotkeysLabel')}
size="sm"
variant="link"
data-variant="link"
fontSize={20}
icon={<FaKeyboard />}
/>
</HotkeysModal>
{isLocalizationEnabled && <LanguagePicker />}
{isBugLinkEnabled && (
<Link
isExternal
href="http://github.com/invoke-ai/InvokeAI/issues"
marginBottom="-0.25rem"
>
<IAIIconButton
aria-label={t('common.reportBugLabel')}
tooltip={t('common.reportBugLabel')}
variant="link"
data-variant="link"
fontSize={20}
size="sm"
icon={<FaBug />}
/>
</Link>
)}
{isGithubLinkEnabled && (
<Link
isExternal
href="http://github.com/invoke-ai/InvokeAI"
marginBottom="-0.25rem"
>
<IAIIconButton
aria-label={t('common.githubLabel')}
tooltip={t('common.githubLabel')}
variant="link"
data-variant="link"
fontSize={20}
size="sm"
icon={<FaGithub />}
/>
</Link>
)}
{isDiscordLinkEnabled && (
<Link
isExternal
href="https://discord.gg/ZmtBAhwWhy"
marginBottom="-0.25rem"
>
<IAIIconButton
aria-label={t('common.discordLabel')}
tooltip={t('common.discordLabel')}
variant="link"
data-variant="link"
fontSize={20}
size="sm"
icon={<FaDiscord />}
/>
</Link>
)}
<SettingsModal>
<IAIIconButton
aria-label={t('common.settingsLabel')}
tooltip={t('common.settingsLabel')}
variant="link"
data-variant="link"
fontSize={22}
size="sm"
icon={<MdSettings />}
/>
</SettingsModal>
</Flex>
);
};
SiteHeaderMenu.displayName = 'SiteHeaderMenu';
export default SiteHeaderMenu;

View File

@ -3,7 +3,6 @@ export type { PartialAppConfig } from './app/types/invokeai';
export { default as IAIIconButton } from './common/components/IAIIconButton'; export { default as IAIIconButton } from './common/components/IAIIconButton';
export { default as IAIPopover } from './common/components/IAIPopover'; export { default as IAIPopover } from './common/components/IAIPopover';
export { default as ParamMainModelSelect } from './features/parameters/components/Parameters/MainModel/ParamMainModelSelect'; export { default as ParamMainModelSelect } from './features/parameters/components/Parameters/MainModel/ParamMainModelSelect';
export { default as ColorModeButton } from './features/system/components/ColorModeButton';
export { default as InvokeAiLogoComponent } from './features/system/components/InvokeAILogoComponent'; export { default as InvokeAiLogoComponent } from './features/system/components/InvokeAILogoComponent';
export { default as SettingsModal } from './features/system/components/SettingsModal/SettingsModal'; export { default as SettingsModal } from './features/system/components/SettingsModal/SettingsModal';
export { default as StatusIndicator } from './features/system/components/StatusIndicator'; export { default as StatusIndicator } from './features/system/components/StatusIndicator';