Skip to content

Commit 3dc57d5

Browse files
authored
Feat: external adds (#90)
* feat: add external ads feature with layout and page components * feat: enhance gallery functionality with store management and debug options * feat: refactor external ads and gallery components for improved structure and functionality - Added new layout and page components for external ads under (random-set) route. - Implemented logic to handle external ads, including random selection and error handling. - Refactored gallery components to align with new structure, including store management for current item. - Removed deprecated components and styles related to external ads and gallery. - Enhanced utility styles for better layout management. * feat: consolidate store management for external ads and gallery components * feat: update external ads and gallery components to use musical parameter in item parsing and storage functions * feat: improve code formatting and readability in layout and store management files * feat: update import statement for sharedStore to use namespace import
1 parent 7eaff12 commit 3dc57d5

File tree

15 files changed

+480
-58
lines changed

15 files changed

+480
-58
lines changed

src/_styles/util.pcss

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,44 @@ h6,
226226
hyphens: none;
227227
word-break: keep-all;
228228
}
229+
230+
.flow {
231+
--flow-gap: 1em;
232+
}
233+
234+
.flow--gap-0 {
235+
--flow-gap: 0;
236+
}
237+
238+
.flow--gap-xxs {
239+
--flow-gap: var(--fs-xxs);
240+
}
241+
242+
.flow--gap-xs {
243+
--flow-gap: var(--fs-xs);
244+
}
245+
246+
.flow--gap-s {
247+
--flow-gap: var(--fs-s);
248+
}
249+
250+
.flow--gap-m {
251+
--flow-gap: var(--fs-m);
252+
}
253+
254+
.flow--gap-l {
255+
--flow-gap: var(--fs-l);
256+
}
257+
258+
.flow--gap-xl {
259+
--flow-gap: var(--fs-xl);
260+
}
261+
262+
.flow > *:first-child {
263+
margin-top: 0;
264+
margin-bottom: 0;
265+
}
266+
.flow > * + * {
267+
margin-bottom: 0;
268+
margin-top: var(--flow-gap, 1em);
269+
}

src/lib/ShowData.d.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ type RolePersons = {
55
};
66

77
type SourceImage = {
8+
type: 'image';
89
source: Array<{ srcset: string; type?: string }>;
910
img: { src: string; srcset?: string; alt?: string; focus?: string };
1011
};
1112

