Update editor, workspace, Git services, appearance, and project guides
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy, tick } from "svelte";
|
||||
import { tick } from "svelte";
|
||||
import Icon from "./Icon.svelte";
|
||||
import type { IconName } from "./IconButton.svelte";
|
||||
|
||||
@@ -17,19 +17,13 @@
|
||||
let hovered = false;
|
||||
let keyboardFocus = false;
|
||||
let group: HTMLDivElement;
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
const expansionDelay = 1500;
|
||||
const selected = $derived(Math.max(0, options.findIndex(option => option.value === value)));
|
||||
|
||||
function scheduleExpansion() {
|
||||
clearTimeout(timer);
|
||||
if (!expanded && (hovered || keyboardFocus)) {
|
||||
timer = setTimeout(() => { expanded = true; }, expansionDelay);
|
||||
}
|
||||
if (hovered || keyboardFocus) expanded = true;
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
clearTimeout(timer);
|
||||
expanded = false;
|
||||
}
|
||||
|
||||
@@ -39,7 +33,6 @@
|
||||
}
|
||||
|
||||
async function choose(index: number) {
|
||||
// Cycling should leave a full pause before the targets start moving.
|
||||
scheduleExpansion();
|
||||
const hadFocus = group.contains(document.activeElement);
|
||||
onchange(options[index].value);
|
||||
@@ -50,7 +43,6 @@
|
||||
|
||||
function keydown(event: KeyboardEvent) {
|
||||
keyboardFocus = true;
|
||||
if (event.key === "Enter" || event.key === " ") clearTimeout(timer);
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
@@ -59,7 +51,6 @@
|
||||
group.querySelector<HTMLButtonElement>(`[data-value="${value}"]`)?.focus();
|
||||
} else if (["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) {
|
||||
event.preventDefault();
|
||||
clearTimeout(timer);
|
||||
expanded = true;
|
||||
const index = event.key === "Home" ? 0 : event.key === "End" ? options.length - 1
|
||||
: (selected + (event.key === "ArrowRight" ? 1 : -1) + options.length) % options.length;
|
||||
@@ -67,7 +58,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
onDestroy(() => clearTimeout(timer));
|
||||
</script>
|
||||
|
||||
<div
|
||||
@@ -107,7 +97,7 @@
|
||||
tabindex={expanded || option.value === value ? 0 : -1}
|
||||
onmouseenter={() => { tooltipDismissed = false; }}
|
||||
onfocus={() => { tooltipDismissed = false; }}
|
||||
onpointerdown={() => { keyboardFocus = false; clearTimeout(timer); }}
|
||||
onpointerdown={() => { keyboardFocus = false; }}
|
||||
onpointerup={scheduleExpansion}
|
||||
onpointercancel={scheduleExpansion}
|
||||
onkeydown={keydown}
|
||||
@@ -127,15 +117,14 @@
|
||||
flex: 0 0 auto;
|
||||
width: calc(var(--segment) * var(--count) + 6px);
|
||||
height: 34px;
|
||||
border: 1px solid var(--rs-border);
|
||||
border-radius: 8px;
|
||||
transition: width 180ms ease;
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--rs-control-radius);
|
||||
}
|
||||
.selection {
|
||||
position: absolute;
|
||||
inset: 2px auto 2px 2px;
|
||||
width: var(--segment);
|
||||
border-radius: 5px;
|
||||
border-radius: var(--rs-control-radius);
|
||||
background: var(--rs-bg-active);
|
||||
transform: translateX(calc(var(--selected) * var(--segment)));
|
||||
transition: transform 180ms ease;
|
||||
@@ -152,14 +141,14 @@
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 5px;
|
||||
border-radius: var(--rs-control-radius);
|
||||
background: transparent;
|
||||
color: var(--rs-text-dim);
|
||||
font-size: 12px;
|
||||
transform: translateX(calc(var(--index) * var(--segment)));
|
||||
transition: transform 180ms ease, opacity 120ms ease;
|
||||
transition: opacity 120ms ease;
|
||||
}
|
||||
button.current { color: var(--rs-accent); }
|
||||
button.current { color: var(--rs-text-strong); }
|
||||
button:hover { color: var(--rs-text-strong); }
|
||||
button.concealed { visibility: hidden; opacity: 0; pointer-events: none; }
|
||||
button:hover, button:focus-visible { z-index: 1; }
|
||||
|
||||
Reference in New Issue
Block a user