Skip to content

Commit

Permalink
feat(list): first draft for lists
Browse files Browse the repository at this point in the history
  • Loading branch information
dvcol committed Jan 26, 2025
1 parent 9d69d2a commit 8750c6f
Show file tree
Hide file tree
Showing 13 changed files with 540 additions and 86 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ See examples in the demo (code [here](https://github.com/dvcol/neo-svelte/tree/f
## TODO
- [ ] @media any-pointer:coarse any-hover:none
- [x] Buttons
- [x] toggle
- [x] groups
- [x] Tabs
- [x] Card
- [x] Inputs
Expand Down Expand Up @@ -78,6 +80,7 @@ See examples in the demo (code [here](https://github.com/dvcol/neo-svelte/tree/f
- [x] custom before-after
- [x] steps
- [ ] vertical
- [ ] rating (stars)
- [x] select
- [x] native
- [ ] custom
Expand All @@ -87,6 +90,19 @@ See examples in the demo (code [here](https://github.com/dvcol/neo-svelte/tree/f
- [ ] nested menus

- [ ] list
- [ ] snippets
- [ ] children
- [ ] header
- [ ] footer
- [ ] select
- [ ] multiple
- [ ] disabled
- [ ] readonly
- [ ] header (pills or item count)
- [ ] separator
- [ ] label (sections
- [ ] keyboard navigation
- [ ] scroll shadow
- [ ] virtualized
- [ ] infinite scroll
- [ ] drag & drop
Expand All @@ -98,6 +114,27 @@ See examples in the demo (code [here](https://github.com/dvcol/neo-svelte/tree/f
- [ ] select
- [ ] tree

- [ ] Chat
- [ ] infinite scroll
- [ ] virtual scroll
- [ ] async
- [ ] stream
- [ ] generative text animation
- [ ] scroll to bottom
- [ ] typing indicator
- [ ] read indicator
- [ ] reactions
- [ ] threads
- [ ] @ / # tags
- [ ] mentions
- [ ] attachments
- [ ] gifs/images
- [ ] videos
- [ ] audio
- [ ] custom cards (contact, etc.)
- [ ] custom bubbles
- [ ] custom input

- [ ] Modal/dialog
- [ ] drawer/panel
- [ ] collapsible
Expand Down
10 changes: 9 additions & 1 deletion demo/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@
in: fade,
out: fade,
params: { in: { delay: 200, duration: 200 }, out: { duration: 200 } },
props: { container: { style: 'display: flex; justify-content: center; align-items: center;' } },
props: {
container: {
style: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
},
},
},
skipFirst: true,
};
Expand Down
121 changes: 121 additions & 0 deletions demo/components/DemoLists.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<script lang="ts">
import { fade } from 'svelte/transition';
import type { NeoListItem, NeoListProps } from '~/list/neo-list.model.js';
import NeoButton from '~/buttons/NeoButton.svelte';
import NeoButtonGroup from '~/buttons/NeoButtonGroup.svelte';
import NeoCard from '~/cards/NeoCard.svelte';
import IconCircleLoading from '~/icons/IconCircleLoading.svelte';
import NeoList from '~/list/NeoList.svelte';
import { Colors } from '~/utils/colors.utils';
import { enterTransitionProps } from '~/utils/transition.utils';
const options = $state<NeoListProps>({
loading: false,
skeleton: false,
});
const list: NeoListItem[] = $state([
{ value: 'Line item label 1' },
{ value: 'Line item with longer label 2' },
{ value: 'Line item error', color: Colors.Error },
{ value: 'Line item warning', color: Colors.Warning },
{ value: 'Line item success', color: Colors.Success },
{ value: 'Line item primary', color: Colors.Primary },
{ value: 'Line item secondary', color: Colors.Secondary },
]);
let isEmpty = $state(false);
const items = $derived(isEmpty ? [] : list);
</script>

<div class="row">
<NeoButtonGroup rounded={options.rounded}>
<NeoButton toggle bind:checked={isEmpty}>Empty</NeoButton>
<NeoButton toggle bind:checked={options.loading}>Loading</NeoButton>
<NeoButton toggle bind:checked={options.skeleton}>Skeleton</NeoButton>
</NeoButtonGroup>
</div>

<div class="row">
<div class="column content">
<span class="label">List</span>
<NeoCard spacing="1rem" elevation="0">
<NeoList {items} {...options} />
</NeoCard>
</div>
<div class="column content">
<span class="label">Custom loader</span>
<NeoList {items} {...options}>
{#snippet loader()}
<div class="custom-list-loader">
<IconCircleLoading size="2rem" />
</div>
{/snippet}
</NeoList>
</div>
<div class="column content">
<span class="label">Custom Empty</span>
<NeoList {items} {...options}>
{#snippet empty()}
<div class="custom-list-loader" in:fade={enterTransitionProps}>
<span> Custom empty snippet</span>
</div>
{/snippet}
</NeoList>
</div>

<!-- custom item-->

<!-- custom empty-->

<!-- buttons item -->

<!-- tooltip item (menu drawer) -->

<!-- select items -->

<!-- multi select items -->

<!-- search items -->

<!-- custom filter snippet -->
</div>

<style lang="scss">
@use 'src/lib/styles/common/flex' as flex;
.label {
max-width: 80vw;
white-space: pre-line;
word-break: break-all;
}
.custom-list-loader {
display: flex;
justify-content: center;
padding: 0.5rem;
}
.neo-tooltip-content {
@include flex.column($center: true, $gap: var(--neo-gap-xxs));
}
.column {
@include flex.column($center: true, $gap: var(--neo-gap-lg), $flex: 0 1 auto);
&.content {
flex: 1 0 20%;
min-width: fit-content;
max-width: min(25%, 50rem);
}
}
.row {
@include flex.row($center: true, $gap: var(--neo-gap-xl), $flex: 0 1 auto);
min-width: 80vw;
margin: 2rem 0;
}
</style>
7 changes: 7 additions & 0 deletions demo/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const Route = {
Skeleton: 'skeleton' as const,
Inputs: 'inputs' as const,
Tooltips: 'tooltips' as const,
Lists: 'lists' as const,
} as const;

export type Routes = (typeof Route)[keyof typeof Route];
Expand All @@ -25,6 +26,7 @@ export const Path: Record<keyof typeof Route, string> = {
Skeleton: '/skeleton' as const,
Inputs: '/inputs' as const,
Tooltips: '/tooltips' as const,
Lists: '/lists' as const,
Any: '*' as const,
} as const;

Expand Down Expand Up @@ -79,6 +81,11 @@ export const options: RouterOptions<Routes> = {
path: Path.Tooltips,
component: () => import('../components/DemoTooltips.svelte'),
},
{
name: Route.Lists,
path: Path.Lists,
component: () => import('../components/DemoLists.svelte'),
},
{
name: Route.Any,
path: Path.Any,
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@
"svelte": ">=5"
},
"dependencies": {
"@dvcol/common-utils": "^1.20.0",
"@dvcol/common-utils": "^1.21.2",
"@dvcol/svelte-utils": "^1.6.1",
"@skeletonlabs/floating-ui-svelte": "^0.3.9",
"svelte": "^5.19.0"
"svelte": "^5.19.3"
},
"devDependencies": {
"@commitlint/cli": "^19.4.1",
"@commitlint/config-conventional": "^19.4.1",
"@dvcol/eslint-plugin-presets": "^1.3.11",
"@dvcol/stylelint-plugin-presets": "^2.1.2",
"@dvcol/svelte-simple-router": "^1.10.0",
"@dvcol/svelte-simple-router": "^1.10.1",
"@sveltejs/adapter-auto": "^4.0.0",
"@sveltejs/kit": "^2.16.0",
"@sveltejs/package": "^2.3.7",
Expand Down Expand Up @@ -162,7 +162,7 @@
"sass": "^1.83.4",
"standard-version": "^9.5.0",
"stylelint": "^16.9.0",
"svelte-check": "^4.1.1",
"svelte-check": "^4.1.4",
"svelte-preprocess": "^6.0.3",
"typescript": "^5.5.4",
"vite": "^6.0.7",
Expand Down
Loading

0 comments on commit 8750c6f

Please sign in to comment.