Branch picker is a command palette: one searchable list with Branches and Tags sections, tip ages, a default chip and key hints
Browse files at this commit749adabe20dce7a519ab04ab9dd713e97ca5e6ceParent: 3d6ee62- style
- branch picker is a command palette: one searchable list with Branches and Tags sections, tip ages, a default chip and key hints
4 changed files +267 -172
- crates/forge-web/assets/nav.js +44 -39
- crates/forge-web/src/pages/refs.rs +1 -0
- crates/forge-web/src/views/mod.rs +56 -42
- style/main.scss +166 -91
crates/forge-web/assets/nav.jsmodified+44 -39
| @@ -2053,54 +2053,65 @@ | |||
| 2053 | }, false); | 2053 | }, false); |
| 2054 | 2054 | ||
| 2055 | // ---- branch switcher ------------------------------------------------------------------------ | 2055 | // ---- branch switcher ------------------------------------------------------------------------ |
| 2056 | - // The ref popover in the browse bar: a filter over the active list, Branches and Tags tabs, and | 2056 | + // The ref popover in the browse bar: one filter over a Branches and a Tags section, the matched |
| 2057 | - // arrow keys through the visible entries as in the file finder. Entries past the first REF_SHOWN | 2057 | + // part of each name marked, and arrow keys (or the pointer) through the visible entries as in the |
| 2058 | - // stay hidden until the filter narrows them, so the filter still reaches every name. | 2058 | + // file finder. Entries past the first REF_SHOWN of a section stay hidden until the filter narrows |
| 2059 | + // them, so the filter still reaches every name. | ||
| 2059 | 2060 | ||
| 2060 | - var REF_SHOWN = 10; | 2061 | + var REF_SHOWN = 8; |
| 2061 | 2062 | ||
| 2062 | function refSwitchOf(el) { | 2063 | function refSwitchOf(el) { |
| 2063 | return el && el.closest ? el.closest('details[data-ref-switch]') : null; | 2064 | return el && el.closest ? el.closest('details[data-ref-switch]') : null; |
| 2064 | } | 2065 | } |
| 2065 | 2066 | ||
| 2066 | - function refPanelOf(sw) { | 2067 | + function refShown(sw) { |
| 2067 | - var tab = sw.querySelector('[data-ref-tab][aria-selected="true"]'); | 2068 | + return Array.prototype.filter.call(sw.querySelectorAll('[data-ref-item]'), function (li) { |
| 2068 | - var kind = tab ? tab.getAttribute('data-ref-tab') : 'branches'; | ||
| 2069 | - return sw.querySelector('[data-ref-panel="' + kind + '"]'); | ||
| 2070 | - } | ||
| 2071 | - | ||
| 2072 | - function refShown(panel) { | ||
| 2073 | - return Array.prototype.filter.call(panel.querySelectorAll('[data-ref-item]'), function (li) { | ||
| 2074 | return !li.hidden; | 2069 | return !li.hidden; |
| 2075 | }); | 2070 | }); |
| 2076 | } | 2071 | } |
| 2077 | 2072 | ||
| 2078 | - // Applies the filter to the active panel: every match, or the first entries when it is empty. | 2073 | + // Writes `name` into `el`, the first case-insensitive match of `q` wrapped in <mark>. |
| 2074 | + function refMark(el, name, q) { | ||
| 2075 | + var at = q ? name.toLowerCase().indexOf(q) : -1; | ||
| 2076 | + el.textContent = ''; | ||
| 2077 | + if (at < 0) { el.textContent = name; return; } | ||
| 2078 | + var mark = document.createElement('mark'); | ||
| 2079 | + mark.textContent = name.slice(at, at + q.length); | ||
| 2080 | + el.append(name.slice(0, at), mark, name.slice(at + q.length)); | ||
| 2081 | + } | ||
| 2082 | + | ||
| 2083 | + // Applies the filter to every section: each match, or the first entries when it is empty. A | ||
| 2084 | + // section with nothing to show hides with its heading. | ||
| 2079 | function refApply(sw) { | 2085 | function refApply(sw) { |
| 2080 | var q = sw.querySelector('[data-ref-filter]').value.trim().toLowerCase(); | 2086 | var q = sw.querySelector('[data-ref-filter]').value.trim().toLowerCase(); |
| 2081 | - var panel = refPanelOf(sw); | 2087 | + var groups = sw.querySelectorAll('[data-ref-group]'); |
| 2082 | - var empty = panel.querySelector('[data-ref-empty]'); | 2088 | + var total = 0; |
| 2089 | + groups.forEach(function (group) { | ||
| 2083 | var shown = 0; | 2090 | var shown = 0; |
| 2084 | - Array.prototype.forEach.call(panel.querySelectorAll('[data-ref-item]'), function (li, i) { | 2091 | + group.querySelectorAll('[data-ref-item]').forEach(function (li, i) { |
| 2085 | - var show = q ? li.textContent.trim().toLowerCase().indexOf(q) >= 0 : i < REF_SHOWN; | 2092 | + var name = li.getAttribute('data-ref-name') || ''; |
| 2093 | + var show = q ? name.toLowerCase().indexOf(q) >= 0 : i < REF_SHOWN; | ||
| 2086 | li.hidden = !show; | 2094 | li.hidden = !show; |
| 2087 | li.removeAttribute('aria-selected'); | 2095 | li.removeAttribute('aria-selected'); |
| 2088 | - if (show) { shown++; } | 2096 | + if (show) { shown++; refMark(li.querySelector('.ref-text'), name, q); } |
| 2089 | }); | 2097 | }); |
| 2090 | - if (empty) { empty.hidden = shown > 0; } | 2098 | + group.hidden = shown === 0; |
| 2099 | + total += shown; | ||
| 2100 | + }); | ||
| 2101 | + var empty = sw.querySelector('[data-ref-empty]'); | ||
| 2102 | + if (empty && groups.length) { empty.hidden = total > 0; } | ||
| 2091 | refSelect(sw, 0); | 2103 | refSelect(sw, 0); |
| 2092 | } | 2104 | } |
| 2093 | 2105 | ||
| 2094 | - function refSelect(sw, index) { | 2106 | + function refSelect(sw, index, keep) { |
| 2095 | - var panel = refPanelOf(sw); | ||
| 2096 | var input = sw.querySelector('[data-ref-filter]'); | 2107 | var input = sw.querySelector('[data-ref-filter]'); |
| 2097 | - var shown = refShown(panel); | 2108 | + var shown = refShown(sw); |
| 2098 | if (!shown.length) { input.removeAttribute('aria-activedescendant'); return; } | 2109 | if (!shown.length) { input.removeAttribute('aria-activedescendant'); return; } |
| 2099 | index = Math.max(0, Math.min(shown.length - 1, index)); | 2110 | index = Math.max(0, Math.min(shown.length - 1, index)); |
| 2100 | shown.forEach(function (li, i) { li.setAttribute('aria-selected', i === index ? 'true' : 'false'); }); | 2111 | shown.forEach(function (li, i) { li.setAttribute('aria-selected', i === index ? 'true' : 'false'); }); |
| 2101 | input.setAttribute('aria-activedescendant', shown[index].id); | 2112 | input.setAttribute('aria-activedescendant', shown[index].id); |
| 2102 | - shown[index].scrollIntoView({ block: 'nearest' }); | 2113 | + if (!keep) { shown[index].scrollIntoView({ block: 'nearest' }); } |
| 2103 | - panel.__sel = index; | 2114 | + sw.__refSel = index; |
| 2104 | } | 2115 | } |
| 2105 | 2116 | ||
| 2106 | // Opening the switcher clears the filter and focuses it. | 2117 | // Opening the switcher clears the filter and focuses it. |
| @@ -2113,31 +2124,25 @@ | |||
| 2113 | input.focus(); | 2124 | input.focus(); |
| 2114 | }, true); | 2125 | }, true); |
| 2115 | 2126 | ||
| 2116 | - document.addEventListener('click', function (e) { | 2127 | + // The pointer moves the selection, so the keys pick up where it is. |
| 2117 | - var tab = e.target && e.target.closest ? e.target.closest('[data-ref-tab]') : null; | 2128 | + document.addEventListener('mouseover', function (e) { |
| 2118 | - if (!tab) { return; } | 2129 | + var li = e.target && e.target.closest ? e.target.closest('[data-ref-item]') : null; |
| 2119 | - var sw = refSwitchOf(tab); | 2130 | + if (!li) { return; } |
| 2120 | - var kind = tab.getAttribute('data-ref-tab'); | 2131 | + var sw = refSwitchOf(li); |
| 2121 | - sw.querySelectorAll('[data-ref-tab]').forEach(function (t) { | 2132 | + var i = refShown(sw).indexOf(li); |
| 2122 | - t.setAttribute('aria-selected', t === tab ? 'true' : 'false'); | 2133 | + if (i >= 0 && i !== sw.__refSel) { refSelect(sw, i, true); } |
| 2123 | - }); | ||
| 2124 | - sw.querySelectorAll('[data-ref-panel]').forEach(function (p) { | ||
| 2125 | - p.hidden = p.getAttribute('data-ref-panel') !== kind; | ||
| 2126 | - }); | ||
| 2127 | - refApply(sw); | ||
| 2128 | }, false); | 2134 | }, false); |
| 2129 | 2135 | ||
| 2130 | document.addEventListener('keydown', function (e) { | 2136 | document.addEventListener('keydown', function (e) { |
| 2131 | var input = e.target && e.target.closest ? e.target.closest('[data-ref-filter]') : null; | 2137 | var input = e.target && e.target.closest ? e.target.closest('[data-ref-filter]') : null; |
| 2132 | if (!input) { return; } | 2138 | if (!input) { return; } |
| 2133 | var sw = refSwitchOf(input); | 2139 | var sw = refSwitchOf(input); |
| 2134 | - var panel = refPanelOf(sw); | 2140 | + var sel = sw.__refSel || 0; |
| 2135 | - var sel = panel.__sel || 0; | ||
| 2136 | if (e.key === 'ArrowDown') { e.preventDefault(); refSelect(sw, sel + 1); } | 2141 | if (e.key === 'ArrowDown') { e.preventDefault(); refSelect(sw, sel + 1); } |
| 2137 | else if (e.key === 'ArrowUp') { e.preventDefault(); refSelect(sw, sel - 1); } | 2142 | else if (e.key === 'ArrowUp') { e.preventDefault(); refSelect(sw, sel - 1); } |
| 2138 | else if (e.key === 'Enter') { | 2143 | else if (e.key === 'Enter') { |
| 2139 | e.preventDefault(); | 2144 | e.preventDefault(); |
| 2140 | - var item = refShown(panel)[sel]; | 2145 | + var item = refShown(sw)[sel]; |
| 2141 | var link = item ? item.querySelector('a') : null; | 2146 | var link = item ? item.querySelector('a') : null; |
| 2142 | if (link) { sw.open = false; link.click(); } | 2147 | if (link) { sw.open = false; link.click(); } |
| 2143 | } | 2148 | } |
crates/forge-web/src/pages/refs.rsmodified+1 -0
| @@ -53,6 +53,7 @@ pub fn ref_links( | |||
| 53 | name: r.name.clone(), | 53 | name: r.name.clone(), |
| 54 | href: repo_href(&repo.owner_name, &repo.name, "tree", &r.name), | 54 | href: repo_href(&repo.owner_name, &repo.name, "tree", &r.name), |
| 55 | current: r.name == current, | 55 | current: r.name == current, |
| 56 | + default: r.kind == RefKind::Branch && r.name == default_branch, | ||
| 56 | updated: r.committer_time, | 57 | updated: r.committer_time, |
| 57 | }; | 58 | }; |
| 58 | let branches = sorted | 59 | let branches = sorted |
crates/forge-web/src/views/mod.rsmodified+56 -42
| @@ -23,7 +23,7 @@ use topcoat::context::{Cx, try_app_context}; | |||
| 23 | use topcoat::router::request::uri; | 23 | use topcoat::router::request::uri; |
| 24 | use topcoat::router::response::{Response, response_headers}; | 24 | use topcoat::router::response::{Response, response_headers}; |
| 25 | use topcoat::router::{Body, Next, layer}; | 25 | use topcoat::router::{Body, Next, layer}; |
| 26 | -use topcoat::view::{Child, View, component, view}; | 26 | +use topcoat::view::{Child, Unescaped, View, component, view}; |
| 27 | 27 | ||
| 28 | use crate::i18n::admin::{self as ad, K as AK}; | 28 | use crate::i18n::admin::{self as ad, K as AK}; |
| 29 | use crate::i18n::code::{self as g, K}; | 29 | use crate::i18n::code::{self as g, K}; |
| @@ -1222,61 +1222,69 @@ pub async fn repo_tabs( | |||
| 1222 | } | 1222 | } |
| 1223 | 1223 | ||
| 1224 | /// A branch or tag in the ref switcher. `href` points at its root tree; `updated` is the commit | 1224 | /// A branch or tag in the ref switcher. `href` points at its root tree; `updated` is the commit |
| 1225 | -/// time of its tip (unix seconds). | 1225 | +/// time of its tip (unix seconds); `default` marks the repository's default branch. |
| 1226 | #[derive(Clone)] | 1226 | #[derive(Clone)] |
| 1227 | pub struct RefLink { | 1227 | pub struct RefLink { |
| 1228 | pub name: String, | 1228 | pub name: String, |
| 1229 | pub href: String, | 1229 | pub href: String, |
| 1230 | pub current: bool, | 1230 | pub current: bool, |
| 1231 | + pub default: bool, | ||
| 1231 | pub updated: i64, | 1232 | pub updated: i64, |
| 1232 | } | 1233 | } |
| 1233 | 1234 | ||
| 1234 | -/// Entries listed before the filter narrows the list. The rest stay in the page, hidden, so the | 1235 | +/// Entries each section lists before the filter narrows it. The rest stay in the page, hidden, so |
| 1235 | -/// filter still finds every name. | 1236 | +/// the filter still finds every name. |
| 1236 | -pub const REF_SHOWN: usize = 10; | 1237 | +pub const REF_SHOWN: usize = 8; |
| 1237 | 1238 | ||
| 1238 | -/// One tab of the ref switcher: its entries, then the link to the full list. | 1239 | +const BRANCH_ICON: &str = r#"<svg viewBox="0 0 24 24"><circle cx="6" cy="5" r="2"/><circle cx="6" cy="19" r="2"/><circle cx="18" cy="6" r="2"/><path d="M6 7v10M18 8c0 4-6 4-12 9"/></svg>"#; |
| 1240 | +const TAG_ICON: &str = r#"<svg viewBox="0 0 24 24"><path d="M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8z"/><circle cx="7.5" cy="7.5" r="1.5"/></svg>"#; | ||
| 1241 | + | ||
| 1242 | +/// One section of the ref switcher: a heading with its count, then its entries. An empty section | ||
| 1243 | +/// is left out. | ||
| 1239 | #[component] | 1244 | #[component] |
| 1240 | -async fn ref_panel( | 1245 | +async fn ref_group( |
| 1241 | lang: Lang, | 1246 | lang: Lang, |
| 1242 | kind: &'static str, | 1247 | kind: &'static str, |
| 1248 | + heading: &'static str, | ||
| 1243 | links: Vec<RefLink>, | 1249 | links: Vec<RefLink>, |
| 1244 | - all_href: String, | 1250 | + now: i64, |
| 1245 | - all_label: &'static str, | ||
| 1246 | ) -> Result<impl View> { | 1251 | ) -> Result<impl View> { |
| 1247 | - let empty = links.is_empty(); | 1252 | + let count = links.len(); |
| 1253 | + let icon = if kind == "tags" { TAG_ICON } else { BRANCH_ICON }; | ||
| 1254 | + let head_id = format!("ref-head-{kind}"); | ||
| 1248 | Ok(view! { | 1255 | Ok(view! { |
| 1249 | - <div class="ref-panel" role="tabpanel" data-ref-panel=(kind) hidden=(kind != "branches")> | 1256 | + if count > 0 { |
| 1250 | - if empty { | 1257 | + <div class="ref-group" data-ref-group=""> |
| 1251 | - <p class="muted small ref-note">(g::t(lang, K::NothingHere))</p> | 1258 | + <div class="ref-head" id=(head_id.as_str())> |
| 1252 | - } else { | 1259 | + <span>(heading)</span> |
| 1253 | - <ul class="ref-list" role="listbox"> | 1260 | + <span class="ref-count">(count)</span> |
| 1261 | + </div> | ||
| 1262 | + <ul class="ref-list" role="group" aria-labelledby=(head_id.as_str())> | ||
| 1254 | for (n, link) in links.into_iter().enumerate() { | 1263 | for (n, link) in links.into_iter().enumerate() { |
| 1255 | - <li role="option" id=(format!("ref-{kind}-{n}")) data-ref-item="" hidden=((n >= REF_SHOWN).then_some(""))> | 1264 | + <li role="option" id=(format!("ref-{kind}-{n}")) data-ref-item="" |
| 1256 | - if link.current { | 1265 | + data-ref-name=(link.name.as_str()) aria-current=(link.current.then_some("true")) |
| 1257 | - <a class="current" aria-current="true" href=(link.href)> | 1266 | + hidden=((n >= REF_SHOWN).then_some(""))> |
| 1258 | - <span class="ref-check" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg></span> | ||
| 1259 | - <span class="ref-text">(link.name)</span> | ||
| 1260 | - </a> | ||
| 1261 | - } else { | ||
| 1262 | <a href=(link.href)> | 1267 | <a href=(link.href)> |
| 1263 | - <span class="ref-check" aria-hidden="true"></span> | 1268 | + <span class="ref-kind" aria-hidden="true">(Unescaped::new_unchecked(icon))</span> |
| 1264 | - <span class="ref-text">(link.name)</span> | 1269 | + <span class="ref-text">(link.name.as_str())</span> |
| 1265 | - </a> | 1270 | + if link.default { |
| 1271 | + <span class="ref-chip">(g::t(lang, K::DefaultBadge))</span> | ||
| 1266 | } | 1272 | } |
| 1273 | + <span class="ref-age">(relative_time(lang, link.updated, now))</span> | ||
| 1274 | + </a> | ||
| 1267 | </li> | 1275 | </li> |
| 1268 | } | 1276 | } |
| 1269 | </ul> | 1277 | </ul> |
| 1270 | - <p class="muted small ref-note" data-ref-empty="" hidden=(true)>(g::t(lang, K::NoMatches))</p> | ||
| 1271 | - } | ||
| 1272 | - <a class="ref-all" href=(all_href)>(all_label)</a> | ||
| 1273 | </div> | 1278 | </div> |
| 1279 | + } | ||
| 1274 | }) | 1280 | }) |
| 1275 | } | 1281 | } |
| 1276 | 1282 | ||
| 1277 | /// Branch and tag switcher for the browse bar: a button showing the current ref that opens a | 1283 | /// Branch and tag switcher for the browse bar: a button showing the current ref that opens a |
| 1278 | -/// popover with a filter, Branches and Tags tabs, and a link to each full list. The filter, tabs and | 1284 | +/// command-palette popover: a search field over one list with a Branches and a Tags section, each |
| 1279 | -/// arrow keys are wired in `assets/nav.js`; without it the popover still lists the first entries. | 1285 | +/// row with its last commit's age, and a footer with key hints and links to the full lists. The |
| 1286 | +/// filter, match highlight and arrow keys are wired in `assets/nav.js`; without it the popover | ||
| 1287 | +/// still lists the first entries of each section. | ||
| 1280 | #[component] | 1288 | #[component] |
| 1281 | pub async fn ref_selector( | 1289 | pub async fn ref_selector( |
| 1282 | lang: Lang, | 1290 | lang: Lang, |
| @@ -1289,29 +1297,35 @@ pub async fn ref_selector( | |||
| 1289 | ) -> Result<impl View> { | 1297 | ) -> Result<impl View> { |
| 1290 | // A tag shows a tag icon only when it is the current ref and no branch of that name is. | 1298 | // A tag shows a tag icon only when it is the current ref and no branch of that name is. |
| 1291 | let is_tag = !branches.iter().any(|b| b.current) && tags.iter().any(|t| t.current); | 1299 | let is_tag = !branches.iter().any(|b| b.current) && tags.iter().any(|t| t.current); |
| 1300 | + let none = branches.is_empty() && tags.is_empty(); | ||
| 1301 | + let now = now_unix(); | ||
| 1292 | Ok(view! { | 1302 | Ok(view! { |
| 1293 | <details class="ref-select" data-ref-switch=""> | 1303 | <details class="ref-select" data-ref-switch=""> |
| 1294 | <summary title=(label) aria-label=(format!("{label}: {current}"))> | 1304 | <summary title=(label) aria-label=(format!("{label}: {current}"))> |
| 1295 | - if is_tag { | 1305 | + <span class="ref-icon" aria-hidden="true">(Unescaped::new_unchecked(if is_tag { TAG_ICON } else { BRANCH_ICON }))</span> |
| 1296 | - <span class="ref-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8z"/><circle cx="7.5" cy="7.5" r="1.5"/></svg></span> | ||
| 1297 | - } else { | ||
| 1298 | - <span class="ref-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="6" cy="5" r="2"/><circle cx="6" cy="19" r="2"/><circle cx="18" cy="6" r="2"/><path d="M6 7v10M18 8c0 4-6 4-12 9"/></svg></span> | ||
| 1299 | - } | ||
| 1300 | <code class="ref-name">(current.as_str())</code> | 1306 | <code class="ref-name">(current.as_str())</code> |
| 1301 | <span class="ref-caret" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg></span> | 1307 | <span class="ref-caret" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg></span> |
| 1302 | </summary> | 1308 | </summary> |
| 1303 | <div class="ref-menu"> | 1309 | <div class="ref-menu"> |
| 1304 | - <div class="ref-top"> | 1310 | + <label class="ref-search"> |
| 1311 | + <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> | ||
| 1305 | <input type="text" class="ref-filter" data-ref-filter="" autocomplete="off" spellcheck="false" | 1312 | <input type="text" class="ref-filter" data-ref-filter="" autocomplete="off" spellcheck="false" |
| 1306 | placeholder=(g::t(lang, K::FilterRefs)) aria-label=(g::t(lang, K::FilterRefs)) | 1313 | placeholder=(g::t(lang, K::FilterRefs)) aria-label=(g::t(lang, K::FilterRefs)) |
| 1307 | - role="combobox" aria-expanded="true" aria-autocomplete="list"> | 1314 | + role="combobox" aria-expanded="true" aria-autocomplete="list" aria-controls="ref-results"> |
| 1308 | - <div class="ref-tabs" role="tablist"> | 1315 | + <kbd>"esc"</kbd> |
| 1309 | - <button type="button" role="tab" aria-selected="true" data-ref-tab="branches">(g::t(lang, K::BranchesTitle))</button> | 1316 | + </label> |
| 1310 | - <button type="button" role="tab" aria-selected="false" data-ref-tab="tags">(g::t(lang, K::TagsTitle))</button> | 1317 | + <div class="ref-results" id="ref-results" role="listbox"> |
| 1318 | + ref_group(lang: lang, kind: "branches", heading: g::t(lang, K::BranchesTitle), links: branches, now: now) | ||
| 1319 | + ref_group(lang: lang, kind: "tags", heading: g::t(lang, K::TagsTitle), links: tags, now: now) | ||
| 1320 | + <p class="muted small ref-note" data-ref-empty="" hidden=(!none)> | ||
| 1321 | + (g::t(lang, if none { K::NothingHere } else { K::NoMatches })) | ||
| 1322 | + </p> | ||
| 1311 | </div> | 1323 | </div> |
| 1324 | + <div class="ref-foot"> | ||
| 1325 | + <span class="ref-keys" aria-hidden="true"><kbd>"↑"</kbd><kbd>"↓"</kbd><kbd>"↵"</kbd></span> | ||
| 1326 | + <a href=(branches_href) title=(g::t(lang, K::ViewAllBranches))>(g::t(lang, K::BranchesTitle))" ↗"</a> | ||
| 1327 | + <a href=(tags_href) title=(g::t(lang, K::ViewAllTags))>(g::t(lang, K::TagsTitle))" ↗"</a> | ||
| 1312 | </div> | 1328 | </div> |
| 1313 | - ref_panel(lang: lang, kind: "branches", links: branches, all_href: branches_href, all_label: g::t(lang, K::ViewAllBranches)) | ||
| 1314 | - ref_panel(lang: lang, kind: "tags", links: tags, all_href: tags_href, all_label: g::t(lang, K::ViewAllTags)) | ||
| 1315 | </div> | 1329 | </div> |
| 1316 | </details> | 1330 | </details> |
| 1317 | }) | 1331 | }) |
style/main.scssmodified+166 -91
| @@ -1164,148 +1164,229 @@ code { | |||
| 1164 | } | 1164 | } |
| 1165 | } | 1165 | } |
| 1166 | 1166 | ||
| 1167 | -// Branch switcher popover: filter and tabs on top, the entries below, scrolling inside. | 1167 | +// Branch switcher popover, laid out as a command palette: a borderless search row, one scrolling |
| 1168 | +// list with a Branches and a Tags section, and a footer with key hints and the full lists. | ||
| 1168 | .ref-menu { | 1169 | .ref-menu { |
| 1169 | position: absolute; | 1170 | position: absolute; |
| 1170 | left: 0; | 1171 | left: 0; |
| 1171 | top: calc(100% + 6px); | 1172 | top: calc(100% + 6px); |
| 1172 | z-index: 10; | 1173 | z-index: 10; |
| 1173 | - width: 300px; | 1174 | + width: 360px; |
| 1174 | max-width: calc(100vw - 32px); | 1175 | max-width: calc(100vw - 32px); |
| 1175 | - max-height: 60vh; | 1176 | + max-height: min(60vh, 480px); |
| 1176 | display: flex; | 1177 | display: flex; |
| 1177 | flex-direction: column; | 1178 | flex-direction: column; |
| 1179 | + overflow: hidden; | ||
| 1178 | background: var(--surface); | 1180 | background: var(--surface); |
| 1179 | border: 1px solid var(--border); | 1181 | border: 1px solid var(--border); |
| 1180 | border-radius: var(--radius-lg); | 1182 | border-radius: var(--radius-lg); |
| 1181 | - box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); | 1183 | + box-shadow: var(--shadow); |
| 1182 | -} | ||
| 1183 | 1184 | ||
| 1184 | -// The tabs row is the bottom edge of the top block: its underline sits on the divider. | 1185 | + kbd { |
| 1185 | -.ref-top { | 1186 | + min-width: 18px; |
| 1186 | - padding: 8px 8px 0; | 1187 | + padding: 0 5px; |
| 1187 | - border-bottom: 1px solid var(--border); | 1188 | + font-family: var(--mono); |
| 1189 | + font-size: 11px; | ||
| 1190 | + line-height: 18px; | ||
| 1191 | + text-align: center; | ||
| 1192 | + color: var(--muted); | ||
| 1193 | + background: var(--surface); | ||
| 1194 | + border: 1px solid var(--border-strong); | ||
| 1195 | + border-radius: var(--radius-sm); | ||
| 1196 | + } | ||
| 1188 | } | 1197 | } |
| 1189 | 1198 | ||
| 1190 | -.ref-filter { | 1199 | +// The search row is part of the menu, not a field inside it: no box, only the divider below. |
| 1191 | - width: 100%; | 1200 | +.ref-search { |
| 1192 | - height: var(--control-h); | 1201 | + flex: none; |
| 1193 | - box-sizing: border-box; | 1202 | + display: flex; |
| 1194 | - padding: 0 10px; | 1203 | + align-items: center; |
| 1195 | - font: inherit; | 1204 | + gap: 10px; |
| 1196 | - font-size: 14px; | 1205 | + padding: 0 12px; |
| 1197 | - color: var(--text); | 1206 | + color: var(--muted); |
| 1198 | - background: var(--surface-2); | 1207 | + border-bottom: 1px solid var(--border); |
| 1199 | - border: 1px solid var(--border); | ||
| 1200 | - border-radius: var(--radius-md); | ||
| 1201 | 1208 | ||
| 1202 | - &:focus, | 1209 | + &:focus-within { |
| 1203 | - &:focus-visible { | 1210 | + color: var(--accent); |
| 1204 | - outline: none; | ||
| 1205 | - border-color: var(--focus); | ||
| 1206 | - box-shadow: 0 0 0 3px var(--accent-soft); | ||
| 1207 | } | 1211 | } |
| 1208 | } | 1212 | } |
| 1209 | 1213 | ||
| 1210 | -// Underline tabs: the 2px underline overlaps the 1px divider of .ref-top. | 1214 | +.ref-filter { |
| 1211 | -.ref-tabs { | 1215 | + flex: 1 1 auto; |
| 1212 | - display: flex; | 1216 | + min-width: 0; |
| 1213 | - gap: 16px; | 1217 | + height: 46px; |
| 1214 | - margin: 8px 0 -1px; | 1218 | + padding: 0; |
| 1215 | - | ||
| 1216 | - button { | ||
| 1217 | - flex: 0 0 auto; | ||
| 1218 | - min-height: 32px; | ||
| 1219 | - padding: 0 2px; | ||
| 1220 | font: inherit; | 1219 | font: inherit; |
| 1221 | - font-size: 13px; | 1220 | + font-size: 15px; |
| 1222 | - color: var(--muted); | 1221 | + color: var(--text); |
| 1223 | background: transparent; | 1222 | background: transparent; |
| 1224 | border: 0; | 1223 | border: 0; |
| 1225 | - border-bottom: 2px solid transparent; | ||
| 1226 | - border-radius: 0; | ||
| 1227 | - cursor: pointer; | ||
| 1228 | 1224 | ||
| 1229 | - &:hover { | 1225 | + &::placeholder { |
| 1230 | - color: var(--text); | 1226 | + color: var(--muted); |
| 1231 | - } | ||
| 1232 | - | ||
| 1233 | - &[aria-selected="true"] { | ||
| 1234 | - color: var(--text); | ||
| 1235 | - font-weight: 600; | ||
| 1236 | - border-bottom-color: var(--accent); | ||
| 1237 | } | 1227 | } |
| 1238 | 1228 | ||
| 1229 | + &:focus, | ||
| 1239 | &:focus-visible { | 1230 | &:focus-visible { |
| 1240 | - outline: 2px solid var(--focus); | 1231 | + outline: none; |
| 1241 | - outline-offset: -2px; | ||
| 1242 | box-shadow: none; | 1232 | box-shadow: none; |
| 1243 | } | 1233 | } |
| 1244 | } | 1234 | } |
| 1245 | -} | ||
| 1246 | 1235 | ||
| 1247 | -.ref-panel { | 1236 | +.ref-results { |
| 1248 | min-height: 0; | 1237 | min-height: 0; |
| 1249 | overflow-y: auto; | 1238 | overflow-y: auto; |
| 1250 | - padding: 4px 0; | 1239 | + padding: 6px; |
| 1251 | } | 1240 | } |
| 1252 | 1241 | ||
| 1253 | -.ref-note { | 1242 | +.ref-group + .ref-group { |
| 1254 | - margin: 8px 14px; | 1243 | + margin-top: 6px; |
| 1244 | + padding-top: 6px; | ||
| 1245 | + border-top: 1px dashed var(--border); | ||
| 1255 | } | 1246 | } |
| 1256 | 1247 | ||
| 1257 | -.ref-all { | 1248 | +.ref-head { |
| 1258 | - display: block; | 1249 | + display: flex; |
| 1259 | - margin-top: 4px; | 1250 | + align-items: center; |
| 1260 | - padding: 8px 14px; | 1251 | + gap: 6px; |
| 1261 | - font-size: 13px; | 1252 | + padding: 6px 8px 4px; |
| 1262 | - color: var(--text-2); | 1253 | + font-size: 11px; |
| 1263 | - text-decoration: none; | 1254 | + font-weight: 600; |
| 1264 | - border-top: 1px solid var(--border); | 1255 | + letter-spacing: 0.06em; |
| 1256 | + text-transform: uppercase; | ||
| 1257 | + color: var(--muted); | ||
| 1258 | +} | ||
| 1265 | 1259 | ||
| 1266 | - &:hover { | 1260 | +.ref-count { |
| 1267 | - color: var(--text); | 1261 | + padding: 0 6px; |
| 1262 | + font-family: var(--mono); | ||
| 1263 | + font-size: 10px; | ||
| 1264 | + letter-spacing: 0; | ||
| 1265 | + line-height: 16px; | ||
| 1268 | background: var(--surface-2); | 1266 | background: var(--surface-2); |
| 1267 | + border-radius: var(--radius-full); | ||
| 1269 | } | 1268 | } |
| 1269 | + | ||
| 1270 | +.ref-note { | ||
| 1271 | + margin: 10px 8px; | ||
| 1270 | } | 1272 | } |
| 1271 | 1273 | ||
| 1272 | -// Rows: a fixed 16px gutter holds the checkmark on the current ref, so names line up. | 1274 | +// Rows: kind icon, the name in mono, an optional default chip, and the tip's age pushed right. |
| 1275 | +// The selected row (keys or pointer) gets a soft fill; the current ref an accent rail and name. | ||
| 1273 | .ref-list { | 1276 | .ref-list { |
| 1274 | list-style: none; | 1277 | list-style: none; |
| 1275 | margin: 0; | 1278 | margin: 0; |
| 1276 | padding: 0; | 1279 | padding: 0; |
| 1277 | 1280 | ||
| 1278 | - li[aria-selected="true"] a, | ||
| 1279 | - a:hover { | ||
| 1280 | - background: var(--surface-2); | ||
| 1281 | - } | ||
| 1282 | - | ||
| 1283 | a { | 1281 | a { |
| 1282 | + position: relative; | ||
| 1284 | display: flex; | 1283 | display: flex; |
| 1285 | align-items: center; | 1284 | align-items: center; |
| 1286 | gap: 8px; | 1285 | gap: 8px; |
| 1287 | - padding: 6px 14px; | 1286 | + padding: 7px 8px 7px 10px; |
| 1288 | color: var(--text); | 1287 | color: var(--text); |
| 1289 | text-decoration: none; | 1288 | text-decoration: none; |
| 1289 | + border-radius: var(--radius-md); | ||
| 1290 | + } | ||
| 1290 | 1291 | ||
| 1291 | - &.current { | 1292 | + li[aria-selected="true"] a { |
| 1293 | + background: var(--surface-2); | ||
| 1294 | + } | ||
| 1295 | + | ||
| 1296 | + li[aria-current="true"] a { | ||
| 1297 | + color: var(--accent); | ||
| 1298 | + background: var(--accent-soft); | ||
| 1299 | + | ||
| 1300 | + &::before { | ||
| 1301 | + content: ""; | ||
| 1302 | + position: absolute; | ||
| 1303 | + left: 0; | ||
| 1304 | + top: 7px; | ||
| 1305 | + bottom: 7px; | ||
| 1306 | + width: 3px; | ||
| 1307 | + background: var(--accent); | ||
| 1308 | + border-radius: var(--radius-full); | ||
| 1309 | + } | ||
| 1310 | + | ||
| 1311 | + .ref-text { | ||
| 1292 | font-weight: 600; | 1312 | font-weight: 600; |
| 1293 | } | 1313 | } |
| 1314 | + | ||
| 1315 | + .ref-kind { | ||
| 1316 | + color: inherit; | ||
| 1317 | + } | ||
| 1294 | } | 1318 | } |
| 1295 | 1319 | ||
| 1296 | - .ref-check { | 1320 | + .ref-kind { |
| 1297 | display: inline-flex; | 1321 | display: inline-flex; |
| 1298 | flex: none; | 1322 | flex: none; |
| 1299 | - width: 16px; | 1323 | + color: var(--muted); |
| 1300 | - height: 16px; | 1324 | + |
| 1325 | + svg { | ||
| 1326 | + width: 14px; | ||
| 1327 | + height: 14px; | ||
| 1328 | + } | ||
| 1301 | } | 1329 | } |
| 1302 | 1330 | ||
| 1303 | .ref-text { | 1331 | .ref-text { |
| 1304 | min-width: 0; | 1332 | min-width: 0; |
| 1333 | + font-family: var(--mono); | ||
| 1334 | + font-size: 13px; | ||
| 1305 | word-break: break-all; | 1335 | word-break: break-all; |
| 1336 | + | ||
| 1337 | + mark { | ||
| 1338 | + color: inherit; | ||
| 1339 | + background: var(--row-target); | ||
| 1340 | + border-radius: 2px; | ||
| 1341 | + } | ||
| 1342 | + } | ||
| 1343 | + | ||
| 1344 | + .ref-chip { | ||
| 1345 | + flex: none; | ||
| 1346 | + padding: 0 6px; | ||
| 1347 | + font-size: 11px; | ||
| 1348 | + line-height: 18px; | ||
| 1349 | + color: var(--text-2); | ||
| 1350 | + border: 1px solid var(--border-strong); | ||
| 1351 | + border-radius: var(--radius-full); | ||
| 1352 | + } | ||
| 1353 | + | ||
| 1354 | + .ref-age { | ||
| 1355 | + flex: none; | ||
| 1356 | + margin-left: auto; | ||
| 1357 | + padding-left: 8px; | ||
| 1358 | + font-size: 12px; | ||
| 1359 | + color: var(--muted); | ||
| 1360 | + white-space: nowrap; | ||
| 1306 | } | 1361 | } |
| 1307 | } | 1362 | } |
| 1308 | 1363 | ||
| 1364 | +.ref-foot { | ||
| 1365 | + flex: none; | ||
| 1366 | + display: flex; | ||
| 1367 | + align-items: center; | ||
| 1368 | + gap: 14px; | ||
| 1369 | + padding: 8px 12px; | ||
| 1370 | + font-size: 12px; | ||
| 1371 | + background: var(--surface-2); | ||
| 1372 | + border-top: 1px solid var(--border); | ||
| 1373 | + | ||
| 1374 | + a { | ||
| 1375 | + color: var(--text-2); | ||
| 1376 | + text-decoration: none; | ||
| 1377 | + | ||
| 1378 | + &:hover { | ||
| 1379 | + color: var(--accent); | ||
| 1380 | + } | ||
| 1381 | + } | ||
| 1382 | +} | ||
| 1383 | + | ||
| 1384 | +.ref-keys { | ||
| 1385 | + display: inline-flex; | ||
| 1386 | + gap: 4px; | ||
| 1387 | + margin-right: auto; | ||
| 1388 | +} | ||
| 1389 | + | ||
| 1309 | .crumbs { | 1390 | .crumbs { |
| 1310 | min-width: 0; | 1391 | min-width: 0; |
| 1311 | font-size: 0.9375rem; | 1392 | font-size: 0.9375rem; |
| @@ -2040,29 +2121,23 @@ code { | |||
| 2040 | box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12), 0 0 0 100vmax rgba(0, 0, 0, 0.4); | 2121 | box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12), 0 0 0 100vmax rgba(0, 0, 0, 0.4); |
| 2041 | } | 2122 | } |
| 2042 | 2123 | ||
| 2043 | - .ref-top { | ||
| 2044 | - padding: 8px 16px 0; | ||
| 2045 | - } | ||
| 2046 | - | ||
| 2047 | - .ref-note { | ||
| 2048 | - margin: 8px 16px; | ||
| 2049 | - } | ||
| 2050 | - | ||
| 2051 | .ref-filter { | 2124 | .ref-filter { |
| 2052 | - height: 44px; | 2125 | + height: 52px; |
| 2053 | font-size: 16px; | 2126 | font-size: 16px; |
| 2054 | } | 2127 | } |
| 2055 | 2128 | ||
| 2056 | - .ref-tabs button { | 2129 | + .ref-list a { |
| 2057 | - min-height: 44px; | 2130 | + padding: 12px 10px 12px 12px; |
| 2058 | } | 2131 | } |
| 2059 | 2132 | ||
| 2060 | - .ref-list a { | 2133 | + // No keyboard on a phone: the footer keeps only the links. |
| 2061 | - padding: 12px 16px; | 2134 | + .ref-keys { |
| 2135 | + display: none; | ||
| 2062 | } | 2136 | } |
| 2063 | 2137 | ||
| 2064 | - .ref-all { | 2138 | + .ref-foot { |
| 2065 | - padding: 14px 16px; | 2139 | + justify-content: flex-end; |
| 2140 | + padding: 12px 16px; | ||
| 2066 | } | 2141 | } |
| 2067 | } | 2142 | } |
| 2068 | 2143 | ||