bref-ui 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**[Live Demo](https://feuersteiner.github.io/bref/)**
|
|
4
4
|
|
|
5
|
-
Bref is a Svelte UI component library designed to be minimal, flexible, and easy to use. It uses Svelte's built-in scoped CSS for styling
|
|
5
|
+
Bref is a Svelte UI component library designed to be minimal, flexible, and easy to use. It uses Svelte's built-in scoped CSS for styling, no external CSS frameworks required.
|
|
6
6
|
|
|
7
7
|
## What We Promise
|
|
8
8
|
|
|
@@ -32,7 +32,7 @@ npm install bref-ui
|
|
|
32
32
|
|
|
33
33
|
## Why Bref?
|
|
34
34
|
|
|
35
|
-
- **Scoped CSS**: Uses Svelte's built-in scoped styling
|
|
35
|
+
- **Scoped CSS**: Uses Svelte's built-in scoped styling, each component's styles are encapsulated and won't leak or conflict.
|
|
36
36
|
- **Minimal**: Only essential components, nothing extra.
|
|
37
37
|
- **Flexible**: Use as an npm package or copy components directly into your project with our CLI tool (WIP).
|
|
38
38
|
- **Batteries included theming**: Just provide your base colors and we handle the rest (see below).
|
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
import type { TreeNodeProps } from './types.js';
|
|
3
3
|
import Icon from '../icon/icon.svelte';
|
|
4
4
|
import TreeNode from './tree-node.svelte';
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
node,
|
|
7
|
+
level,
|
|
8
|
+
size,
|
|
9
|
+
onSelect,
|
|
10
|
+
selectedIds,
|
|
11
|
+
filledIcon,
|
|
12
|
+
wide,
|
|
13
|
+
expandOnSelect
|
|
14
|
+
}: TreeNodeProps = $props();
|
|
6
15
|
|
|
7
16
|
let expanded: boolean = $state(false);
|
|
8
17
|
let selected: boolean = $derived(selectedIds?.has(node.id) ?? false);
|
|
@@ -14,7 +23,12 @@
|
|
|
14
23
|
if (hasChildren) expanded = !expanded;
|
|
15
24
|
};
|
|
16
25
|
|
|
17
|
-
const handleSelect = () =>
|
|
26
|
+
const handleSelect = () => {
|
|
27
|
+
onSelect(node.id);
|
|
28
|
+
if (expandOnSelect && hasChildren) expanded = true;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const nextLevel = $derived(level + 1);
|
|
18
32
|
</script>
|
|
19
33
|
|
|
20
34
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
@@ -48,7 +62,16 @@
|
|
|
48
62
|
|
|
49
63
|
{#if expanded && hasChildren}
|
|
50
64
|
{#each node.children as child (child.id)}
|
|
51
|
-
<TreeNode
|
|
65
|
+
<TreeNode
|
|
66
|
+
node={child}
|
|
67
|
+
level={nextLevel}
|
|
68
|
+
{size}
|
|
69
|
+
{onSelect}
|
|
70
|
+
{selectedIds}
|
|
71
|
+
{filledIcon}
|
|
72
|
+
{wide}
|
|
73
|
+
{expandOnSelect}
|
|
74
|
+
/>
|
|
52
75
|
{/each}
|
|
53
76
|
{/if}
|
|
54
77
|
|
|
@@ -2,12 +2,29 @@
|
|
|
2
2
|
import type { TreeViewProps } from './types.js';
|
|
3
3
|
import TreeNode from './tree-node.svelte';
|
|
4
4
|
|
|
5
|
-
let {
|
|
5
|
+
let {
|
|
6
|
+
data,
|
|
7
|
+
size = 'medium',
|
|
8
|
+
onSelect,
|
|
9
|
+
selectedIds,
|
|
10
|
+
wide,
|
|
11
|
+
filledIcon,
|
|
12
|
+
expandOnSelect
|
|
13
|
+
}: TreeViewProps = $props();
|
|
6
14
|
</script>
|
|
7
15
|
|
|
8
16
|
<div role="tree" class={size} class:wide>
|
|
9
17
|
{#each data as node (node.id)}
|
|
10
|
-
<TreeNode
|
|
18
|
+
<TreeNode
|
|
19
|
+
{node}
|
|
20
|
+
level={0}
|
|
21
|
+
{size}
|
|
22
|
+
{onSelect}
|
|
23
|
+
{selectedIds}
|
|
24
|
+
{wide}
|
|
25
|
+
{filledIcon}
|
|
26
|
+
{expandOnSelect}
|
|
27
|
+
/>
|
|
11
28
|
{/each}
|
|
12
29
|
</div>
|
|
13
30
|
|
|
@@ -24,7 +24,14 @@
|
|
|
24
24
|
<div class="container">
|
|
25
25
|
<Logo />
|
|
26
26
|
<div class="content">
|
|
27
|
-
<TreeView
|
|
27
|
+
<TreeView
|
|
28
|
+
wide
|
|
29
|
+
size="small"
|
|
30
|
+
{selectedIds}
|
|
31
|
+
{onSelect}
|
|
32
|
+
data={PAGES.map(pageToNode)}
|
|
33
|
+
expandOnSelect
|
|
34
|
+
/>
|
|
28
35
|
</div>
|
|
29
36
|
<Footer />
|
|
30
37
|
</div>
|