web/src/components/EventImageGenerator.svelte

217 lines
6 KiB
Svelte
Raw Normal View History

2024-03-06 21:33:24 +01:00
<script>
import core from '../core.json';
import { dateFormat } from '../lib/events.js';
import { marked } from 'marked';
import { onMount } from 'svelte';
import { writable } from 'svelte/store';
import Square from './event-formats/square.svelte';
import WideSquare from './event-formats/wide-square.svelte';
import Wide from './event-formats/wide.svelte';
import SquareSpeaker from './event-formats/square-speaker.svelte';
import Poster from './event-formats/poster.svelte';
import PosterSimple from './event-formats/poster-simple.svelte';
const topics = [
'identity',
2024-03-06 23:11:20 +01:00
'network states',
'fullstack privacy',
2024-03-06 21:33:24 +01:00
'private messaging',
'r&d: ZK, MPC, THE',
'on-chain privacy',
'regulation vs. privacy',
'lunarpunk vs. solarpunk',
'human rights daos',
'privacy activism',
]
2024-03-07 14:39:18 +01:00
/*const events = {
2024-03-07 11:41:34 +01:00
s23prg: { image: 'summit01' },
2024-03-06 22:28:23 +01:00
m24buc: { image: 'bucharest01' },
2024-03-06 21:54:37 +01:00
m24ath: { image: 'athens01' },
m24ams: { image: 'amsterdam01' },
2024-03-06 21:58:07 +01:00
m24tll: { image: 'tallinn01' },
2024-03-06 21:54:37 +01:00
m24opo: { image: 'porto01' },
2024-03-06 22:28:23 +01:00
m24ber: { image: 'berlin02' },
2024-03-06 23:11:20 +01:00
s24prg: { image: 'summit02' },
2024-03-06 22:28:23 +01:00
m24lju: { image: 'ljubljana01' },
m24bcn: { image: 'barcelona01' },
m24cph: { image: 'copenhagen01' },
2024-03-06 21:54:37 +01:00
m24rom: { image: 'rome01' },
s24brn: { image: 'brno01' },
2024-03-07 14:39:18 +01:00
}*/
2024-03-06 21:33:24 +01:00
let searchParams = null
2024-03-06 21:54:37 +01:00
2024-03-06 21:33:24 +01:00
//let eventSelected = core.events[0].id;
const eventSelected = writable('');
const speakerSelected = writable('alona-shevchenko');
2024-03-07 12:31:03 +01:00
const imageSelected = writable('');
2024-03-06 21:33:24 +01:00
onMount(() => {
searchParams = new URL(document.location).searchParams;
const id = searchParams.get('id');
if (id) {
eventSelected.set(id);
}
const speaker = searchParams.get('speaker');
if (speaker) {
speakerSelected.set(speaker);
}
2024-03-07 12:31:03 +01:00
const img = searchParams.get('img');
if (img) {
imageSelected.set(img);
}
2024-03-06 21:33:24 +01:00
});
eventSelected.subscribe((id, next) => {
const event = core.events.find(e => e.id === id);
if (!event) {
return;
}
if (event.speakers?.length > 0) {
speakerSelected.set(event.speakers[0]);
}
2024-03-07 14:39:18 +01:00
if (event.design?.image) {
imageSelected.set(event.design.image);
}
2024-03-06 21:33:24 +01:00
return next
})
2024-03-07 14:39:18 +01:00
function getImageUrl(img) {
return `/gen-img/events/${img}.png`
2024-03-06 21:33:24 +01:00
}
2024-03-07 14:39:18 +01:00
$: image = $imageSelected ? getImageUrl($imageSelected) : '';
2024-03-06 21:33:24 +01:00
$: event = core.events.find(e => e.id === $eventSelected);
$: speaker = core.people.find(p => p.id === $speakerSelected);
const tools = {
dateFormat
}
2024-03-07 14:39:18 +01:00
let imagesSrc = import.meta.glob("../../public/gen-img/events/*.png");
const images = [];
for (const path in imagesSrc) {
const splitted = path.split('/')
images.push(splitted[splitted.length-1].split('.')[0])
}
2024-03-06 21:33:24 +01:00
</script>
<div class="w-full p-10">
<div>
<div>
Event:
<select bind:value={$eventSelected} class="text-black">
<option value="">---</option>
2024-03-07 14:39:18 +01:00
{#each core.events as e}
2024-03-06 21:33:24 +01:00
<option value={e.id}>[{e.id}] {e.type} {e.city} - {dateFormat(e.date)}</option>
{/each}
</select>
</div>
<!--div>
Image:
<select bind:value={imageSelected} class="text-black">
{#each Object.keys(images) as image}
<option value={image}>{image}</option>
{/each}
</select>
</div-->
</div>
</div>
{#if !$eventSelected}
2024-03-07 12:08:01 +01:00
<div class="w-full px-10">
2024-03-06 21:33:24 +01:00
Please select event.
2024-03-07 14:39:18 +01:00
<div class="mt-10 flex flex-wrap gap-4 mb-20">
{#each core.events as event}
<div>
<div class="mb-2 text-[#909090]">{event.id} [{event.design?.image || '-'}]</div>
<div class="w-[380px] h-[570px] relative">
<div class="scale-50 absolute -left-[172px] -top-[285px] bg-red-200 {!event.design?.image ? 'opacity-50' : ''}" style="margin-left: -1rem;">
<a href="/gen/event?id={event.id}"><PosterSimple {event} image={getImageUrl(event.design?.image)} {tools} /></a>
</div>
2024-03-06 21:33:24 +01:00
</div>
</div>
{/each}
</div>
</div>
{:else}
<div class="px-10 py-4">
2024-03-07 12:08:01 +01:00
<a href="/gen/event" class="underline hover:no-underline">Back to events overview</a>
2024-03-06 21:33:24 +01:00
</div>
2024-03-07 14:39:18 +01:00
<div class="px-10 py-4">
Image:
<select bind:value={$imageSelected} class="text-black">
<option value="">---</option>
{#each images as img}
<option value={img}>{img} {#if event.design?.image && event.design.image === img}[fixed]{/if}</option>
{/each}
</select>
</div>
2024-03-06 21:33:24 +01:00
<div class="w-full flex flex-wrap gap-10 p-10">
<div>
2024-03-07 11:23:15 +01:00
<div class="mb-4 text-xl text-[#909090]">Square (1:1)</div>
2024-03-06 21:33:24 +01:00
2024-03-07 11:23:15 +01:00
<div class="w-[404px]">
2024-03-06 21:33:24 +01:00
<Square {event} {image} {tools} />
</div>
</div>
<div>
2024-03-07 11:23:15 +01:00
<div class="mb-4 text-xl text-[#909090]">Wide-square (4:3)</div>
2024-03-06 21:33:24 +01:00
2024-03-07 11:23:15 +01:00
<div class="h-[404px]">
2024-03-06 21:33:24 +01:00
<WideSquare {event} {image} {tools} />
</div>
</div>
<div>
2024-03-07 11:23:15 +01:00
<div class="mb-4 text-xl text-[#909090]">Wide (16:9)</div>
2024-03-06 21:33:24 +01:00
2024-03-07 11:23:15 +01:00
<div class="h-[404px]">
<Wide {event} {image} {tools} />
</div>
2024-03-06 21:33:24 +01:00
</div>
<div>
2024-03-07 11:23:15 +01:00
<div class="mb-4 text-xl text-[#909090]">Square (speaker) (1:1)</div>
2024-03-06 21:33:24 +01:00
<div class="my-4">
Speaker:
<select bind:value={$speakerSelected} class="text-black">
{#if event.speakers}
{#each event.speakers as sp}
<option value={sp}>{sp}</option>
{/each}
{/if}
</select>
</div>
2024-03-07 11:23:15 +01:00
<div class="w-[404px]">
2024-03-06 21:33:24 +01:00
<SquareSpeaker {speaker} {event} {image} {tools} />
</div>
</div>
<div>
2024-03-07 11:23:15 +01:00
<div class="mb-4 text-xl text-[#909090]">Poster (3:2)</div>
2024-03-06 21:33:24 +01:00
2024-03-07 11:23:15 +01:00
<div class="w-[764px]">
2024-03-06 21:33:24 +01:00
<Poster {topics} {event} {image} {tools} />
</div>
</div>
<div>
2024-03-07 11:23:15 +01:00
<div class="mb-4 text-xl text-[#909090]">Poster (simple) (3:2)</div>
2024-03-06 21:33:24 +01:00
2024-03-07 11:23:15 +01:00
<div class="w-[764px]">
2024-03-06 21:33:24 +01:00
<PosterSimple {event} {image} {tools} />
</div>
</div>
</div>
{/if}