Skip to content

Commit

Permalink
Make /Items display craftable items only
Browse files Browse the repository at this point in the history
/Items/All now displays all items.
  • Loading branch information
MatthiasKunnen committed Jan 14, 2024
1 parent 71a12ec commit 0eb62a4
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/lib/RecipeItems.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{#each items as item, i}
<li class="sum">{#if i > 0}+{/if}</li>
<li class="item" data-name={item.item.name}>
<a href="/Items/{item.item.name}">
<a href="/Items/Item/{item.item.name}">
<GameIcon
counter={item.count}
icon={item.item.icon}
Expand Down
1 change: 1 addition & 0 deletions src/routes/Items/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const load = async () => {

return {
items: Object.entries(data.items)
.filter(([_, item]) => item.recipes.length > 0)
.sort(([, a], [, b]) => {
return a.displayName.localeCompare(b.displayName);
}),
Expand Down
30 changes: 20 additions & 10 deletions src/routes/Items/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
</script>

<h1>All Icarus Items</h1>
<h1>All Craftable Icarus Items</h1>
<p>Other lists of Icarus items:</p>
<ul class="other-lists">
<li><a href="/Items/All" class="link">All items including non-craftable experimental items</a></li>
</ul>

<div class="items">
{#each data.items as [name, item]}
<a href="/Items/{name}">
<a href="/Items/Item/{name}">
<GameIcon
icon={item.icon}
alt="{item.displayName}"
Expand All @@ -21,22 +25,28 @@
</div>

<style>
a {
display: flex;
align-items: center;
color: white;
gap: 4px;
text-decoration: none;
}
h2 {
font-size: 1.3em;
}
.other-lists {
list-style-position: inside;
padding-left: 1em;
}
.items {
display: grid;
gap: 2em;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
--game-icon-width: 64px;
}
.items a {
display: flex;
align-items: center;
color: white;
gap: 4px;
text-decoration: none;
}
</style>
13 changes: 13 additions & 0 deletions src/routes/Items/All/+page.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {getData} from '$lib/data';

export const load = async () => {
const data = await getData();

return {
items: Object.entries(data.items)
.sort(([, a], [, b]) => {
return a.displayName.localeCompare(b.displayName);
}),
title: 'Items',
};
};
46 changes: 46 additions & 0 deletions src/routes/Items/All/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<script lang="ts">
import GameIcon from '$lib/GameIcon.svelte'
export let data;
</script>

<h1>All Icarus Items</h1>
<p>
This includes items that are experimental and not craftable. For a list of craftable items, go
<a href="/Items" class="link">here</a>.
</p>

<div class="items">
{#each data.items as [name, item]}
<a href="/Items/Item/{name}">
<GameIcon
icon={item.icon}
alt="{item.displayName}"
size="64"
showCaption={false}></GameIcon>
<h2>{item.displayName}</h2>
</a>
{/each}
</div>

<style>
h2 {
font-size: 1.3em;
}
.items {
display: grid;
gap: 2em;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
--game-icon-width: 64px;
}
.items a {
display: flex;
align-items: center;
color: white;
gap: 4px;
text-decoration: none;
}
</style>
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/routes/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ h2 {
h3 {
font-size: 1.3em;
}

a.link {
text-decoration: underline;
}

0 comments on commit 0eb62a4

Please sign in to comment.