forge
Explore
Log in

Don't you dare go Hollow

Branch pill opens a filterable switcher for branches and tags

Browse files at this commit

02c773dc609d576aacc21e7312efda9731925ff5Ahmet Kaan GümüşParent: 93ac114
  • feat
    • branch pill opens a filterable switcher for branches and tags
Show full message
✨ feat: branch pill opens a filterable switcher for branches and tags

The browse bar's ref pill now opens a popover with a filter, Branches
and Tags tabs, entries sorted by latest commit (default branch first),
and a "View all" link per tab. Long lists keep the first ten entries
visible and hide the rest until the filter narrows them. Arrow keys and
Enter work in the filter as in the file finder. On phones the popover
opens as a full-width sheet.

The repo home aside lists the five most recently updated branches as
links with a "View all" link. The tree page uses the same switcher.
crates/forge-web/assets/nav.jsmodified+96 -0
@@ -2024,6 +2024,102 @@
20242024 if (btn) { e.preventDefault(); copyLog(btn); }
20252025 }, false);
20262026
2027+ // ---- branch switcher ------------------------------------------------------------------------
2028+ // The ref popover in the browse bar: a filter over the active list, Branches and Tags tabs, and
2029+ // arrow keys through the visible entries as in the file finder. Entries past the first REF_SHOWN
2030+ // stay hidden until the filter narrows them, so the filter still reaches every name.
2031+
2032+ var REF_SHOWN = 10;
2033+
2034+ function refSwitchOf(el) {
2035+ return el && el.closest ? el.closest('details[data-ref-switch]') : null;
2036+ }
2037+
2038+ function refPanelOf(sw) {
2039+ var tab = sw.querySelector('[data-ref-tab][aria-selected="true"]');
2040+ var kind = tab ? tab.getAttribute('data-ref-tab') : 'branches';
2041+ return sw.querySelector('[data-ref-panel="' + kind + '"]');
2042+ }
2043+
2044+ function refShown(panel) {
2045+ return Array.prototype.filter.call(panel.querySelectorAll('[data-ref-item]'), function (li) {
2046+ return !li.hidden;
2047+ });
2048+ }
2049+
2050+ // Applies the filter to the active panel: every match, or the first entries when it is empty.
2051+ function refApply(sw) {
2052+ var q = sw.querySelector('[data-ref-filter]').value.trim().toLowerCase();
2053+ var panel = refPanelOf(sw);
2054+ var empty = panel.querySelector('[data-ref-empty]');
2055+ var shown = 0;
2056+ Array.prototype.forEach.call(panel.querySelectorAll('[data-ref-item]'), function (li, i) {
2057+ var show = q ? li.textContent.trim().toLowerCase().indexOf(q) >= 0 : i < REF_SHOWN;
2058+ li.hidden = !show;
2059+ li.removeAttribute('aria-selected');
2060+ if (show) { shown++; }
2061+ });
2062+ if (empty) { empty.hidden = shown > 0; }
2063+ refSelect(sw, 0);
2064+ }
2065+
2066+ function refSelect(sw, index) {
2067+ var panel = refPanelOf(sw);
2068+ var input = sw.querySelector('[data-ref-filter]');
2069+ var shown = refShown(panel);
2070+ if (!shown.length) { input.removeAttribute('aria-activedescendant'); return; }
2071+ index = Math.max(0, Math.min(shown.length - 1, index));
2072+ shown.forEach(function (li, i) { li.setAttribute('aria-selected', i === index ? 'true' : 'false'); });
2073+ input.setAttribute('aria-activedescendant', shown[index].id);
2074+ shown[index].scrollIntoView({ block: 'nearest' });
2075+ panel.__sel = index;
2076+ }
2077+
2078+ // Opening the switcher clears the filter and focuses it.
2079+ document.addEventListener('toggle', function (e) {
2080+ var sw = e.target;
2081+ if (!sw || !sw.hasAttribute || !sw.hasAttribute('data-ref-switch') || !sw.open) { return; }
2082+ var input = sw.querySelector('[data-ref-filter]');
2083+ input.value = '';
2084+ refApply(sw);
2085+ input.focus();
2086+ }, true);
2087+
2088+ document.addEventListener('click', function (e) {
2089+ var tab = e.target && e.target.closest ? e.target.closest('[data-ref-tab]') : null;
2090+ if (!tab) { return; }
2091+ var sw = refSwitchOf(tab);
2092+ var kind = tab.getAttribute('data-ref-tab');
2093+ sw.querySelectorAll('[data-ref-tab]').forEach(function (t) {
2094+ t.setAttribute('aria-selected', t === tab ? 'true' : 'false');
2095+ });
2096+ sw.querySelectorAll('[data-ref-panel]').forEach(function (p) {
2097+ p.hidden = p.getAttribute('data-ref-panel') !== kind;
2098+ });
2099+ refApply(sw);
2100+ }, false);
2101+
2102+ document.addEventListener('keydown', function (e) {
2103+ var input = e.target && e.target.closest ? e.target.closest('[data-ref-filter]') : null;
2104+ if (!input) { return; }
2105+ var sw = refSwitchOf(input);
2106+ var panel = refPanelOf(sw);
2107+ var sel = panel.__sel || 0;
2108+ if (e.key === 'ArrowDown') { e.preventDefault(); refSelect(sw, sel + 1); }
2109+ else if (e.key === 'ArrowUp') { e.preventDefault(); refSelect(sw, sel - 1); }
2110+ else if (e.key === 'Enter') {
2111+ e.preventDefault();
2112+ var item = refShown(panel)[sel];
2113+ var link = item ? item.querySelector('a') : null;
2114+ if (link) { sw.open = false; link.click(); }
2115+ }
2116+ }, false);
2117+
2118+ document.addEventListener('input', function (e) {
2119+ var input = e.target && e.target.closest ? e.target.closest('[data-ref-filter]') : null;
2120+ if (input) { refApply(refSwitchOf(input)); }
2121+ }, false);
2122+
20272123 document.addEventListener('input', function (e) {
20282124 var input = e.target && e.target.closest ? e.target.closest('[data-finder-input]') : null;
20292125 if (input) { renderFinder(input.closest('dialog')); }
crates/forge-web/src/i18n/code.rsmodified+16 -0
@@ -23,6 +23,10 @@ pub enum K {
2323 CloneTitle,
2424 SshRequiresKey,
2525 BranchesTitle,
26+ FilterRefs,
27+ ViewAll,
28+ ViewAllBranches,
29+ ViewAllTags,
2630 EmptyRepoPush,
2731 OverHttps,
2832 OverSsh,
@@ -157,6 +161,14 @@ pub fn t(lang: Lang, key: K) -> &'static str {
157161 (SshRequiresKey, Tr) => "SSH (hesabınızda bir ed25519 veya ECDSA anahtarı olmalı)",
158162 (BranchesTitle, En) => "Branches",
159163 (BranchesTitle, Tr) => "Dallar",
164+ (FilterRefs, En) => "Filter branches and tags",
165+ (FilterRefs, Tr) => "Dal ve etiketleri süz",
166+ (ViewAll, En) => "View all",
167+ (ViewAll, Tr) => "Tümünü gör",
168+ (ViewAllBranches, En) => "View all branches",
169+ (ViewAllBranches, Tr) => "Tüm dalları gör",
170+ (ViewAllTags, En) => "View all tags",
171+ (ViewAllTags, Tr) => "Tüm etiketleri gör",
160172 (EmptyRepoPush, En) => "This repository is empty. Push a branch to get started:",
161173 (EmptyRepoPush, Tr) => "Bu depo boş. Başlamak için bir dal gönderin:",
162174 (OverHttps, En) => "Over HTTPS",
@@ -530,6 +542,10 @@ mod tests {
530542 K::CloneTitle,
531543 K::SshRequiresKey,
532544 K::BranchesTitle,
545+ K::FilterRefs,
546+ K::ViewAll,
547+ K::ViewAllBranches,
548+ K::ViewAllTags,
533549 K::EmptyRepoPush,
534550 K::OverHttps,
535551 K::OverSsh,
crates/forge-web/src/pages/refs.rsmodified+40 -28
@@ -1,6 +1,7 @@
11 //! Page: the tag list at `/{owner}/{repo}/tags` (branches are in `branches`).
22 //! Also the ref helpers shared with the tree page (the ref selector).
33
4+use std::cmp::Reverse;
45 use std::path::PathBuf;
56
67 use crate::state::AppState;
@@ -27,38 +28,49 @@ pub async fn load_refs(path: PathBuf) -> Result<Vec<RefInfo>> {
2728 Ok(tokio::task::spawn_blocking(move || browse::list_refs(&path)).await??)
2829 }
2930
30-/// Branch and tag links for the ref selector. The default branch sorts first.
31-pub fn ref_links(
32- refs: &[RefInfo],
31+/// Branch and tag links for the ref switcher, each with the commit time of its tip. The default
32+/// branch sorts first, the rest newest first.
33+pub async fn ref_links(
34+ path: PathBuf,
35+ refs: Vec<RefInfo>,
3336 current: &str,
3437 default_branch: &str,
3538 repo: &RepoRow,
36-) -> (Vec<RefLink>, Vec<RefLink>) {
37- let branches = sorted(refs, RefKind::Branch, default_branch)
38- .into_iter()
39- .map(|r| ref_link(repo, &r.name, current));
40- let tags = sorted(refs, RefKind::Tag, default_branch)
41- .into_iter()
42- .map(|r| ref_link(repo, &r.name, current));
43- (branches.collect(), tags.collect())
44-}
45-
46-fn ref_link(repo: &RepoRow, name: &str, current: &str) -> RefLink {
47- RefLink {
48- name: name.to_owned(),
49- href: repo_href(&repo.owner_name, &repo.name, "tree", name),
50- current: name == current,
51- }
52-}
53-
54-/// Refs of one kind: the default branch first, then by name.
55-fn sorted<'a>(refs: &'a [RefInfo], kind: RefKind, default_branch: &str) -> Vec<&'a RefInfo> {
56- let mut out: Vec<&RefInfo> = refs.iter().filter(|r| r.kind == kind).collect();
57- out.sort_by(|a, b| {
58- (a.name != default_branch, a.name.as_str())
59- .cmp(&(b.name != default_branch, b.name.as_str()))
39+) -> Result<(Vec<RefLink>, Vec<RefLink>)> {
40+ let mut timed = tokio::task::spawn_blocking(move || -> forge_git::Result<_> {
41+ refs.into_iter()
42+ .map(|r| {
43+ let updated =
44+ browse::read_commit(&path, &r.target)?.map_or(0, |c| c.committer_time);
45+ Ok((r, updated))
46+ })
47+ .collect::<forge_git::Result<Vec<(RefInfo, i64)>>>()
48+ })
49+ .await??;
50+ timed.sort_by(|(a, ta), (b, tb)| {
51+ (a.name != default_branch, Reverse(*ta), a.name.as_str()).cmp(&(
52+ b.name != default_branch,
53+ Reverse(*tb),
54+ b.name.as_str(),
55+ ))
6056 });
61- out
57+ let link = |(r, updated): &(RefInfo, i64)| RefLink {
58+ name: r.name.clone(),
59+ href: repo_href(&repo.owner_name, &repo.name, "tree", &r.name),
60+ current: r.name == current,
61+ updated: *updated,
62+ };
63+ let branches = timed
64+ .iter()
65+ .filter(|(r, _)| r.kind == RefKind::Branch)
66+ .map(link)
67+ .collect();
68+ let tags = timed
69+ .iter()
70+ .filter(|(r, _)| r.kind == RefKind::Tag)
71+ .map(link)
72+ .collect();
73+ Ok((branches, tags))
6274 }
6375
6476 /// One row of the branch or tag table.
crates/forge-web/src/pages/repo.rsmodified+25 -12
@@ -26,18 +26,21 @@ use crate::pages::finder::file_finder;
2626 use crate::pages::issue_parts::stamp_unix;
2727 use crate::pages::notifications::watch_form;
2828 use crate::pages::packages::{self, repo_packages_card};
29-use crate::pages::refs::load_refs;
29+use crate::pages::refs::{load_refs, ref_links};
3030 use crate::pages::releases::latest_card;
3131 use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
3232 use crate::pages::tree::{
3333 entry_rows, last_commits, latest_bar, load_readme, read_dir, readme_card, tree_table,
3434 };
3535 use crate::state::AppState;
36-use crate::views::{now_unix, relative_time, repo_href, repo_tabs, shell, user_link};
36+use crate::views::{now_unix, ref_selector, relative_time, repo_href, repo_tabs, shell, user_link};
3737
3838 path_param!(owner);
3939 path_param!(repo);
4040
41+/// Branches listed in the aside, most recently updated first. The switcher lists the rest.
42+const RECENT_BRANCHES: usize = 5;
43+
4144 /// HTTPS clone URL: `{base_url}/{owner}/{repo}.git`.
4245 pub fn https_clone_url(config: &Config, owner: &str, name: &str) -> String {
4346 format!(
@@ -416,6 +419,12 @@ async fn repo_page(cx: &Cx) -> Result<impl View> {
416419 let branch = repo.default_branch.clone();
417420
418421 let refs = load_refs(ctx.path.clone()).await?;
422+ let (branches, tags) =
423+ ref_links(ctx.path.clone(), refs.clone(), &branch, &branch, repo).await?;
424+ let mut recent = branches.clone();
425+ recent.sort_by_key(|link| std::cmp::Reverse(link.updated));
426+ recent.truncate(RECENT_BRANCHES);
427+ let branch_names: Vec<String> = branches.iter().map(|link| link.name.clone()).collect();
419428 let head = default_commit(ctx.path.clone(), branch.clone()).await?;
420429
421430 let https = https_clone_url(&state.config, &repo.owner_name, &repo.name);
@@ -460,14 +469,10 @@ async fn repo_page(cx: &Cx) -> Result<impl View> {
460469 }
461470 let follows = follows_branch(&refs, &branch);
462471 let live = live_url(&repo.owner_name, &repo.name, &refs, &branch);
463- let branch_names: Vec<String> = refs
464- .into_iter()
465- .filter(|r| r.kind == browse::RefKind::Branch)
466- .map(|r| r.name)
467- .collect();
468-
469472 let owner_name = repo.owner_name.clone();
470473 let repo_name = repo.name.clone();
474+ let branches_href = repo_href(&owner_name, &repo_name, "branches", "");
475+ let tags_href = repo_href(&owner_name, &repo_name, "tags", "");
471476 let mut header = ctx.head(state, "code").await?;
472477 header.live = live;
473478 let latest = crate::pages::releases::latest_release_for_home(state, &ctx).await?;
@@ -486,8 +491,8 @@ async fn repo_page(cx: &Cx) -> Result<impl View> {
486491 }
487492 if let Some(rows) = tree {
488493 <div class="browse-bar" data-live-code=(follows.then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))>
489- <span class="muted small">(g::t(lang, K::BranchLabel))</span>
490- <code>(branch.clone())</code>
494+ ref_selector(lang: lang, label: g::t(lang, K::BranchLabel), current: branch.clone(), branches: branches, tags: tags,
495+ branches_href: branches_href.clone(), tags_href: tags_href)
491496 file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(),
492497 ref_name: branch.clone())
493498 archive_links(owner: owner_name, repo: repo_name,
@@ -508,10 +513,17 @@ async fn repo_page(cx: &Cx) -> Result<impl View> {
508513 <section>
509514 <h2>(g::t(lang, K::BranchesTitle))</h2>
510515 <ul class="branch-list">
511- for name in branch_names.into_iter() {
512- <li><code>(name)</code></li>
516+ for link in recent.into_iter() {
517+ <li>
518+ if link.current {
519+ <a class="current" aria-current="true" href=(link.href)>(link.name)</a>
520+ } else {
521+ <a href=(link.href)>(link.name)</a>
522+ }
523+ </li>
513524 }
514525 </ul>
526+ <p class="small"><a href=(branches_href)>(g::t(lang, K::ViewAll))</a></p>
515527 </section>
516528 </aside>
517529 </div>
@@ -666,6 +678,7 @@ mod tests {
666678 );
667679 assert!(body.contains("/tahinli/demo/archive/main.tar.gz"));
668680 assert!(body.contains("/tahinli/demo/branches"));
681+ assert!(body.contains("data-ref-filter"), "branch switcher rendered");
669682
670683 // Trees list their entries and link to subtrees and blobs.
671684 let (status, body) = get(&router, "/tahinli/demo/tree/main/src").await;
crates/forge-web/src/pages/tree.rsmodified+13 -2
@@ -16,6 +16,7 @@ use topcoat::router::{page, path_param};
1616 use topcoat::view::{Unescaped, View, component, view};
1717
1818 use crate::i18n::code::{self as g, K};
19+use crate::i18n::misc::{self as mi, K as MK};
1920 use crate::i18n::{self, Lang};
2021 use crate::pages::code_live::{follows_branch, live_url};
2122 use crate::pages::finder::file_finder;
@@ -547,7 +548,16 @@ async fn tree_page(cx: &Cx) -> Result<impl View> {
547548 now_unix(),
548549 ctx.viewer_tz(),
549550 );
550- let (branches, tags) = ref_links(&refs, &ref_name, &repo.default_branch, repo);
551+ let (branches, tags) = ref_links(
552+ ctx.path.clone(),
553+ refs.clone(),
554+ &ref_name,
555+ &repo.default_branch,
556+ repo,
557+ )
558+ .await?;
559+ let branches_href = repo_href(&repo.owner_name, &repo.name, "branches", "");
560+ let tags_href = repo_href(&repo.owner_name, &repo.name, "tags", "");
551561 let live = follows_branch(&refs, &ref_name)
552562 .then(|| live_url(&repo.owner_name, &repo.name, &refs, &ref_name));
553563
@@ -566,7 +576,8 @@ async fn tree_page(cx: &Cx) -> Result<impl View> {
566576 shell(title: title.as_str(), viewer: ctx.viewer.as_ref(),
567577 repo_head(head: header)
568578 <div class="browse-bar" data-live=(live.as_deref()) data-live-code=(live.is_some().then_some("true")) data-live-gone=(g::t(lang, K::LivePathGone))>
569- ref_selector(lang: lang, current: ref_name.clone(), branches: branches, tags: tags)
579+ ref_selector(lang: lang, label: mi::t(lang, MK::RefLabel), current: ref_name.clone(), branches: branches, tags: tags,
580+ branches_href: branches_href, tags_href: tags_href)
570581 breadcrumb(lang: lang, crumbs: crumbs)
571582 file_finder(lang: lang, owner: finder_owner, repo: finder_repo, ref_name: finder_ref)
572583 </div>
crates/forge-web/src/views/mod.rsmodified+54 -21
@@ -1120,51 +1120,84 @@ pub async fn repo_tabs(
11201120 })
11211121 }
11221122
1123-/// A branch or tag in the ref selector. `href` points at its root tree.
1123+/// A branch or tag in the ref switcher. `href` points at its root tree; `updated` is the commit
1124+/// time of its tip (unix seconds).
1125+#[derive(Clone)]
11241126 pub struct RefLink {
11251127 pub name: String,
11261128 pub href: String,
11271129 pub current: bool,
1130+ pub updated: i64,
11281131 }
11291132
1133+/// Entries listed before the filter narrows the list. The rest stay in the page, hidden, so the
1134+/// filter still finds every name.
1135+pub const REF_SHOWN: usize = 10;
1136+
1137+/// One tab of the ref switcher: its entries, then the link to the full list.
11301138 #[component]
1131-async fn ref_group(title: &str, links: Vec<RefLink>) -> Result<impl View> {
1139+async fn ref_panel(
1140+ lang: Lang,
1141+ kind: &'static str,
1142+ links: Vec<RefLink>,
1143+ all_href: String,
1144+ all_label: &'static str,
1145+) -> Result<impl View> {
1146+ let empty = links.is_empty();
11321147 Ok(view! {
1133- <p class="ref-heading">(title)</p>
1134- <ul class="ref-list">
1135- for link in links.into_iter() {
1136- <li>
1137- if link.current {
1138- <a class="current" aria-current="true" href=(link.href)>(link.name)</a>
1139- } else {
1140- <a href=(link.href)>(link.name)</a>
1148+ <div class="ref-panel" role="tabpanel" data-ref-panel=(kind) hidden=(kind != "branches")>
1149+ if empty {
1150+ <p class="muted small ref-note">(g::t(lang, K::NothingHere))</p>
1151+ } else {
1152+ <ul class="ref-list" role="listbox">
1153+ for (n, link) in links.into_iter().enumerate() {
1154+ <li role="option" id=(format!("ref-{kind}-{n}")) data-ref-item="" hidden=((n >= REF_SHOWN).then_some(""))>
1155+ if link.current {
1156+ <a class="current" aria-current="true" href=(link.href)>(link.name)</a>
1157+ } else {
1158+ <a href=(link.href)>(link.name)</a>
1159+ }
1160+ </li>
11411161 }
1142- </li>
1162+ </ul>
1163+ <p class="muted small ref-note" data-ref-empty="" hidden=(true)>(g::t(lang, K::NoMatches))</p>
11431164 }
1144- </ul>
1165+ <a class="ref-all" href=(all_href)>(all_label)</a>
1166+ </div>
11451167 })
11461168 }
11471169
1148-/// Branch and tag selector. A plain `<details>` list, so it works without JavaScript.
1170+/// Branch and tag switcher for the browse bar: a button showing the current ref that opens a
1171+/// popover with a filter, Branches and Tags tabs, and a link to each full list. The filter, tabs and
1172+/// arrow keys are wired in `assets/nav.js`; without it the popover still lists the first entries.
11491173 #[component]
11501174 pub async fn ref_selector(
11511175 lang: Lang,
1176+ label: &'static str,
11521177 current: String,
11531178 branches: Vec<RefLink>,
11541179 tags: Vec<RefLink>,
1180+ branches_href: String,
1181+ tags_href: String,
11551182 ) -> Result<impl View> {
1156- let has_tags = !tags.is_empty();
11571183 Ok(view! {
1158- <details class="ref-select">
1184+ <details class="ref-select" data-ref-switch="">
11591185 <summary>
1160- <span class="muted small">(mi::t(lang, MK::RefLabel))</span>
1161- <code>(current)</code>
1186+ <span class="muted small">(label)</span>
1187+ <code>(current.as_str())</code>
11621188 </summary>
11631189 <div class="ref-menu">
1164- ref_group(title: g::t(lang, K::BranchesTitle), links: branches)
1165- if has_tags {
1166- ref_group(title: g::t(lang, K::TagsTitle), links: tags)
1167- }
1190+ <div class="ref-top">
1191+ <input type="text" class="ref-filter" data-ref-filter="" autocomplete="off" spellcheck="false"
1192+ placeholder=(g::t(lang, K::FilterRefs)) aria-label=(g::t(lang, K::FilterRefs))
1193+ role="combobox" aria-expanded="true" aria-autocomplete="list">
1194+ <div class="ref-tabs" role="tablist">
1195+ <button type="button" role="tab" aria-selected="true" data-ref-tab="branches">(g::t(lang, K::BranchesTitle))</button>
1196+ <button type="button" role="tab" aria-selected="false" data-ref-tab="tags">(g::t(lang, K::TagsTitle))</button>
1197+ </div>
1198+ </div>
1199+ ref_panel(lang: lang, kind: "branches", links: branches, all_href: branches_href, all_label: g::t(lang, K::ViewAllBranches))
1200+ ref_panel(lang: lang, kind: "tags", links: tags, all_href: tags_href, all_label: g::t(lang, K::ViewAllTags))
11681201 </div>
11691202 </details>
11701203 })
style/main.scssmodified+113 -11
@@ -815,6 +815,12 @@ code {
815815 padding: 6px 0;
816816 }
817817
818+.branch-list a {
819+ font-family: var(--mono);
820+ font-size: 13.5px;
821+ word-break: break-all;
822+}
823+
818824 // Tables
819825
820826 .table-wrap {
@@ -1095,28 +1101,93 @@ code {
10951101 }
10961102 }
10971103
1104+// Branch switcher popover: filter and tabs on top, the entries below, scrolling inside.
10981105 .ref-menu {
10991106 position: absolute;
11001107 left: 0;
11011108 top: calc(100% + 6px);
11021109 z-index: 10;
1103- min-width: 240px;
1110+ width: 300px;
1111+ max-width: calc(100vw - 32px);
11041112 max-height: 60vh;
1105- overflow-y: auto;
1106- padding: 8px 0;
1113+ display: flex;
1114+ flex-direction: column;
11071115 background: var(--surface);
11081116 border: 1px solid var(--border);
11091117 border-radius: var(--radius-lg);
11101118 box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
11111119 }
11121120
1113-.ref-heading {
1114- margin: 6px 14px 4px;
1115- font-size: 0.75rem;
1116- font-weight: 600;
1117- color: var(--muted);
1118- text-transform: uppercase;
1119- letter-spacing: 0.04em;
1121+.ref-top {
1122+ padding: 8px;
1123+ border-bottom: 1px solid var(--border);
1124+}
1125+
1126+.ref-filter {
1127+ width: 100%;
1128+ height: var(--control-h);
1129+ box-sizing: border-box;
1130+ padding: 0 10px;
1131+ font: inherit;
1132+ font-size: 14px;
1133+ color: var(--text);
1134+ background: var(--surface-2);
1135+ border: 1px solid var(--border);
1136+ border-radius: var(--radius-md);
1137+
1138+ &:focus-visible {
1139+ outline: 2px solid var(--focus);
1140+ outline-offset: 1px;
1141+ }
1142+}
1143+
1144+.ref-tabs {
1145+ display: flex;
1146+ gap: 4px;
1147+ margin-top: 8px;
1148+
1149+ button {
1150+ flex: 1 1 0;
1151+ min-height: 32px;
1152+ padding: 0 10px;
1153+ font: inherit;
1154+ font-size: 13px;
1155+ color: var(--muted);
1156+ background: none;
1157+ border: 0;
1158+ border-radius: var(--radius-md);
1159+ cursor: pointer;
1160+
1161+ &[aria-selected="true"] {
1162+ color: var(--text);
1163+ background: var(--accent-soft);
1164+ font-weight: 600;
1165+ }
1166+
1167+ &:focus-visible {
1168+ outline: 2px solid var(--focus);
1169+ outline-offset: 1px;
1170+ }
1171+ }
1172+}
1173+
1174+.ref-panel {
1175+ min-height: 0;
1176+ overflow-y: auto;
1177+ padding: 4px 0;
1178+}
1179+
1180+.ref-note {
1181+ margin: 8px 14px;
1182+}
1183+
1184+.ref-all {
1185+ display: block;
1186+ margin-top: 4px;
1187+ padding: 8px 14px;
1188+ font-size: 13px;
1189+ color: var(--text-2);
1190+ border-top: 1px solid var(--border);
11201191 }
11211192
11221193 .ref-list {
@@ -1124,6 +1195,11 @@ code {
11241195 margin: 0;
11251196 padding: 0;
11261197
1198+ li[aria-selected="true"] a,
1199+ a:hover {
1200+ background: var(--accent-soft);
1201+ }
1202+
11271203 a {
11281204 display: block;
11291205 padding: 6px 14px;
@@ -1855,8 +1931,34 @@ code {
18551931 margin-left: 0;
18561932 }
18571933
1934+ // The branch switcher opens as a full-width sheet from the bottom, with larger tap targets.
18581935 .ref-menu {
1859- max-width: calc(100vw - 32px);
1936+ position: fixed;
1937+ top: auto;
1938+ left: 0;
1939+ right: 0;
1940+ bottom: 0;
1941+ width: auto;
1942+ max-width: none;
1943+ max-height: 75vh;
1944+ border-radius: var(--radius-lg) var(--radius-lg) 0 0;
1945+ }
1946+
1947+ .ref-filter {
1948+ height: 44px;
1949+ font-size: 16px;
1950+ }
1951+
1952+ .ref-tabs button {
1953+ min-height: 44px;
1954+ }
1955+
1956+ .ref-list a {
1957+ padding: 12px 16px;
1958+ }
1959+
1960+ .ref-all {
1961+ padding: 14px 16px;
18601962 }
18611963 }
18621964