Skip to content

Commit

Permalink
Merge pull request #65 from yoyurec/master
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 authored Oct 29, 2022
2 parents d0c89a5 + 5e93c8a commit 191f1a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/PageTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function isTabEqual(
interface TabsProps {
tabs: ITabInfo[];
closeButtonLeft: boolean;
hideCloseAllButton: boolean;
showSingleTab: boolean;
activeTab: ITabInfo | null | undefined;
onClickTab: (tab: ITabInfo) => void;
Expand All @@ -72,6 +73,7 @@ const Tabs = React.forwardRef<HTMLElement, TabsProps>(
onClickTab,
tabs,
closeButtonLeft,
hideCloseAllButton,
showSingleTab,
onCloseTab,
onCloseAllTabs,
Expand Down Expand Up @@ -181,6 +183,7 @@ const Tabs = React.forwardRef<HTMLElement, TabsProps>(
</div>
);
})}
{!hideCloseAllButton && (
<div
onClick={() => onCloseAllTabs(true)}
key={"Close All"}
Expand All @@ -189,6 +192,7 @@ const Tabs = React.forwardRef<HTMLElement, TabsProps>(
>
<span className="logseq-tab-title">Close All</span>
</div>
)}
</div>
);
}
Expand Down Expand Up @@ -503,6 +507,7 @@ export function PageTabs(): JSX.Element {
const latestTabsRef = useLatest(tabs);
const showSingleTab = !!logseq.settings?.["tabs:show-single-tab"];
const closeButtonLeft = !!logseq.settings?.["tabs:close-button-left"];
const hideCloseAllButton = !!logseq.settings?.["tabs:hide-close-all-button"];

const onCloseTab = useEventCallback((tab: ITabInfo, force?: boolean) => {
const idx = tabs.findIndex((t) => isTabEqual(t, tab));
Expand Down Expand Up @@ -686,6 +691,7 @@ export function PageTabs(): JSX.Element {
activeTab={activeTab}
tabs={tabs}
closeButtonLeft={closeButtonLeft}
hideCloseAllButton={hideCloseAllButton}
showSingleTab={showSingleTab}
onSwapTab={onSwapTab}
onPinTab={onPinTab}
Expand Down
11 changes: 10 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,18 @@ export const closeButtonLeft: SettingSchemaDesc = {
default: false,
}

export const hideCloseAllButton: SettingSchemaDesc = {
key: "tabs:hide-close-all-button",
title: "Hide 'Close All' button?",
description: "When turned on 'Close All' button at the end of tabs list will be hidden.",
type: "boolean",
default: false,
}

export const settings: SettingSchemaDesc[] = [
...keybindingSettings,
inheritCustomCSSSetting,
showSingleTab,
closeButtonLeft
closeButtonLeft,
hideCloseAllButton
];

0 comments on commit 191f1a0

Please sign in to comment.