mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
feat(app): add keyboard hint in the account switcher (#3425)
This commit is contained in:
1 parent
b4fc1241ae
commit
49eb8cdd81
2 files changed
+37
No files matched your search
+12
@@ -59,10 +59,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.accountsStage {
|
.accountsStage {
|
||||||
|
position: relative;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shortcutTitle {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 100%;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
padding-bottom: 0.625rem;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.authStage {
|
.authStage {
|
||||||
display: flex;
|
display: flex;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|||||||
+25
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
import Accessibility from '@app/features/accessibility/state/Accessibility';
|
||||||
import {AccountProfilePicker} from '@app/features/auth/components/accounts/account_switcher_modal/AccountProfilePicker';
|
import {AccountProfilePicker} from '@app/features/auth/components/accounts/account_switcher_modal/AccountProfilePicker';
|
||||||
import {
|
import {
|
||||||
type AccountSwitcherContentView,
|
type AccountSwitcherContentView,
|
||||||
@@ -7,9 +8,11 @@ import {
|
|||||||
} from '@app/features/auth/components/accounts/account_switcher_modal/AccountSwitcherModalTypes';
|
} from '@app/features/auth/components/accounts/account_switcher_modal/AccountSwitcherModalTypes';
|
||||||
import styles from '@app/features/auth/components/accounts/account_switcher_modal/AccountSwitcherOverlay.module.css';
|
import styles from '@app/features/auth/components/accounts/account_switcher_modal/AccountSwitcherOverlay.module.css';
|
||||||
import {AccountSwitcherViewTransition} from '@app/features/auth/components/accounts/account_switcher_modal/AccountSwitcherViewTransition';
|
import {AccountSwitcherViewTransition} from '@app/features/auth/components/accounts/account_switcher_modal/AccountSwitcherViewTransition';
|
||||||
|
import Keybind, {type KeybindCommand} from '@app/features/input/state/InputKeybind';
|
||||||
import type {Account} from '@app/features/platform/state/AuthSession';
|
import type {Account} from '@app/features/platform/state/AuthSession';
|
||||||
import FocusRingScope from '@app/features/ui/focus_ring/FocusRingScope';
|
import FocusRingScope from '@app/features/ui/focus_ring/FocusRingScope';
|
||||||
import {usePrefersReducedMotion} from '@app/features/ui/hooks/usePrefersReducedMotion';
|
import {usePrefersReducedMotion} from '@app/features/ui/hooks/usePrefersReducedMotion';
|
||||||
|
import {KeybindHint} from '@app/features/ui/keybind_hint/KeybindHint';
|
||||||
import {AnimeButton, type AnimeTarget, createAnimeFlxElement} from '@app/features/ui/motion/AnimeElement';
|
import {AnimeButton, type AnimeTarget, createAnimeFlxElement} from '@app/features/ui/motion/AnimeElement';
|
||||||
import LayerManager, {LayerType} from '@app/features/ui/state/LayerManager';
|
import LayerManager, {LayerType} from '@app/features/ui/state/LayerManager';
|
||||||
import {getZIndexForStack} from '@app/features/ui/state/Modal';
|
import {getZIndexForStack} from '@app/features/ui/state/Modal';
|
||||||
@@ -18,12 +21,15 @@ import {isDesktop} from '@app/features/ui/utils/NativeUtils';
|
|||||||
import {flxElementClassName} from '@app/lib/react';
|
import {flxElementClassName} from '@app/lib/react';
|
||||||
import {msg} from '@lingui/core/macro';
|
import {msg} from '@lingui/core/macro';
|
||||||
import {Trans, useLingui} from '@lingui/react/macro';
|
import {Trans, useLingui} from '@lingui/react/macro';
|
||||||
|
import {observer} from 'mobx-react-lite';
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
import {useCallback, useContext, useEffect, useId, useRef} from 'react';
|
import {useCallback, useContext, useEffect, useId, useRef} from 'react';
|
||||||
|
|
||||||
const AccountSwitcherAnimatedRoot = createAnimeFlxElement('flx-auth-account-switcher-overlay');
|
const AccountSwitcherAnimatedRoot = createAnimeFlxElement('flx-auth-account-switcher-overlay');
|
||||||
const AccountSwitcherAnimatedShell = createAnimeFlxElement('flx-auth-account-switcher-overlay-shell');
|
const AccountSwitcherAnimatedShell = createAnimeFlxElement('flx-auth-account-switcher-overlay-shell');
|
||||||
|
|
||||||
|
const SYSTEM_OPEN_ACCOUNT_SWITCHER_ACTION: KeybindCommand = 'system_open_account_switcher';
|
||||||
|
|
||||||
const CLOSE_ACCOUNT_SWITCHER_DESCRIPTOR = msg({
|
const CLOSE_ACCOUNT_SWITCHER_DESCRIPTOR = msg({
|
||||||
message: 'Close account switcher',
|
message: 'Close account switcher',
|
||||||
comment: 'Accessible label for closing the account switcher overlay.',
|
comment: 'Accessible label for closing the account switcher overlay.',
|
||||||
@@ -48,6 +54,24 @@ interface AccountSwitcherStageProps {
|
|||||||
readonly view: AccountSwitcherContentView;
|
readonly view: AccountSwitcherContentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AccountSwitcherShortcutHint = observer(function AccountSwitcherShortcutHint(): React.ReactElement | null {
|
||||||
|
const {combo} = Keybind.getByAction(SYSTEM_OPEN_ACCOUNT_SWITCHER_ACTION);
|
||||||
|
if (Accessibility.hideKeyboardHints || (!combo.key && !combo.code)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={styles.shortcutTitle}
|
||||||
|
data-flx="auth.accounts.account-switcher-modal.account-switcher-overlay.account-switcher-shortcut-hint.shortcut-title"
|
||||||
|
>
|
||||||
|
<KeybindHint
|
||||||
|
combo={combo}
|
||||||
|
data-flx="auth.accounts.account-switcher-modal.account-switcher-overlay.account-switcher-shortcut-hint.keybind-hint"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
function AccountSwitcherStage({
|
function AccountSwitcherStage({
|
||||||
accounts,
|
accounts,
|
||||||
authContent,
|
authContent,
|
||||||
@@ -73,6 +97,7 @@ function AccountSwitcherStage({
|
|||||||
className={flxElementClassName(styles.accountsStage)}
|
className={flxElementClassName(styles.accountsStage)}
|
||||||
data-flx="auth.accounts.account-switcher-modal.account-switcher-overlay.account-switcher-stage.accounts-stage"
|
data-flx="auth.accounts.account-switcher-modal.account-switcher-overlay.account-switcher-stage.accounts-stage"
|
||||||
>
|
>
|
||||||
|
<AccountSwitcherShortcutHint data-flx="auth.accounts.account-switcher-modal.account-switcher-overlay.account-switcher-stage.account-switcher-shortcut-hint" />
|
||||||
{accounts.length === 0 ? (
|
{accounts.length === 0 ? (
|
||||||
<flx-auth-account-switcher-overlay-empty
|
<flx-auth-account-switcher-overlay-empty
|
||||||
className={flxElementClassName(styles.noAccounts)}
|
className={flxElementClassName(styles.noAccounts)}
|
||||||
|
|||||||
Reference in new issue
Block a user