mirror of
https://github.com/LukeHagar/sveltesociety.dev.git
synced 2025-12-07 12:47:45 +00:00
Simplfy sorting + simply package manager
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import Tag from '../Tag.svelte';
|
import Tag from '../Tag.svelte';
|
||||||
import { copyToClipboard } from '$lib/utils/clipboard';
|
import { copyToClipboard } from '$lib/utils/clipboard';
|
||||||
|
import { packageManager as manager } from '$stores/packageManager';
|
||||||
|
|
||||||
export let active = false;
|
export let active = false;
|
||||||
export let title = '';
|
export let title = '';
|
||||||
@@ -10,12 +11,11 @@
|
|||||||
export let url = '';
|
export let url = '';
|
||||||
export let npm = '';
|
export let npm = '';
|
||||||
export let repo = '';
|
export let repo = '';
|
||||||
export let manager = 'npm';
|
|
||||||
|
|
||||||
let clipboardCopy = false;
|
let clipboardCopy = false;
|
||||||
|
|
||||||
const copy = () => {
|
const copy = () => {
|
||||||
copyToClipboard(`${packageManagers[manager]} ${cleanupNpm(npm)}`).then(
|
copyToClipboard(`${packageManagers[$manager]} ${cleanupNpm(npm)}`).then(
|
||||||
() => (clipboardCopy = false)
|
() => (clipboardCopy = false)
|
||||||
);
|
);
|
||||||
clipboardCopy = true;
|
clipboardCopy = true;
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
{#if npm}<Tag
|
{#if npm}<Tag
|
||||||
click={() => copy()}
|
click={() => copy()}
|
||||||
variant="copy"
|
variant="copy"
|
||||||
title={clipboardCopy ? 'copied!' : `${packageManagers[manager]} ${cleanupNpm(npm)}`}
|
title={clipboardCopy ? 'copied!' : `${packageManagers[$manager]} ${cleanupNpm(npm)}`}
|
||||||
/>{/if}
|
/>{/if}
|
||||||
</h3>
|
</h3>
|
||||||
<p class="flex-grow">{description}</p>
|
<p class="flex-grow">{description}</p>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
{#if label}
|
{#if label}
|
||||||
<span>{label}</span>
|
<span>{label}</span>
|
||||||
{/if}
|
{/if}
|
||||||
<SvelteSelect containerClasses="select-container" bind:value {...$$restProps} />
|
<SvelteSelect containerClasses="select-container" bind:value {...$$restProps} on:select />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -33,7 +33,6 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: var(--s-2);
|
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
min-height: 3rem;
|
min-height: 3rem;
|
||||||
|
|||||||
9
src/lib/stores/packageManager.ts
Normal file
9
src/lib/stores/packageManager.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { localStorage, persist } from '@macfja/svelte-persistent-store';
|
||||||
|
import type { PersistentStore } from '@macfja/svelte-persistent-store';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
|
export const packageManager: PersistentStore<string> = persist(
|
||||||
|
writable('npm'),
|
||||||
|
localStorage(),
|
||||||
|
'packageManager'
|
||||||
|
);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import components from './components.json';
|
import components from './components.json';
|
||||||
import SearchableJson from '../_searchableJson.svelte';
|
import SearchableJson from '../searchableJson.svelte';
|
||||||
|
|
||||||
const categoryId = {
|
const categoryId = {
|
||||||
Animations: 'animations',
|
Animations: 'animations',
|
||||||
|
|||||||
@@ -6,20 +6,16 @@
|
|||||||
import Seo from '$lib/components/Seo.svelte';
|
import Seo from '$lib/components/Seo.svelte';
|
||||||
import Search from '$lib/components/Search.svelte';
|
import Search from '$lib/components/Search.svelte';
|
||||||
import Select from '../lib/components/Select.svelte';
|
import Select from '../lib/components/Select.svelte';
|
||||||
import { localStorage, persist } from '@macfja/svelte-persistent-store';
|
import { packageManager } from '$stores/packageManager';
|
||||||
import { writable } from 'svelte/store';
|
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let displayTitle = '';
|
export let displayTitle = '';
|
||||||
export let displayTitleSingular = '';
|
export let displayTitleSingular = '';
|
||||||
export let submittingType = '';
|
export let submittingType = '';
|
||||||
|
|
||||||
let selectedPackageManager = { value: 'npm' };
|
|
||||||
const packageManager = persist(writable('npm'), localStorage(), 'packageManager');
|
|
||||||
let searchValue;
|
let searchValue;
|
||||||
let dataToDisplay = [];
|
let dataToDisplay = [];
|
||||||
|
|
||||||
$: $packageManager = selectedPackageManager.value;
|
|
||||||
$: categories = extractUnique(dataToDisplay, 'category');
|
$: categories = extractUnique(dataToDisplay, 'category');
|
||||||
|
|
||||||
export let categoryId = {};
|
export let categoryId = {};
|
||||||
@@ -35,11 +31,10 @@
|
|||||||
dataDefault={{ category: '' }}
|
dataDefault={{ category: '' }}
|
||||||
bind:query={searchValue}
|
bind:query={searchValue}
|
||||||
sortableFields={[
|
sortableFields={[
|
||||||
{ identifier: 'addedOn', title: 'Last added first', ascending: false },
|
{ identifier: 'addedOn', title: 'Most recent', ascending: false },
|
||||||
{ identifier: 'addedOn', title: 'Oldest first', ascending: true },
|
{ identifier: 'addedOn', title: 'Oldest', ascending: true },
|
||||||
{ identifier: 'title', title: 'Name (A-Z)', ascending: true },
|
{ identifier: 'title', title: 'Name', ascending: true },
|
||||||
{ identifier: 'title', title: 'Name (Z-A)', ascending: false },
|
{ identifier: 'stars', title: 'Stars', ascending: false }
|
||||||
{ identifier: 'stars', title: 'Most stars first', ascending: false }
|
|
||||||
]}
|
]}
|
||||||
searchableFields={['title', 'description']}
|
searchableFields={['title', 'description']}
|
||||||
facetsConfig={[
|
facetsConfig={[
|
||||||
@@ -60,8 +55,10 @@
|
|||||||
<Select
|
<Select
|
||||||
label="Package manager"
|
label="Package manager"
|
||||||
isClearable={false}
|
isClearable={false}
|
||||||
|
isSearchable={false}
|
||||||
showIndicator
|
showIndicator
|
||||||
bind:value={selectedPackageManager}
|
value={{ value: $packageManager }}
|
||||||
|
on:select={({ detail }) => ($packageManager = detail.value)}
|
||||||
items={[
|
items={[
|
||||||
{ label: 'NPM', value: 'npm' },
|
{ label: 'NPM', value: 'npm' },
|
||||||
{ label: 'PNPM', value: 'pnpm' },
|
{ label: 'PNPM', value: 'pnpm' },
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import templates from './templates.json';
|
import templates from './templates.json';
|
||||||
import SearchableJson from '../_searchableJson.svelte';
|
import SearchableJson from '../searchableJson.svelte';
|
||||||
|
|
||||||
const categoryId = {
|
const categoryId = {
|
||||||
Sapper: 'sapper',
|
Sapper: 'sapper',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import tools from '../tools/tools.json';
|
import tools from '../tools/tools.json';
|
||||||
import SearchableJson from '../_searchableJson.svelte';
|
import SearchableJson from '../searchableJson.svelte';
|
||||||
|
|
||||||
const categoryId = {
|
const categoryId = {
|
||||||
'Bundler Plugins': 'bundling',
|
'Bundler Plugins': 'bundling',
|
||||||
|
|||||||
Reference in New Issue
Block a user