merge upstream
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<circle cx="9" cy="6" r="1.5" fill="#000000"/>
|
||||||
|
<circle cx="15" cy="6" r="1.5" fill="#000000"/>
|
||||||
|
<circle cx="9" cy="12" r="1.5" fill="#000000"/>
|
||||||
|
<circle cx="15" cy="12" r="1.5" fill="#000000"/>
|
||||||
|
<circle cx="9" cy="18" r="1.5" fill="#000000"/>
|
||||||
|
<circle cx="15" cy="18" r="1.5" fill="#000000"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 400 B |
@@ -1,5 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount, tick} from "svelte"
|
import {onMount, tick} from "svelte"
|
||||||
|
import {flip} from "svelte/animate"
|
||||||
|
import {cubicOut} from "svelte/easing"
|
||||||
import {derived as _derived} from "svelte/store"
|
import {derived as _derived} from "svelte/store"
|
||||||
import {dec, insertAt, removeAt, sleep} from "@welshman/lib"
|
import {dec, insertAt, removeAt, sleep} from "@welshman/lib"
|
||||||
import type {RelayProfile} from "@welshman/util"
|
import type {RelayProfile} from "@welshman/util"
|
||||||
@@ -7,6 +9,7 @@
|
|||||||
import {relays, createSearch} from "@welshman/app"
|
import {relays, createSearch} from "@welshman/app"
|
||||||
import {createScroller} from "@lib/html"
|
import {createScroller} from "@lib/html"
|
||||||
import {fly} from "@lib/transition"
|
import {fly} from "@lib/transition"
|
||||||
|
import DragHandle from "@assets/icons/drag-handle.svg?dataurl"
|
||||||
import Widget from "@assets/icons/widget-4.svg?dataurl"
|
import Widget from "@assets/icons/widget-4.svg?dataurl"
|
||||||
import AddCircle from "@assets/icons/add-circle.svg?dataurl"
|
import AddCircle from "@assets/icons/add-circle.svg?dataurl"
|
||||||
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
|
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
|
||||||
@@ -98,6 +101,8 @@
|
|||||||
const onDragStart = (e: DragEvent, url: string) => {
|
const onDragStart = (e: DragEvent, url: string) => {
|
||||||
draggedUrl = url
|
draggedUrl = url
|
||||||
dragStartOrder = [...orderedSpaceUrls]
|
dragStartOrder = [...orderedSpaceUrls]
|
||||||
|
lastDragTarget = undefined
|
||||||
|
didDrop = false
|
||||||
|
|
||||||
if (e.dataTransfer) {
|
if (e.dataTransfer) {
|
||||||
e.dataTransfer.effectAllowed = "move"
|
e.dataTransfer.effectAllowed = "move"
|
||||||
@@ -105,15 +110,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onDragOver = (e: DragEvent, targetUrl: string) => {
|
const onDragOver = (e: DragEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
const onDragEnter = (e: DragEvent, targetUrl: string) => {
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
if (lastDragTarget === targetUrl) return
|
||||||
|
|
||||||
|
lastDragTarget = targetUrl
|
||||||
reorderSpaceUrls(targetUrl)
|
reorderSpaceUrls(targetUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onDrop = (e: DragEvent, targetUrl: string) => {
|
const onDrop = (e: DragEvent, targetUrl: string) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
reorderSpaceUrls(targetUrl)
|
reorderSpaceUrls(targetUrl)
|
||||||
|
didDrop = true
|
||||||
draggedUrl = undefined
|
draggedUrl = undefined
|
||||||
|
lastDragTarget = undefined
|
||||||
|
|
||||||
if (dragStartOrder && !isSameOrder(dragStartOrder, orderedSpaceUrls)) {
|
if (dragStartOrder && !isSameOrder(dragStartOrder, orderedSpaceUrls)) {
|
||||||
void setSpaceMembershipOrder(orderedSpaceUrls).catch(console.error)
|
void setSpaceMembershipOrder(orderedSpaceUrls).catch(console.error)
|
||||||
@@ -123,8 +138,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onDragEnd = () => {
|
const onDragEnd = () => {
|
||||||
|
if (!didDrop && dragStartOrder && !isSameOrder(dragStartOrder, orderedSpaceUrls)) {
|
||||||
|
orderedSpaceUrls = dragStartOrder
|
||||||
|
}
|
||||||
|
|
||||||
draggedUrl = undefined
|
draggedUrl = undefined
|
||||||
dragStartOrder = undefined
|
dragStartOrder = undefined
|
||||||
|
lastDragTarget = undefined
|
||||||
|
didDrop = false
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
@@ -143,6 +164,8 @@
|
|||||||
let orderedSpaceUrls = $state<string[]>([])
|
let orderedSpaceUrls = $state<string[]>([])
|
||||||
let draggedUrl = $state<string | undefined>()
|
let draggedUrl = $state<string | undefined>()
|
||||||
let dragStartOrder = $state<string[] | undefined>()
|
let dragStartOrder = $state<string[] | undefined>()
|
||||||
|
let lastDragTarget = $state<string | undefined>()
|
||||||
|
let didDrop = $state(false)
|
||||||
|
|
||||||
const openSearch = () => {
|
const openSearch = () => {
|
||||||
showSearch = true
|
showSearch = true
|
||||||
@@ -247,17 +270,25 @@
|
|||||||
<Divider>Your spaces</Divider>
|
<Divider>Your spaces</Divider>
|
||||||
{#each filteredUserUrls as url (url)}
|
{#each filteredUserUrls as url (url)}
|
||||||
<div
|
<div
|
||||||
class:opacity-60={draggedUrl === url}
|
animate:flip={{duration: 300, easing: cubicOut}}
|
||||||
|
class="transition-opacity duration-200 {draggedUrl === url ? 'opacity-50' : ''}"
|
||||||
draggable="true"
|
draggable="true"
|
||||||
role="listitem"
|
role="listitem"
|
||||||
ondragstart={e => onDragStart(e, url)}
|
ondragstart={e => onDragStart(e, url)}
|
||||||
ondragover={e => onDragOver(e, url)}
|
ondragover={onDragOver}
|
||||||
|
ondragenter={e => onDragEnter(e, url)}
|
||||||
ondrop={e => onDrop(e, url)}
|
ondrop={e => onDrop(e, url)}
|
||||||
ondragend={onDragEnd}>
|
ondragend={onDragEnd}>
|
||||||
<Button
|
<Button
|
||||||
class="card2 bg-alt shadow-md transition-all hover:shadow-lg hover:dark:brightness-[1.1] w-full relative"
|
class="group card2 bg-alt shadow-md transition-all hover:shadow-lg hover:dark:brightness-[1.1] w-full relative min-w-0"
|
||||||
onclick={() => openSpace(url)}>
|
onclick={() => openSpace(url)}>
|
||||||
<RelaySummary hideFavorites {url} />
|
<div class="flex w-full items-start gap-2">
|
||||||
|
<div
|
||||||
|
class="mt-4 flex cursor-grab p-1 text-base-content/30 transition-colors group-hover:text-base-content/60">
|
||||||
|
<Icon icon={DragHandle} />
|
||||||
|
</div>
|
||||||
|
<RelaySummary hideFavorites {url} />
|
||||||
|
</div>
|
||||||
{#if $notifications.has(makeSpacePath(url))}
|
{#if $notifications.has(makeSpacePath(url))}
|
||||||
<div class="absolute right-3 top-3 h-2 w-2 rounded-full bg-primary"></div>
|
<div class="absolute right-3 top-3 h-2 w-2 rounded-full bg-primary"></div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user