feat: Added dev-container

This commit is contained in:
2025-09-25 22:03:37 +01:00
parent a83022c46e
commit f71b054ae5
25 changed files with 822 additions and 803 deletions
+12 -12
View File
@@ -1,12 +1,12 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}
export {};
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}
export {};
+31 -31
View File
@@ -1,31 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="description"
content="Luke Else - Software Developer at Thales UK. I specialise in developing distributed systems in C++ using highly scalable internal frameworks. I also develop backend and system applications in my spare time using both Svelte, Rust and C++. Feel free to check my work out at https://git.luke-else.co.uk."
/>
<meta name="author" content="Luke Else (mail@luke-else.co.uk)" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/devicons/devicon@v2.15.1/devicon.min.css"
/>
<meta name="viewport" content="width=device-width" />
<script
async
src="https://tracking.luke-else.co.uk/tracker.js"
data-ackee-server="https://tracking.luke-else.co.uk"
data-ackee-domain-id="6c59ab88-dc6d-4d53-9831-0d6bff919dcd"
data-ackee-opts='{ "detailed": true }'
></script>
%sveltekit.head%
<style></style>
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="description"
content="Luke Else - Software Developer at Thales UK. I specialise in developing distributed systems in C++ using highly scalable internal frameworks. I also develop backend and system applications in my spare time using both Svelte, Rust and C++. Feel free to check my work out at https://git.luke-else.co.uk."
/>
<meta name="author" content="Luke Else (mail@luke-else.co.uk)" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/devicons/devicon@v2.15.1/devicon.min.css"
/>
<meta name="viewport" content="width=device-width" />
<script
async
src="https://tracking.luke-else.co.uk/tracker.js"
data-ackee-server="https://tracking.luke-else.co.uk"
data-ackee-domain-id="6c59ab88-dc6d-4d53-9831-0d6bff919dcd"
data-ackee-opts='{ "detailed": true }'
></script>
%sveltekit.head%
<style></style>
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
+66 -66
View File
@@ -1,67 +1,67 @@
import type { GitRepo } from "../types";
const API_BASE_URL = "https://git.luke-else.co.uk/api/v1";
export const IMAGE_URL_SUFFIX = "/raw/branch/main/assets/images/main.png";
export async function fetchRepos(): Promise<GitRepo[]> {
try {
console.log("Fetching repos...");
const response = await fetch(`${API_BASE_URL}/repos/search?sort=updated&order=desc&limit=12`, {
headers: {
// "Authorization": `token ${ACCESS_TOKEN}`,
"Content-Type": "application/json"
}
});
if (!response.ok) {
throw new Error(`Error: ${response.statusText}`);
}
const data: { data: GitRepo[] } = await response.json();
return data.data; // Extract the list of repositories
} catch (error) {
console.error("Failed to fetch repos:", error);
return [];
}
}
export function timeSince(inputDate: Date | string): string {
const date = new Date(inputDate); // Ensure it's a Date object
if (isNaN(date.getTime())) {
throw new Error("Invalid date provided");
}
const now: Date = new Date();
const diffInMs: number = now.getTime() - date.getTime();
const diffInSeconds: number = Math.floor(diffInMs / 1000);
const diffInMinutes: number = Math.floor(diffInSeconds / 60);
const diffInHours: number = Math.floor(diffInMinutes / 60);
const diffInDays: number = Math.floor(diffInHours / 24);
const diffInMonths: number = Math.floor(diffInDays / 30); // Approximate
const diffInYears: number = Math.floor(diffInDays / 365); // Approximate
if (diffInDays === 0) return "Today";
if (diffInDays === 1) return "Yesterday";
if (diffInDays < 7) return `${diffInDays} days ago`;
if (diffInDays < 30) return `${Math.floor(diffInDays / 7)} week${diffInDays >= 14 ? 's' : ''} ago`;
if (diffInMonths < 12) return `${diffInMonths} month${diffInMonths > 1 ? 's' : ''} ago`;
return `${diffInYears} year${diffInYears > 1 ? 's' : ''} ago`;
}
export async function checkImage(repo: GitRepo): Promise<boolean> {
try {
const URL = repo.html_url + IMAGE_URL_SUFFIX;
console.log("Checking image:", URL);
const response = await fetch(URL);
if (response.ok) {
console.log("Image found!");
return true;
} else {
console.log("Image not found!");
return false;
}
} catch (error) {
return false;
}
import type { GitRepo } from "../types";
const API_BASE_URL = "https://git.luke-else.co.uk/api/v1";
export const IMAGE_URL_SUFFIX = "/raw/branch/main/assets/images/main.png";
export async function fetchRepos(): Promise<GitRepo[]> {
try {
console.log("Fetching repos...");
const response = await fetch(`${API_BASE_URL}/repos/search?sort=updated&order=desc&limit=12`, {
headers: {
// "Authorization": `token ${ACCESS_TOKEN}`,
"Content-Type": "application/json"
}
});
if (!response.ok) {
throw new Error(`Error: ${response.statusText}`);
}
const data: { data: GitRepo[] } = await response.json();
return data.data; // Extract the list of repositories
} catch (error) {
console.error("Failed to fetch repos:", error);
return [];
}
}
export function timeSince(inputDate: Date | string): string {
const date = new Date(inputDate); // Ensure it's a Date object
if (isNaN(date.getTime())) {
throw new Error("Invalid date provided");
}
const now: Date = new Date();
const diffInMs: number = now.getTime() - date.getTime();
const diffInSeconds: number = Math.floor(diffInMs / 1000);
const diffInMinutes: number = Math.floor(diffInSeconds / 60);
const diffInHours: number = Math.floor(diffInMinutes / 60);
const diffInDays: number = Math.floor(diffInHours / 24);
const diffInMonths: number = Math.floor(diffInDays / 30); // Approximate
const diffInYears: number = Math.floor(diffInDays / 365); // Approximate
if (diffInDays === 0) return "Today";
if (diffInDays === 1) return "Yesterday";
if (diffInDays < 7) return `${diffInDays} days ago`;
if (diffInDays < 30) return `${Math.floor(diffInDays / 7)} week${diffInDays >= 14 ? 's' : ''} ago`;
if (diffInMonths < 12) return `${diffInMonths} month${diffInMonths > 1 ? 's' : ''} ago`;
return `${diffInYears} year${diffInYears > 1 ? 's' : ''} ago`;
}
export async function checkImage(repo: GitRepo): Promise<boolean> {
try {
const URL = repo.html_url + IMAGE_URL_SUFFIX;
console.log("Checking image:", URL);
const response = await fetch(URL);
if (response.ok) {
console.log("Image found!");
return true;
} else {
console.log("Image not found!");
return false;
}
} catch (error) {
return false;
}
}
+4 -4
View File
@@ -1,5 +1,5 @@
export async function getJson(path: string) {
let response = await fetch(path);
let users = await response.json();
return users;
export async function getJson(path: string) {
let response = await fetch(path);
let users = await response.json();
return users;
}
+11 -11
View File
@@ -1,12 +1,12 @@
import { writable } from "svelte/store";
import type { GitRepo } from "./types";
import { fetchRepos } from "./api/git";
////////////////////////////////////////
// Git Repo Stores
////////////////////////////////////////
export const repos = writable<GitRepo[]>([]);
export async function loadRepos() {
repos.set(await fetchRepos());
import { writable } from "svelte/store";
import type { GitRepo } from "./types";
import { fetchRepos } from "./api/git";
////////////////////////////////////////
// Git Repo Stores
////////////////////////////////////////
export const repos = writable<GitRepo[]>([]);
export async function loadRepos() {
repos.set(await fetchRepos());
}
+22 -22
View File
@@ -1,22 +1,22 @@
export type TimelinePosition = 'right' | 'left' | 'alternate';
export type ParentPosition = 'right' | 'left';
export type TimelineConfig = {
rootPosition: TimelinePosition;
};
export interface GitRepo {
name: string;
description: string;
language: string;
size: number;
updated_at: Date;
html_url: string;
private: boolean;
fork: boolean;
owner: {
login: string;
avatar_url: string;
};
}
export type TimelinePosition = 'right' | 'left' | 'alternate';
export type ParentPosition = 'right' | 'left';
export type TimelineConfig = {
rootPosition: TimelinePosition;
};
export interface GitRepo {
name: string;
description: string;
language: string;
size: number;
updated_at: Date;
html_url: string;
private: boolean;
fork: boolean;
owner: {
login: string;
avatar_url: string;
};
}
+85 -85
View File
@@ -1,85 +1,85 @@
<script lang="ts">
import { getJson } from '$lib/data';
import { toasts } from 'svelte-toasts';
import {
Loading,
Section,
Card,
GridGallery,
SkillProgress,
Timeline,
Collapsible
} from '@luke-else/component-lib';
</script>
{#await getJson('/json/me.json')}
<Loading />
{:then info}
<div style="display: none;">
{toasts.add({
title: 'Welcome',
duration: 5000,
type: 'success',
placement: 'bottom-center',
showProgress: true
})}
</div>
<!-- Main Card -->
<Section label="[About]">
<Card>
<h2 slot="headerLeft">{info.name}</h2>
<h2 slot="headerRight">{info.job_title}</h2>
<div slot="content" class="flex flex-row items-center gap-5">
<img
src={info.profile_photo}
alt="Avatar"
class="max-md:hidden rounded-full w-32 h-32 md:w-48 md:h-48 mt-2 mb-2 p-2 border-3"
/>
<p
class="[&>*]:underline [&>*]:decoration-2 [&>*]:decoration-transparent [&>*]:hover:decoration-inherit [&>*]:transition-all [&>*]:duration-300 [&>*]:text-green-600"
>
{@html info.about}
</p>
</div>
<h3 slot="footerLeft">{@html info.location}</h3>
</Card>
</Section>
<!-- SKills -->
<Section label="[Skills]">
<GridGallery>
{#each info.skills as skill}
<Card
containerStyle="opacity-100 hover:opacity-100 hover:scale-[105%] md:opacity-70 transition-all duration-300"
>
<h2 slot="headerLeft">{skill.name}</h2>
<i slot="headerRight" class="text-slate-300 text-5xl {skill.logo}"></i>
<div slot="content">
<Collapsible>
<span slot="label" class="text-lg">About {skill.name}</span>
<span slot="content">{skill.about}</span>
</Collapsible>
<SkillProgress skillColour={skill.colour} value={skill.competency} />
</div>
<h3 slot="footerLeft"><a href={skill.link} target="_blank">{skill.link}</a></h3>
</Card>
{/each}
</GridGallery>
</Section>
<Section label="[Experience]">
<Timeline timelineData={info.timeline} />
</Section>
{:catch}
<div style="display: none;">
{toasts.add({
title: 'Error',
description: 'There was an error loading static site data',
duration: 0,
placement: 'bottom-center',
showProgress: true
})}
</div>
{/await}
<script lang="ts">
import { getJson } from '$lib/data';
import { toasts } from 'svelte-toasts';
import {
Loading,
Section,
Card,
GridGallery,
SkillProgress,
Timeline,
Collapsible
} from '@luke-else/component-lib';
</script>
{#await getJson('/json/me.json')}
<Loading />
{:then info}
<div style="display: none;">
{toasts.add({
title: 'Welcome',
duration: 5000,
type: 'success',
placement: 'bottom-center',
showProgress: true
})}
</div>
<!-- Main Card -->
<Section label="[About]">
<Card>
<h2 slot="headerLeft">{info.name}</h2>
<h2 slot="headerRight">{info.job_title}</h2>
<div slot="content" class="flex flex-row items-center gap-5">
<img
src={info.profile_photo}
alt="Avatar"
class="max-md:hidden rounded-full w-32 h-32 md:w-48 md:h-48 mt-2 mb-2 p-2 border-3"
/>
<p
class="[&>*]:underline [&>*]:decoration-2 [&>*]:decoration-transparent [&>*]:hover:decoration-inherit [&>*]:transition-all [&>*]:duration-300 [&>*]:text-green-600"
>
{@html info.about}
</p>
</div>
<h3 slot="footerLeft">{@html info.location}</h3>
</Card>
</Section>
<!-- SKills -->
<Section label="[Skills]">
<GridGallery>
{#each info.skills as skill}
<Card
containerStyle="opacity-100 hover:opacity-100 hover:scale-[105%] md:opacity-70 transition-all duration-300"
>
<h2 slot="headerLeft">{skill.name}</h2>
<i slot="headerRight" class="text-slate-300 text-5xl {skill.logo}"></i>
<div slot="content">
<Collapsible>
<span slot="label" class="text-lg">About {skill.name}</span>
<span slot="content">{skill.about}</span>
</Collapsible>
<SkillProgress skillColour={skill.colour} value={skill.competency} />
</div>
<h3 slot="footerLeft"><a href={skill.link} target="_blank">{skill.link}</a></h3>
</Card>
{/each}
</GridGallery>
</Section>
<Section label="[Experience]">
<Timeline timelineData={info.timeline} />
</Section>
{:catch}
<div style="display: none;">
{toasts.add({
title: 'Error',
description: 'There was an error loading static site data',
duration: 0,
placement: 'bottom-center',
showProgress: true
})}
</div>
{/await}
+28 -28
View File
@@ -1,28 +1,28 @@
<script lang="ts">
import '../app.css';
import { ToastContainer, FlatToast } from 'svelte-toasts';
import { PageIcon } from '@luke-else/component-lib';
</script>
<div
class="min-h-screen px-8 py-4 bg-white text-slate-600 dark:bg-slate-900/90 dark:text-slate-200/60 md:text-2xl sm:text-md font-mono flex flex-col gap-5 transition duration-1000 ease-in-out"
>
<nav
class="w-full px-8 py-4 flex gap-10 text-xl justify-center items-center text-green-600 font-semibold"
>
<a href="/" class="hover:underline">//Profile</a>
<a href="/repos" class="hover:underline">//Repos</a>
<a href="/contact" class="hover:underline">//Contact</a>
</nav>
<a href="https://git.luke-else.co.uk" target="_blank">
<PageIcon iconClass="devicon-git-plain" />
</a>
<div class="container mx-auto justify-center items-center flex flex-col">
<slot />
<ToastContainer let:data>
<FlatToast {data} />
</ToastContainer>
</div>
</div>
<script lang="ts">
import '../app.css';
import { ToastContainer, FlatToast } from 'svelte-toasts';
import { PageIcon } from '@luke-else/component-lib';
</script>
<div
class="min-h-screen px-8 py-4 bg-white text-slate-600 dark:bg-slate-900/90 dark:text-slate-200/60 md:text-2xl sm:text-md font-mono flex flex-col gap-5 transition duration-1000 ease-in-out"
>
<nav
class="w-full px-8 py-4 flex gap-10 text-xl justify-center items-center text-green-600 font-semibold"
>
<a href="/" class="hover:underline">//Profile</a>
<a href="/repos" class="hover:underline">//Repos</a>
<a href="/contact" class="hover:underline">//Contact</a>
</nav>
<a href="https://git.luke-else.co.uk" target="_blank">
<PageIcon iconClass="devicon-git-plain" />
</a>
<div class="container mx-auto justify-center items-center flex flex-col">
<slot />
<ToastContainer let:data>
<FlatToast {data} />
</ToastContainer>
</div>
</div>
+6 -6
View File
@@ -1,7 +1,7 @@
<script>
import Main from '../main.svelte';
</script>
<div>
<Main></Main>
<script>
import Main from '../main.svelte';
</script>
<div>
<Main></Main>
</div>
+103 -103
View File
@@ -1,103 +1,103 @@
<script lang="ts">
import { toasts } from 'svelte-toasts';
import { Card, Section } from '@luke-else/component-lib';
import { page } from '$app/state';
const sent = page.url.searchParams.get('sent');
if (sent == 'true') {
toasts.add({
title: 'Message sent!',
description: 'Thank you for contacting me.',
type: 'success',
duration: 4000,
placement: 'bottom-center'
});
}
if (sent == 'false') {
toasts.add({
title: 'Message not sent!',
description: 'Please try again later.',
type: 'error',
duration: 4000,
placement: 'bottom-center'
});
}
</script>
<Section label="[Contact]">
<div>
</div>
<Card>
<div slot="headerLeft">
Contact Me
</div>
<!-- Contact Form -->
<form slot="content" class="w-full max-w-3xl mx-auto flex flex-col gap-4 text-lg" action="https://api.staticforms.xyz/submit" method="post">
<div class="hidden">
<input type="hidden" name="accessKey" value="fbb5ec04-506b-448a-a445-a2e47579a966">
<input type="hidden" name="replyTo" value="@">
<input type="text" name="honeypot" style="display: none;">
<input type="hidden" name="redirectTo" value="https://luke-else.co.uk/contact?sent=true">
</div>
<div class="flex flex-row md:flex-row gap-3">
<div class="flex-1">
<label class="block text-xs font-medium mb-1" for="name">Name</label>
<input
id="name"
name="name"
type="text"
class="w-full rounded-lg border border-gray-400 px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-600 transition placeholder-gray-400"
required
placeholder="Your name"
/>
</div>
<div class="flex-1">
<label class="block text-xs font-medium mb-1" for="email">Email</label>
<input
id="email"
name="email"
type="email"
class="w-full rounded-lg border border-gray-400 px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-600 transition placeholder-gray-400"
required
placeholder="you@email.com"
/>
</div>
<div class="flex-1">
<label class="block text-xs font-medium mb-1" for="subject">Subject</label>
<input
id="subject"
name="subject"
type="text"
class="w-full rounded-lg border border-gray-400 px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-600 transition placeholder-gray-400"
required
placeholder="Subject"
/>
</div>
</div>
<div>
<label class="block text-xs font-medium mb-1" for="message">Message</label>
<textarea
id="message"
name="message"
class="w-full rounded-lg border border-gray-400 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-600 transition min-h-[80px] placeholder-gray-400"
required
placeholder="Your message"
></textarea>
</div>
<!-- reCAPTCHA integration -->
<div class="">
<div class="g-recaptcha" data-sitekey="6LfjQAwrAAAAAIF57u8Wt4w5L5vBEWi5DfXXBuGy"></div>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</div>
<button
type="submit"
class="self-end bg-blue-600 hover:bg-blue-700 text-white font-semibold py-1.5 px-8 rounded-lg transition"
>
Send Message
</button>
</form>
</Card>
</Section>
<script lang="ts">
import { toasts } from 'svelte-toasts';
import { Card, Section } from '@luke-else/component-lib';
import { page } from '$app/state';
const sent = page.url.searchParams.get('sent');
if (sent == 'true') {
toasts.add({
title: 'Message sent!',
description: 'Thank you for contacting me.',
type: 'success',
duration: 4000,
placement: 'bottom-center'
});
}
if (sent == 'false') {
toasts.add({
title: 'Message not sent!',
description: 'Please try again later.',
type: 'error',
duration: 4000,
placement: 'bottom-center'
});
}
</script>
<Section label="[Contact]">
<div>
</div>
<Card>
<div slot="headerLeft">
Contact Me
</div>
<!-- Contact Form -->
<form slot="content" class="w-full max-w-3xl mx-auto flex flex-col gap-4 text-lg" action="https://api.staticforms.xyz/submit" method="post">
<div class="hidden">
<input type="hidden" name="accessKey" value="fbb5ec04-506b-448a-a445-a2e47579a966">
<input type="hidden" name="replyTo" value="@">
<input type="text" name="honeypot" style="display: none;">
<input type="hidden" name="redirectTo" value="https://luke-else.co.uk/contact?sent=true">
</div>
<div class="flex flex-row md:flex-row gap-3">
<div class="flex-1">
<label class="block text-xs font-medium mb-1" for="name">Name</label>
<input
id="name"
name="name"
type="text"
class="w-full rounded-lg border border-gray-400 px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-600 transition placeholder-gray-400"
required
placeholder="Your name"
/>
</div>
<div class="flex-1">
<label class="block text-xs font-medium mb-1" for="email">Email</label>
<input
id="email"
name="email"
type="email"
class="w-full rounded-lg border border-gray-400 px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-600 transition placeholder-gray-400"
required
placeholder="you@email.com"
/>
</div>
<div class="flex-1">
<label class="block text-xs font-medium mb-1" for="subject">Subject</label>
<input
id="subject"
name="subject"
type="text"
class="w-full rounded-lg border border-gray-400 px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-600 transition placeholder-gray-400"
required
placeholder="Subject"
/>
</div>
</div>
<div>
<label class="block text-xs font-medium mb-1" for="message">Message</label>
<textarea
id="message"
name="message"
class="w-full rounded-lg border border-gray-400 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-600 transition min-h-[80px] placeholder-gray-400"
required
placeholder="Your message"
></textarea>
</div>
<!-- reCAPTCHA integration -->
<div class="">
<div class="g-recaptcha" data-sitekey="6LfjQAwrAAAAAIF57u8Wt4w5L5vBEWi5DfXXBuGy"></div>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</div>
<button
type="submit"
class="self-end bg-blue-600 hover:bg-blue-700 text-white font-semibold py-1.5 px-8 rounded-lg transition"
>
Send Message
</button>
</form>
</Card>
</Section>
+73 -73
View File
@@ -1,73 +1,73 @@
<script lang="ts">
import { loadRepos, repos } from '$lib/stores';
import { timeSince, checkImage, IMAGE_URL_SUFFIX } from '$lib/api/git';
import { toasts } from 'svelte-toasts';
import { GridGallery, Card, Loading, Section, Collapsible } from '@luke-else/component-lib';
let repoImages: Record<string, string | null> = {};
// When repos load, check for images
$: if ($repos.length) {
(async () => {
for (const repo of $repos) {
if (repoImages[repo.name] === undefined) {
const url = repo.html_url + IMAGE_URL_SUFFIX;
repoImages[repo.name] = (await checkImage(repo)) ? url : null;
}
}
})();
}
</script>
<Section label="[Repositories]">
{#await loadRepos()}
<Loading />
{:then _}
{#if $repos.length == 0}
{console.log('No Repos')}
<div style="display: none;">
{toasts.add({
title: 'Error',
description: 'Failed to load repositories',
duration: 5000,
type: 'error',
placement: 'bottom-center',
showProgress: true
})}
</div>
<p>Sorry... we can't show you anything here</p>
{/if}
<!-- Repositories loaded successfully -->
<GridGallery>
{#each $repos as repo}
<!-- <Loading /> -->
<Card
containerStyle="opacity-100 hover:opacity-100 hover:scale-[105%] md:opacity-70 transition-all duration-300"
>
<h2 slot="headerLeft">{repo.name}</h2>
<h2 slot="headerRight" class="text-sm text-gray-500">
{repo.language}
</h2>
<div class="flex flex-col gap-5" slot="content">
{repo.description}
{#if repoImages[repo.name]}
<Collapsible>
<span slot="label" class="text-lg">See More</span>
<!-- svelte-ignore a11y_img_redundant_alt -->
<img
slot="content"
src={repoImages[repo.name]}
alt="repo image"
class=""
/>
</Collapsible>
{/if}
</div>
<h3 slot="footerLeft">
Last Updated: {timeSince(repo.updated_at)}
</h3>
</Card>
{/each}
</GridGallery>
{/await}
</Section>
<script lang="ts">
import { loadRepos, repos } from '$lib/stores';
import { timeSince, checkImage, IMAGE_URL_SUFFIX } from '$lib/api/git';
import { toasts } from 'svelte-toasts';
import { GridGallery, Card, Loading, Section, Collapsible } from '@luke-else/component-lib';
let repoImages: Record<string, string | null> = {};
// When repos load, check for images
$: if ($repos.length) {
(async () => {
for (const repo of $repos) {
if (repoImages[repo.name] === undefined) {
const url = repo.html_url + IMAGE_URL_SUFFIX;
repoImages[repo.name] = (await checkImage(repo)) ? url : null;
}
}
})();
}
</script>
<Section label="[Repositories]">
{#await loadRepos()}
<Loading />
{:then _}
{#if $repos.length == 0}
{console.log('No Repos')}
<div style="display: none;">
{toasts.add({
title: 'Error',
description: 'Failed to load repositories',
duration: 5000,
type: 'error',
placement: 'bottom-center',
showProgress: true
})}
</div>
<p>Sorry... we can't show you anything here</p>
{/if}
<!-- Repositories loaded successfully -->
<GridGallery>
{#each $repos as repo}
<!-- <Loading /> -->
<Card
containerStyle="opacity-100 hover:opacity-100 hover:scale-[105%] md:opacity-70 transition-all duration-300"
>
<h2 slot="headerLeft">{repo.name}</h2>
<h2 slot="headerRight" class="text-sm text-gray-500">
{repo.language}
</h2>
<div class="flex flex-col gap-5" slot="content">
{repo.description}
{#if repoImages[repo.name]}
<Collapsible>
<span slot="label" class="text-lg">See More</span>
<!-- svelte-ignore a11y_img_redundant_alt -->
<img
slot="content"
src={repoImages[repo.name]}
alt="repo image"
class=""
/>
</Collapsible>
{/if}
</div>
<h3 slot="footerLeft">
Last Updated: {timeSince(repo.updated_at)}
</h3>
</Card>
{/each}
</GridGallery>
{/await}
</Section>