@nil-/doc 0.2.6 → 0.2.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @nil-/doc
2
2
 
3
+ ## 0.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 865eef0: Adjusted Container to allow collapsing (based on primary/secondary and double clicking the divider)
8
+
9
+ ## 0.2.7
10
+
11
+ ### Patch Changes
12
+
13
+ - a286896: Removed fonts to css
14
+ Moved common style to css files
15
+ Moved static in src
16
+ Moved Controls to its own component
17
+ Scoped styles by `nil-doc` prefix
18
+ Fixed css reset for Layout and Block
19
+ Allow filtering after renaming (url paths)
20
+ Added title to +layout.svelte
21
+ Updated layout documentation
22
+ Update dependencies
23
+
3
24
  ## 0.2.6
4
25
 
5
26
  ### Patch Changes
@@ -1,14 +1,12 @@
1
1
  <style>
2
- .wrapper {
3
- width: 100%;
4
- height: 100%;
5
- font-family: "Fira Code", "Courier New", Courier, monospace;
6
- }
2
+ @import "../styles/reset.css";
3
+ @import "../styles/scrollable.css";
7
4
 
8
- .wrapper {
9
- overflow: hidden;
10
- background-color: rgb(34, 36, 37);
5
+ .root {
6
+ width: 100%;
11
7
  color: rgb(201, 205, 207);
8
+ background-color: rgb(34, 36, 37);
9
+ font-family: "Fira Code", "Courier New", Courier, monospace;
12
10
  }
13
11
 
14
12
  .content {
@@ -17,34 +15,24 @@
17
15
  display: flex;
18
16
  flex-direction: column;
19
17
  }
20
-
21
- .scrollable {
22
- overflow: scroll;
23
- scrollbar-width: none; /* Firefox */
24
- -ms-overflow-style: none; /* IE and Edge */
25
- }
26
-
27
- .scrollable::-webkit-scrollbar {
28
- display: none;
29
- }
30
18
  </style>
31
19
 
32
20
  <script>import Container from "./etc/Container.svelte";
33
21
  import Nav from "./navigation/Nav.svelte";
34
- import Font from "./etc/Font.svelte";
22
+ import { inRoot } from "./context";
35
23
  export let data;
36
24
  export let current = null;
37
25
  export let sorter = null;
38
26
  export let renamer = null;
27
+ const r = inRoot();
39
28
  </script>
40
- <Font />
41
- <div class="wrapper">
29
+ <div class="root" class:nil-doc-reset={r}>
42
30
  <Container offset={250} padding={250} vertical>
43
31
  <svelte:fragment slot="a">
44
32
  <Nav
45
33
  info={data}
46
34
  selected={current ?? ""}
47
- sorter={sorter ?? ((l, r) => (l < r ? -1 : l > r ? +1 : 0))}
35
+ sorter={sorter ?? ((l, r) => (l === r ? 0 : l < r ? -1 : +1))}
48
36
  renamer={renamer ?? ((s) => s)}
49
37
  on:navigate
50
38
  >
@@ -52,7 +40,7 @@ export let renamer = null;
52
40
  </Nav>
53
41
  </svelte:fragment>
54
42
  <svelte:fragment slot="b">
55
- <div class="content scrollable">
43
+ <div class="content nil-doc-scrollable">
56
44
  {#key current}
57
45
  <slot name="content" />
58
46
  {/key}
@@ -1,18 +1,22 @@
1
1
  <script>import { initCurrent, initParams, initControls } from "./context";
2
+ import { inRoot } from "../context";
2
3
  initParams();
3
4
  initCurrent();
4
5
  initControls();
6
+ const r = inRoot();
5
7
  </script>
6
8
  <style>
9
+ @import "../../styles/reset.css";
10
+
7
11
  div {
8
- width: 100%;
9
12
  display: flex;
10
13
  flex-direction: column;
14
+ font-family: "Fira Code", "Courier New", Courier, monospace;
11
15
  }
12
16
  </style>
13
17
 
14
18
 
15
- <div>
19
+ <div class:nil-doc-reset={r}>
16
20
  <slot />
17
21
  </div>
18
22
 
@@ -1,4 +1,6 @@
1
1
  <style>
2
+ @import "../../styles/scrollable.css";
3
+
2
4
  .template {
3
5
  display: flex;
4
6
  flex-direction: column;
@@ -14,53 +16,30 @@
14
16
  }
15
17
 
16
18
  .content {
17
- padding: 10px;
19
+ padding: 3px;
18
20
  min-height: 100px;
19
21
  border-radius: 5px 5px 5px 5px;
20
- background-color: rgb(100, 96, 96);
21
- }
22
-
23
- .scrollable {
24
- width: 100%;
25
- overflow: scroll;
26
- scrollbar-width: none; /* Firefox */
27
- -ms-overflow-style: none; /* IE and Edge */
22
+ border: rgb(100, 96, 96) solid 1px;
23
+ background-color: rgb(33, 36, 37);
28
24
  }
29
25
 
30
- .scrollable::-webkit-scrollbar {
31
- display: none;
26
+ .content > :global(*) {
27
+ all: initial;
32
28
  }
33
29
 
34
30
  .misc {
35
- margin-top: 5px;
36
- padding: 5px;
37
- background-color: rgb(100, 96, 96);
31
+ margin-top: 2px;
32
+ outline: rgb(100, 96, 96) solid 1px;
38
33
  border-bottom-left-radius: 5px;
39
34
  border-bottom-right-radius: 5px;
40
35
  user-select: none;
41
36
  }
42
-
43
- .misc > .controls {
44
- width: 100%;
45
- display: grid;
46
- grid-template-columns: 1fr 200px 75px;
47
- grid-auto-rows: 1fr;
48
- }
49
-
50
- .misc > .controls > .header {
51
- text-align: center;
52
- }
53
37
  </style>
54
38
  <svelte:window on:click={() => ($current = null)} />
55
39
 
56
40
  <script>import { beforeUpdate } from "svelte";
57
41
  import { getParams, getCurrent, getControls } from "./context";
58
- import Text from "./controls/Text.svelte";
59
- import Number from "./controls/Number.svelte";
60
- import Range from "./controls/Range.svelte";
61
- import Switch from "./controls/Switch.svelte";
62
- import Select from "./controls/Select.svelte";
63
- import Font from "../etc/Font.svelte";
42
+ import Controls from "./controls/Component.svelte";
64
43
  import { slide } from "svelte/transition";
65
44
  const params = getParams();
66
45
  const current = getCurrent();
@@ -94,7 +73,6 @@ let hovered = null;
94
73
  let rerender = false;
95
74
  beforeUpdate(() => (rerender = !rerender));
96
75
  </script>
97
- <Font />
98
76
  <div class="template">
99
77
  {#each $params as { id, tag, values } (id)}
100
78
  <div
@@ -105,32 +83,13 @@ beforeUpdate(() => (rerender = !rerender));
105
83
  on:keypress={null}
106
84
  >
107
85
  {#key rerender}
108
- <div class="content scrollable">
86
+ <div class="content nil-doc-scrollable">
109
87
  <slot {tag} props={resolve(defaults, values)} />
110
88
  </div>
111
89
  {/key}
112
90
  {#if $controls.length > 0 && ($current === id || hovered === id)}
113
- <div class="misc scrollable" transition:slide>
114
- <div class="controls">
115
- <div class="header">Name</div>
116
- <div class="header">Value</div>
117
- <div class="header">In Use</div>
118
- {#each $controls as info}
119
- {@const type = info.type}
120
- {@const name = info.name}
121
- {#if type === "text"}
122
- <Text {info} bind:value={values[name]} />
123
- {:else if type === "number"}
124
- <Number {info} bind:value={values[name]} />
125
- {:else if type === "range"}
126
- <Range {info} bind:value={values[name]} />
127
- {:else if type === "select"}
128
- <Select {info} bind:value={values[name]} />
129
- {:else if type === "switch"}
130
- <Switch {info} bind:value={values[name]} />
131
- {/if}
132
- {/each}
133
- </div>
91
+ <div class="misc nil-doc-scrollable" transition:slide>
92
+ <Controls infos={$controls} bind:values />
134
93
  </div>
135
94
  {/if}
136
95
  </div>
@@ -0,0 +1,71 @@
1
+ <style>
2
+ .controls {
3
+ width: 100%;
4
+ display: grid;
5
+ grid-auto-rows: 1fr;
6
+ }
7
+
8
+ .header {
9
+ text-align: center;
10
+ }
11
+
12
+ .row {
13
+ width: 100%;
14
+ display: grid;
15
+ padding: 2px 0px;
16
+ grid-template-columns: 1fr 200px 75px;
17
+ background-color: hsl(205, 50%, 5%);
18
+ }
19
+
20
+ .row:nth-child(even) {
21
+ background-color: hsl(205, 15%, 15%);
22
+ }
23
+
24
+ .row > :global(div:nth-child(1)) {
25
+ padding-left: 10px;
26
+ }
27
+
28
+ .row > :global(div) {
29
+ display: grid;
30
+ align-items: center;
31
+ }
32
+
33
+ .row > :global(div > *) {
34
+ width: 100%;
35
+ height: 100%;
36
+ }
37
+ </style>
38
+
39
+ <script>import Text from "./Text.svelte";
40
+ import Number from "./Number.svelte";
41
+ import Range from "./Range.svelte";
42
+ import Switch from "./Switch.svelte";
43
+ import Select from "./Select.svelte";
44
+ export let infos;
45
+ export let values;
46
+ </script>
47
+ <div class="controls">
48
+ <div class="row">
49
+ <div class="header">Name</div>
50
+ <div class="header">Value</div>
51
+ <div class="header">Use</div>
52
+ </div>
53
+ {#each infos as info}
54
+ {@const type = info.type}
55
+ {@const name = info.name}
56
+ <div class="row">
57
+ {#if type === "text"}
58
+ <Text {info} bind:value={values[name]} />
59
+ {:else if type === "number"}
60
+ <Number {info} bind:value={values[name]} />
61
+ {:else if type === "range"}
62
+ <Range {info} bind:value={values[name]} />
63
+ {:else if type === "select"}
64
+ <Select {info} bind:value={values[name]} />
65
+ {:else if type === "switch"}
66
+ <Switch {info} bind:value={values[name]} />
67
+ {/if}
68
+ </div>
69
+ {/each}
70
+ </div>
71
+
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Control } from "./types";
3
+ import type { ParamValues } from "../context";
4
+ declare const __propDef: {
5
+ props: {
6
+ infos: Control[];
7
+ values: ParamValues;
8
+ };
9
+ events: {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {};
13
+ };
14
+ export type ComponentProps = typeof __propDef.props;
15
+ export type ComponentEvents = typeof __propDef.events;
16
+ export type ComponentSlots = typeof __propDef.slots;
17
+ export default class Component extends SvelteComponentTyped<ComponentProps, ComponentEvents, ComponentSlots> {
18
+ }
19
+ export {};
@@ -5,6 +5,6 @@ let ivalue = value ?? 0;
5
5
  let enabled = value !== undefined;
6
6
  $: value = enabled ? ivalue : undefined;
7
7
  </script>
8
- <span>{info.name}</span>
9
- <input type="number" bind:value={ivalue} disabled={!enabled} />
10
- <input type="checkbox" bind:checked={enabled} />
8
+ <div>{info.name}</div>
9
+ <div><input type="number" bind:value={ivalue} disabled={!enabled} /></div>
10
+ <div><input type="checkbox" bind:checked={enabled} /></div>
@@ -1,11 +1,11 @@
1
1
  <style>
2
- div {
2
+ .input {
3
3
  width: 100%;
4
4
  display: grid;
5
5
  grid-template-columns: 40px 1fr;
6
6
  }
7
7
 
8
- div > span {
8
+ .input > span {
9
9
  text-align: center;
10
10
  }
11
11
  </style>
@@ -16,8 +16,8 @@ let ivalue = value ?? info.min;
16
16
  let enabled = value !== undefined;
17
17
  $: value = enabled ? ivalue : undefined;
18
18
  </script>
19
- <span>{info.name}</span>
20
- <div>
19
+ <div>{info.name}</div>
20
+ <div class="input">
21
21
  <span>{ivalue}</span>
22
22
  <input
23
23
  type="range"
@@ -28,5 +28,5 @@ $: value = enabled ? ivalue : undefined;
28
28
  disabled={!enabled}
29
29
  />
30
30
  </div>
31
- <input type="checkbox" bind:checked={enabled} />
31
+ <div><input type="checkbox" bind:checked={enabled} /></div>
32
32
 
@@ -5,10 +5,12 @@ let ivalue = value ?? (info.values.length > 0 ? info.values[0] : undefined);
5
5
  let enabled = value !== undefined;
6
6
  $: value = enabled ? ivalue : undefined;
7
7
  </script>
8
- <span>{info.name}</span>
9
- <select bind:value={ivalue} disabled={!enabled}>
10
- {#each info.values as value}
11
- <option {value}>{value}</option>
12
- {/each}
13
- </select>
14
- <input type="checkbox" bind:checked={enabled} />
8
+ <div>{info.name}</div>
9
+ <div>
10
+ <select bind:value={ivalue} disabled={!enabled}>
11
+ {#each info.values as value}
12
+ <option {value}>{value}</option>
13
+ {/each}
14
+ </select>
15
+ </div>
16
+ <div><input type="checkbox" bind:checked={enabled} /></div>
@@ -5,6 +5,6 @@ let ivalue = value ?? false;
5
5
  let enabled = value !== undefined;
6
6
  $: value = enabled ? ivalue : undefined;
7
7
  </script>
8
- <span>{info.name}</span>
9
- <input type="checkbox" bind:checked={ivalue} disabled={!enabled} />
10
- <input type="checkbox" bind:checked={enabled} />
8
+ <div>{info.name}</div>
9
+ <div><input type="checkbox" bind:checked={ivalue} disabled={!enabled} /></div>
10
+ <div><input type="checkbox" bind:checked={enabled} /></div>
@@ -5,6 +5,6 @@ let ivalue = value ?? "";
5
5
  let enabled = value !== undefined;
6
6
  $: value = enabled ? ivalue : undefined;
7
7
  </script>
8
- <span>{info.name}</span>
9
- <input type="text" bind:value={ivalue} disabled={!enabled} />
10
- <input type="checkbox" bind:checked={enabled} />
8
+ <div>{info.name}</div>
9
+ <div><input type="text" bind:value={ivalue} disabled={!enabled} /></div>
10
+ <div><input type="checkbox" bind:checked={enabled} /></div>
@@ -0,0 +1 @@
1
+ export declare function inRoot(): boolean;
@@ -0,0 +1,7 @@
1
+ import { setContext, getContext } from "svelte";
2
+ const root = Symbol();
3
+ export function inRoot() {
4
+ const value = getContext(root);
5
+ setContext(root, false);
6
+ return value !== false;
7
+ }
@@ -1,5 +1,5 @@
1
1
  <style>
2
- .root {
2
+ .container {
3
3
  display: flex;
4
4
  position: relative;
5
5
  width: 100%;
@@ -20,8 +20,8 @@
20
20
  user-select: none;
21
21
  }
22
22
 
23
- .root > div {
24
- outline: white solid 1px;
23
+ .container > div {
24
+ outline: rgb(100, 96, 96) solid 1px;
25
25
  }
26
26
  </style>
27
27
 
@@ -40,6 +40,7 @@ export let thickness = 10;
40
40
  export let padding = 0;
41
41
  let width;
42
42
  let height;
43
+ let collapse = false;
43
44
  const { position, draggable } = createDraggable(offset);
44
45
  function update(w, h, limit, value) {
45
46
  if (w == null || h == null) {
@@ -49,11 +50,11 @@ function update(w, h, limit, value) {
49
50
  offset = Math.max(Math.min(value, span - limit), limit);
50
51
  }
51
52
  $: update(width, height, padding, $position);
52
- $: offsetpx = `${offset}px`;
53
+ $: offsetpx = collapse ? "10px" : `${offset}px`;
53
54
  $: thicknesspx = `${thickness}px`;
54
55
  </script>
55
56
  <div
56
- class="root"
57
+ class="container"
57
58
  bind:clientHeight={height}
58
59
  bind:clientWidth={width}
59
60
  style:flex-direction={vertical ? "row" : "column"}
@@ -62,14 +63,12 @@ $: thicknesspx = `${thickness}px`;
62
63
  <div
63
64
  class:primary={!reversed}
64
65
  class:secondary={reversed}
65
- style:min-height={!vertical ? `${padding}px` : null}
66
- style:max-height={!vertical ? `${height - padding}px` : null}
67
- style:min-width={vertical ? `${padding}px` : null}
68
- style:max-width={vertical ? `${width - padding}px` : null}
69
66
  style:width={!reversed && vertical ? offsetpx : null}
70
67
  style:height={!reversed && !vertical ? offsetpx : null}
71
68
  >
72
- <slot name="a" />
69
+ {#if !collapse || reversed}
70
+ <slot name="a" />
71
+ {/if}
73
72
  </div>
74
73
  <div
75
74
  class="divider"
@@ -83,19 +82,18 @@ $: thicknesspx = `${thickness}px`;
83
82
  style:cursor={vertical ? "col-resize" : "row-resize"}
84
83
  style:transform={vertical ? "translateX(-50%)" : "translateY(-50%)"}
85
84
  use:draggable={{ reset: () => offset, reversed, vertical }}
85
+ on:dblclick={() => (collapse = !collapse)}
86
86
  />
87
87
  </div>
88
88
  <div
89
89
  class:primary={reversed}
90
90
  class:secondary={!reversed}
91
- style:min-height={!vertical ? `${padding}px` : null}
92
- style:max-height={!vertical ? `${height - padding}px` : null}
93
- style:min-width={vertical ? `${padding}px` : null}
94
- style:max-width={vertical ? `${width - padding}px` : null}
95
91
  style:width={reversed && vertical ? offsetpx : null}
96
92
  style:height={reversed && !vertical ? offsetpx : null}
97
93
  >
98
- <slot name="b" />
94
+ {#if !collapse || !reversed}
95
+ <slot name="b" />
96
+ {/if}
99
97
  </div>
100
98
  {/if}
101
99
  </div>
@@ -24,6 +24,7 @@ export const createDraggable = (offset) => {
24
24
  div.addEventListener("mousedown", engage);
25
25
  document.addEventListener("mouseup", disengage);
26
26
  document.addEventListener("mousemove", move);
27
+ document.addEventListener("dblclick", disengage);
27
28
  return {
28
29
  update: (parameter) => {
29
30
  if (param.reversed !== parameter.reversed ||
@@ -31,12 +32,12 @@ export const createDraggable = (offset) => {
31
32
  moving = false;
32
33
  }
33
34
  param = parameter;
34
- position.set(param.reset());
35
35
  },
36
36
  destroy: () => {
37
37
  div.removeEventListener("mousedown", engage);
38
38
  document.removeEventListener("mouseup", disengage);
39
39
  document.removeEventListener("mousemove", move);
40
+ document.removeEventListener("dblclick", disengage);
40
41
  }
41
42
  };
42
43
  }
@@ -1,5 +1,5 @@
1
1
  <style>
2
- .root {
2
+ .nav {
3
3
  gap: 10px;
4
4
  padding-top: 20px;
5
5
  display: flex;
@@ -18,8 +18,7 @@
18
18
  }
19
19
  </style>
20
20
 
21
- <script context="module">"use strict";
22
- function apply(paths, init, pre, next, post) {
21
+ <script context="module">function apply(paths, init, pre, next, post) {
23
22
  const retval = {};
24
23
  for (const path of paths) {
25
24
  const parts = path.split("/");
@@ -45,6 +44,15 @@ function apply(paths, init, pre, next, post) {
45
44
  }
46
45
  return retval;
47
46
  }
47
+ function filt(path, filter, renamer) {
48
+ return path.includes(filter) || path.split("/").map(renamer).join("/").includes(filter);
49
+ }
50
+ function populate(filter, info, renamer) {
51
+ return apply(filter.length > 0 ? info.filter((path) => filt(path, filter, renamer)) : info, () => ({ url: null, sub: {} }), (t) => t, (t) => t.sub, (t, p) => {
52
+ t.url = p;
53
+ });
54
+ }
55
+ export {};
48
56
  </script>
49
57
  <script>import Tree from "./Tree.svelte";
50
58
  export let info;
@@ -53,20 +61,15 @@ export let sorter;
53
61
  export let renamer;
54
62
  let filter = "";
55
63
  let states = apply(info, () => ({ expanded: false, sub: {} }), (t, path) => ({ expanded: t.expanded || selected === path, sub: t.sub }), (t) => t.sub);
56
- function populate(f, i) {
57
- return apply(f.length > 0 ? i.filter((d) => d.includes(f)) : i, () => ({ url: null, sub: {} }), (t) => t, (t) => t.sub, (t, p) => {
58
- t.url = p;
59
- });
60
- }
61
64
  </script>
62
- <div class="root">
65
+ <div class="nav">
63
66
  <div class="logo"><slot /></div>
64
67
  <div class="search-bar">
65
68
  <input bind:value={filter} type="text" />
66
69
  </div>
67
70
  <div class="tree">
68
71
  <Tree
69
- tree={populate(filter, info)}
72
+ tree={populate(filter, info, renamer)}
70
73
  {selected}
71
74
  {sorter}
72
75
  {renamer}
@@ -38,6 +38,7 @@
38
38
 
39
39
  .header.selected {
40
40
  background-color: rgba(2, 157, 253, 0.822);
41
+ color: black;
41
42
  }
42
43
  </style>
43
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nil-/doc",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "author": {
5
5
  "email": "njaldea@gmail.com",
6
6
  "name": "Neil Aldea"
@@ -0,0 +1,19 @@
1
+ @font-face {
2
+ font-family: "Fira Code";
3
+ src: url("https://fonts.googleapis.com/css?family=Fira Code");
4
+ }
5
+
6
+ .nil-doc-reset {
7
+ width: 100%;
8
+ height: 100%;
9
+ box-sizing: border-box;
10
+ font-family: "Fira Code", "Courier New", Courier, monospace;
11
+ }
12
+
13
+ .nil-doc-reset *,
14
+ .nil-doc-reset *::before,
15
+ .nil-doc-reset *::after {
16
+ box-sizing: inherit;
17
+ padding: 0px;
18
+ margin: 0px;
19
+ }
@@ -0,0 +1,9 @@
1
+ .nil-doc-scrollable {
2
+ overflow: scroll;
3
+ scrollbar-width: none; /* Firefox */
4
+ -ms-overflow-style: none; /* IE and Edge */
5
+ }
6
+
7
+ .nil-doc-scrollable::-webkit-scrollbar {
8
+ display: none;
9
+ }