mirror of
https://github.com/pheralb/svgl.git
synced 2024-11-13 08:46:56 +08:00
Merge branch 'main' into main
This commit is contained in:
commit
71e4a1dfd6
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@ -4,5 +4,12 @@
|
|||||||
},
|
},
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"tailwindCSS.experimental.classRegex": [["[\"'`]([^\"'`]*).*?[\"'`]"]]
|
"tailwindCSS.experimental.classRegex": [
|
||||||
|
[
|
||||||
|
"[\"'`]([^\"'`]*).*?[\"'`]"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"[svelte]": {
|
||||||
|
"editor.defaultFormatter": "svelte.svelte-vscode"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
7
src/data/index.ts
Normal file
7
src/data/index.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import type { iSVG } from '@/types/svg';
|
||||||
|
import { svgs } from './svgs';
|
||||||
|
|
||||||
|
export const svgsData = svgs.map((svg: iSVG, index: number) => {
|
||||||
|
svg.id = index;
|
||||||
|
return svg;
|
||||||
|
});
|
@ -1805,42 +1805,36 @@ export const svgs: iSVG[] = [
|
|||||||
url: 'https://www.linux.org/'
|
url: 'https://www.linux.org/'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 5876149632,
|
|
||||||
title: 'XD',
|
title: 'XD',
|
||||||
category: 'Design',
|
category: 'Design',
|
||||||
route: '/library/adobe-xd.svg',
|
route: '/library/adobe-xd.svg',
|
||||||
url: 'https://helpx.adobe.com/xd/get-started.html'
|
url: 'https://helpx.adobe.com/xd/get-started.html'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 5882201288,
|
|
||||||
title: 'Axure',
|
title: 'Axure',
|
||||||
category: 'Design',
|
category: 'Design',
|
||||||
route: '/library/axure.svg',
|
route: '/library/axure.svg',
|
||||||
url: 'https://www.axure.com/'
|
url: 'https://www.axure.com/'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 6841462408,
|
|
||||||
title: 'Penpot',
|
title: 'Penpot',
|
||||||
category: 'Design',
|
category: 'Design',
|
||||||
route: '/library/penpot.svg',
|
route: '/library/penpot.svg',
|
||||||
url: 'https://penpot.app/'
|
url: 'https://penpot.app/'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 6481118154,
|
|
||||||
title: 'Sketch',
|
title: 'Sketch',
|
||||||
category: 'Design',
|
category: 'Design',
|
||||||
route: '/library/sketch.svg',
|
route: '/library/sketch.svg',
|
||||||
url: 'https://www.sketch.com/'
|
url: 'https://www.sketch.com/'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 5822536555,
|
|
||||||
title: 'Gimp',
|
title: 'Gimp',
|
||||||
category: 'Design',
|
category: 'Design',
|
||||||
route: '/library/gimp.svg',
|
route: '/library/gimp.svg',
|
||||||
url: 'https://www.gimp.org/'
|
url: 'https://www.gimp.org/'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 253,
|
|
||||||
title: 'Ubuntu',
|
title: 'Ubuntu',
|
||||||
category: 'Software',
|
category: 'Software',
|
||||||
route: '/library/ubuntu.svg',
|
route: '/library/ubuntu.svg',
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
import type { iSVG } from '@/types/svg';
|
import type { iSVG } from '@/types/svg';
|
||||||
|
|
||||||
// Get all svgs:
|
// Get all svgs:
|
||||||
import { svgs } from '@/data/svgs';
|
import { svgsData } from '@/data';
|
||||||
const allSvgs = JSON.parse(JSON.stringify(svgs));
|
const allSvgs = JSON.parse(JSON.stringify(svgsData));
|
||||||
|
|
||||||
// Components:
|
// Components:
|
||||||
import Search from '@/components/search.svelte';
|
import Search from '@/components/search.svelte';
|
||||||
@ -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} />
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import type { tCategory } from './categories';
|
import type { tCategory } from './categories';
|
||||||
|
|
||||||
export interface iSVG {
|
export interface iSVG {
|
||||||
|
id?: number;
|
||||||
title: string;
|
title: string;
|
||||||
category: tCategory;
|
category: tCategory;
|
||||||
route:
|
route:
|
||||||
|
Loading…
Reference in New Issue
Block a user