13+
type SourceVideo = {
14+
type: 'video';
15+
source: Array<{ src: string; type: string }>;
16+
video: { poster?: string | null };
17+
};
18+
1219
type SingleShow = {
1320
isPublic: boolean;
1421
timestamp: string;
@@ -23,6 +30,7 @@ type SingleShow = {
2330

2431
type ShowData = {
2532
common: {
33+
showId: string;
2634
title: string;
2735
venue: {
2836
type: string;
@@ -35,19 +43,25 @@ type ShowData = {
3543
orchestra: RolePersons[];
3644
creativeTeam: (RolePersons & { lead: boolean })[];
3745
foh: RolePersons[];
38-
disclaimer: string?;
46+
disclaimer?: string;
3947
media: {
4048
image: SourceImage?;
4149
video: {
4250
source: Array<{ src: string; type: string }>;
4351
video: { poster: string | null };
4452
} | null;
4553
};
46-
gallery: Array<{
54+
gallery?: Array<{
55+
showId: string;
4756
title: string;
4857
subtitle?: string;
4958
year: string;
5059
images: SourceImage[];
60+
photographers?: string[];
61+
}>;
62+
externalAds?: Array<{
63+
company: string;
64+
media: SourceImage | SourceVideo;
5165
}>;
5266
};
5367
shows: SingleShow[];

src/routes/+page.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export const load: PageLoad = async ({ fetch }) => {
1818
return {
1919
productionsData
2020
};
21-
} catch {
21+
} catch (e) {
22+
console.error('Error fetching data from server:', e);
23+
2224
error(500, 'Failed to fetch data from server');
2325
}
2426
};

src/routes/[musical]/(heroimage)/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<li><a href="{params.musical}/crew">Crew</a></li>
1717
<li><a href="{params.musical}/disclaimer">Disclaimer</a></li>
1818
<li><a href="{params.musical}/gallery">Gallery</a></li>
19+
<li><a href="{params.musical}/external-ads">External Ads</a></li>
1920
</ul>
2021
</main>
2122

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
4+
const { children } = $props<{ children: Snippet }>();
5+
</script>
6+
7+
<main>
8+
{@render children()}
9+
</main>
10+
11+
<style>
12+
main {
13+
max-width: none;
14+
padding: var(--m);
15+
gap: var(--m);
16+
max-height: 100vh;
17+
height: calc(100vh - 2 * var(--m));
18+
overflow: hidden;
19+
display: grid;
20+
align-items: stretch;
21+
grid-template-columns: 1fr;
22+
grid-template-rows: 7fr 1fr;
23+
}
24+
</style>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { error } from '@sveltejs/kit';
2+
import type { LayoutLoad } from './$types';
3+
import sharedStore, { parseItemParam } from '../store.svelte';
4+
5+
export const load = (async ({ url, params, parent }) => {
6+
const { showData } = await parent();
7+
8+
if (showData.common.externalAds === undefined || showData.common.externalAds.length === 0) {
9+
error(404, 'No external ads found for ' + showData.common.title);
10+
}
11+
12+
const numItem = parseItemParam(
13+
url,
14+
params.musical,
15+
'external-ads',
16+
showData.common.externalAds.length
17+
);
18+
sharedStore.numItem.set(numItem);
19+
20+
return {};
21+
}) satisfies LayoutLoad;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<script lang="ts">
2+
import type { ShowData } from '$lib';
3+
import type { PageData } from './$types';
4+
import * as sharedStore from '../store.svelte';
5+
6+
const { data } = $props<{ data: PageData }>();
7+
const showData: ShowData = $derived(data.showData);
8+
9+
let currentNumItem = $state(0);
10+
sharedStore.numItem.subscribe((value) => {
11+
currentNumItem = value;
12+
});
13+
14+
const singleAd = $derived(showData.common.externalAds?.[currentNumItem]);
15+
</script>
16+
17+
{#if singleAd?.media.type === 'image'}
18+
<picture>
19+
{#each singleAd.media.source as source}
20+
<source srcset={source.srcset} type={source.type} />
21+
{/each}
22+
<img
23+
src={singleAd.media.img.src}
24+
alt={singleAd.media.img.alt}
25+
style="object-position: {singleAd.media.img.focus ?? '50% 50%'}"
26+
/>
27+
</picture>
28+
{:else if singleAd?.media.type === 'video'}
29+
<video autoplay loop muted playsinline poster={singleAd.media.video.poster ?? undefined}>
30+
{#each singleAd.media.source as source}
31+
<source src={source.src} type={source.type} />
32+
{/each}
33+
Your browser does not support the video tag.
34+
</video>
35+
{:else}
36+
<p>Kein gültiges Werbematerial gefunden.</p>
37+
{/if}
38+
39+
<header class="flow flow--gap-0 ta-center">
40+
{#if singleAd?.company}
41+
<p class="fs-xxs c-fg-3">Anzeige von</p>
42+
<h1 class=" typo-heading-2">{singleAd.company}</h1>
43+
{/if}
44+
</header>
45+
46+
<style lang="scss">
47+
header {
48+
align-self: center;
49+
justify-self: center;
50+
}
51+
52+
picture {
53+
display: block;
54+
align-self: stretch;
55+
justify-self: stretch;
56+
width: 100%;
57+
height: 100%;
58+
}
59+
60+
img {
61+
width: 100%;
62+
height: 100%;
63+
aspect-ratio: 1 / 1.414;
64+
object-fit: contain;
65+
}
66+
67+
video {
68+
width: 100%;
69+
height: 100%;
70+
object-fit: contain;
71+
}
72+
</style>
File renamed without changes.
File renamed without changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { error } from '@sveltejs/kit';
2+
import type { LayoutLoad } from './$types';
3+
import sharedStore, { parseItemParam } from '../store.svelte';
4+
5+
export const load = (async ({ url, params, parent }) => {
6+
const { showData } = await parent();
7+
8+
if (showData.common.gallery === undefined || showData.common.gallery.length === 0) {
9+
error(404, 'No gallery items found for ' + showData.common.title);
10+
}
11+
12+
const numItem = parseItemParam(url, params.musical, 'gallery', showData.common.gallery.length);
13+
sharedStore.numItem.set(numItem);
14+
15+
// Debug
16+
const debugParam = url.searchParams.get('debug');
17+
const debug = debugParam === 'true' || debugParam === '1' || debugParam !== null;
18+
19+
return {
20+
debug
21+
};
22+
}) satisfies LayoutLoad;

0 commit comments

Comments
 (0)