feat(git): make the repository switcher responsive (#1130)

Keep the contributor label work but place the control above Changes per the product decision: chips at natural width while every root fits, one native select once it does not. A hidden measurement row makes the decision content-driven; the More -> Repository submenu stays as the folded fallback.
This commit is contained in:
Menghuan1918 committed 2026-11-16 00:37:02 +08:00
1 parent da860d9aef
commit 83a25c27bc
9 files changed
+350 -113

No files matched your search

+86
View File
@@ -58,6 +58,92 @@
.scmHeader:hover .scmActions, .scmHeader:focus-within .scmActions { opacity: 1; }
@media (hover: none) { .scmActions { opacity: 1; } }
/* Child repositories of a workspace container: every view in this panel is
pinned to ONE root, so the switcher is the only surface that says the others
exist. The SAME list renders as natural-width chips while it fits on one
line and as one native select once it does not; a hidden measurement row
makes that decision from content width, not a viewport breakpoint. */
.repoSwitcher {
position: relative;
flex: none;
display: flex;
align-items: center;
min-width: 0;
padding: 0 6px 2px;
}
.repoChips {
flex: 1;
display: flex;
align-items: center;
gap: 4px;
min-width: 0;
overflow-x: auto;
overflow-y: hidden;
scrollbar-width: none;
}
.repoChips::-webkit-scrollbar { display: none; }
.repoChip {
flex: none;
min-height: 22px;
padding: 2px 8px;
border: 1px solid var(--dsw-alias-border-l1);
border-radius: 3px;
background: transparent;
color: var(--dsw-alias-label-secondary);
font: var(--dsw-font-xxxs-11);
text-align: left;
white-space: nowrap;
cursor: pointer;
}
.repoChip:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
.repoChip[data-active='true'] {
border-color: var(--dsw-alias-border-l2);
background: var(--dsw-alias-interactive-bg-hover-accent);
color: var(--dsw-alias-label-primary);
}
.repoChip:disabled { opacity: 0.45; cursor: default; }
.repoChip:focus-visible { outline: 2px solid var(--dsw-alias-interactive-bg-hover-accent); outline-offset: -2px; }
/* The narrow form: the same caption/box rhythm as the graph's branch select. */
.repoPick {
flex: 1;
display: flex;
align-items: center;
gap: 6px;
min-width: 0;
font: var(--dsw-font-xxs-strong-12);
color: var(--dsw-alias-label-primary);
}
.repoPickLabel { flex: none; white-space: nowrap; }
.repoPickSelect {
flex: 1;
min-width: 0;
max-width: 100%;
height: 28px;
border: 1px solid var(--dsw-alias-border-l2);
border-radius: 3px;
background: var(--dsw-alias-bg-base);
color: var(--dsw-alias-label-primary);
font: inherit;
}
.repoPickSelect:disabled { opacity: 0.45; cursor: default; }
.repoPickSelect:focus-visible { outline: 2px solid var(--dsw-alias-interactive-bg-hover-accent); outline-offset: -2px; }
/* Natural-width copy used only for the fit decision. Keep it in the layout
tree (visibility, not display) so scrollWidth is measurable. */
.repoMeasure {
position: absolute;
left: 0;
top: 0;
display: flex;
gap: 4px;
height: 0;
overflow: hidden;
visibility: hidden;
pointer-events: none;
white-space: nowrap;
}
/* Docked by the flex column above (a sibling of `.gitScroll`), plus sticky so
it also survives the case where the host tab body itself scrolls the whole
tab — the branch control must never leave the bottom of the pane.