[feat] folder borders

This commit is contained in:
kwaroran
2023-07-22 20:45:27 +09:00
parent d5a057168d
commit 2e7619ec37
3 changed files with 39 additions and 19 deletions

View File

@@ -89,8 +89,8 @@
CharEmotion.set({}); CharEmotion.set({});
} }
type sortTypeNormal = { type:'normal',img: string; index: number; } type sortTypeNormal = { type:'normal',img: string, index: number, name:string }
type sortType = sortTypeNormal|{type:'folder',folder:sortTypeNormal[],id:string} type sortType = sortTypeNormal|{type:'folder',folder:sortTypeNormal[],id:string, name:string}
let charImages: sortType[] = []; let charImages: sortType[] = [];
let IconRounded = false let IconRounded = false
let openFolders:string[] = [] let openFolders:string[] = []
@@ -108,7 +108,8 @@
newCharImages.push({ newCharImages.push({
img:cha.image ?? "", img:cha.image ?? "",
index:index, index:index,
type: "normal" type: "normal",
name: cha.name
}); });
} }
} }
@@ -122,14 +123,16 @@
folderCharImages.push({ folderCharImages.push({
img:cha.image ?? "", img:cha.image ?? "",
index:index, index:index,
type: "normal" type: "normal",
name: cha.name
}); });
} }
} }
newCharImages.push({ newCharImages.push({
folder: folderCharImages, folder: folderCharImages,
type: "folder", type: "folder",
id: folder.id id: folder.id,
name: folder.name
}); });
} }
} }
@@ -313,12 +316,6 @@
return false return false
} }
const preventIfPolyfilled = (e:Event) => {
// e.preventDefault()
// e.stopPropagation()
// return false
}
onDestroy(unsub); onDestroy(unsub);
</script> </script>
@@ -387,7 +384,6 @@
on:dragover={avatarDragOver} on:dragover={avatarDragOver}
on:drop={(e) => {avatarDrop({index:ind}, e)}} on:drop={(e) => {avatarDrop({index:ind}, e)}}
on:dragenter={preventAll} on:dragenter={preventAll}
on:contextmenu={preventIfPolyfilled}
> >
<SidebarIndicator <SidebarIndicator
isActive={char.type === 'normal' && $selectedCharID === char.index && sideBarMode !== 1} isActive={char.type === 'normal' && $selectedCharID === char.index && sideBarMode !== 1}
@@ -409,9 +405,9 @@
tabindex="0" tabindex="0"
> >
{#if char.type === 'normal'} {#if char.type === 'normal'}
<SidebarAvatar src={char.img ? getCharImage(char.img, "plain") : "/none.webp"} size="56" rounded={IconRounded} /> <SidebarAvatar src={char.img ? getCharImage(char.img, "plain") : "/none.webp"} size="56" rounded={IconRounded} name={char.name} />
{:else if char.type === "folder"} {:else if char.type === "folder"}
<SidebarAvatar src="slot" size="56" rounded={IconRounded} onClick={() => { <SidebarAvatar src="slot" size="56" rounded={IconRounded} bordered name={char.name} onClick={() => {
if(char.type !== 'folder'){ if(char.type !== 'folder'){
return return
} }
@@ -433,8 +429,8 @@
</div> </div>
</div> </div>
{#if char.type === 'folder' && openFolders.includes(char.id)} {#if char.type === 'folder' && openFolders.includes(char.id)}
<div class="w-full flex flex-col items-center py-1 mt-1 rounded-lg relative"> <div class="p-1 flex flex-col items-center py-1 mt-1 rounded-lg relative">
<div class="absolute top-0 left-1 bg-darkbg w-full h-full rounded-lg z-0"></div> <div class="absolute top-0 left-1 bg-darkbg border border-selected w-full h-full rounded-lg z-0"></div>
<div class="h-4 min-h-4 w-14 relative z-10" on:dragover={(e) => { <div class="h-4 min-h-4 w-14 relative z-10" on:dragover={(e) => {
e.preventDefault() e.preventDefault()
e.dataTransfer.dropEffect = 'move' e.dataTransfer.dropEffect = 'move'
@@ -456,7 +452,6 @@
on:dragover={avatarDragOver} on:dragover={avatarDragOver}
on:drop={(e) => {if(char.type === 'folder'){avatarDrop({index: ind, folder:char.id}, e)}}} on:drop={(e) => {if(char.type === 'folder'){avatarDrop({index: ind, folder:char.id}, e)}}}
on:dragenter={preventAll} on:dragenter={preventAll}
on:contextmenu={preventIfPolyfilled}
> >
<SidebarIndicator <SidebarIndicator
isActive={$selectedCharID === char2.index && sideBarMode !== 1} isActive={$selectedCharID === char2.index && sideBarMode !== 1}
@@ -477,7 +472,7 @@
}} }}
tabindex="0" tabindex="0"
> >
<SidebarAvatar src={char2.img ? getCharImage(char2.img, "plain") : "/none.webp"} size="56" rounded={IconRounded} /> <SidebarAvatar src={char2.img ? getCharImage(char2.img, "plain") : "/none.webp"} size="56" rounded={IconRounded} name={char2.name}/>
</div> </div>
</div> </div>
<div class="h-4 min-h-4 w-14 relative z-20" on:dragover={(e) => { <div class="h-4 min-h-4 w-14 relative z-20" on:dragover={(e) => {

View File

@@ -1,12 +1,20 @@
<script lang="ts"> <script lang="ts">
import { tooltipRight } from "src/ts/gui/tooltip";
export let rounded:boolean export let rounded:boolean
export let src:string|Promise<string>; export let src:string|Promise<string>;
export let name:string
export let size = "22"; export let size = "22";
export let onClick = () => {} export let onClick = () => {}
export let bordered = false
</script> </script>
<!-- svelte-ignore a11y-click-events-have-key-events --> <!-- svelte-ignore a11y-click-events-have-key-events -->
<span class="flex shrink-0 items-center justify-center avatar" on:click={onClick}> <span class="flex shrink-0 items-center justify-center avatar"
class:border = {bordered}
class:border-selected={bordered}
class:rounded-md={bordered}
on:click={onClick} use:tooltipRight={name}>
{#if src} {#if src}
{#if src === "slot"} {#if src === "slot"}
<div <div

View File

@@ -1,11 +1,28 @@
import tippy from 'tippy.js' import tippy from 'tippy.js'
import 'tippy.js/dist/tippy.css'; import 'tippy.js/dist/tippy.css';
import 'tippy.js/themes/translucent.css';
export function tooltip(node:HTMLElement, tip:string) { export function tooltip(node:HTMLElement, tip:string) {
const instance = tippy(node, { const instance = tippy(node, {
content: tip, content: tip,
animation: 'fade', animation: 'fade',
arrow: true, arrow: true,
theme: 'translucent',
})
return {
destroy() {
instance.destroy()
}
};
}
export function tooltipRight(node:HTMLElement, tip:string) {
const instance = tippy(node, {
content: tip,
animation: 'fade',
arrow: true,
placement: 'right',
theme: 'translucent',
}) })
return { return {
destroy() { destroy() {