mirror of
https://github.com/LukeHagar/sveltesociety.dev.git
synced 2025-12-10 04:21:49 +00:00
Cleanup NPM data to display
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export const primary = false;
|
export const primary = false;
|
||||||
export let active = false;
|
export let active = false;
|
||||||
|
export let small = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -14,6 +15,10 @@
|
|||||||
padding: 5px 15px;
|
padding: 5px 15px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
div.small {
|
||||||
|
font-size: 0.8em;
|
||||||
|
padding: 3px 10px;
|
||||||
|
}
|
||||||
div:hover {
|
div:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-color: var(--color) !important;
|
border-color: var(--color) !important;
|
||||||
@@ -37,8 +42,8 @@
|
|||||||
.popin {
|
.popin {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: calc(100% - 1rem);
|
left: calc(100% - 1em);
|
||||||
top: 1rem;
|
top: 1em;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -59,7 +64,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div on:click>
|
<div on:click class:small>
|
||||||
<span>
|
<span>
|
||||||
<slot />
|
<slot />
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
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 copyToClipboard = (text) => {
|
const copyToClipboard = (text) => {
|
||||||
@@ -20,6 +21,16 @@
|
|||||||
})
|
})
|
||||||
.catch(() => alert('Clipboard copy Permission denied'));
|
.catch(() => alert('Clipboard copy Permission denied'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const packageManagers = {
|
||||||
|
'npm': "npm install",
|
||||||
|
"pnpm": "pnpm add",
|
||||||
|
"yarn": "yarn add"
|
||||||
|
}
|
||||||
|
|
||||||
|
const cleanupNpm = (npm) => {
|
||||||
|
return npm.replace('https://www.npmjs.com/package/', '')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -76,7 +87,7 @@
|
|||||||
<div class="card" class:active id="component-{escape(title)}">
|
<div class="card" class:active id="component-{escape(title)}">
|
||||||
<h3>
|
<h3>
|
||||||
<a href="#component-{escape(title)}">#</a> <a href={url}>{title}</a>
|
<a href="#component-{escape(title)}">#</a> <a href={url}>{title}</a>
|
||||||
{#if npm}<Tag click={() => copyToClipboard(`npm install ${npm}`)} variant="copy" title={clipboardCopy ? 'copied!' : `npm install ${npm}`}/>{/if}
|
{#if npm}<Tag click={() => copyToClipboard(`${packageManagers[manager]}l ${cleanupNpm(npm)}`)} variant="copy" title={clipboardCopy ? 'copied!' : `${packageManagers[manager]} ${cleanupNpm(npm)}`}/>{/if}
|
||||||
</h3>
|
</h3>
|
||||||
<p class="flex-grow">{description}</p>
|
<p class="flex-grow">{description}</p>
|
||||||
<div class="card__tags">
|
<div class="card__tags">
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
let filterTag = []
|
let filterTag = []
|
||||||
let filterCategory = null
|
let filterCategory = null
|
||||||
let sorting = 'added_desc';
|
let sorting = 'added_desc';
|
||||||
|
let packageManager = 'npm'
|
||||||
|
|
||||||
const intersection = (array1, array2) => {
|
const intersection = (array1, array2) => {
|
||||||
return array1.filter(item => array2.includes(item))
|
return array1.filter(item => array2.includes(item))
|
||||||
@@ -203,6 +204,14 @@
|
|||||||
<li><label><input type="radio" bind:group={sorting} value="name_desc"> Name Desc</label></li>
|
<li><label><input type="radio" bind:group={sorting} value="name_desc"> Name Desc</label></li>
|
||||||
</ul>
|
</ul>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button small active={packageManager !== ''}>
|
||||||
|
Package Manager
|
||||||
|
<ul slot="menu" role="menu" class="popin no-wrap">
|
||||||
|
<li><label><input type="radio" bind:group={packageManager} value="npm"> NPM</label></li>
|
||||||
|
<li><label><input type="radio" bind:group={packageManager} value="pnpm"> PNPM</label></li>
|
||||||
|
<li><label><input type="radio" bind:group={packageManager} value="yarn"> Yarn</label></li>
|
||||||
|
</ul>
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
@@ -216,7 +225,7 @@
|
|||||||
{#each categories as category}
|
{#each categories as category}
|
||||||
<List title={category||"Unclassified"}>
|
<List title={category||"Unclassified"}>
|
||||||
{#each dataToDisplay.filter(d => d.category === category) as data}
|
{#each dataToDisplay.filter(d => d.category === category) as data}
|
||||||
<ComponentCard {...data} />
|
<ComponentCard {...data} manager={packageManager} />
|
||||||
{/each}
|
{/each}
|
||||||
</List>
|
</List>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in New Issue
Block a user