summaryrefslogblamecommitdiffstatshomepage
path: root/frontend/src/lib/toolbar/FilterFavourites.svelte
blob: 6591cefd10e11847f74eb554d10bde26741b794e (plain) (tree)























                                                                                                
<script lang="ts">
	import { page } from '$app/stores';
	import { ComicFilterContext, cycleBooleanFilter, getFilterContext } from '$lib/Filter';
	import { accelerator } from '$lib/Shortcuts';
	import Star from '$lib/icons/Star.svelte';

	const filter = getFilterContext<ComicFilterContext>();
	$: favourite = $filter.include.controls.favourite.value;

	const toggle = () => {
		$filter.include.controls.favourite.value = cycleBooleanFilter(favourite, false);
		$filter.apply($page.url.searchParams);
	};
</script>

<button
	class:toggled={favourite}
	class="btn-slate"
	title="Filter favourites"
	on:click={toggle}
	use:accelerator={'f'}
>
	<Star {favourite} />
</button>