Skip to content

Commit

Permalink
Abstracted playground to an image gallery with resolver componentgit …
Browse files Browse the repository at this point in the history
…status!
  • Loading branch information
milkcee12 committed Feb 21, 2024
1 parent 19c25fd commit f13650b
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 96 deletions.
153 changes: 153 additions & 0 deletions src/lib/components/ImageGallery.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<script lang="ts">
import LazyImage from "./common/LazyImage.svelte";
import { openModal } from "svelte-modals";
import GalleryModal from "$lib/components/common/GalleryModal.svelte";
import ImageLoader from "$lib/components/common/ImageLoader.svelte";
import { loadImagesFromModule } from "$lib/util";
import { playgroundModules, PlaygroundModule } from "$lib/imageModules";
import data from "$lib/data/playground.yml";
export let module: PlaygroundModule;
let dataTyped: PlaygroundYaml[] = data.images;
interface PlaygroundYaml {
id: number;
title?: string;
desc: string;
date: number;
link?: string;
link_text?: string;
video?: boolean;
}
async function getImageMapFromModule(index: PlaygroundModule) {
let images = await loadImagesFromModule(playgroundModules[index]);
return images;
}
</script>

<div class="gallery">
{#await getImageMapFromModule(module)}
<ImageLoader />
{:then images}
{#each images as image}
{#if !image.filename.includes("-video")}
{@const id = parseInt(image.filename) - 1}
{@const title = dataTyped[id].title ?? "Untitled"}
{@const isVideo = dataTyped[id].video ?? false}
{@const imageData = Object.assign(image, dataTyped[id])}

{#if isVideo}
<div class="item">
<!-- svelte-ignore a11y-media-has-caption -->
<video poster={image.url} controls>
<source src={image.url.replace(".jpg", "-video.mp4")} type="video/mp4" />
</video>
</div>
{:else}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="item"
on:click={() => openModal(GalleryModal, { imageData: imageData })}>
<div class="hover-overlay" />
<p>{title}<br /><small><i>{imageData.date}</i></small></p>
<LazyImage src={image.url} alt={title} />
</div>
{/if}
{/if}
{/each}
{/await}
</div>

<style lang="scss">
.gallery {
display: flex;
flex: 1;
flex-wrap: wrap;
justify-content: flex-start;
width: 100%;
gap: 1em;
.item {
flex: 1 1 auto;
flex-grow: 1;
height: 19em;
box-sizing: border-box;
position: relative;
text-align: center;
transition: all 0.25s;
border-radius: 1em;
transition: opacity 0.5s;
video {
border-radius: 1em;
height: 100%;
max-width: 100%;
}
p {
color: $white;
margin-inline: 1em;
font-size: 1.2em;
max-width: 100%;
top: 0;
margin: auto;
position: absolute;
left: 0;
right: 0;
opacity: 0;
// animation: float-reverse 0.6s;
}
.hover-overlay {
position: absolute;
justify-self: flex-start;
width: 100%;
height: 100%;
background-color: none;
border-radius: 1em;
transition: all 0.5s ease-out;
}
&:hover {
cursor: pointer;
.hover-overlay {
background-color: rgba(9, 10, 13, 0.6);
}
p {
animation: float 0.7s forwards;
}
}
@keyframes float {
from {
top: 0%;
}
70% {
top: 52%;
}
to {
transform: translateY(-50%);
top: 50%;
opacity: 1;
}
}
@keyframes float-reverse {
from {
transform: translateY(-50%);
top: 50%;
opacity: 1;
}
30% {
top: 52%;
}
to {
top: 0%;
}
}
}
}
</style>
7 changes: 7 additions & 0 deletions src/lib/data/archive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# next_id: 2
- id: 1
title: Re:STORE
desc: Your toy shop is suddenly taken over by murderous teddy bears! Use your potions to restore them back to their normal state and save your store.
date: 2021
link: https://jteaaa.itch.io/re-store
link_text: Play the game
8 changes: 7 additions & 1 deletion src/lib/data/playground.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# next_id: 14
# next_id: 17
images:
- id: 1
title: Beneath the Fireflies
Expand Down Expand Up @@ -93,3 +93,9 @@ images:
An experiment where Rain is from fantasy world that combines western and eastern
visuals.
date: 2022
- id: 15
title: Cow's Room still
date: 2022
desc: Modeled, textured, and rendered in Maya.
- id: 16
video: true
11 changes: 11 additions & 0 deletions src/lib/imageModules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export enum PlaygroundModule {
FEATURED = 0,
FANART = 1,
ANIMATION_3D = 2,
}

export const playgroundModules = [
import.meta.glob("$lib/images/playground/featured/*"),
import.meta.glob("$lib/images/playground/fanart/*"),
import.meta.glob("$lib/images/playground/3d-animation/*"),
];
File renamed without changes.
6 changes: 4 additions & 2 deletions src/routes/(app)/archive/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<script lang="ts">
import Heading from "$lib/components/common/Heading.svelte";
</script>

<svelte:head>
<title>Archive | Milkcee Studios</title>
</svelte:head>

<Heading headingText="Archive" emoji="📷🗂️" hasLink={false}></Heading>
<p>Older and smaller projects for record-keeping.</p>
<p>
Older and smaller projects for record-keeping. Game jams, hackathons, and
other projects that didn't make the main page.
</p>
98 changes: 5 additions & 93 deletions src/routes/(app)/playground/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,12 @@
import GalleryModal from "$lib/components/common/GalleryModal.svelte";
import Heading from "$lib/components/common/Heading.svelte";
import LazyImage from "$lib/components/common/LazyImage.svelte";
import { loadImagesFromModule } from "$lib/util";
import ImageLoader from "$lib/components/common/ImageLoader.svelte";
import data from "$lib/data/playground.yml";
import { PlaygroundModule } from "$lib/imageModules";
import cowsRoomStill1 from "$lib/images/playground/cows_room_still1.jpg";
import cowsRoomPlaceholder from "$lib/images/playground/cows_room_placeholder.jpg";
import cowsRoomVideo from "$lib/images/playground/cows_room.mp4";
enum Module {
FEATURED = 0,
FANART = 1,
}
interface PlaygroundYaml {
id: number;
title?: string;
desc: string;
date: string;
link?: string;
link_text?: string;
}
let dataTyped: PlaygroundYaml[] = data.images;
const modules = [
import.meta.glob("$lib/images/playground/featured/*"),
import.meta.glob("$lib/images/playground/fanart/*"),
];
async function getImageMapFromModule(index: Module) {
let images = await loadImagesFromModule(modules[index]);
return images;
}
import ImageGallery from "$lib/components/ImageGallery.svelte";
</script>

<svelte:head>
Expand Down Expand Up @@ -63,81 +37,19 @@
<section id="featured">
<Heading headingText="Originals" emoji="🎈" hasLink={false} />
<p>Visions from the worlds inside my head.</p>
<div class="gallery">
{#await getImageMapFromModule(Module.FEATURED)}
<ImageLoader />
{:then images}
{#each images as image}
{@const id = parseInt(image.filename) - 1}
{@const title = dataTyped[id].title ?? "Untitled"}
{@const imageData = Object.assign(image, dataTyped[id])}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="item"
on:click={() => openModal(GalleryModal, { imageData: imageData })}>
<div class="hover-overlay" />
<p>{title}<br /><small><i>{imageData.date}</i></small></p>
<LazyImage src={image.url} alt={title} />
</div>
{/each}
{/await}
</div>
<ImageGallery module={PlaygroundModule.FEATURED} />
</section>

<section id="fanart">
<Heading headingText="Fanart" emoji="📸" hasLink={false} />
<p>Paying homage to some of my favorite works by other artists.</p>
<div class="gallery">
{#await getImageMapFromModule(Module.FANART)}
<ImageLoader />
{:then images}
{#each images as image}
{@const id = parseInt(image.filename) - 1}
{@const title = dataTyped[id].title ?? "Untitled"}
{@const imageData = Object.assign(image, dataTyped[id])}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="item"
on:click={() => openModal(GalleryModal, { imageData: imageData })}>
<div class="hover-overlay" />
<p>{title}<br /><small><i>{imageData.date}</i></small></p>
<LazyImage src={image.url} alt={title} />
</div>
{/each}
{/await}
</div>
<ImageGallery module={PlaygroundModule.FANART} />
</section>

<section id="animation-3d">
<Heading headingText="3-D Animation" emoji="📚" hasLink={false} />
<p>Some work produced from my 3-D Animation minor at USC.</p>
<div class="gallery">
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="item"
on:click={() =>
openModal(GalleryModal, {
imageData: {
url: cowsRoomStill1,
title: "Cow's Room still",
date: "2022",
desc: "Modeled, textured, and rendered in Maya.",
},
})}>
<div class="hover-overlay" />
<p>Cow's Room still<small><br><i>2022</i></small></p>
<LazyImage src={cowsRoomStill1} alt="Cow's Room still" />
</div>
<div class="item">
<!-- svelte-ignore a11y-media-has-caption -->
<video poster={cowsRoomPlaceholder} controls>
<source src={cowsRoomVideo} type="video/mp4" />
</video>
</div>
</div>
<ImageGallery module={PlaygroundModule.ANIMATION_3D} />
</section>

<style lang="scss">
Expand Down

0 comments on commit f13650b

Please sign in to comment.