~siegfriedehret/nyrst.tools

8cd37eb1c3c17247d2909313e73d5f9a282098a4 — Siegfried Ehret 3 years ago 64decf0
:truck: move apps to freezer route
3 files changed, 94 insertions(+), 119 deletions(-)

M src/components/Nav.svelte
D src/routes/apps/index.svelte
M src/routes/freezer/index.svelte
M src/components/Nav.svelte => src/components/Nav.svelte +1 -2
@@ 57,8 57,7 @@
	<ul>
		<li><a aria-current="{segment === undefined ? 'page' : undefined}" href="https://nyrst.tools">nyrst.tools</a></li>
		<li><a href="https://brrr.nyrst.tools">🔧 brrr</a></li>
		<li><a aria-current="{segment === 'freezer' ? 'page' : undefined}" href="freezer">❄️ freezer</a></li>
		<li><a aria-current="{segment === 'apps' ? 'page' : undefined}" href="apps">📝 apps</a></li>
		<li><a aria-current="{segment === 'freezer' ? 'page' : undefined}" href="/freezer">❄️ freezer</a></li>

		<!-- for the blog link, we're using rel=prefetch so that Sapper prefetches
		     the blog data when we hover over the link or tap it on a touchscreen -->

D src/routes/apps/index.svelte => src/routes/apps/index.svelte +0 -106
@@ 1,106 0,0 @@
<script context="module">
	export async function preload() {
		const resApps = await this.fetch("https://raw.githubusercontent.com/nyrst/freezer/main/data/apps.json");
		const data = await resApps.json();

		const apps = data.sort((a, b) => {
			const nameA = a.name.toUpperCase();
			const nameB = b.name.toUpperCase();
			if (nameA < nameB) {
				return -1;
			}

			if (nameA > nameB) {
				return 1;
			}

			return 0;
		});

		return { apps };
	}
</script>

<script>
	import App from '../../components/freezer/App.svelte';

	export let apps;

	let filteredApps = apps;
	let archKey = "all"

	const filter = arch => () => {
		if (arch) {
			archKey = arch;
			filteredApps = apps.filter(a => a.archs.includes(arch))
		} else {
			archKey = "all";
			filteredApps = apps;
		}
	}
</script>

<svelte:head>
	<title>freezer - nyrst.tools</title>
</svelte:head>

<style>
	nav	{
		margin-bottom: 1rem;
		display: flex;
	}

	nav button {
		display: inline-flex;
		flex-direction: column;
		margin: 0;
		padding: .5rem 1rem;
		border-radius: 0;
		border: 1px solid var(--color-second);
		background: var(--color-second);
		font-weight: 300;
	}

	nav button::after {
		content: attr(title);
		height: 0;
		visibility: hidden;
		overflow: hidden;
		font-weight: bold;
		user-select: none;
		pointer-events: none;
	}
	
	nav button:first-child {
		border-top-left-radius: .5rem;
		border-bottom-left-radius: .5rem;
	}
	
	nav button:last-child {
		border-top-right-radius: .5rem;
		border-bottom-right-radius: .5rem;
	}

	nav button.enabled,
	nav button:active,
	nav button:focus,
	nav button:hover {
		color: #fff;
		background: var(--color-main);
		border: 1px solid var(--color-main);
		font-weight: bold;
	}
</style>

<h1>Available apps in the freezer repository</h1>

<nav>
	<button class:enabled={archKey === "all"} on:click={filter()} title="All">All</button>
	<button class:enabled={archKey === "linux"} on:click={filter("linux")} title="Linux">Linux</button>
	<button class:enabled={archKey === "macos"} on:click={filter("macos")} title="MacOS">MacOS</button>
	<button class:enabled={archKey === "macosarm"} on:click={filter("macosarm")} title="MacOS ARM">MacOS ARM</button>
</nav>

{#each filteredApps as app}
	<App {app} />
{/each}

M src/routes/freezer/index.svelte => src/routes/freezer/index.svelte +93 -11
@@ 1,26 1,108 @@
<script context="module">
	import { Remarkable } from 'remarkable';

	export async function preload() {
		const md = new Remarkable();
 
		const resHelp = await this.fetch("https://nyrst.github.io/freezer/README.md");
		const helpText = await resHelp.text();
		const help = md.render(helpText);
		const resApps = await this.fetch("https://raw.githubusercontent.com/nyrst/freezer/main/data/apps.json");
		const data = await resApps.json();

		const apps = data.sort((a, b) => {
			const nameA = a.name.toUpperCase();
			const nameB = b.name.toUpperCase();
			if (nameA < nameB) {
				return -1;
			}

			if (nameA > nameB) {
				return 1;
			}

		return { help };
			return 0;
		});

		return { apps };
	}
</script>

<script>
	export let help;
	import App from '../../components/freezer/App.svelte';

	export let apps;

	let filteredApps = apps;
	let archKey = "all"

	const filter = arch => () => {
		if (arch) {
			archKey = arch;
			filteredApps = apps.filter(a => a.archs.includes(arch))
		} else {
			archKey = "all";
			filteredApps = apps;
		}
	}
</script>

<svelte:head>
	<title>apps - nyrst.tools</title>
	<title>freezer - nyrst.tools</title>
</svelte:head>

<style>
	nav	{
		margin-bottom: 1rem;
		display: flex;
	}

	nav button {
		display: inline-flex;
		flex-direction: column;
		margin: 0;
		padding: .5rem 1rem;
		border-radius: 0;
		border: 1px solid var(--color-second);
		background: var(--color-second);
		font-weight: 300;
	}

	nav button::after {
		content: attr(title);
		height: 0;
		visibility: hidden;
		overflow: hidden;
		font-weight: bold;
		user-select: none;
		pointer-events: none;
	}
	
	nav button:first-child {
		border-top-left-radius: .5rem;
		border-bottom-left-radius: .5rem;
	}
	
	nav button:last-child {
		border-top-right-radius: .5rem;
		border-bottom-right-radius: .5rem;
	}

	nav button.enabled,
	nav button:active,
	nav button:focus,
	nav button:hover {
		color: #fff;
		background: var(--color-main);
		border: 1px solid var(--color-main);
		font-weight: bold;
	}
</style>

{@html help}
\ No newline at end of file
<h1>Available apps in the freezer repository</h1>

<nav>
	<button class:enabled={archKey === "all"} on:click={filter()} title="All">All</button>
	<button class:enabled={archKey === "linux"} on:click={filter("linux")} title="Linux">Linux</button>
	<button class:enabled={archKey === "macos"} on:click={filter("macos")} title="MacOS">MacOS</button>
	<button class:enabled={archKey === "macosarm"} on:click={filter("macosarm")} title="MacOS ARM">MacOS ARM</button>
</nav>

{#each filteredApps as app}
	<App {app} />
{/each}

<p>Learn mode about <a href="https://brrr.nyrst.tools/contributing/package-definition.html">package definitions</a>.</p>
\ No newline at end of file