<script lang="ts">
    import BannerTitleAlt from "$lib/banner-title-alt.svelte";
    import TableOfContents from "$lib/table-of-contents.svelte";
    import Content from "$lib/content.svelte";
    import type { Project } from './projects';
    import { projects } from './projects';
    import LinkList from "$lib/link-list.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"
    subtitle="Here's a collection of my more noteworthy projects that can be found on the web in some way: projects in programming, 3D modelling, and music production."
/>

<Content>
    <TableOfContents />

    <h2>Active Projects</h2>
    {#each getActiveProjects(projects, true) as activeProject}
        {@render projectSummary({ project: activeProject })}
    {/each}

    <h2>Past Projects</h2>
    {#each getActiveProjects(projects, false) as pastProject}
        {@render projectSummary({ project: pastProject })}
    {/each}
</Content>

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

<style>
    .subtitle {
        color: var(--color-highlight);
        font-weight: 700;
        font-style: italic;
        margin-top: 0;
    }
    
    .banner {
        width: 80%;
        margin-left: auto;
        margin-right: auto;
        display: flex;
    }

    .icon {
        float: left;
        margin: 16px 16px 16px 0;
        width: 20%;
    }
</style>