-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Merge categories/tags and improve filtering (#541)
* Experiment with SSR and query params * Require all tags to be present * Fix when no query param present * Add tag links * Working add/remove tags * Fix templates route * Remove old category/tags selectors * Button style * More styling * Remove unused code * Remove @sindresorhus/slugify * Format and disable prerender * Improve css grid * Use searchParams.getAll * Replace itemsjs with filter/sort functions * Always show selected tags * Add data-sveltekit-noscroll * Move sortableFields to prop level * Simplify code * Fix sortArray for dates * Add an icon to clear filters * Convert tags to kebab-case * Add category to tags * Delete category field * Remove duplicated tags * Merge more tags
- Loading branch information
1 parent
54114c2
commit 11d5ed5
Showing
17 changed files
with
892 additions
and
1,333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<script lang="ts"> | ||
import { page } from '$app/stores'; | ||
import Icon from '$lib/components/Icon/index.svelte'; | ||
export let tags: string[]; | ||
export let selectedTags: string[]; | ||
</script> | ||
|
||
<div data-sveltekit-noscroll> | ||
{#each selectedTags as tag} | ||
{@const newTags = selectedTags.filter((t) => t !== tag)} | ||
{@const title = tag.replaceAll('-', ' ')} | ||
{#if newTags.length === 0} | ||
<a class="tag active" href={$page.url.pathname}>{title}</a> | ||
{:else} | ||
<a | ||
class="tag active" | ||
href={`${$page.url.pathname}?${newTags.map((t) => `tag=${t}`).join('&')}`} | ||
> | ||
{title} | ||
</a> | ||
{/if} | ||
{/each} | ||
|
||
{#each tags as tag} | ||
{#if !selectedTags.includes(tag)} | ||
{@const newTags = [...selectedTags, tag]} | ||
{@const title = tag.replaceAll('-', ' ')} | ||
<a class="tag" href={`${$page.url.pathname}?${newTags.map((t) => `tag=${t}`).join('&')}`}> | ||
{title} | ||
</a> | ||
{/if} | ||
{/each} | ||
|
||
{#if selectedTags.length !== 0} | ||
<a href={$page.url.pathname}><Icon name="close" /></a> | ||
{/if} | ||
</div> | ||
|
||
<style> | ||
div { | ||
display: flex; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
gap: 0.5rem; | ||
} | ||
a { | ||
border: none; | ||
} | ||
.tag { | ||
padding: 4px 12px; | ||
border: 1px solid var(--link-color); | ||
border-radius: 9999px; | ||
font-family: Overpass; | ||
font-style: normal; | ||
font-weight: normal; | ||
font-size: 14px; | ||
line-height: 150%; | ||
text-align: center; | ||
} | ||
.active { | ||
color: #ff3e01; | ||
background: #ffdbcf; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.