Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion lxl-web/src/lib/components/Draggable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
side: 'left' | 'right';
minWidth?: number;
maxWidth?: number;
step?: number;
isDragging?: boolean;
disabled?: boolean;
collapseWidth?: number;
Expand All @@ -25,6 +26,7 @@
isDragging = $bindable(false),
minWidth = 200,
maxWidth = 400,
step = 20,
collapseWidth,
side = 'right',
disabled = false,
Expand Down Expand Up @@ -80,6 +82,51 @@
document.addEventListener('pointerup', onPointerUp, { once: true });
}

// https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/slider_role#keyboard_interactions
function handleKeyDown(e: KeyboardEvent) {
e.preventDefault();
isDragging = true;

switch (e.key) {
case 'ArrowRight':
case 'ArrowUp':
stepUp(step);
break;
case 'ArrowLeft':
case 'ArrowDown':
stepDown(step);
break;
case 'PageUp':
stepUp(step * 2);
break;
case 'PageDown':
stepDown(step * 2);
break;
case 'Home':
width = minWidth;
break;
case 'End':
width = maxWidth;
break;
}

function stepUp(s: number) {
if (width + s < maxWidth) {
width = width + s;
} else {
width = maxWidth;
}
}

function stepDown(s: number) {
if (width - s > minWidth) {
width = width - s;
} else {
width = minWidth;
}
}
}

function onPointerUp() {
document.removeEventListener('pointermove', throttledOnPointerMove);
isDragging = false;
Expand All @@ -97,6 +144,7 @@
});
</script>

<!-- role 'slider' vs 'separator' discussion -->
<!-- https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/ -->
<!-- https://github.com/w3c/aria-practices/issues/130#issuecomment-2301520761 -->
<div
Expand All @@ -108,14 +156,16 @@
]}
aria-disabled={disabled}
tabindex="0"
aria-label={page.data.t('panes.resizeMe')}
aria-label={page.data.t('panes.resizablePane')}
role="slider"
aria-valuenow={width}
aria-valuemin={minWidth}
aria-valuemax={maxWidth}
aria-orientation="vertical"
aria-controls={parentId}
onpointerdown={handlePointerDown}
onkeydown={handleKeyDown}
onkeyup={() => (isDragging = false)}
></div>

<style lang="postcss">
Expand Down
2 changes: 1 addition & 1 deletion lxl-web/src/lib/components/find/FacetValue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<a
class={[
`focusable flex min-h-8 items-center text-sm no-underline`,
`focusable truncate flex min-h-8 items-center text-sm no-underline`,
data.selected && 'selected',
variant === 'checkbox' && 'with-checkbox',
variant === 'radio' && 'with-radio',
Expand Down
2 changes: 1 addition & 1 deletion lxl-web/src/lib/i18n/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export default {
show: 'Show pane',
hide: 'Hide pane',
trailingPane: 'Trailing pane',
resizeMe: 'Drag to resize pane'
resizablePane: 'Resizable pane'
},
citations: {
cite: 'Cite',
Expand Down
2 changes: 1 addition & 1 deletion lxl-web/src/lib/i18n/locales/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export default {
show: 'Visa sidopanel',
hide: 'Dölj sidopanel',
trailingPane: 'Högerpanel',
resizeMe: 'Dra för att ändra panelens storlek'
resizablePane: 'Ändra storlek på panel'
},
citations: {
cite: 'Referera',
Expand Down
Loading