mirror of
https://github.com/pheralb/svgl.git
synced 2024-11-13 08:46:56 +08:00
✨ Add new options.
This commit is contained in:
parent
7abef9f5e7
commit
0184f1b027
@ -12,13 +12,17 @@
|
|||||||
import Grid from '@/components/grid.svelte';
|
import Grid from '@/components/grid.svelte';
|
||||||
import NotFound from '@/components/notFound.svelte';
|
import NotFound from '@/components/notFound.svelte';
|
||||||
|
|
||||||
|
// Icons:
|
||||||
|
import ArrowsClockWise from 'phosphor-svelte/lib/ArrowsClockwise';
|
||||||
|
import ArrowSquareOut from 'phosphor-svelte/lib/ArrowSquareOut';
|
||||||
|
|
||||||
// Search:
|
// Search:
|
||||||
let searchTerm = '';
|
let searchTerm = '';
|
||||||
let filteredSvgs: iSVG[] = [];
|
let filteredSvgs: iSVG[] = [];
|
||||||
|
|
||||||
if (searchTerm.length === 0) {
|
if (searchTerm.length === 0) {
|
||||||
filteredSvgs = allSvgs.sort((a: iSVG, b: iSVG) => {
|
filteredSvgs = allSvgs.sort((a: iSVG, b: iSVG) => {
|
||||||
return a.title.localeCompare(b.title);
|
return b.id - a.id;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,6 +37,32 @@
|
|||||||
searchTerm = '';
|
searchTerm = '';
|
||||||
searchSvgs();
|
searchSvgs();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Sort:
|
||||||
|
let sorted: boolean = false;
|
||||||
|
|
||||||
|
const sort = () => {
|
||||||
|
if (sorted) {
|
||||||
|
sortByLatest();
|
||||||
|
} else {
|
||||||
|
sortAlphabetically();
|
||||||
|
}
|
||||||
|
sorted = !sorted;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Sort alphabetically:
|
||||||
|
const sortAlphabetically = () => {
|
||||||
|
filteredSvgs = filteredSvgs.sort((a: iSVG, b: iSVG) => {
|
||||||
|
return a.title.localeCompare(b.title);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Sort by latest:
|
||||||
|
const sortByLatest = () => {
|
||||||
|
filteredSvgs = filteredSvgs.sort((a: iSVG, b: iSVG) => {
|
||||||
|
return b.id - a.id;
|
||||||
|
});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@ -46,6 +76,23 @@
|
|||||||
clearSearch={() => clearSearch()}
|
clearSearch={() => clearSearch()}
|
||||||
placeholder={`Search ${filteredSvgs.length} logos...`}
|
placeholder={`Search ${filteredSvgs.length} logos...`}
|
||||||
/>
|
/>
|
||||||
|
<div class={`flex items-center justify-between my-4 ${filteredSvgs.length === 0 && 'hidden'}`}>
|
||||||
|
<button
|
||||||
|
class="flex items-center justify-center space-x-2 rounded-md py-1.5 text-sm font-medium text-neutral-500 dark:text-neutral-400 hover:text-dark dark:hover:text-white duration-100 transition-colors"
|
||||||
|
on:click={() => sort()}
|
||||||
|
>
|
||||||
|
<ArrowsClockWise size={14} />
|
||||||
|
<span>{sorted ? 'Sort by latest' : 'Sort alphabetically'}</span>
|
||||||
|
</button>
|
||||||
|
<a
|
||||||
|
class="flex items-center justify-center space-x-2 rounded-md py-1.5 text-sm font-medium text-neutral-500 dark:text-neutral-400 hover:text-dark dark:hover:text-white duration-100 transition-colors"
|
||||||
|
href="https://github.com/pheralb/svgl?tab=readme-ov-file#-getting-started"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<span>Submit SVG</span>
|
||||||
|
<ArrowSquareOut size={14} />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
<Grid>
|
<Grid>
|
||||||
{#each filteredSvgs as svg}
|
{#each filteredSvgs as svg}
|
||||||
<SvgCard svgInfo={svg} />
|
<SvgCard svgInfo={svg} />
|
||||||
|
Loading…
Reference in New Issue
Block a user