From 6f1cec59fd1baa5ae539606d5c2453ecd624f3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ebbinghaus?= Date: Thu, 21 Jul 2022 16:30:48 +0200 Subject: [PATCH 1/3] Add setting to hide a single tab Show, when there are at least two tabs or at least one pinned tab. --- src/PageTabs.tsx | 8 ++++++++ src/settings.ts | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/PageTabs.tsx b/src/PageTabs.tsx index cf5893a..82b4a18 100644 --- a/src/PageTabs.tsx +++ b/src/PageTabs.tsx @@ -55,6 +55,7 @@ function isTabEqual( interface TabsProps { tabs: ITabInfo[]; + showSingleTab: boolean; activeTab: ITabInfo | null | undefined; onClickTab: (tab: ITabInfo) => void; onCloseTab: (tab: ITabInfo, force?: boolean) => void; @@ -69,6 +70,7 @@ const Tabs = React.forwardRef( activeTab, onClickTab, tabs, + showSingleTab, onCloseTab, onCloseAllTabs, onPinTab, @@ -89,7 +91,11 @@ const Tabs = React.forwardRef( }, []); const debouncedSwap = useDebounceFn(onSwapTab, 0); + const showTabs = showSingleTab || 0 < tabs.filter(tab => tab.pinned).length || 1 < tabs.length; + if (!showTabs) { + return null; + } return (
(); const latestTabsRef = useLatest(tabs); + const showSingleTab = logseq.settings["tabs:show-single-tab"]; const onCloseTab = useEventCallback((tab: ITabInfo, force?: boolean) => { const idx = tabs.findIndex((t) => isTabEqual(t, tab)); @@ -667,6 +674,7 @@ export function PageTabs(): JSX.Element { onClickTab={onChangeTab} activeTab={activeTab} tabs={tabs} + showSingleTab={showSingleTab} onSwapTab={onSwapTab} onPinTab={onPinTab} onCloseTab={onCloseTab} diff --git a/src/settings.ts b/src/settings.ts index 5a47bf4..ca0169a 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -16,7 +16,7 @@ export const keyBindings = { "tabs:select-prev": { label: "Select Previous Tab", binding: "ctrl+shift+tab", - }, + } }; const keybindingSettings: SettingSchemaDesc[] = Object.entries(keyBindings).map( @@ -43,7 +43,16 @@ export const inheritCustomCSSSetting: SettingSchemaDesc = { type: "boolean", }; +export const showSingleTab: SettingSchemaDesc = { + key: "tabs:show-single-tab", + title: "Show single tab?", + description: "When turned on the tab bar will only show if at least two tabs are open.", + type: "boolean", + default: true, +} + export const settings: SettingSchemaDesc[] = [ ...keybindingSettings, inheritCustomCSSSetting, + showSingleTab, ]; From de2dc87ae02a870fda00b427ce28957c914fb48a Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Thu, 21 Jul 2022 23:09:58 +0800 Subject: [PATCH 2/3] fix: bump for new version --- src/PageTabs.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PageTabs.tsx b/src/PageTabs.tsx index 82b4a18..38f78ef 100644 --- a/src/PageTabs.tsx +++ b/src/PageTabs.tsx @@ -491,7 +491,7 @@ export function PageTabs(): JSX.Element { const currActiveTabRef = React.useRef(); const latestTabsRef = useLatest(tabs); - const showSingleTab = logseq.settings["tabs:show-single-tab"]; + const showSingleTab = logseq.settings?.["tabs:show-single-tab"]; const onCloseTab = useEventCallback((tab: ITabInfo, force?: boolean) => { const idx = tabs.findIndex((t) => isTabEqual(t, tab)); From 7f4be312443ee0b66bc20d3f8abce86d28465dd9 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 21 Jul 2022 15:10:52 +0000 Subject: [PATCH 3/3] chore(release): 1.15.2 [skip ci] ## [1.15.2](https://github.com/pengx17/logseq-plugin-tabs/compare/v1.15.1...v1.15.2) (2022-07-21) ### Bug Fixes * bump for new version ([de2dc87](https://github.com/pengx17/logseq-plugin-tabs/commit/de2dc87ae02a870fda00b427ce28957c914fb48a)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1710c30..437b22a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.15.2](https://github.com/pengx17/logseq-plugin-tabs/compare/v1.15.1...v1.15.2) (2022-07-21) + + +### Bug Fixes + +* bump for new version ([de2dc87](https://github.com/pengx17/logseq-plugin-tabs/commit/de2dc87ae02a870fda00b427ce28957c914fb48a)) + ## [1.15.1](https://github.com/pengx17/logseq-plugin-tabs/compare/v1.15.0...v1.15.1) (2022-06-29) diff --git a/package.json b/package.json index a8474b7..ca3149f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "logseq-plugin-tabs", - "version": "1.15.1", + "version": "1.15.2", "schemaVersion": "1.0.0", "main": "dist/index.html", "scripts": {