Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 2ff58ca

Browse files
committed
feat: touch screen UX alternative for reordering home sections
1 parent c9617a1 commit 2ff58ca

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

common/views/Settings/HomeSectionsSettings.svelte

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script>
22
import { click } from '@/modules/click.js'
33
import { sections } from '@/modules/sections.js'
4+
import { SUPPORTS } from '@/modules/support.js';
45
56
const allowedHomeSections = sections.map(({ title }) => title)
67
export let homeSections
@@ -20,6 +21,15 @@
2021
draggingItemIndex = hoveredItemIndex
2122
}
2223
}
24+
25+
function moveItem(index, direction) {
26+
if (direction === 'up' && index > 0) {
27+
[homeSections[index], homeSections[index - 1]] = [homeSections[index - 1], homeSections[index]];
28+
} else if (direction === 'down' && index < homeSections.length - 1) {
29+
[homeSections[index], homeSections[index + 1]] = [homeSections[index + 1], homeSections[index]];
30+
}
31+
homeSections = homeSections; // Trigger reactivity
32+
}
2333
</script>
2434

2535
{#if mouseYCoordinate}
@@ -45,7 +55,7 @@
4555
class:tp={draggingItem === item}
4656
draggable='true'
4757
role='menuitem'
48-
tabindex='0'
58+
tabindex='-1'
4959
on:dragstart={({ clientY, target }) => {
5060
mouseYCoordinate = clientY
5161
draggingItem = item
@@ -59,10 +69,21 @@
5969
draggingItem = null
6070
hoveredItemIndex = null
6171
}}>
62-
<div class='input-group-prepend grab'>
63-
<span class='input-group-text d-flex justify-content-center px-5 material-symbols-outlined font-size-20'>swap_vert</span>
64-
</div>
65-
<select class='form-control bg-dark w-300 mw-full' bind:value={homeSections[index]}>
72+
{#if !SUPPORTS.isAndroid}
73+
<div class='input-group-prepend grab'>
74+
<span class='input-group-text d-flex justify-content-center px-5 material-symbols-outlined font-size-20'>swap_vert</span>
75+
</div>
76+
{:else}
77+
<div class='input-group-prepend'>
78+
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
79+
<!-- svelte-ignore a11y-click-events-have-key-events -->
80+
<button on:click={() => moveItem(index, 'up')} class='input-group-text d-flex justify-content-center px-5 material-symbols-outlined font-size-20 pointer'>arrow_upward</button>
81+
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
82+
<!-- svelte-ignore a11y-click-events-have-key-events -->
83+
<button on:click={() => moveItem(index, 'down')} class='input-group-text d-flex justify-content-center px-5 material-symbols-outlined font-size-20 pointer'>arrow_downward</button>
84+
</div>
85+
{/if}
86+
<select class='form-control bg-dark w-400 mw-full' bind:value={homeSections[index]}>
6687
{#each allowedHomeSections as section}
6788
<option>{section}</option>
6889
{/each}
@@ -89,4 +110,8 @@
89110
.grab{
90111
cursor: grab;
91112
}
92-
</style>
113+
114+
.pointer {
115+
cursor: pointer;
116+
}
117+
</style>

0 commit comments

Comments
 (0)