Tab bar: Fix tabs on Windows & Linux

This commit is contained in:
Martynas Bagdonas 2020-10-22 13:12:31 +03:00 committed by Dan Stillman
parent 2f505862d7
commit 783f9c50d5
9 changed files with 48 additions and 43 deletions

View file

@ -31,7 +31,7 @@ import cx from 'classnames';
const TabBar = forwardRef(function (props, ref) { const TabBar = forwardRef(function (props, ref) {
const [tabs, setTabs] = useState([]); const [tabs, setTabs] = useState([]);
const draggingID = useRef(null); const draggingID = useRef(null);
const tabsHolderRef = useRef(); const tabsRef = useRef();
const mouseMoveWaitUntil = useRef(0); const mouseMoveWaitUntil = useRef(0);
useEffect(() => { useEffect(() => {
@ -55,7 +55,7 @@ const TabBar = forwardRef(function (props, ref) {
if (!draggingID.current || mouseMoveWaitUntil.current > Date.now()) { if (!draggingID.current || mouseMoveWaitUntil.current > Date.now()) {
return; return;
} }
let points = Array.from(tabsHolderRef.current.children).map((child) => { let points = Array.from(tabsRef.current.children).map((child) => {
let rect = child.getBoundingClientRect(); let rect = child.getBoundingClientRect();
return rect.left + rect.width / 2; return rect.left + rect.width / 2;
}); });
@ -116,12 +116,8 @@ const TabBar = forwardRef(function (props, ref) {
} }
return ( return (
<div className="tabs" onMouseMove={handleMouseMove}> <div className="tabs" ref={tabsRef} onMouseMove={handleMouseMove}>
<div className="tabs-spacer-before"/> {tabs.map((tab, index) => renderTab(tab, index))}
<div className="tabs-holder" ref={tabsHolderRef}>
{tabs.map((tab, index) => renderTab(tab, index))}
</div>
<div className="tabs-spacer-after"/>
</div> </div>
); );
}); });

View file

@ -42,6 +42,12 @@ const ZoteroStandalone = new function() {
window.document.documentElement.setAttribute('sizemode', 'normal'); window.document.documentElement.setAttribute('sizemode', 'normal');
} }
if (Zotero.isMac) {
document.documentElement.setAttribute('drawintitlebar', true);
document.documentElement.setAttribute('tabsintitlebar', true);
document.documentElement.setAttribute('chromemargin', '0,-1,-1,-1');
}
Zotero.Promise.try(function () { Zotero.Promise.try(function () {
if(!Zotero) { if(!Zotero) {
throw true; throw true;

View file

@ -47,9 +47,6 @@
windowtype="navigator:browser" windowtype="navigator:browser"
title="&brandShortName;" title="&brandShortName;"
width="1000" height="600" width="1000" height="600"
drawintitlebar="true"
tabsintitlebar="true"
chromemargin="0,-1,-1,-1"
persist="screenX screenY width height sizemode"> persist="screenX screenY width height sizemode">
<script type="application/javascript" src="resource://zotero/require.js"/> <script type="application/javascript" src="resource://zotero/require.js"/>
<script type="application/javascript" src="standalone.js"/> <script type="application/javascript" src="standalone.js"/>
@ -124,7 +121,6 @@
</hbox> </hbox>
</hbox> </hbox>
</vbox> </vbox>
<vbox id="tab-bar-container"/>
<toolbox id="navigator-toolbox" class="toolbox-top" mode="icons" defaultmode="icons"> <toolbox id="navigator-toolbox" class="toolbox-top" mode="icons" defaultmode="icons">
<!-- Menu --> <!-- Menu -->
<toolbar type="menubar" id="toolbar-menubar" class="chromeclass-menubar" customizable="true" <toolbar type="menubar" id="toolbar-menubar" class="chromeclass-menubar" customizable="true"
@ -385,6 +381,7 @@
</toolbaritem> </toolbaritem>
</toolbar> </toolbar>
</toolbox> </toolbox>
<vbox id="tab-bar-container"/>
<!--<toolbarpalette/> <!--<toolbarpalette/>
<toolbar id="nav-bar" class="toolbar-primary chromeclass-toolbar" <toolbar id="nav-bar" class="toolbar-primary chromeclass-toolbar"

View file

@ -63,6 +63,8 @@ var Zotero_Tabs = new function () {
title: tab.title, title: tab.title,
selected: tab.id == this._selectedID selected: tab.id == this._selectedID
}))); })));
var { tab } = this._getTab(this._selectedID);
document.title = (tab.title.length ? tab.title + ' - ' : '') + 'Zotero';
}; };
this.init = function () { this.init = function () {

View file

@ -90,6 +90,10 @@ toolbarpaletteitem {
/* ::::: Tabs in Titlebar :::::: */ /* ::::: Tabs in Titlebar :::::: */
#main-window:not([chromemargin]) > #titlebar {
display: none;
}
/** /**
* For tabs in titlebar on OS X, we stretch the titlebar down so that the * For tabs in titlebar on OS X, we stretch the titlebar down so that the
* tabstrip can overlap it. * tabstrip can overlap it.

View file

@ -4,16 +4,29 @@
.tabs { .tabs {
display: flex; display: flex;
}
.tabs-holder { &:before {
display: flex; content: "";
width: 0px;
min-width: 0px;
border-bottom: $tab-border;
border-inline-end: $tab-border;
}
&:after {
content: "";
flex: 1 0 0%;
width: 100%;
min-width: 0px;
border-bottom: $tab-border;
border-inline-start: $tab-border;
}
} }
.tab { .tab {
-moz-appearance: none; -moz-appearance: none;
max-width: 200px; max-width: 200px;
flex: 1; flex: 1 1 200px;
height: 30px; height: 30px;
line-height: 30px; line-height: 30px;
position: relative; position: relative;
@ -24,7 +37,7 @@
padding: 0 30px; padding: 0 30px;
&:not(:last-child) { &:not(:last-child) {
border-right: $tab-border; border-inline-end: $tab-border;
} }
&.selected { &.selected {
@ -56,4 +69,8 @@
&:hover:not(:first-child) .tab-close { &:hover:not(:first-child) .tab-close {
display: block; display: block;
} }
&:not(.selected) {
border-bottom: $tab-border;
}
} }

View file

@ -1,3 +0,0 @@
.tabs-holder {
flex: 1;
}

View file

@ -2,30 +2,17 @@
-moz-window-dragging: drag; -moz-window-dragging: drag;
} }
.tabs-spacer-before {
width: 78px;
border-bottom: $tab-border;
border-inline-end: $tab-border;
}
.tabs-spacer-after {
flex: 1;
border-inline-start: $tab-border;
border-bottom: $tab-border;
}
.tab { .tab {
-moz-window-dragging: no-drag; -moz-window-dragging: no-drag;
} }
.tab:not(.selected) { .tabs {
border-bottom: $tab-border; &:before {
} width: 78px;
min-width: 78px;
}
.tab:first-child { &:after {
border-left: 0; min-width: 20px;
} }
.tab:last-child {
border-right: 0;
} }

View file

@ -7,5 +7,4 @@
@import "linux/createParent"; @import "linux/createParent";
@import "linux/editable"; @import "linux/editable";
@import "linux/search"; @import "linux/search";
@import "linux/tabBar";
@import "linux/tagsBox"; @import "linux/tagsBox";