@nil-/doc 0.3.0 → 0.3.2
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/components/Base.svelte +6 -3
- package/components/block/Block.svelte +1 -1
- package/components/block/Instance.svelte +21 -6
- package/components/block/controls/Controls.svelte +52 -16
- package/components/block/controls/Controls.svelte.d.ts +4 -1
- package/components/block/controls/props/Color.svelte +1 -1
- package/components/block/controls/props/Props.svelte +0 -1
- package/components/block/controls/props/Range.svelte +4 -0
- package/components/block/icons/ControlView.svelte +2 -4
- package/components/block/icons/ControlView.svelte.d.ts +1 -1
- package/components/layout/Container.svelte +4 -3
- package/components/layout/Container.svelte.d.ts +1 -0
- package/components/layout/Layout.svelte +30 -4
- package/components/layout/Layout.svelte.d.ts +1 -0
- package/components/navigation/Node.svelte +2 -1
- package/package.json +1 -1
- package/sveltekit/index.d.ts +1 -0
- package/sveltekit/index.js +5 -1
package/components/Base.svelte
CHANGED
|
@@ -26,7 +26,6 @@ export let fill = false;
|
|
|
26
26
|
|
|
27
27
|
--i-nil-doc-block-bg-color: var(--nil-doc-block-bg-color, hsla(0, 0%, 98%, 0.3));
|
|
28
28
|
--i-nil-doc-block-outline-color: var(--nil-doc-block-outline-color, hsla(0, 0%, 0%, 0.3));
|
|
29
|
-
--i-nil-doc-instance-selected-color: var(--nil-doc-instance-selected-color, hsla(203, 98%, 50%, 0.85));
|
|
30
29
|
|
|
31
30
|
--i-nil-doc-container-p: var(--nil-doc-container-p, hsl(0, 2%, 70%));
|
|
32
31
|
--i-nil-doc-container-s: var(--nil-doc-container-s, hsl(0, 0%, 0%));
|
|
@@ -55,10 +54,14 @@ export let fill = false;
|
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
div {
|
|
58
|
-
--i-nil-doc-nav-hovered: var(--nil-doc-nav-hovered, hsla(203, 98%, 50%, 0.
|
|
59
|
-
--i-nil-doc-nav-page-hovered: var(--nil-doc-nav-page-hovered, hsla(203, 98%, 50%, 0.
|
|
57
|
+
--i-nil-doc-nav-hovered: var(--nil-doc-nav-hovered, hsla(203, 98%, 50%, 0.25));
|
|
58
|
+
--i-nil-doc-nav-page-hovered: var(--nil-doc-nav-page-hovered, hsla(203, 98%, 50%, 0.6));
|
|
60
59
|
--i-nil-doc-nav-selected: var(--nil-doc-nav-selected, hsla(203, 98%, 50%, 0.85));
|
|
61
60
|
|
|
61
|
+
--i-nil-doc-instance-hovered: var(--nil-doc-instance-hovered, hsla(203, 98%, 50%, 0.25));
|
|
62
|
+
--i-nil-doc-instance-control-hovered: var(--nil-doc-instance-control-hovered, hsla(203, 98%, 50%, 0.6));
|
|
63
|
+
--i-nil-doc-instance-selected-color: var(--nil-doc-instance-selected-color, hsla(203, 98%, 50%, 0.85));
|
|
64
|
+
|
|
62
65
|
--i-nil-doc-transition-time: var(--nil-doc-transition-time, 350ms);
|
|
63
66
|
}
|
|
64
67
|
</style>
|
|
@@ -43,16 +43,16 @@ const populate = (ext) => {
|
|
|
43
43
|
obj[name] = (ev) => {
|
|
44
44
|
const detail = stringify(ev.detail);
|
|
45
45
|
if ($values.events.length > 0) {
|
|
46
|
-
const last = $values.events[
|
|
46
|
+
const last = $values.events[0];
|
|
47
47
|
if (last.name === name && last.detail === detail && last.count < 99) {
|
|
48
48
|
last.count += 1;
|
|
49
49
|
$values.events = $values.events;
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
$values.events.
|
|
54
|
-
if ($values.events.length >
|
|
55
|
-
$values.events.
|
|
53
|
+
$values.events.unshift({ name, detail, count: 1 });
|
|
54
|
+
if ($values.events.length > 50) {
|
|
55
|
+
$values.events.pop();
|
|
56
56
|
}
|
|
57
57
|
$values.events = $values.events;
|
|
58
58
|
};
|
|
@@ -67,7 +67,13 @@ const populate = (ext) => {
|
|
|
67
67
|
See [documentation](https://mono-doc.vercel.app/3-Components/2-Block/1-Content/1-Instance) for more details.
|
|
68
68
|
-->
|
|
69
69
|
|
|
70
|
-
<div
|
|
70
|
+
<div
|
|
71
|
+
class="instance"
|
|
72
|
+
class:selected={$vv === values}
|
|
73
|
+
class:controls={$controls.events.length > 0 || $controls.props.length > 0}
|
|
74
|
+
on:click={focus}
|
|
75
|
+
on:keypress={null}
|
|
76
|
+
>
|
|
71
77
|
<div class="content">
|
|
72
78
|
{#if noreset}
|
|
73
79
|
<slot
|
|
@@ -109,7 +115,16 @@ const populate = (ext) => {
|
|
|
109
115
|
box-sizing: border-box;
|
|
110
116
|
}
|
|
111
117
|
|
|
112
|
-
.instance
|
|
118
|
+
.instance:hover {
|
|
119
|
+
border-color: var(--i-nil-doc-instance-hovered);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.instance.controls:hover {
|
|
123
|
+
border-color: var(--i-nil-doc-instance-control-hovered);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.instance.selected,
|
|
127
|
+
.instance.selected:hover {
|
|
113
128
|
border-color: var(--i-nil-doc-instance-selected-color);
|
|
114
129
|
}
|
|
115
130
|
</style>
|
|
@@ -2,42 +2,78 @@
|
|
|
2
2
|
import Props from "./props/Props.svelte";
|
|
3
3
|
import Events from "./events/Events.svelte";
|
|
4
4
|
import { getControlInfo, getControlValue } from "../context";
|
|
5
|
+
import Button from "../icons/Button.svelte";
|
|
6
|
+
import ControlView from "../icons/ControlView.svelte";
|
|
7
|
+
import Position from "../icons/Position.svelte";
|
|
5
8
|
const controls = getControlInfo();
|
|
6
9
|
const values = getControlValue();
|
|
7
10
|
$:
|
|
8
11
|
cc = $controls;
|
|
9
12
|
$:
|
|
10
13
|
vv = $values;
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export let mode = "props";
|
|
15
|
+
export let position = "bottom";
|
|
16
|
+
const cyclePosition = () => {
|
|
17
|
+
switch (position) {
|
|
18
|
+
case "bottom":
|
|
19
|
+
position = "right";
|
|
20
|
+
break;
|
|
21
|
+
case "right":
|
|
22
|
+
position = "bottom";
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const cycleMode = () => {
|
|
27
|
+
switch (mode) {
|
|
28
|
+
case "events":
|
|
29
|
+
mode = "props";
|
|
30
|
+
break;
|
|
31
|
+
case "props":
|
|
32
|
+
mode = "events";
|
|
33
|
+
break;
|
|
17
34
|
}
|
|
18
35
|
};
|
|
19
36
|
</script>
|
|
20
37
|
|
|
21
|
-
<Styler type={
|
|
22
|
-
|
|
23
|
-
<div
|
|
38
|
+
<Styler type={mode}>
|
|
39
|
+
<div class="header">
|
|
40
|
+
<div class="buttons">
|
|
41
|
+
<Button scale on:click={cyclePosition} title={position}>
|
|
42
|
+
<Position {position} />
|
|
43
|
+
</Button>
|
|
44
|
+
<Button scale on:click={cycleMode} title={mode}>
|
|
45
|
+
<ControlView {mode} />
|
|
46
|
+
</Button>
|
|
47
|
+
</div>
|
|
48
|
+
{#if mode === "props"}
|
|
24
49
|
<div>Name</div>
|
|
25
50
|
<div>Value</div>
|
|
26
51
|
<div>Use</div>
|
|
27
|
-
|
|
28
|
-
{:else if style === "events"}
|
|
29
|
-
<div on:dblclick={cycle} on:keypress={null}>
|
|
52
|
+
{:else if mode === "events"}
|
|
30
53
|
<div>Events</div>
|
|
31
54
|
<div>Detail</div>
|
|
32
|
-
|
|
33
|
-
|
|
55
|
+
{/if}
|
|
56
|
+
</div>
|
|
34
57
|
{#key $values && $controls}
|
|
35
58
|
{#if cc != null && $cc != null && vv != null && $vv != null}
|
|
36
|
-
<Props infos={$cc.props} visible={
|
|
37
|
-
<Events events={$vv.events} visible={
|
|
59
|
+
<Props infos={$cc.props} visible={mode === "props"} bind:values={$vv.props} />
|
|
60
|
+
<Events events={$vv.events} visible={mode === "events"} />
|
|
38
61
|
{/if}
|
|
39
62
|
{/key}
|
|
40
63
|
</Styler>
|
|
41
64
|
|
|
42
65
|
<style>
|
|
66
|
+
.header {
|
|
67
|
+
position: relative;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.buttons {
|
|
71
|
+
position: absolute;
|
|
72
|
+
width: 3.5rem;
|
|
73
|
+
height: 1.75rem;
|
|
74
|
+
left: 0.3rem;
|
|
75
|
+
top: 0.15rem;
|
|
76
|
+
display: flex;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
}
|
|
43
79
|
</style>
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
<script>export let mode = "prop";
|
|
1
|
+
<script>export let mode = "props";
|
|
4
2
|
</script>
|
|
5
3
|
|
|
6
4
|
<svg viewBox="-50 -50 100 100">
|
|
7
5
|
<rect width="60" height="60" x="-30" y="-30" fill="transparent" />
|
|
8
6
|
<rect
|
|
9
|
-
x={mode === "
|
|
7
|
+
x={mode === "props" ? 0 : -20}
|
|
10
8
|
class="mv"
|
|
11
9
|
height="40"
|
|
12
10
|
width="20"
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { tweened } from "svelte/motion";
|
|
3
3
|
import { createDraggable } from "./action";
|
|
4
4
|
export let vertical = false;
|
|
5
|
-
export let offset =
|
|
5
|
+
export let offset = 4;
|
|
6
6
|
export let b = false;
|
|
7
|
+
export let persistent = false;
|
|
7
8
|
let width;
|
|
8
9
|
let height;
|
|
9
10
|
const { position, draggable } = createDraggable(offset);
|
|
@@ -65,7 +66,7 @@ const check = (v, flag, s) => {
|
|
|
65
66
|
>
|
|
66
67
|
{#if width != null && height != null}
|
|
67
68
|
<div style:grid-area="A">
|
|
68
|
-
{#if check($off, !b, span)}
|
|
69
|
+
{#if persistent || check($off, !b, span)}
|
|
69
70
|
<slot name="A" />
|
|
70
71
|
{/if}
|
|
71
72
|
</div>
|
|
@@ -84,7 +85,7 @@ const check = (v, flag, s) => {
|
|
|
84
85
|
/>
|
|
85
86
|
</div>
|
|
86
87
|
<div style:grid-area="B">
|
|
87
|
-
{#if check($off, b, span)}
|
|
88
|
+
{#if persistent || check($off, b, span)}
|
|
88
89
|
<slot name="B" />
|
|
89
90
|
{/if}
|
|
90
91
|
</div>
|
|
@@ -10,21 +10,47 @@ import Scrollable from "./Scrollable.svelte";
|
|
|
10
10
|
import VerticalPanel from "./VerticalPanel.svelte";
|
|
11
11
|
import Nav from "../navigation/Nav.svelte";
|
|
12
12
|
import Icon from "./icons/Icon.svelte";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
initControlInfo,
|
|
15
|
+
initControlValue
|
|
16
|
+
} from "../block/context";
|
|
14
17
|
import { getTheme, initTheme } from "../context";
|
|
15
18
|
import ThemeIcon from "./icons/Theme.svelte";
|
|
19
|
+
import { get } from "svelte/store";
|
|
16
20
|
export let data;
|
|
17
21
|
export let current = null;
|
|
18
22
|
export let sorter = null;
|
|
19
23
|
export let renamer = null;
|
|
20
24
|
export let theme = void 0;
|
|
21
25
|
export let offset = 250;
|
|
22
|
-
|
|
26
|
+
export let panel = "bottom";
|
|
27
|
+
let mode = "props";
|
|
28
|
+
let panelOffset = 4;
|
|
23
29
|
initControlValue();
|
|
30
|
+
const activeControl = initControlInfo();
|
|
24
31
|
const parentTheme = getTheme();
|
|
25
32
|
const dark = initTheme();
|
|
26
33
|
$:
|
|
27
34
|
$dark = theme === void 0 ? $parentTheme : "dark" === theme;
|
|
35
|
+
const panelChange = (info) => {
|
|
36
|
+
if (info != null) {
|
|
37
|
+
const i = get(info);
|
|
38
|
+
if (i != null && panelOffset == 4) {
|
|
39
|
+
if (i.props.length > 0) {
|
|
40
|
+
panelOffset = 250;
|
|
41
|
+
mode = "props";
|
|
42
|
+
return;
|
|
43
|
+
} else if (i.events.length > 0) {
|
|
44
|
+
panelOffset = 250;
|
|
45
|
+
mode = "events";
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
panelOffset = 4;
|
|
51
|
+
};
|
|
52
|
+
$:
|
|
53
|
+
panelChange($activeControl);
|
|
28
54
|
const toggle = () => {
|
|
29
55
|
if (theme !== void 0) {
|
|
30
56
|
theme = $dark ? "light" : "dark";
|
|
@@ -66,7 +92,7 @@ const toggle = () => {
|
|
|
66
92
|
</Scrollable>
|
|
67
93
|
</svelte:fragment>
|
|
68
94
|
<svelte:fragment slot="B">
|
|
69
|
-
<Container offset={
|
|
95
|
+
<Container vertical={panel === "right"} persistent bind:offset={panelOffset}>
|
|
70
96
|
<svelte:fragment slot="A">
|
|
71
97
|
<Scrollable>
|
|
72
98
|
<Content>
|
|
@@ -77,7 +103,7 @@ const toggle = () => {
|
|
|
77
103
|
</Scrollable>
|
|
78
104
|
</svelte:fragment>
|
|
79
105
|
<svelte:fragment slot="B">
|
|
80
|
-
<Controls />
|
|
106
|
+
<Controls bind:position={panel} bind:mode />
|
|
81
107
|
</svelte:fragment>
|
|
82
108
|
</Container>
|
|
83
109
|
</svelte:fragment>
|
package/package.json
CHANGED
package/sveltekit/index.d.ts
CHANGED
package/sveltekit/index.js
CHANGED
|
@@ -22,6 +22,8 @@ export const sveltekit = (detail, prefix = null) => {
|
|
|
22
22
|
const theme = browser && "light" === localStorage.getItem(keyTheme) ? "light" : "dark";
|
|
23
23
|
const keyOffset = "@nil-/doc/offset";
|
|
24
24
|
const offset = browser ? parseFloat(localStorage.getItem(keyOffset) ?? "250") : 250;
|
|
25
|
+
const keyPos = "@nil-/doc/panel";
|
|
26
|
+
const panelPos = browser ? localStorage.getItem(keyPos) ?? "bottom" : "bottom";
|
|
25
27
|
const result = {
|
|
26
28
|
data: Object.keys(detail)
|
|
27
29
|
.map(toRoute)
|
|
@@ -39,9 +41,11 @@ export const sveltekit = (detail, prefix = null) => {
|
|
|
39
41
|
}),
|
|
40
42
|
navigate: prefix ? (e) => goto(`${prefix}${e.detail}`) : (e) => goto(e.detail),
|
|
41
43
|
theme: writable(theme),
|
|
42
|
-
offset: writable(offset)
|
|
44
|
+
offset: writable(offset),
|
|
45
|
+
panel: writable(panelPos)
|
|
43
46
|
};
|
|
44
47
|
browser && result.theme.subscribe((v) => localStorage.setItem(keyTheme, v));
|
|
45
48
|
browser && result.offset.subscribe((v) => localStorage.setItem(keyOffset, `${v}`));
|
|
49
|
+
browser && result.panel.subscribe((v) => localStorage.setItem(keyPos, v));
|
|
46
50
|
return result;
|
|
47
51
|
};
|