refactor: rename sidebarShortcutHints to showSideBarText

This commit is contained in:
linonetwo 2023-07-06 21:48:18 +08:00 committed by lin onetwo
parent 4b7a196f6c
commit caffbcc0fd
12 changed files with 64 additions and 57 deletions

View file

@ -277,7 +277,7 @@
"DefaultUserName": "User Name",
"DefaultUserNameDetail": "The user name in the Wiki, this only take effect after restart, this will fill in the creator field of the newly created or edited tiddlers. Can be override by user name set in the workspace setting.",
"ShowSideBarDetail": "Sidebar lets you switch easily between workspaces.",
"ShowSideBarShortcut": "Show keyboard shortcut hints on sidebar",
"ShowSideBarText": "Show button label on sidebar",
"ShowNavigationBar": "Show navigation bar",
"ShowNavigationBarDetail": "Navigation bar on the top lets you go back, forward, home, reload and see the URL.",
"ShowTitleBar": "Show title bar",
@ -364,7 +364,7 @@
"SyncOnlyWhenNoDraftDescription": "Check if there are drafts before synchronizing, if so, it will not be synchronized this time, preventing the drafts from being synchronized to your blog. \n(Not working for sync-before-shutdown, for you may want to bring drafts from one computer to another to continue editing)",
"MoreWorkspaceSyncSettingsDescription": "Please right-click the workspace icon, open its workspace setting by click on \"Edit Workspace\" context menu item, and configure its independent synchronization settings in it.",
"MoreWorkspaceSyncSettings": "More Workspace Sync Settings",
"HideSideBarIcon": "Hide sidebar workspace icons",
"ShowSideBarIcon": "Show sidebar workspace icons",
"HideSideBarIconDetail": "Hide the icon and only display the name of the workspace to make the workspace list more compact",
"OpenV8CacheFolder": "Open the V8 cache folder",
"OpenV8CacheFolderDetail": "The V8 cache folder stores cached files that accelerate application startup",

View file

@ -316,7 +316,7 @@
"SyncIntervalDescription": "每经过这段长度的时间后,就会自动开始备份到 Github如果工作区是本地工作区则会创建本地备份重启后生效",
"General": "界面和交互",
"ShowSideBarDetail": "侧边栏让你可以在工作区之间快速切换",
"ShowSideBarShortcut": "展示侧边栏的快捷方式",
"ShowSideBarText": "展示侧边栏上按钮的文本",
"OpenLogFolder": "打开Log文件夹",
"OpenLogFolderDetail": "上报问题时,请打开日期最新的一个 .log 文件,将其内容发送给开发者,或黏贴到 pastebin.com 后将 URL 黏贴到 Github Issue 里",
"OpenMetaDataFolder": "打开太记工作区元信息文件夹",
@ -337,7 +337,7 @@
"LightTheme": "亮色主题",
"ShowSideBar": "显示侧边栏",
"HideSideBar": "隐藏侧边栏",
"HideSideBarIcon": "隐藏侧边栏工作区图标",
"ShowSideBarIcon": "展示侧边栏工作区图标",
"HideSideBarIconDetail": "隐藏图标只显示工作区的名字,让工作区列表更紧凑",
"SystemDefaultTheme": "系统默认主题色",
"Theme": "主题色",

View file

