Файли
openidea/src/ui/Tabs.module.css
T
lleviathe 06ff2e51c3 fix(editor): even out the spacing of editor tabs (#4606)
Editor tabs sit 4px apart and keep an 18px close slot at one edge: before the icon when the close button is on the left, after the label when it is on the right, so switching sides no longer resizes tabs. The drag ghost keeps the strip's classes so it renders with the same layout. Verified with e2e editorTabClose/editor, src/ui vitest, typecheck, and both close positions in the app.

Co-authored-by: lleviathe <[email protected]>
2026-11-20 07:52:02 +08:00

346 рядки
7.3 KiB
CSS

.strip {
--tab-selected-bg: var(--bg-tab-selected);
--tab-selected-border: var(--border-tab-selected);
flex: none;
display: flex;
align-items: stretch;
min-width: 0;
}
/* IDEA: only the part holding focus accents its selected tab (src/ui/focusScope.ts). */
:where([data-focus-scope]:not([data-focus-active])) .strip {
--tab-selected-bg: var(--bg-tab-selected-inactive);
--tab-selected-border: var(--border-tab-selected-inactive);
}
/* Islands tabs: the selected tab is a rounded pill (tab-selected-bg / -border); no underline, no separators. */
.editor {
--tab-inline-padding: var(--space-2);
height: var(--h-header);
font-size: var(--fs-chrome);
padding: 0 4px;
}
.compact {
/* Shrinks inside tool window headers so the overflow dropdown can take over. */
flex: 0 1 auto;
height: var(--h-tab);
}
.scroller {
display: flex;
align-items: center;
gap: var(--space-0-5);
min-width: 0;
overflow-x: auto;
overflow-y: hidden;
scrollbar-width: none;
}
.scroller::-webkit-scrollbar {
display: none;
}
.tab {
position: relative;
flex: none;
display: flex;
align-items: stretch;
height: calc(100% - 6px);
min-height: 22px;
max-height: var(--h-tab);
border-radius: var(--radius-tab, 6px);
color: var(--fg-strong);
transition:
color var(--dur-fast) var(--ease),
background var(--dur-fast) var(--ease);
}
/* showContextMenu's owner keeps its hover appearance while the menu is open. */
.tab:hover,
.tab:where([data-context-menu-open]) {
background: var(--bg-toolbar-hover);
}
.selected,
.selected:hover {
background: var(--tab-selected-bg);
box-shadow: inset 0 0 0 1px var(--tab-selected-border);
}
.tinted {
--tab-tint-mix: color-mix(in srgb, var(--tab-tint) var(--tab-tint-strength, var(--tint-strength, 22%)), transparent);
background: var(--tab-tint-mix);
}
.tinted:hover,
.tinted:where([data-context-menu-open]) {
background: linear-gradient(var(--bg-toolbar-hover), var(--bg-toolbar-hover)), var(--tab-tint-mix);
}
.tinted.selected {
background: color-mix(
in srgb,
var(--tab-tint) var(--tab-tint-strength, var(--tint-strength, 22%)),
var(--tab-selected-bg)
);
}
.tabButton {
display: flex;
align-items: center;
gap: var(--space-1-5);
padding: 0 var(--tab-inline-padding, 10px);
border-radius: inherit;
white-space: nowrap;
color: inherit;
}
.compact .tabButton {
padding: 0 10px;
}
.closable .tabButton {
padding-right: 2px;
}
.tabButton:focus-visible {
outline: 2px solid var(--focus-ring);
outline-offset: -2px;
}
.tabIcon {
flex: none;
color: var(--fg-muted);
}
.tabLabel {
overflow: hidden;
text-overflow: ellipsis;
max-width: 260px;
}
.italic {
font-style: italic;
}
/* A file with errors, as the Project view marks it. */
.error {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: var(--danger);
text-decoration-skip-ink: none;
text-underline-offset: 3px;
/* Room for the wave below the line box, which the ellipsis' overflow would clip. */
padding-block: 4px;
margin-block: -4px;
}
.dimmed {
opacity: 0.6;
}
.closeSlot {
position: relative;
display: flex;
align-items: center;
width: 20px;
/* Squeezed tabs shrink the label, never the close button (#1740). */
flex: none;
margin-right: 4px;
}
.close {
color: var(--fg-muted);
opacity: 0;
transition: opacity var(--dur-fast) var(--ease);
}
.unpin {
color: var(--fg-muted);
}
.tab:hover .close,
.tab:where([data-context-menu-open]) .close,
.selected .close,
.close:focus-visible {
opacity: 1;
}
.modified {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--fg-muted);
flex: none;
}
.closeSlot .modified {
position: absolute;
left: 7px;
pointer-events: none;
transition: opacity var(--dur-fast) var(--ease);
}
.tab:hover .closeSlot .modified,
.tab:where([data-context-menu-open]) .closeSlot .modified,
.selected .closeSlot .modified {
opacity: 0;
}
.more {
align-self: center;
margin: 0 4px;
}
.trailing {
flex: 1 0 auto;
min-width: 0;
display: flex;
align-items: center;
justify-content: flex-end;
}
/* Tabs that don't fit: squeezed (labels ellipsized) or wrapped into rows. */
.squeeze .scroller {
flex: 0 1 auto;
}
.squeeze .tab {
flex: 0 1 auto;
min-width: 40px;
}
/* A closable tab keeps room for its close slot: only the label shrinks. */
.squeeze .closable {
min-width: 64px;
}
.squeeze .closeSlot {
flex: none;
}
.squeeze .tabButton {
flex: 1 1 auto;
min-width: 0;
overflow: hidden;
}
.squeeze .tabLabel {
min-width: 0;
}
.wrap {
height: auto;
min-height: var(--h-header);
}
.wrap .scroller {
flex: 1;
flex-wrap: wrap;
overflow: visible;
row-gap: var(--space-0-5);
padding: 3px 0;
}
.wrap .tab {
height: calc(var(--h-header) - 6px);
}
.editor.wrap .tab {
max-inline-size: 100%;
}
.editor.wrap .tabButton {
min-inline-size: 0;
}
/* Vertical strip (editor tabs placed left / right): a scrolling column of full-width tabs. */
.vertical {
flex-direction: column;
height: auto;
min-height: 0;
padding: 4px;
}
.vertical .scroller {
flex: 0 1 auto;
flex-direction: column;
align-items: stretch;
min-height: 0;
overflow-x: hidden;
overflow-y: auto;
scrollbar-width: thin;
}
.vertical .scroller::-webkit-scrollbar {
display: initial;
}
.vertical .tab {
height: 24px;
min-height: 24px;
}
.vertical .tabButton {
flex: 1 1 auto;
min-width: 0;
}
.vertical .tabLabel {
min-width: 0;
max-width: none;
}
.vertical .trailing {
flex: none;
justify-content: flex-end;
padding-bottom: 4px;
}
.vertical .dropBefore::before,
.vertical .dropAfter::after {
top: auto;
bottom: auto;
left: 4px;
right: 4px;
width: auto;
height: 2px;
}
.vertical .dropBefore::before {
top: 0;
}
.vertical .dropAfter::after {
bottom: 0;
}
/* Close button on the left of the label */
.closeLeft .closeSlot {
order: -1;
margin: 0 0 0 4px;
}
.closeLeft .closable .tabButton {
padding: 0 var(--tab-inline-padding, 10px) 0 2px;
}
/* Editor tabs in a row sit 4px apart; wrapped rows keep their row gap. */
.editor:not(.vertical) .scroller {
column-gap: var(--space-1);
}
/* Every closable tab keeps a close slot at one edge (IDEA), cut to what the close glyph needs: 18px, a 2px
inset and the 16px button. The label side keeps the 8px inset, so the side doesn't change a tab's width. */
.editor:not(.vertical) .closeSlot {
position: absolute;
top: 0;
bottom: 0;
right: 2px;
width: auto;
margin: 0;
}
.editor:not(.vertical) .close {
width: 16px;
}
.editor:not(.vertical) .closeSlot .modified {
left: 5px;
}
.editor:not(.vertical, .closeLeft) .closable .tabButton {
padding-right: 18px;
}
.editor.closeLeft:not(.vertical) .closeSlot {
right: auto;
left: 2px;
}
.editor.closeLeft:not(.vertical) .closable .tabButton {
padding-left: 18px;
}
/* drag & drop: the dragged tab is an empty slot the other tabs make room for (IDEA) */
.tab.dragging,
.tab.dragging:hover {
background: var(--bg-toolbar-hover);
box-shadow: none;
}
.dragging > * {
visibility: hidden;
}
.dropBefore::before,
.dropAfter::after {
content: "";
position: absolute;
top: 4px;
bottom: 4px;
width: 2px;
background: var(--accent);
z-index: 1;
pointer-events: none;
}
/* Inside the tab: the scroller clips anything past the first and last tab. */
.dropBefore::before {
left: 0;
}
.dropAfter::after {
right: 0;
}
@media (prefers-reduced-motion: reduce) {
.tab,
.close,
.closeSlot .modified {
transition: none;
}
}