@nil-/doc 0.2.29 → 0.2.31

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,21 @@
1
1
  # @nil-/doc
2
2
 
3
+ ## 0.2.31
4
+
5
+ ### Patch Changes
6
+
7
+ - [doc] better container style ([#45](https://github.com/njaldea/mono/pull/45))
8
+
9
+ - [doc] improved ThemeIcon ([#45](https://github.com/njaldea/mono/pull/45))
10
+
11
+ ## 0.2.30
12
+
13
+ ### Patch Changes
14
+
15
+ - [doc] Added color transition in Layout ([#43](https://github.com/njaldea/mono/pull/43))
16
+
17
+ - [doc] added Instance component ([#43](https://github.com/njaldea/mono/pull/43))
18
+
3
19
  ## 0.2.29
4
20
 
5
21
  ### Patch Changes
@@ -49,6 +49,7 @@
49
49
 
50
50
  /* colors */
51
51
  .layout {
52
+ transition: color 350ms, background-color 350ms;
52
53
  background-color: hsl(0, 0%, 100%);
53
54
  color: hsl(0, 100%, 0%);
54
55
  color-scheme: light;
@@ -89,7 +90,7 @@ $:
89
90
  <slot name="title"><span>@nil-/doc</span></slot>
90
91
  <ThemeIcon bind:dark={$isDark} />
91
92
  </div>
92
- <Container offset={250} padding={250} vertical secondary>
93
+ <Container offset={250} vertical secondary>
93
94
  <svelte:fragment slot="primary">
94
95
  <div class="content scrollable">
95
96
  <Nav
@@ -0,0 +1,11 @@
1
+
2
+ <script>import Template from "./Template.svelte";
3
+ import Params from "./Params.svelte";
4
+ export let defaults = void 0;
5
+ export let noreset = false;
6
+ const cast = (t) => t;
7
+ </script>
8
+ <Template {defaults} {noreset} let:props let:key>
9
+ <slot props={cast(props)} {key} />
10
+ </Template>
11
+ <Params />
@@ -0,0 +1,22 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare class __sveltets_Render<Args> {
3
+ props(): {
4
+ defaults?: Args | undefined;
5
+ noreset?: boolean | undefined;
6
+ };
7
+ events(): {} & {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots(): {
11
+ default: {
12
+ props: Args;
13
+ key: boolean;
14
+ };
15
+ };
16
+ }
17
+ export type InstanceProps<Args> = ReturnType<__sveltets_Render<Args>['props']>;
18
+ export type InstanceEvents<Args> = ReturnType<__sveltets_Render<Args>['events']>;
19
+ export type InstanceSlots<Args> = ReturnType<__sveltets_Render<Args>['slots']>;
20
+ export default class Instance<Args> extends SvelteComponentTyped<InstanceProps<Args>, InstanceEvents<Args>, InstanceSlots<Args>> {
21
+ }
22
+ export {};
@@ -1,4 +1,8 @@
1
1
  <style>
2
+ div {
3
+ box-sizing: border-box;
4
+ }
5
+
2
6
  .container {
3
7
  width: 100%;
4
8
  height: 100%;
@@ -20,110 +24,156 @@
20
24
  overflow: hidden;
21
25
  }
22
26
 
23
- /* need higher specificity than above */
24
27
  .container > .divider {
25
28
  z-index: 10;
26
- width: auto;
27
- height: 0px;
28
29
  overflow: visible;
29
30
  user-select: none;
30
31
  grid-area: divider;
31
32
  }
32
33
 
33
- .container > .divider.vertical {
34
- width: 0px;
35
- height: auto;
34
+ .overlay {
35
+ touch-action: none;
36
36
  }
37
37
 
38
38
  .container > .divider > .overlay {
39
39
  width: 100%;
40
40
  height: 20px;
41
- cursor: row-resize;
41
+ cursor: ns-resize;
42
42
  transform: translateY(-50%);
43
- touch-action: none;
44
43
  }
45
44
 
46
- .container > .divider.vertical > .overlay {
45
+ .container.vertical > .divider > .overlay {
47
46
  width: 20px;
48
47
  height: 100%;
49
- cursor: col-resize;
48
+ cursor: ew-resize;
50
49
  transform: translateX(-50%);
51
50
  }
52
51
 
53
52
  /* colors */
54
- .container > .divider {
55
- outline: hsl(0, 2%, 70%) solid 1px;
53
+ .container {
54
+ --color-p: hsl(0, 2%, 70%);
55
+ --color-s: hsl(0, 0%, 0%);
56
+ }
57
+
58
+ .container.dark {
59
+ --color-p: hsl(0, 2%, 38%);
60
+ --color-s: hsl(0, 0%, 100%);
61
+ }
62
+
63
+ .container:not(.vertical) > .divider {
64
+ border-bottom: var(--color-p) solid 2.5px;
65
+ border-top: var(--color-p) solid 2.5px;
66
+ background-color: var(--color-p);
67
+ }
68
+
69
+ .container.vertical > .divider {
70
+ border-right: var(--color-p) solid 2.5px;
71
+ border-left: var(--color-p) solid 2.5px;
72
+ background-color: var(--color-p);
56
73
  }
57
74
 
58
- .container > .divider.moving {
59
- outline: hsl(0, 0%, 0%) solid 1px;
75
+ .container.moving:not(.secondary):not(.vertical) > .divider {
76
+ border-bottom: var(--color-s) solid 2.5px;
60
77
  }
61
78
 
62
- .container.dark > .divider {
63
- outline: hsl(0, 2%, 38%) solid 1px;
79
+ .container.moving.secondary:not(.vertical) > .divider {
80
+ border-top: var(--color-s) solid 2.5px;
64
81
  }
65
82
 
66
- .container.dark > .divider.moving {
67
- outline: hsl(0, 0%, 100%) solid 1px;
83
+ .container.moving:not(.secondary).vertical > .divider {
84
+ border-right: var(--color-s) solid 2.5px;
85
+ }
86
+
87
+ .container.moving.vertical.secondary > .divider {
88
+ border-left: var(--color-s) solid 2.5px;
68
89
  }
69
90
  </style>
70
91
 
71
92
  <script>import { writable } from "svelte/store";
93
+ import { tweened } from "svelte/motion";
72
94
  import { createDraggable } from "./action";
73
95
  import { getTheme } from "../context";
74
96
  const isDark = getTheme();
75
97
  export let vertical = false;
76
98
  export let offset = 0;
77
99
  export let secondary = false;
78
- export let padding = 0;
79
100
  let width;
80
101
  let height;
81
- let collapse = false;
82
102
  const { position, draggable } = createDraggable(offset);
83
- function update(w, h, limit, value) {
84
- if (w == null || h == null || collapse) {
103
+ $:
104
+ span = vertical ? width : height;
105
+ function update(limit, value) {
106
+ if (span == null) {
85
107
  return;
86
108
  }
87
- const span = vertical ? w : h;
88
109
  offset = Math.max(Math.min(value, span - limit), limit);
89
110
  }
111
+ const off = tweened(offset, { duration: 50 });
112
+ let last = [];
90
113
  $:
91
- update(width, height, padding, $position);
114
+ update(10, $position);
92
115
  $:
93
- offsetpx = collapse ? "10px" : `${offset}px`;
116
+ $off = offset;
94
117
  $:
95
- style = !secondary ? `auto 0px ${offsetpx}` : `${offsetpx} 0px auto`;
118
+ style = !secondary ? `auto 5px ${$off}px` : `${$off}px 5px auto`;
96
119
  const moving = writable(false);
120
+ function addLast(v) {
121
+ if (v > 10) {
122
+ if (last.length < 2) {
123
+ last = [...last, v];
124
+ } else {
125
+ last = [last[1], v];
126
+ }
127
+ }
128
+ }
129
+ function dbltap() {
130
+ if ($off > 10) {
131
+ addLast(offset);
132
+ offset = 10;
133
+ } else if (last.length > 0) {
134
+ offset = last.pop();
135
+ }
136
+ }
137
+ function check(v, flag, s) {
138
+ if (flag) {
139
+ return v < s - 10;
140
+ } else {
141
+ return v > 10;
142
+ }
143
+ }
97
144
  </script>
98
145
  <div
99
146
  class="container"
100
147
  class:vertical
148
+ class:secondary
101
149
  class:dark={$isDark}
102
- bind:clientHeight={height}
150
+ class:moving={$moving}
103
151
  bind:clientWidth={width}
152
+ bind:clientHeight={height}
104
153
  style:grid-template-columns={vertical ? style : null}
105
154
  style:grid-template-rows={!vertical ? style : null}
106
155
  >
107
156
  {#if width != null && height != null}
108
157
  <div style:grid-area="primary">
109
- {#if !collapse || !secondary}
158
+ {#if check($off, !secondary, span)}
110
159
  <slot name="primary" />
111
160
  {/if}
112
161
  </div>
113
- <div class="divider" class:vertical class:moving={$moving}>
162
+ <div class="divider">
114
163
  <div
115
164
  class="overlay"
116
165
  use:draggable={{
117
166
  reset: () => offset,
118
167
  reversed: !secondary,
119
168
  vertical,
120
- dbltap: () => (collapse = !collapse),
169
+ dbltap: dbltap,
170
+ tap: () => addLast($off),
121
171
  moving
122
172
  }}
123
173
  />
124
174
  </div>
125
175
  <div style:grid-area="secondary">
126
- {#if !collapse || secondary}
176
+ {#if check($off, secondary, span)}
127
177
  <slot name="secondary" />
128
178
  {/if}
129
179
  </div>
@@ -4,7 +4,6 @@ declare const __propDef: {
4
4
  vertical?: boolean | undefined;
5
5
  offset?: number | undefined;
6
6
  secondary?: boolean | undefined;
7
- padding?: number | undefined;
8
7
  };
9
8
  events: {
10
9
  [evt: string]: CustomEvent<any>;
@@ -1,69 +1,76 @@
1
- <script context="module">let indexer = 0;
2
- </script>
3
- <script>export let dark = true;
4
- import { spring } from "svelte/motion";
5
- function iter() {
6
- dark = !dark;
7
- }
8
- const rotate = spring(dark ? 90 : 40);
9
- const mcx = spring(dark ? 30 : 12);
10
- const mcy = spring(dark ? 0 : 4);
11
- const cr = spring(dark ? 5 : 9);
12
- const opacity = spring(dark ? 0 : 1);
13
- $:
14
- rotate.set(dark ? 90 : 40);
15
- $:
16
- mcx.set(dark ? 30 : 12);
17
- $:
18
- mcy.set(dark ? 0 : 4);
1
+ <script>import { tweened } from "svelte/motion";
2
+ import { elasticOut } from "svelte/easing";
3
+ export let dark = true;
4
+ const values = tweened(dark ? vdark : vlight, { duration: 1e3, easing: elasticOut });
19
5
  $:
20
- cr.set(dark ? 5 : 9);
21
- $:
22
- opacity.set(dark ? 1 : 0);
6
+ $values = dark ? vdark : vlight;
23
7
  const index = indexer++;
24
8
  </script>
25
9
  <style>
26
10
  svg {
27
- all: unset;
28
- width: 50%;
29
- height: 50%;
30
- fill: none;
11
+ cursor: pointer;
12
+ fill: currentColor;
31
13
  stroke: currentColor;
14
+
15
+ -webkit-tap-highlight-color: transparent;
16
+ -moz-tap-highlight-color: transparent;
17
+ -o-tap-highlight-color: transparent;
18
+ tap-highlight-color: transparent;
19
+ }
20
+
21
+ svg,
22
+ rect {
23
+ width: 100%;
24
+ height: 100%;
25
+ }
26
+
27
+ line {
32
28
  stroke-width: 2;
33
29
  stroke-linecap: round;
34
30
  stroke-linejoin: round;
35
- cursor: pointer;
36
- color: black;
37
- margin: auto;
38
- }
39
-
40
- svg.dark {
41
- color: white;
42
31
  }
43
32
  </style>
44
33
 
45
-
34
+ <script context="module">let indexer = 0;
35
+ const vlight = {
36
+ rotate: 40,
37
+ mcy: -8,
38
+ cr: 10,
39
+ v: 0
40
+ };
41
+ const vdark = {
42
+ rotate: 180,
43
+ mcy: -24,
44
+ cr: 5,
45
+ v: 1
46
+ };
47
+ </script>
46
48
  <svg
47
- on:click={iter}
48
- on:keypress={null}
49
- viewBox="0 0 24 24"
50
49
  class:dark
51
- style={`transform: rotate(${$rotate}deg)`}
50
+ viewBox="-25 -25 50 50"
51
+ transform={`rotate(${$values.rotate})`}
52
+ style={`color: hsl(0, 0%, ${$values.v * 100}%);`}
53
+ on:click={() => (dark = !dark)}
54
+ on:keypress={null}
52
55
  >
53
- <mask id={`theme_icon_${index}`}>
54
- <rect x="0" y="0" width="100%" height="100%" fill="white" />
55
- <circle cx={$mcx} cy={$mcy} r="9" fill="currentColor" />
56
+ <mask id={`nil_doc_theme_icon_${index}`}>
57
+ <rect x="-25" y="-25" fill="white" />
58
+ <circle cy={$values.mcy} r="11" />
56
59
  </mask>
57
- <circle cx="12" cy="12" r={$cr} fill="currentColor" mask={`url(#theme_icon_${index})`} />
58
- <g style={`opacity: ${$opacity}`}>
59
- <line x1="12" y1="1" x2="12" y2="3" />
60
- <line x1="12" y1="21" x2="12" y2="23" />
61
- <line x1="4.22" y1="4.22" x2="5.64" y2="5.64" />
62
- <line x1="18.36" y1="18.36" x2="19.78" y2="19.78" />
63
- <line x1="1" y1="12" x2="3" y2="12" />
64
- <line x1="21" y1="12" x2="23" y2="12" />
65
- <line x1="4.22" y1="19.78" x2="5.64" y2="18.36" />
66
- <line x1="18.36" y1="5.64" x2="19.78" y2="4.22" />
60
+ <circle r={$values.cr} mask={`url(#nil_doc_theme_icon_${index})`} />
61
+ <g style={`opacity: ${$values.v}`}>
62
+ <g>
63
+ <line x1="0" y1="9" x2="0" y2="11" />
64
+ <line x1="9" y1="0" x2="11" y2="0" />
65
+ <line x1="0" y1="-11" x2="0" y2="-9" />
66
+ <line x1="-11" y1="0" x2="-9" y2="0" />
67
+ </g>
68
+ <g transform="rotate(45)">
69
+ <line x1="0" y1="9" x2="0" y2="11" />
70
+ <line x1="9" y1="0" x2="11" y2="0" />
71
+ <line x1="0" y1="-11" x2="0" y2="-9" />
72
+ <line x1="-11" y1="0" x2="-9" y2="0" />
73
+ </g>
67
74
  </g>
68
75
  </svg>
69
76
 
@@ -5,6 +5,7 @@ type Parameter = {
5
5
  vertical: boolean;
6
6
  reversed: boolean;
7
7
  dbltap?: () => void;
8
+ tap?: () => void;
8
9
  moving: Writable<boolean>;
9
10
  };
10
11
  type Return = {
@@ -24,6 +24,7 @@ export const createDraggable = (offset) => {
24
24
  param.moving.set(true);
25
25
  position.set(param.reset());
26
26
  current_page = param.vertical ? e.pageX : e.pageY;
27
+ param?.tap?.();
27
28
  }
28
29
  function move(e) {
29
30
  if (get(param.moving)) {
@@ -3,7 +3,6 @@
3
3
  width: 100%;
4
4
  height: 100%;
5
5
  gap: 10px;
6
- padding-top: 20px;
7
6
  display: flex;
8
7
  flex-direction: column;
9
8
  }
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { renamer, sorter } from "./components/navigation/utils";
2
2
  export type { Control } from "./components/block/controls/types";
3
3
  export { default as Layout } from "./components/Layout.svelte";
4
+ export { default as Instance } from "./components/block/Instance.svelte";
4
5
  export { default as Block } from "./components/block/Block.svelte";
5
6
  export { default as Template } from "./components/block/Template.svelte";
6
7
  export { default as Controls } from "./components/block/Controls.svelte";
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { renamer, sorter } from "./components/navigation/utils";
2
2
  export { default as Layout } from "./components/Layout.svelte";
3
+ export { default as Instance } from "./components/block/Instance.svelte";
3
4
  export { default as Block } from "./components/block/Block.svelte";
4
5
  export { default as Template } from "./components/block/Template.svelte";
5
6
  export { default as Controls } from "./components/block/Controls.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nil-/doc",
3
- "version": "0.2.29",
3
+ "version": "0.2.31",
4
4
  "author": {
5
5
  "email": "njaldea@gmail.com",
6
6
  "name": "Neil Aldea"