Branch picker uses underline tabs, a checkmark on the current ref and a neutral row highlight
Browse files at this commitaec2066d3b32f94955906abbb0fc52dd2cac47c9Parent: 334cead- style
- branch picker uses underline tabs, a checkmark on the current ref and a neutral row highlight
2 changed files +83 -19
- crates/forge-web/src/views/mod.rs +18 -5
- style/main.scss +65 -14
crates/forge-web/src/views/mod.rsmodified+18 -5
| @@ -1254,9 +1254,15 @@ async fn ref_panel( | |||
| 1254 | for (n, link) in links.into_iter().enumerate() { | 1254 | 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(""))> | 1255 | <li role="option" id=(format!("ref-{kind}-{n}")) data-ref-item="" hidden=((n >= REF_SHOWN).then_some(""))> |
| 1256 | if link.current { | 1256 | if link.current { |
| 1257 | - <a class="current" aria-current="true" href=(link.href)>(link.name)</a> | 1257 | + <a class="current" aria-current="true" href=(link.href)> |
| 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> | ||
| 1258 | } else { | 1261 | } else { |
| 1259 | - <a href=(link.href)>(link.name)</a> | 1262 | + <a href=(link.href)> |
| 1263 | + <span class="ref-check" aria-hidden="true"></span> | ||
| 1264 | + <span class="ref-text">(link.name)</span> | ||
| 1265 | + </a> | ||
| 1260 | } | 1266 | } |
| 1261 | </li> | 1267 | </li> |
| 1262 | } | 1268 | } |
| @@ -1281,11 +1287,18 @@ pub async fn ref_selector( | |||
| 1281 | branches_href: String, | 1287 | branches_href: String, |
| 1282 | tags_href: String, | 1288 | tags_href: String, |
| 1283 | ) -> Result<impl View> { | 1289 | ) -> Result<impl View> { |
| 1290 | + // 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); | ||
| 1284 | Ok(view! { | 1292 | Ok(view! { |
| 1285 | <details class="ref-select" data-ref-switch=""> | 1293 | <details class="ref-select" data-ref-switch=""> |
| 1286 | - <summary> | 1294 | + <summary title=(label) aria-label=(format!("{label}: {current}"))> |
| 1287 | - <span class="muted small">(label)</span> | 1295 | + if is_tag { |
| 1288 | - <code>(current.as_str())</code> | 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> | ||
| 1301 | + <span class="ref-caret" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg></span> | ||
| 1289 | </summary> | 1302 | </summary> |
| 1290 | <div class="ref-menu"> | 1303 | <div class="ref-menu"> |
| 1291 | <div class="ref-top"> | 1304 | <div class="ref-top"> |
style/main.scssmodified+65 -14
| @@ -1137,6 +1137,30 @@ code { | |||
| 1137 | code { | 1137 | code { |
| 1138 | background: none; | 1138 | background: none; |
| 1139 | padding: 0; | 1139 | padding: 0; |
| 1140 | + min-width: 0; | ||
| 1141 | + max-width: 220px; | ||
| 1142 | + overflow: hidden; | ||
| 1143 | + text-overflow: ellipsis; | ||
| 1144 | + white-space: nowrap; | ||
| 1145 | + } | ||
| 1146 | + | ||
| 1147 | + // Inline SVG icons: the trigger's branch or tag and caret, and the checkmark in the list. | ||
| 1148 | + svg { | ||
| 1149 | + flex: none; | ||
| 1150 | + width: 16px; | ||
| 1151 | + height: 16px; | ||
| 1152 | + fill: none; | ||
| 1153 | + stroke: currentColor; | ||
| 1154 | + stroke-width: 1.8; | ||
| 1155 | + stroke-linecap: round; | ||
| 1156 | + stroke-linejoin: round; | ||
| 1157 | + } | ||
| 1158 | + | ||
| 1159 | + .ref-icon, | ||
| 1160 | + .ref-caret { | ||
| 1161 | + display: inline-flex; | ||
| 1162 | + flex: none; | ||
| 1163 | + color: var(--muted); | ||
| 1140 | } | 1164 | } |
| 1141 | } | 1165 | } |
| 1142 | 1166 | ||
| @@ -1157,8 +1181,9 @@ code { | |||
| 1157 | box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); | 1181 | box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); |
| 1158 | } | 1182 | } |
| 1159 | 1183 | ||
| 1184 | +// The tabs row is the bottom edge of the top block: its underline sits on the divider. | ||
| 1160 | .ref-top { | 1185 | .ref-top { |
| 1161 | - padding: 8px; | 1186 | + padding: 8px 8px 0; |
| 1162 | border-bottom: 1px solid var(--border); | 1187 | border-bottom: 1px solid var(--border); |
| 1163 | } | 1188 | } |
| 1164 | 1189 | ||
| @@ -1182,32 +1207,38 @@ code { | |||
| 1182 | } | 1207 | } |
| 1183 | } | 1208 | } |
| 1184 | 1209 | ||
| 1210 | +// Underline tabs: the 2px underline overlaps the 1px divider of .ref-top. | ||
| 1185 | .ref-tabs { | 1211 | .ref-tabs { |
| 1186 | display: flex; | 1212 | display: flex; |
| 1187 | - gap: 4px; | 1213 | + gap: 16px; |
| 1188 | - margin-top: 8px; | 1214 | + margin: 8px 0 -1px; |
| 1189 | 1215 | ||
| 1190 | button { | 1216 | button { |
| 1191 | - flex: 1 1 0; | 1217 | + flex: 0 0 auto; |
| 1192 | min-height: 32px; | 1218 | min-height: 32px; |
| 1193 | - padding: 0 10px; | 1219 | + padding: 0 2px; |
| 1194 | font: inherit; | 1220 | font: inherit; |
| 1195 | font-size: 13px; | 1221 | font-size: 13px; |
| 1196 | color: var(--muted); | 1222 | color: var(--muted); |
| 1197 | - background: none; | 1223 | + background: transparent; |
| 1198 | border: 0; | 1224 | border: 0; |
| 1199 | - border-radius: var(--radius-md); | 1225 | + border-bottom: 2px solid transparent; |
| 1226 | + border-radius: 0; | ||
| 1200 | cursor: pointer; | 1227 | cursor: pointer; |
| 1201 | 1228 | ||
| 1229 | + &:hover { | ||
| 1230 | + color: var(--text); | ||
| 1231 | + } | ||
| 1232 | + | ||
| 1202 | &[aria-selected="true"] { | 1233 | &[aria-selected="true"] { |
| 1203 | color: var(--text); | 1234 | color: var(--text); |
| 1204 | - background: var(--accent-soft); | ||
| 1205 | font-weight: 600; | 1235 | font-weight: 600; |
| 1236 | + border-bottom-color: var(--accent); | ||
| 1206 | } | 1237 | } |
| 1207 | 1238 | ||
| 1208 | &:focus-visible { | 1239 | &:focus-visible { |
| 1209 | outline: 2px solid var(--focus); | 1240 | outline: 2px solid var(--focus); |
| 1210 | - outline-offset: 1px; | 1241 | + outline-offset: -2px; |
| 1211 | box-shadow: none; | 1242 | box-shadow: none; |
| 1212 | } | 1243 | } |
| 1213 | } | 1244 | } |
| @@ -1229,9 +1260,16 @@ code { | |||
| 1229 | padding: 8px 14px; | 1260 | padding: 8px 14px; |
| 1230 | font-size: 13px; | 1261 | font-size: 13px; |
| 1231 | color: var(--text-2); | 1262 | color: var(--text-2); |
| 1263 | + text-decoration: none; | ||
| 1232 | border-top: 1px solid var(--border); | 1264 | border-top: 1px solid var(--border); |
| 1265 | + | ||
| 1266 | + &:hover { | ||
| 1267 | + color: var(--text); | ||
| 1268 | + background: var(--surface-2); | ||
| 1269 | + } | ||
| 1233 | } | 1270 | } |
| 1234 | 1271 | ||
| 1272 | +// Rows: a fixed 16px gutter holds the checkmark on the current ref, so names line up. | ||
| 1235 | .ref-list { | 1273 | .ref-list { |
| 1236 | list-style: none; | 1274 | list-style: none; |
| 1237 | margin: 0; | 1275 | margin: 0; |
| @@ -1239,20 +1277,33 @@ code { | |||
| 1239 | 1277 | ||
| 1240 | li[aria-selected="true"] a, | 1278 | li[aria-selected="true"] a, |
| 1241 | a:hover { | 1279 | a:hover { |
| 1242 | - background: var(--accent-soft); | 1280 | + background: var(--surface-2); |
| 1243 | } | 1281 | } |
| 1244 | 1282 | ||
| 1245 | a { | 1283 | a { |
| 1246 | - display: block; | 1284 | + display: flex; |
| 1285 | + align-items: center; | ||
| 1286 | + gap: 8px; | ||
| 1247 | padding: 6px 14px; | 1287 | padding: 6px 14px; |
| 1248 | color: var(--text); | 1288 | color: var(--text); |
| 1249 | - word-break: break-all; | 1289 | + text-decoration: none; |
| 1250 | 1290 | ||
| 1251 | &.current { | 1291 | &.current { |
| 1252 | - color: var(--accent); | ||
| 1253 | font-weight: 600; | 1292 | font-weight: 600; |
| 1254 | } | 1293 | } |
| 1255 | } | 1294 | } |
| 1295 | + | ||
| 1296 | + .ref-check { | ||
| 1297 | + display: inline-flex; | ||
| 1298 | + flex: none; | ||
| 1299 | + width: 16px; | ||
| 1300 | + height: 16px; | ||
| 1301 | + } | ||
| 1302 | + | ||
| 1303 | + .ref-text { | ||
| 1304 | + min-width: 0; | ||
| 1305 | + word-break: break-all; | ||
| 1306 | + } | ||
| 1256 | } | 1307 | } |
| 1257 | 1308 | ||
| 1258 | .crumbs { | 1309 | .crumbs { |
| @@ -1990,7 +2041,7 @@ code { | |||
| 1990 | } | 2041 | } |
| 1991 | 2042 | ||
| 1992 | .ref-top { | 2043 | .ref-top { |
| 1993 | - padding: 8px 16px; | 2044 | + padding: 8px 16px 0; |
| 1994 | } | 2045 | } |
| 1995 | 2046 | ||
| 1996 | .ref-note { | 2047 | .ref-note { |