feat: switch mode
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { TableMode, imageWidth, mode } from './store';
|
||||
|
||||
export let extraItems:
|
||||
| undefined
|
||||
| {
|
||||
@@ -7,6 +9,16 @@
|
||||
}[] = undefined;
|
||||
|
||||
export let sidebarItems: typeof extraItems = undefined;
|
||||
|
||||
let _imageWidth = 50;
|
||||
let _mode = TableMode.View;
|
||||
|
||||
mode.subscribe((v) => {
|
||||
_mode = v;
|
||||
});
|
||||
$: {
|
||||
imageWidth.set(_imageWidth);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="drawer absolute h-full w-full overflow-y-hidden">
|
||||
@@ -41,14 +53,38 @@
|
||||
<div class="flex-none">
|
||||
{#if extraItems}
|
||||
<ul class="menu menu-horizontal items-center">
|
||||
<slot name="extra" />
|
||||
<li>
|
||||
<div>
|
||||
<input
|
||||
type="range"
|
||||
min="30"
|
||||
max="300"
|
||||
bind:value={_imageWidth}
|
||||
class="range"
|
||||
/>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
{#each extraItems as item}
|
||||
<li>
|
||||
<a on:click={item.onClick}>
|
||||
<button on:click={item.onClick}>
|
||||
{item.label}
|
||||
</a>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
<li>
|
||||
<button
|
||||
on:click={() => {
|
||||
if (_mode === TableMode.Score) {
|
||||
mode.set(TableMode.View);
|
||||
} else {
|
||||
mode.set(TableMode.Score);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{_mode === TableMode.Score ? 'Score' : 'View'}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -2,3 +2,9 @@ import { writable } from 'svelte/store';
|
||||
|
||||
export const imageWidth = writable(50);
|
||||
export const comfyUrl = writable('');
|
||||
|
||||
export enum TableMode {
|
||||
Score,
|
||||
View,
|
||||
}
|
||||
export const mode = writable(TableMode.View);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<tr>
|
||||
<!-- prompts -->
|
||||
<th style="max-width:30vw">{axis.value}</th>
|
||||
<th style="max-width:30vw" class="z-10">{axis.value}</th>
|
||||
{#each axis.children as dim2}
|
||||
{#if dim2.type === 'axis'}
|
||||
<td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { ImgResult } from './models';
|
||||
import { comfyUrl, imageWidth } from './store';
|
||||
import { TableMode, comfyUrl, imageWidth, mode } from './store';
|
||||
import { db, getScore, getUser, updateScore, type User } from '$lib/db';
|
||||
export let value: ImgResult;
|
||||
export let width = 100;
|
||||
@@ -8,14 +8,15 @@
|
||||
let api = '';
|
||||
comfyUrl.subscribe((d) => (api = d));
|
||||
|
||||
let hover = false;
|
||||
let like = false;
|
||||
let _mode = TableMode.View;
|
||||
imageWidth.subscribe((d) => {
|
||||
width = d;
|
||||
});
|
||||
|
||||
$: {
|
||||
if (hover)
|
||||
mode.subscribe((v) => {
|
||||
_mode = v;
|
||||
if (v === TableMode.Score)
|
||||
db.scoreboard
|
||||
.where('uuid')
|
||||
.equals(value.uuid)
|
||||
@@ -27,7 +28,7 @@
|
||||
like = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function updateSelfScore(score: number) {
|
||||
return updateScore(value.uuid, { score });
|
||||
@@ -91,29 +92,26 @@
|
||||
|
||||
<div class="px-0.5 box-border inline-block relative" style={`width:${width}px`}>
|
||||
<img
|
||||
on:mouseenter={() => (hover = true)}
|
||||
class="w-full"
|
||||
src={value.src}
|
||||
alt={value.uuid}
|
||||
style={`width:${width}px`}
|
||||
/>
|
||||
{#if hover}
|
||||
<div
|
||||
class="absolute h-full w-full top-0 left-0 my-img-mask text-white flex flex-col justify-center items-center cursor-default"
|
||||
role="button"
|
||||
{#if _mode === TableMode.Score}
|
||||
<button
|
||||
class="absolute h-full w-full top-0 left-0 my-img-mask text-white flex flex-col justify-center items-center"
|
||||
tabindex="0"
|
||||
on:mouseleave={() => (hover = false)}
|
||||
on:click={like ? onDislike : onLike}
|
||||
>
|
||||
<div class="flex justify-around btn-container">
|
||||
<button on:click={like ? onDislike : onLike}>
|
||||
<svg class="inline-block w-1/3" viewBox="0 0 1024 1024">
|
||||
<path
|
||||
d="M725.333333 192c-89.6 0-168.533333 44.8-213.333333 115.2C467.2 236.8 388.266667 192 298.666667 192 157.866667 192 42.666667 307.2 42.666667 448c0 253.866667 469.333333 512 469.333333 512s469.333333-256 469.333333-512c0-140.8-115.2-256-256-256z"
|
||||
fill={like ? '#F44336' : 'grey'}
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<svg class="inline-block w-1/3" viewBox="0 0 1024 1024">
|
||||
<path
|
||||
d="M725.333333 192c-89.6 0-168.533333 44.8-213.333333 115.2C467.2 236.8 388.266667 192 298.666667 192 157.866667 192 42.666667 307.2 42.666667 448c0 253.866667 469.333333 512 469.333333 512s469.333333-256 469.333333-512c0-140.8-115.2-256-256-256z"
|
||||
fill={like ? '#F44336' : 'grey'}
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -124,7 +122,7 @@
|
||||
background: rgba(0, 0, 0, 0);
|
||||
}
|
||||
100% {
|
||||
backdrop-filter: blur(5px);
|
||||
backdrop-filter: blur(2px);
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import MultiDimTableLayout from '$lib/multi-dim-table/layout.svelte';
|
||||
import AnalyzeTable from '$lib/multi-dim-table/table.svelte';
|
||||
import { comfyUrl, imageWidth } from '$lib/multi-dim-table/store';
|
||||
import { comfyUrl } from '$lib/multi-dim-table/store';
|
||||
import InfoIcon from '$lib/icons/info.svelte';
|
||||
import { db, getUser } from '$lib/db';
|
||||
import { v1 as uuid } from 'uuid';
|
||||
@@ -50,12 +50,6 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let _imageWidth = 50;
|
||||
|
||||
$: {
|
||||
imageWidth.set(_imageWidth);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if typeof data.path === 'string' && data.path.length > 0}
|
||||
@@ -87,17 +81,6 @@
|
||||
<InfoIcon />
|
||||
</div>
|
||||
</div>
|
||||
<li slot="extra">
|
||||
<div>
|
||||
<input
|
||||
type="range"
|
||||
min="30"
|
||||
max="300"
|
||||
bind:value={_imageWidth}
|
||||
class="range"
|
||||
/>
|
||||
</div>
|
||||
</li>
|
||||
<div class="w-full h-full" bind:this={tableContainerRef}>
|
||||
<AnalyzeTable {payload} height={tableContainerRef?.clientHeight ?? 0} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user