@ -120,7 +120,6 @@ const Badge = styled(BadgeRaw)`
interface Props {
active?: boolean;
badgeCount?: number;
hideSideBarIcon: boolean;
icon: React.ReactNode;
id: string;
index?: number;
@ -129,15 +128,16 @@ interface Props {
pageCount?: number;
pageName?: string;
picturePath?: string | null;
showSidebarShortcutHints?: boolean;
showSideBarIcon: boolean;
showSidebarTexts?: boolean;
}
export function PageSelectorBase({
active = false,
badgeCount = 0,
hideSideBarIcon = false,
showSideBarIcon = true,
id,
index = 0,
showSidebarShortcutHints = false,
showSidebarTexts = false,
pageName,
pageClickedLoading = false,
onClick = () => {},
@ -159,20 +159,20 @@ export function PageSelectorBase({
pageCount={pageCount}
>
<Badge color='secondary' badgeContent={badgeCount} max={99}>
{!hideSideBarIcon && (
{showSideBarIcon && (
<Avatar
large={!showSidebarShortcutHints}
large={!showSidebarTexts}
addAvatar={id === 'add'}
highlightAdd={index === 0}
id={id === 'add' || id === 'guide' ? 'add-workspace-button' : `workspace-avatar-${id}`}
>
<AvatarPicture large={!showSidebarShortcutHints} draggable={false}>
<AvatarPicture large={!showSidebarTexts} draggable={false}>
{icon}
</AvatarPicture>
</Avatar>
)}
</Badge>
{(showSidebarShortcutHints || hideSideBarIcon) && (
{(showSidebarTexts || showSideBarIcon) && (
<ShortcutText active={active}>
{id === 'add' ? t('WorkspaceSelector.Add') : (id === 'guide' ? t('WorkspaceSelector.Guide') : shortPageName)}
</ShortcutText>

View file

@ -9,14 +9,14 @@ import { getBuildInPageIcon } from './getBuildInPageIcon';
import { PageSelectorBase } from './PageSelectorBase';
export interface ISortableItemProps {
hideSideBarIcon: boolean;
showSideBarIcon: boolean;
index: number;
page: IPage;
pageCount: number;
showSidebarShortcutHints: boolean;
showSidebarTexts: boolean;
}
export function SortablePageSelectorButton({ index, page, showSidebarShortcutHints, pageCount, hideSideBarIcon }: ISortableItemProps): JSX.Element {
export function SortablePageSelectorButton({ index, page, showSidebarTexts, pageCount, showSideBarIcon }: ISortableItemProps): JSX.Element {
const { t } = useTranslation();
const { active, id, type } = page;
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id });
@ -48,14 +48,14 @@ export function SortablePageSelectorButton({ index, page, showSidebarShortcutHin
icon={icon}
pageClickedLoading={pageClickedLoading}
pageCount={pageCount}
hideSideBarIcon={hideSideBarIcon}
showSideBarIcon={showSideBarIcon}
onClick={onPageClick}
active={active}
id={id}
key={id}
pageName={name}
index={index}
showSidebarShortcutHints={showSidebarShortcutHints}
showSidebarTexts={showSidebarTexts}
/>
</div>
);

View file

@ -5,12 +5,12 @@ import { IPage } from '@services/pages/interface';
import { SortablePageSelectorButton } from './SortablePageSelectorButton';
export interface ISortableListProps {
hideSideBarIcon: boolean;
showSideBarIcon: boolean;
pagesList: IPage[];
sidebarShortcutHints: boolean;
showSideBarText: boolean;
}
export function SortablePageSelectorList({ pagesList, sidebarShortcutHints, hideSideBarIcon }: ISortableListProps): JSX.Element {
export function SortablePageSelectorList({ pagesList, showSideBarText, showSideBarIcon }: ISortableListProps): JSX.Element {
const dndSensors = useSensors(
useSensor(PointerSensor, {
activationConstraint: {
@ -48,8 +48,8 @@ export function SortablePageSelectorList({ pagesList, sidebarShortcutHints, hide
key={`item-${page.id}`}
index={index}
page={page}
showSidebarShortcutHints={sidebarShortcutHints}
hideSideBarIcon={hideSideBarIcon}
showSidebarTexts={showSideBarText}
showSideBarIcon={showSideBarIcon}
pageCount={pageIDs.length}
/>
))}

View file

@ -91,28 +91,28 @@ export function SideBar(): JSX.Element {
const updaterMetaData = useUpdaterObservable();
if (preferences === undefined) return <div>{t('Loading')}</div>;
const { sidebarShortcutHints, hideSideBarIcon } = preferences;
const { showSideBarText, showSideBarIcon } = preferences;
return (
<SidebarContainer>
<SidebarTop titleBar={titleBar}>
{workspacesList === undefined
? <div>{t('Loading')}</div>
: <SortableWorkspaceSelectorList sidebarShortcutHints={sidebarShortcutHints} workspacesList={workspacesList} hideSideBarIcon={hideSideBarIcon} />}
: <SortableWorkspaceSelectorList showSideBarText={showSideBarText} workspacesList={workspacesList} showSideBarIcon={showSideBarIcon} />}
<WorkspaceSelector
id='add'
hideSideBarIcon={hideSideBarIcon}
showSideBarIcon={showSideBarIcon}
index={workspacesList?.length ?? 0}
showSidebarShortcutHints={sidebarShortcutHints}
showSidebarTexts={showSideBarText}
onClick={() => void window.service.window.open(WindowNames.addWorkspace)}
/>
{pagesList === undefined
? <div>{t('Loading')}</div>
: (
<SortablePageSelectorList
sidebarShortcutHints={sidebarShortcutHints}
showSideBarText={showSideBarText}
pagesList={pagesList}
hideSideBarIcon={hideSideBarIcon}
showSideBarIcon={showSideBarIcon}
/>
)}
</SidebarTop>

View file

@ -9,14 +9,14 @@ import { WorkspaceSelector } from './WorkspaceSelector';
import defaultIcon from '@/images/default-icon.png';
export interface ISortableItemProps {
hideSideBarIcon: boolean;
showSideBarIcon: boolean;
index: number;
showSidebarShortcutHints: boolean;
showSidebarTexts: boolean;
workspace: IWorkspace;
workspaceCount: number;
}
export function SortableWorkspaceSelector({ index, workspace, showSidebarShortcutHints, workspaceCount, hideSideBarIcon }: ISortableItemProps): JSX.Element {
export function SortableWorkspaceSelector({ index, workspace, showSidebarTexts, workspaceCount, showSideBarIcon }: ISortableItemProps): JSX.Element {
const { t } = useTranslation();
const { active, id, name, picturePath, hibernated, transparentBackground } = workspace;
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id });
@ -50,7 +50,7 @@ export function SortableWorkspaceSelector({ index, workspace, showSidebarShortcu
<WorkspaceSelector
workspaceClickedLoading={workspaceClickedLoading}
workspaceCount={workspaceCount}
hideSideBarIcon={hideSideBarIcon}
showSideBarIcon={showSideBarIcon}
onClick={onWorkspaceClick}
active={active}
id={id}
@ -60,7 +60,7 @@ export function SortableWorkspaceSelector({ index, workspace, showSidebarShortcu
transparentBackground={transparentBackground}
index={index}
hibernated={hibernated}
showSidebarShortcutHints={showSidebarShortcutHints}
showSidebarTexts={showSidebarTexts}
/>
</div>
);

View file

@ -5,12 +5,12 @@ import { IWorkspace, IWorkspaceWithMetadata } from '@services/workspaces/interfa
import { SortableWorkspaceSelector } from './SortableWorkspaceSelector';
export interface ISortableListProps {
hideSideBarIcon: boolean;
sidebarShortcutHints: boolean;
showSideBarIcon: boolean;
showSideBarText: boolean;
workspacesList: IWorkspaceWithMetadata[];
}
export function SortableWorkspaceSelectorList({ workspacesList, sidebarShortcutHints, hideSideBarIcon }: ISortableListProps): JSX.Element {
export function SortableWorkspaceSelectorList({ workspacesList, showSideBarText, showSideBarIcon }: ISortableListProps): JSX.Element {
const dndSensors = useSensors(
useSensor(PointerSensor, {
activationConstraint: {
@ -48,8 +48,8 @@ export function SortableWorkspaceSelectorList({ workspacesList, sidebarShortcutH
key={`item-${workspace.id}`}
index={index}
workspace={workspace}
showSidebarShortcutHints={sidebarShortcutHints}
hideSideBarIcon={hideSideBarIcon}
showSidebarTexts={showSideBarText}
showSideBarIcon={showSideBarIcon}
workspaceCount={workspaceIDs.length}
/>
))}

View file

@ -133,12 +133,12 @@ interface Props {
active?: boolean;
badgeCount?: number;
hibernated?: boolean;
hideSideBarIcon: boolean;
showSideBarIcon: boolean;
id: string;
index?: number;
onClick?: () => void;
picturePath?: string | null;
showSidebarShortcutHints?: boolean;
showSidebarTexts?: boolean;
transparentBackground?: boolean;
workspaceClickedLoading?: boolean;
workspaceCount?: number;
@ -148,11 +148,11 @@ export function WorkspaceSelector({
active = false,
badgeCount = 0,
hibernated = false,
hideSideBarIcon = false,
showSideBarIcon = true,
id,
index = 0,
picturePath,
showSidebarShortcutHints = false,
showSidebarTexts = false,
transparentBackground = false,
workspaceName,
workspaceClickedLoading = false,
@ -175,9 +175,9 @@ export function WorkspaceSelector({
workspaceCount={workspaceCount}
>
<Badge color='secondary' badgeContent={badgeCount} max={99}>
{!hideSideBarIcon && (
{showSideBarIcon && (
<Avatar
large={!showSidebarShortcutHints}
large={!showSidebarTexts}
transparent={transparentBackground}
addAvatar={id === 'add'}
highlightAdd={index === 0}
@ -191,11 +191,11 @@ export function WorkspaceSelector({
? (
'※'
)
: <AvatarPicture alt='Icon' large={!showSidebarShortcutHints} src={getAssetsFileUrl(picturePath ?? defaultIcon)} draggable={false} />)}
: <AvatarPicture alt='Icon' large={!showSidebarTexts} src={getAssetsFileUrl(picturePath ?? defaultIcon)} draggable={false} />)}
</Avatar>
)}
</Badge>
{(showSidebarShortcutHints || hideSideBarIcon) && (
{(showSidebarTexts || showSideBarIcon) && (
<ShortcutText active={active}>
{id === 'add' ? t('WorkspaceSelector.Add') : (id === 'guide' ? t('WorkspaceSelector.Guide') : shortWorkspaceName)}
</ShortcutText>

View file

@ -95,28 +95,35 @@ export function General(props: Required<ISectionProps>): JSX.Element {
</ListItemSecondaryAction>
</ListItem>
<ListItem>
<ListItemText primary={t('Preference.HideSideBarIcon')} secondary={t('Preference.HideSideBarIconDetail')} />
<ListItemText primary={t('Preference.ShowSideBarIcon')} secondary={t('Preference.HideSideBarIconDetail')} />
<ListItemSecondaryAction>
<Switch
edge='end'
color='primary'
checked={preference.hideSideBarIcon}
checked={preference.showSideBarIcon}
onChange={async (event) => {
await window.service.preference.set('hideSideBarIcon', event.target.checked);
await window.service.preference.set('showSideBarIcon', event.target.checked);
// when you hide icon, show the text
if (!event.target.checked && !preference.showSideBarText) {
await window.service.preference.set('showSideBarText', true);
}
}}
/>
</ListItemSecondaryAction>
</ListItem>
<Divider />
<ListItem>
<ListItemText primary={t('Preference.ShowSideBarShortcut')} />
<ListItemText primary={t('Preference.ShowSideBarText')} />
<ListItemSecondaryAction>
<Switch
edge='end'
color='primary'
checked={preference.sidebarShortcutHints}
checked={preference.showSideBarText}
onChange={async (event) => {
await window.service.preference.set('sidebarShortcutHints', event.target.checked);
await window.service.preference.set('showSideBarText', event.target.checked);
// when you hide text, show the icon
if (!event.target.checked && !preference.showSideBarIcon) {
await window.service.preference.set('showSideBarIcon', true);
}
}}
/>
</ListItemSecondaryAction>

View file

@ -11,7 +11,7 @@ export const defaultPreferences: IPreferences = {
downloadPath: DEFAULT_DOWNLOADS_PATH,
hibernateUnusedWorkspacesAtLaunch: false,
hideMenuBar: false,
hideSideBarIcon: false,
showSideBarIcon: true,
ignoreCertificateErrors: false,
language: 'zh_CN',
languageModel: {
@ -31,7 +31,7 @@ export const defaultPreferences: IPreferences = {
rememberLastPageVisited: true,
shareWorkspaceBrowsingData: false,
sidebar: true,
sidebarShortcutHints: true,
showSideBarText: true,
spellcheck: true,
spellcheckLanguages: ['en-US'],
swipeToNavigate: true,

View file

@ -13,7 +13,7 @@ export interface IPreferences {
downloadPath: string;
hibernateUnusedWorkspacesAtLaunch: boolean;
hideMenuBar: boolean;
hideSideBarIcon: boolean;
showSideBarIcon: boolean;
ignoreCertificateErrors: boolean;
language: string;
languageModel: ILanguageModelPreferences;
@ -26,7 +26,7 @@ export interface IPreferences {
rememberLastPageVisited: boolean;
shareWorkspaceBrowsingData: boolean;
sidebar: boolean;
sidebarShortcutHints: boolean;
showSideBarText: boolean;
spellcheck: boolean;
spellcheckLanguages: HunspellLanguages[];
swipeToNavigate: boolean;