Update editor, themes, menus, backgrounds, and release tooling
This commit is contained in:
@@ -143,13 +143,13 @@
|
||||
max-width: min(280px, calc(100vw - 16px));
|
||||
white-space: pre-line;
|
||||
text-align: left;
|
||||
background: var(--rs-bg-active);
|
||||
background: var(--rs-tooltip-bg);
|
||||
border: 1px solid var(--rs-border);
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 16px #0005;
|
||||
color: var(--rs-text-strong);
|
||||
padding: 6px 10px;
|
||||
font: 12px/1.5 var(--rs-font-ui);
|
||||
border-radius: var(--rs-control-radius);
|
||||
box-shadow: var(--rs-tooltip-shadow);
|
||||
color: var(--rs-tooltip-text);
|
||||
padding: var(--rs-tooltip-padding);
|
||||
font: var(--rs-tooltip-font-size)/1.5 var(--rs-font-ui);
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -156,13 +156,13 @@
|
||||
position: absolute;
|
||||
top: calc(100% + 9px);
|
||||
right: 0;
|
||||
padding: 6px 10px;
|
||||
padding: var(--rs-tooltip-padding);
|
||||
border: 1px solid var(--rs-border);
|
||||
border-radius: 6px;
|
||||
background: var(--rs-bg-active);
|
||||
box-shadow: 0 4px 16px #0005;
|
||||
color: var(--rs-text-strong);
|
||||
font: 12px/1.5 var(--rs-font-ui);
|
||||
border-radius: var(--rs-control-radius);
|
||||
background: var(--rs-tooltip-bg);
|
||||
box-shadow: var(--rs-tooltip-shadow);
|
||||
color: var(--rs-tooltip-text);
|
||||
font: var(--rs-tooltip-font-size)/1.5 var(--rs-font-ui);
|
||||
white-space: nowrap;
|
||||
pointer-events: none;
|
||||
visibility: hidden;
|
||||
|
||||
@@ -66,6 +66,7 @@ export const actionIcons = {
|
||||
link: '<path d="m10 13 4-4M8 16l-2 2a4 4 0 0 1-6-6l5-5a4 4 0 0 1 6 0m2 1 2-2a4 4 0 0 1 6 6l-5 5a4 4 0 0 1-6 0" transform="translate(1 0)"/>',
|
||||
external: '<path d="M14 3h7v7M10 14 21 3M10 5H4v16h16v-7"/>',
|
||||
search: '<circle cx="10" cy="10" r="7"/><path d="m15 15 6 6"/>',
|
||||
filter: '<path d="M3 4h18l-7 8v7l-4 2v-9Z"/>',
|
||||
extract: '<path d="M11 4H4v16h16v-7M14 3h7v7M11 13 21 3"/><path d="M7 8h2M7 12h2M7 16h7"/>',
|
||||
select: '<path d="M8 3H3v5M16 3h5v5M21 16v5h-5M8 21H3v-5M3 11v2M21 11v2M11 3h2M11 21h2"/>',
|
||||
paragraph: '<path d="M13 21V3h-3a5 5 0 0 0 0 10h3M18 3v18M10 3h12"/>',
|
||||
|
||||
@@ -7,6 +7,14 @@ export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClos
|
||||
const opened: { button: HTMLButtonElement; panel: HTMLElement }[] = [];
|
||||
if (label.startsWith("Terminal")) root.style.width = "min(430px, calc(100vw - 16px))";
|
||||
const submenus = new Map<HTMLButtonElement, HTMLElement>();
|
||||
function focusRow(button?: HTMLButtonElement) {
|
||||
if (!button) return;
|
||||
button.focus({ preventScroll: true });
|
||||
const panel = button.parentElement!;
|
||||
const row = button.getBoundingClientRect(), bounds = panel.getBoundingClientRect();
|
||||
if (row.top < bounds.top) panel.scrollTop -= bounds.top - row.top;
|
||||
else if (row.bottom > bounds.bottom) panel.scrollTop += row.bottom - bounds.bottom;
|
||||
}
|
||||
function hideSubmenu(parent: HTMLElement = root) {
|
||||
const keep = parent === root ? 0 : opened.findIndex(entry => entry.panel === parent) + 1;
|
||||
for (const { button, panel } of opened.splice(keep)) { panel.hidden = true; button.setAttribute("aria-expanded", "false"); }
|
||||
@@ -20,7 +28,7 @@ export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClos
|
||||
if (!opened.some(entry => entry.panel === panel)) { hideSubmenu(button.parentElement!); opened.push({ button, panel }); }
|
||||
panel.hidden = false; button.setAttribute("aria-expanded", "true");
|
||||
positionSubmenu(button, panel);
|
||||
if (focus) panel.querySelector<HTMLButtonElement>("button:not(:disabled)")?.focus({ preventScroll: true });
|
||||
if (focus) focusRow(panel.querySelector<HTMLButtonElement>("button:not(:disabled)") ?? undefined);
|
||||
}
|
||||
function populate(panel: HTMLElement, entries: ActionMenuItem[]) {
|
||||
const hasIcons = entries.some(item => !("separator" in item) && (!!item.icon || (item.checked !== undefined && !item.radio)));
|
||||
@@ -64,17 +72,17 @@ export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClos
|
||||
const focused = document.activeElement as HTMLButtonElement, panel = focused.parentElement || root;
|
||||
const buttons = [...panel.querySelectorAll<HTMLButtonElement>(":scope > button:not(:disabled)")], index = buttons.indexOf(focused);
|
||||
if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
|
||||
event.preventDefault(); buttons[event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1 : (index + (event.key === "ArrowDown" ? 1 : -1) + buttons.length) % buttons.length]?.focus();
|
||||
event.preventDefault(); focusRow(buttons[event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1 : (index + (event.key === "ArrowDown" ? 1 : -1) + buttons.length) % buttons.length]);
|
||||
}
|
||||
if (event.key === "ArrowRight" && submenus.has(focused)) { event.preventDefault(); reveal(focused, submenus.get(focused)!, true); }
|
||||
const entry = opened.find(entry => entry.panel === panel);
|
||||
if (event.key === "ArrowLeft" && entry) { event.preventDefault(); hideSubmenu(entry.button.parentElement!); entry.button.focus(); }
|
||||
if (event.key === "ArrowLeft" && entry) { event.preventDefault(); hideSubmenu(entry.button.parentElement!); focusRow(entry.button); }
|
||||
});
|
||||
root.addEventListener("scroll", () => { for (const { button, panel } of opened) positionSubmenu(button, panel); }, true);
|
||||
parent.append(root);
|
||||
root.style.left = `${Math.max(8, Math.min(x, innerWidth - root.offsetWidth - 8))}px`;
|
||||
root.style.top = `${Math.max(8, Math.min(y, innerHeight - root.offsetHeight - 8))}px`;
|
||||
(root.querySelector<HTMLButtonElement>(':scope > button[role="menuitemradio"][aria-checked="true"]:not(:disabled)')
|
||||
?? root.querySelector<HTMLButtonElement>(":scope > button:not(:disabled)"))?.focus();
|
||||
?? root.querySelector<HTMLButtonElement>(":scope > button:not(:disabled)"))?.focus({ preventScroll: true });
|
||||
return root;
|
||||
}
|
||||
|
||||
+14
-9
@@ -1,5 +1,4 @@
|
||||
.rs-menu {
|
||||
position: fixed;
|
||||
.rs-menu, .rs-picker {
|
||||
z-index: 1000;
|
||||
width: var(--rs-menu-width);
|
||||
max-width: calc(100vw - 16px);
|
||||
@@ -8,15 +7,18 @@
|
||||
padding: var(--rs-menu-padding);
|
||||
border: 1px solid var(--rs-menu-border);
|
||||
border-radius: var(--rs-control-radius);
|
||||
background: var(--rs-bg-elevated);
|
||||
background: var(--rs-menu-bg);
|
||||
color: var(--rs-text);
|
||||
box-shadow: var(--rs-menu-shadow);
|
||||
font: var(--rs-menu-font-size)/1.4 var(--rs-font-ui);
|
||||
}
|
||||
|
||||
.rs-menu { position: fixed; }
|
||||
.rs-picker { box-sizing: border-box; }
|
||||
|
||||
.rs-menu.table-cell-submenu { z-index: 1001; }
|
||||
|
||||
.rs-menu > button {
|
||||
.rs-menu > button, .rs-picker .rs-picker-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--rs-menu-icon-gap);
|
||||
@@ -32,14 +34,17 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.rs-menu > button:disabled { opacity: .4; cursor: default; }
|
||||
.rs-menu > button[role="menuitemradio"][aria-checked="true"] { background: var(--rs-bg-active); }
|
||||
.rs-menu > button:disabled, .rs-picker .rs-picker-row:disabled { opacity: .4; cursor: default; }
|
||||
.rs-menu > button[role="menuitemradio"][aria-checked="true"] { background: var(--rs-menu-active-bg); }
|
||||
.rs-menu.rs-menu-text > button > .action-icon { display: none; }
|
||||
.rs-menu > button:not(:disabled):is(:hover, :focus-visible, [aria-expanded="true"]) {
|
||||
background: var(--rs-bg-active);
|
||||
.rs-menu > button:not(:disabled):is(:hover, :focus-visible, [aria-expanded="true"]),
|
||||
.rs-picker .rs-picker-row:not(:disabled):is(:hover, :focus-visible, :focus-within, [aria-selected="true"], [aria-current="true"]) {
|
||||
background: var(--rs-menu-active-bg);
|
||||
outline: none;
|
||||
}
|
||||
.rs-menu > hr { margin: 4px 0; border: 0; border-top: 1px solid var(--rs-border); }
|
||||
.rs-menu > button > .action-icon { width: var(--rs-menu-icon-size); height: var(--rs-menu-icon-size); flex: 0 0 var(--rs-menu-icon-size); }
|
||||
.rs-menu > button > .action-icon, .rs-picker-icon { width: var(--rs-menu-icon-size); height: var(--rs-menu-icon-size); flex: 0 0 var(--rs-menu-icon-size); }
|
||||
.rs-picker-hint { display: block; color: var(--rs-text-dim); font-size: var(--rs-settings-description-size); }
|
||||
.rs-picker-icon > svg { width: 100%; height: 100%; }
|
||||
.rs-menu > button > .action-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
||||
.rs-menu > button > .action-chevron { width: 13px; height: 13px; flex: 0 0 13px; }
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/** A single themed tooltip for DOM controls, with hover and keyboard dismissal. */
|
||||
export function attachTooltip(target: HTMLElement, label: () => string) {
|
||||
const tip = document.createElement('span');
|
||||
tip.className = 'rs-tooltip';
|
||||
tip.setAttribute('popover', 'manual');
|
||||
tip.setAttribute('role', 'tooltip');
|
||||
tip.id = `rs-tooltip-${crypto.randomUUID()}`;
|
||||
document.body.append(tip);
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
const previousDescription = target.getAttribute('aria-describedby');
|
||||
function hide() {
|
||||
clearTimeout(timer);
|
||||
if (tip.matches(':popover-open')) tip.hidePopover();
|
||||
if (previousDescription) target.setAttribute('aria-describedby', previousDescription);
|
||||
else target.removeAttribute('aria-describedby');
|
||||
}
|
||||
function show() {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
if (!target.isConnected || !label()) return;
|
||||
tip.textContent = label();
|
||||
tip.showPopover();
|
||||
const bounds = target.getBoundingClientRect(), size = tip.getBoundingClientRect();
|
||||
tip.style.left = `${Math.max(8, Math.min(bounds.left, innerWidth - size.width - 8))}px`;
|
||||
tip.style.top = `${Math.max(8, bounds.bottom + size.height + 8 > innerHeight ? bounds.top - size.height - 8 : bounds.bottom + 8)}px`;
|
||||
target.setAttribute('aria-describedby', [previousDescription, tip.id].filter(Boolean).join(' '));
|
||||
}, 300);
|
||||
}
|
||||
const escape = (event: KeyboardEvent) => { if (event.key === 'Escape') hide(); };
|
||||
target.addEventListener('mouseenter', show);
|
||||
target.addEventListener('mouseleave', hide);
|
||||
target.addEventListener('focusin', show);
|
||||
target.addEventListener('focusout', hide);
|
||||
target.addEventListener('pointerdown', hide);
|
||||
window.addEventListener('resize', hide);
|
||||
window.addEventListener('scroll', hide, true);
|
||||
window.addEventListener('keydown', escape);
|
||||
return () => {
|
||||
hide(); tip.remove();
|
||||
target.removeEventListener('mouseenter', show);
|
||||
target.removeEventListener('mouseleave', hide);
|
||||
target.removeEventListener('focusin', show);
|
||||
target.removeEventListener('focusout', hide);
|
||||
target.removeEventListener('pointerdown', hide);
|
||||
window.removeEventListener('resize', hide);
|
||||
window.removeEventListener('scroll', hide, true);
|
||||
window.removeEventListener('keydown', escape);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user