<script lang="ts">
    import BannerTitleAlt from "$lib/banner-title-alt.svelte";
    import TableOfContents from "$lib/table-of-contents.svelte";
    import type { Project } from './projects';
    import { projects } from './projects';
    import LinkList from "$lib/link-list.svelte";
    import ContentSidebar from "$lib/content-sidebar.svelte";

    let getActiveProjects = function(projects: Project[], isActive: boolean): Project[] {
        var result: Project[] = [];
        projects.forEach(project => {
            if (project.isActive == isActive) {
                result.push(project);
            }
        });
        return result;
    }
</script>

<svelte:head>
    <title>Projects | denizk0461</title> 
</svelte:head>

<BannerTitleAlt
    title="My Disordered Projects"
    banner="/projects/banner.webp"
    bannerAlt="Closeup of the purple protagonist from Project N5"
    subtitle="Things I have worked on"
/>

<ContentSidebar>
    <TableOfContents slot="side-left" />

    <div slot="main">
        <h2 id="games">Games</h2>
        {#each projects as project}
            {#if project.type == "game"}
                {@render projectSummary({ project: project })}
            {/if}
        {/each}
        <h2 id="hardware">Hardware</h2>
        {#each projects as project}
            {#if project.type == "hardware"}
                {@render projectSummary({ project: project })}
            {/if}
        {/each}
        <h2 id="apps">Apps</h2>
        {#each projects as project}
            {#if project.type == "app"}
                {@render projectSummary({ project: project })}
            {/if}
        {/each}
        <h2 id="music">Music</h2>
        {#each projects as project}
            {#if project.type == "music"}
                {@render projectSummary({ project: project })}
            {/if}
        {/each}
    </div>
</ContentSidebar>

{#snippet projectSummary({
    project
}: {
    project: Project;
})}
    <div>
        <h3 id="{project.id}">{project.title}</h3>
        {#if project.subtitle}
        <p class="project-subtitle">» {project.subtitle}</p>
        {/if}
        {#if project.banner}
        <div class="project-banner-container">
            <img class="project-banner" src="{project.banner}" alt="Overview banner for {project.title}">
            {#if project.date}
            <p class="project-date project-date-embed">{project.date}</p>
            {/if}
        </div>
        {:else}
        {#if project.date}
        <p class="project-date">{project.date}</p>
        {/if}
        {/if}
        {#if project.icon}
        <img class="project-icon" src="{project.icon}" alt="Icon for {project.title}">
        {/if}
        {#each project.paragraphs as paragraph}
            <p>{@html paragraph}</p>
        {/each}
        <LinkList entries={project.links} />
    </div>
{/snippet}