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
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 }
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
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 }
89110 .grab {
90111 cursor : grab ;
91112 }
92- </style >
113+
114+ .pointer {
115+ cursor : pointer ;
116+ }
117+ </style >
0 commit comments