generated from dvcol/svelte-lib-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
178 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<script lang="ts"> | ||
import { debounce } from '@dvcol/common-utils/common/debounce'; | ||
import { getUUID } from '@dvcol/common-utils/common/string'; | ||
import { fade } from 'svelte/transition'; | ||
|
@@ -8,6 +9,8 @@ | |
import NeoButtonGroup from '~/buttons/NeoButtonGroup.svelte'; | ||
import NeoCard from '~/cards/NeoCard.svelte'; | ||
import IconAccount from '~/icons/IconAccount.svelte'; | ||
import IconAlignBottom from '~/icons/IconAlignBottom.svelte'; | ||
import IconAlignTop from '~/icons/IconAlignTop.svelte'; | ||
import IconCircleLoading from '~/icons/IconCircleLoading.svelte'; | ||
import NeoInput from '~/inputs/common/NeoInput.svelte'; | ||
import NeoList from '~/list/NeoList.svelte'; | ||
|
@@ -114,7 +117,6 @@ | |
{ label: 'John Doe', value: 'John', description: '[email protected]' }, | ||
{ label: 'Peter Jackson', value: 'Peter', description: '[email protected]' }, | ||
{ label: 'John Smith', value: 'Smith', description: '[email protected]' }, | ||
{ label: 'Jane Doe', value: 'Jane', description: '[email protected]' }, | ||
{ label: 'Alice Johnson', value: 'Alice', description: '[email protected]' }, | ||
{ label: 'Bob Brown', value: 'Bob', description: '[email protected]' }, | ||
{ label: 'Charlie Davis', value: 'Charlie', description: '[email protected]' }, | ||
|
@@ -126,12 +128,38 @@ | |
{ label: 'Ivy Johnson', value: 'Ivy', description: '[email protected]' }, | ||
{ label: 'Jack King', value: 'Jack', description: '[email protected]' }, | ||
{ label: 'Karen Lee', value: 'Karen', description: '[email protected]' }, | ||
{ | ||
label: 'Directors', | ||
divider: true, | ||
items: [ | ||
{ label: 'Denis VVilleneuve', value: 'Denis', description: '+33 1 25 48 45 45' }, | ||
{ label: 'Christopher Nolan', value: 'Christopher', description: '+44 2 07 94 60 95' }, | ||
{ label: 'Quentin Tarantino', value: 'Quentin', description: '+33 1 05 55 12 34' }, | ||
{ label: 'Martin Scorsese', value: 'Martin', description: '+33 1 25 55 56 78' }, | ||
{ label: 'Steven Spielberg', value: 'Steven', description: '+33 1 85 55 87 65' }, | ||
].map(item => ({ ...item, id: getUUID(), before: avatar })), | ||
}, | ||
{ | ||
label: 'Actors', | ||
divider: true, | ||
items: [ | ||
{ label: 'Leonardo DiCaprio', value: 'Leonardo', description: '+1 310 555 1234' }, | ||
{ label: 'Brad Pitt', value: 'Brad', description: '+1 323 555 5678' }, | ||
{ label: 'Meryl Streep', value: 'Meryl', description: '+1 212 555 8765' }, | ||
{ label: 'Tom Hanks', value: 'Tom', description: '+1 310 555 4321' }, | ||
{ label: 'Natalie Portman', value: 'Natalie', description: '+1 818 555 6789' }, | ||
].map(item => ({ ...item, id: getUUID(), before: avatar })), | ||
}, | ||
].map(item => ({ ...item, id: getUUID(), before: avatar })), | ||
); | ||
let hovered = $state(false); | ||
let focused = $state(false); | ||
let filter = $state(''); | ||
const setFilter = debounce((value: string) => { | ||
filter = value; | ||
}, 300); | ||
let sort = $state(false); | ||
const withComplexList = $derived(isEmpty ? [] : complexList); | ||
const onAdd = () => { | ||
|
@@ -175,7 +203,7 @@ | |
|
||
{#snippet renderSection(_children, _context)} | ||
<h2>Custom Section</h2> | ||
<h4>{_context?.section?.title}</h4> | ||
<h4>{_context?.section?.label}</h4> | ||
<ul> | ||
{@render _children(_context)} | ||
</ul> | ||
|
@@ -209,7 +237,7 @@ | |
<!-- multi line loader--> | ||
<div class="column content"> | ||
<span class="label">Multi-line loader</span> | ||
<NeoList {items} {...options} loaderProps={{ lines: 2, items: 10 }} /> | ||
<NeoList {items} {...options} loaderProps={{ lines: 2, items: 5 }} /> | ||
</div> | ||
|
||
<!-- custom loader--> | ||
|
@@ -283,7 +311,7 @@ | |
<span class="label">Custom section</span> | ||
<NeoList items={withCustomSection} {...options} {item}> | ||
{#snippet section(_children, _context)} | ||
<h2>{_context?.section?.title}</h2> | ||
<h2>{_context?.section?.label}</h2> | ||
<ul> | ||
{@render _children(_context)} | ||
</ul> | ||
|
@@ -317,17 +345,40 @@ | |
beforeProps: { width: '1.875rem', height: '1.875rem' }, | ||
}} | ||
buttonProps={{ rounded: true }} | ||
filter={i => i.label.toLowerCase().includes(filter.toLowerCase())} | ||
filter={i => | ||
i.items?.some(j => j.label.toLowerCase().includes(filter.toLowerCase())) || | ||
(i.label && i.label.toLowerCase().includes(filter.toLowerCase()))} | ||
sort={sort ? (a, b) => a.label.localeCompare(b.label) : (b, a) => a.label.localeCompare(b.label)} | ||
> | ||
{#snippet before(ctx)} | ||
<NeoInput | ||
placeholder="Placeholder" | ||
bind:value={filter} | ||
oninput={e => setFilter(e.target.value)} | ||
elevation={hovered || focused ? 1 : 0} | ||
hover="0" | ||
rounded | ||
containerProps={{ style: 'margin-bottom: 0' }} | ||
/> | ||
> | ||
{#snippet after()} | ||
<NeoButton | ||
text | ||
rounded | ||
shallow | ||
title="Sort alphabetically" | ||
onclick={() => { | ||
sort = !sort; | ||
}} | ||
> | ||
{#snippet icon()} | ||
{#if sort} | ||
<IconAlignTop /> | ||
{:else} | ||
<IconAlignBottom /> | ||
{/if} | ||
{/snippet} | ||
</NeoButton> | ||
{/snippet} | ||
</NeoInput> | ||
{@render values(ctx)} | ||
{/snippet} | ||
</NeoList> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={$$props.size ?? '1em'} | ||
height={$$props.size ?? '1em'} | ||
viewBox="0 0 24 24" | ||
{...$$props} | ||
style:scale={$$props.scale} | ||
scale={undefined} | ||
> | ||
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width={$$props.stroke ?? 2}> | ||
<path stroke-dasharray="20" stroke-dashoffset="20" d="M3 21l18 0"> | ||
<animate fill="freeze" attributeName="stroke-dashoffset" dur="0.2s" values="20;0" /> | ||
</path> | ||
<path stroke-dasharray="16" stroke-dashoffset="16" d="M12 3l0 13.5"> | ||
<animate fill="freeze" attributeName="stroke-dashoffset" begin="0.3s" dur="0.2s" values="16;0" /> | ||
</path> | ||
<path stroke-dasharray="8" stroke-dashoffset="8" d="M12 17l4 -4M12 17l-4 -4"> | ||
<animate fill="freeze" attributeName="stroke-dashoffset" begin="0.5s" dur="0.2s" values="8;0" /> | ||
</path> | ||
</g> | ||
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={$$props.size ?? '1em'} | ||
height={$$props.size ?? '1em'} | ||
viewBox="0 0 24 24" | ||
{...$$props} | ||
style:scale={$$props.scale} | ||
scale={undefined} | ||
> | ||
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width={$$props.stroke ?? 2}> | ||
<path stroke-dasharray="20" stroke-dashoffset="20" d="M3 3l18 0"> | ||
<animate fill="freeze" attributeName="stroke-dashoffset" dur="0.2s" values="20;0" /> | ||
</path> | ||
<path stroke-dasharray="16" stroke-dashoffset="16" d="M12 21l0 -13.5"> | ||
<animate fill="freeze" attributeName="stroke-dashoffset" begin="0.3s" dur="0.2s" values="16;0" /> | ||
</path> | ||
<path stroke-dasharray="8" stroke-dashoffset="8" d="M12 7l4 4M12 7l-4 4"> | ||
<animate fill="freeze" attributeName="stroke-dashoffset" begin="0.5s" dur="0.2s" values="8;0" /> | ||
</path> | ||
</g> | ||
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.