diff --git a/chrome/content/zotero/components/tabBar.jsx b/chrome/content/zotero/components/tabBar.jsx index d45f1e9eea..a33db03a1d 100644 --- a/chrome/content/zotero/components/tabBar.jsx +++ b/chrome/content/zotero/components/tabBar.jsx @@ -37,6 +37,7 @@ const TabBar = forwardRef(function (props, ref) { const [dragMouseX, setDragMouseX] = useState(0); const dragIDRef = useRef(null); const dragGrabbedDeltaXRef = useRef(); + const tabsInnerContainerRef = useRef(); const tabsRef = useRef(); const startArrowRef = useRef(); const endArrowRef = useRef(); @@ -85,17 +86,10 @@ const TabBar = forwardRef(function (props, ref) { }); function updateScrollArrows() { - let enableArrows = tabsRef.current.scrollWidth !== tabsRef.current.clientWidth; - if (enableArrows) { - startArrowRef.current.classList.add('enabled'); - endArrowRef.current.classList.add('enabled'); - } - else { - startArrowRef.current.classList.remove('enabled'); - endArrowRef.current.classList.remove('enabled'); - } + let scrollable = tabsRef.current.scrollWidth !== tabsRef.current.clientWidth; + if (scrollable) { + tabsInnerContainerRef.current.classList.add('scrollable'); - if (enableArrows) { if (tabsRef.current.scrollLeft !== 0) { startArrowRef.current.classList.add('active'); } @@ -110,6 +104,9 @@ const TabBar = forwardRef(function (props, ref) { endArrowRef.current.classList.remove('active'); } } + else { + tabsInnerContainerRef.current.classList.remove('scrollable'); + } } function handleTabMouseDown(event, id) { @@ -271,7 +268,7 @@ const TabBar = forwardRef(function (props, ref) { event.preventDefault(); } - function renderTab({ id, title, selected }, index) { + function renderTab({ id, title, selected, iconBackgroundImage }, index) { return (
handleDragStart(event, id, index)} onDragEnd={handleDragEnd} > -
{title}
+
{iconBackgroundImage && + }{title}
handleTabClose(event, id)} @@ -298,7 +296,16 @@ const TabBar = forwardRef(function (props, ref) { return (
-
+
+
+
+ {tabs.length ? renderTab(tabs[0], 0) : null} +
+
{ + let index = ZoteroPane.collectionsView.selection.focused; + if (!ZoteroPane.collectionsView.getRow(index)) { + return; + } + let icon = ZoteroPane.collectionsView._getIcon(index); + var { tab } = this._getTab('zotero-pane'); + if (!tab || !icon.style.backgroundImage) { + return; + } + tab.iconBackgroundImage = icon.style.backgroundImage; + }; + /** * Close tabs * diff --git a/scss/components/_tabBar.scss b/scss/components/_tabBar.scss index e19caf4ed9..1a5b820cc8 100644 --- a/scss/components/_tabBar.scss +++ b/scss/components/_tabBar.scss @@ -19,10 +19,6 @@ display: none; box-shadow: none; - &.enabled { - display: flex; - } - .icon { display: flex; } @@ -50,6 +46,27 @@ box-shadow: -1px 0 0 0 rgba(0,0,0,0.05); } } + + .pinned-tabs { + display: none; + .tab { + max-width: 110px; + } + } + + &.scrollable { + .tabs-wrapper > .tabs > :first-child { + display: none; + } + + .scroll-start-arrow, .scroll-end-arrow { + display: flex; + } + + .pinned-tabs { + display: block; + } + } } .tabs { @@ -117,6 +134,11 @@ position: relative; top: -2px; overflow-y: hidden; + + .icon-bg { + margin-inline-end: 7px; + margin-top: -2px; + } } .tab-close { @@ -141,7 +163,7 @@ background-color: rgba(0, 0, 0, 0.16); } } - + &:first-child .tab-close { display: none; }