feat: fully implement variants

This commit is contained in:
Ax333l 2023-01-16 21:57:45 +01:00
parent cbf523a365
commit fce3fd2cb3
No known key found for this signature in database
GPG Key ID: D2B4D85271127D23
3 changed files with 16 additions and 11 deletions

View File

@ -1,7 +1,6 @@
<script lang="ts"> <script lang="ts">
import Modal from './Dialogue.svelte'; import Modal from './Dialogue.svelte';
import Variants from './Variants.svelte'; export let name = "";
export let name: string;
export let selected: Array<string>; export let selected: Array<string>;
export let variants; export let variants;
export let clicked = false; export let clicked = false;
@ -13,7 +12,7 @@
let current = variants[0]; let current = variants[0];
function select_logo(id) { function select_logo(id) {
// clicked = !clicked; clicked = !clicked;
if (selected.includes(id)) { if (selected.includes(id)) {
selected = selected.filter((e) => e !== id); selected = selected.filter((e) => e !== id);
} else { } else {
@ -34,13 +33,19 @@
</script> </script>
{#if has_variants}
<Modal bind:modalOpen> <Modal bind:modalOpen>
<svelte:fragment slot="title">{name}</svelte:fragment> <svelte:fragment slot="title">{name}</svelte:fragment>
<svelte:fragment slot="description"> <svelte:fragment slot="description">
guhhhhhhhhhhhhhhhhhhhhh guhhhhhhhhhhhhhhhhhhhhh
</svelte:fragment> </svelte:fragment>
<Variants /> {#each variants as variant}
<!-- Mega Trolley -->
<svelte:self bind:selected variants={[variant]} clicked={selected.includes(variant.id)}/>
{/each}
<!-- <Variants /> -->
</Modal> </Modal>
{/if}
<!-- SHUT UP --> <!-- SHUT UP -->
<!-- svelte-ignore a11y-no-noninteractive-tabindex --> <!-- svelte-ignore a11y-no-noninteractive-tabindex -->

View File

@ -1 +0,0 @@
<img src="https://cdn.discordapp.com/emojis/1063976228660457552.gif?size=48&quality=lossless" style="width: 20rem;" alt="h">

View File

@ -128,14 +128,15 @@ function calc_selected_logo_ids(v) {
if (submit) { if (submit) {
return; return;
} }
selected = [];
logos.forEach((v => {
selected[v.name] = [];
}))
} }
async function submitBallot() { async function submitBallot() {
// console.log(token);
throw Error("This shit needs to be redone now hhhhhhh");
const data = { const data = {
votes: logos.map((logo) => ({ cid: logo.id, vote: selected.includes(logo.id) })) votes: logo_ids.map((id) => ({ cid: id, vote: selected_logo_ids.includes(id) }))
}; };
console.log(data); console.log(data);
@ -197,7 +198,7 @@ function calc_selected_logo_ids(v) {
{#if selected[name].length != 0} {#if selected[name].length != 0}
<span in:fly={{ x: transitionDirection, easing: expoOut, duration: 1000 }}> <span in:fly={{ x: transitionDirection, easing: expoOut, duration: 1000 }}>
<LogoOption <LogoOption
bind:selected bind:selected={selected[name]}
clicked={selected[name].length != 0} clicked={selected[name].length != 0}
{variants} {variants}
{name} {name}
@ -208,7 +209,7 @@ function calc_selected_logo_ids(v) {
{/if} {/if}
</div> </div>
{#if finalPage && !selected.length} {#if finalPage && !selected_logo_ids.length}
<div class="warning" in:fly={{ x: transitionDirection, easing: expoOut, duration: 1000 }}> <div class="warning" in:fly={{ x: transitionDirection, easing: expoOut, duration: 1000 }}>
<h6>No logos have been selected.</h6> <h6>No logos have been selected.</h6>
</div> </div>