@nil-/doc 0.2.33 → 0.2.35

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.35
4
+
5
+ ### Patch Changes
6
+
7
+ - [doc] changed Control "side" flag to "position" prop ([#53](https://github.com/njaldea/mono/pull/53))
8
+
9
+ - [misc] added nil icon ([#53](https://github.com/njaldea/mono/pull/53))
10
+
11
+ ## 0.2.34
12
+
13
+ ### Patch Changes
14
+
15
+ - [doc][new] added Control hide property ([#51](https://github.com/njaldea/mono/pull/51))
16
+ [doc][break] renamed Control expand property to hide
17
+ [doc][break] Control now defaults to show
18
+
3
19
  ## 0.2.33
4
20
 
5
21
  ### Patch Changes
@@ -12,10 +12,10 @@
12
12
 
13
13
  .top {
14
14
  display: grid;
15
- grid-template-columns: 1fr 40px;
15
+ grid-template-columns: 1fr 40px 40px;
16
16
  align-items: center;
17
- padding-left: 20px;
18
- padding-right: 20px;
17
+ padding-left: 10px;
18
+ padding-right: 10px;
19
19
  box-sizing: border-box;
20
20
  user-select: none;
21
21
  }
@@ -76,6 +76,7 @@
76
76
  import Nav from "./navigation/Nav.svelte";
77
77
  import { inRoot, getTheme, initTheme, evalTheme } from "./context";
78
78
  import ThemeIcon from "./etc/ThemeIcon.svelte";
79
+ import NilIcon from "./etc/NilIcon.svelte";
79
80
  export let data;
80
81
  export let current = null;
81
82
  export let sorter = null;
@@ -91,6 +92,7 @@ $:
91
92
  <div class="top">
92
93
  <slot name="title"><span>@nil-/doc</span></slot>
93
94
  <ThemeIcon bind:dark={$isDark} />
95
+ <NilIcon />
94
96
  </div>
95
97
  <Container offset={250} vertical secondary>
96
98
  <svelte:fragment slot="primary">
@@ -27,16 +27,9 @@
27
27
  }
28
28
  </style>
29
29
 
30
- <script>import {
31
- initParams,
32
- initCurrent,
33
- initDefaults,
34
- initControls,
35
- initControlsState
36
- } from "./context";
30
+ <script>import { initParams, initDefaults, initControls, initControlsState } from "./context";
37
31
  import { inRoot, getTheme, initTheme, evalTheme } from "../context";
38
32
  initParams();
39
- initCurrent();
40
33
  initDefaults();
41
34
  initControls();
42
35
  initControlsState();
@@ -1,10 +1,13 @@
1
1
 
2
2
  <script>import { getControls, getControlsState } from "./context";
3
3
  export let props = [];
4
- export let expand = false;
4
+ export let hide = false;
5
+ export let position = void 0;
5
6
  const controls = getControls();
6
7
  $controls = props;
7
8
  const state = getControlsState();
8
9
  $:
9
- $state.expand = expand;
10
+ $state.hide = hide;
11
+ $:
12
+ $state.position = position;
10
13
  </script>
@@ -3,7 +3,8 @@ import type { Control } from "./controls/types";
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  props?: Control[] | undefined;
6
- expand?: boolean | undefined;
6
+ hide?: boolean | undefined;
7
+ position?: undefined | "bottom" | "right";
7
8
  };
8
9
  events: {
9
10
  [evt: string]: CustomEvent<any>;
@@ -4,9 +4,6 @@
4
4
  gap: 5px;
5
5
  padding-bottom: 10px;
6
6
  padding-top: 10px;
7
- }
8
-
9
- .template:not(.column) {
10
7
  grid-auto-rows: 1fr;
11
8
  grid-auto-columns: auto;
12
9
  grid-auto-flow: row;
@@ -18,17 +15,28 @@
18
15
  grid-auto-flow: column;
19
16
  }
20
17
 
18
+ .template > .cside {
19
+ display: grid;
20
+ grid-template-columns: 1fr 550px;
21
+ }
22
+
21
23
  .content {
22
24
  min-height: 100px;
23
25
  border-radius: 5px 5px 5px 5px;
24
26
  }
25
27
 
26
- .misc {
28
+ div:not(.cside) > .misc {
27
29
  border-bottom-left-radius: 5px;
28
30
  border-bottom-right-radius: 5px;
29
31
  user-select: none;
30
32
  }
31
33
 
34
+ .template > .cside > .misc {
35
+ border-top-right-radius: 5px;
36
+ border-bottom-right-radius: 5px;
37
+ user-select: none;
38
+ }
39
+
32
40
  .template > div > div {
33
41
  margin: 3px;
34
42
  }
@@ -63,17 +71,15 @@
63
71
  outline: hsl(0, 2%, 40%) solid 1px;
64
72
  }
65
73
  </style>
66
- <svelte:window on:click={() => ($current = null)} />
67
74
 
68
- <script>import { getParams, getCurrent, getDefaults } from "./context";
75
+ <script>import { getParams, getDefaults } from "./context";
69
76
  import { getControls, getControlsState } from "./context";
70
77
  import { resolve } from "./utils";
71
78
  import { getTheme } from "../context";
72
79
  import Controls from "./controls/Controls.svelte";
80
+ import { cquery } from "./action";
73
81
  import { beforeUpdate } from "svelte";
74
- import { slide } from "svelte/transition";
75
82
  const params = getParams();
76
- const current = getCurrent();
77
83
  const controls = getControls();
78
84
  const controlsState = getControlsState();
79
85
  const defaultsStore = getDefaults();
@@ -87,19 +93,23 @@ const reset = () => {
87
93
  };
88
94
  $:
89
95
  $defaultsStore, reset();
90
- let hovered = null;
96
+ const resolveArgs = resolve;
97
+ $:
98
+ expanded = $controls.length > 0 && !$controlsState.hide;
91
99
  let key = false;
92
100
  beforeUpdate(() => key = !key);
93
- const resolveArgs = resolve;
94
101
  </script>
95
102
  <div class="template" class:columns>
96
103
  {#each $params as param (param.id)}
97
104
  <div
98
105
  class="scrollable"
99
- on:click|stopPropagation={() => ($current = param.id)}
100
- on:mouseenter={() => (hovered = param.id)}
101
- on:mouseleave={() => (hovered = null)}
102
- on:keypress={null}
106
+ class:cside={expanded && "right" === $controlsState.position}
107
+ use:cquery={{
108
+ class: "cside",
109
+ min: 1000,
110
+ w: true,
111
+ enabled: expanded && $controlsState.position === undefined
112
+ }}
103
113
  >
104
114
  {#if noreset}
105
115
  <div class="content scrollable" class:dark={$isDark}>
@@ -122,8 +132,8 @@ const resolveArgs = resolve;
122
132
  </div>
123
133
  {/key}
124
134
  {/if}
125
- {#if $controls.length > 0 && ($controlsState.expand || $current === param.id || hovered === param.id)}
126
- <div class="misc scrollable" class:dark={$isDark} transition:slide|local>
135
+ {#if expanded}
136
+ <div class="misc scrollable" class:dark={$isDark}>
127
137
  <Controls infos={$controls} bind:values={param.values} />
128
138
  </div>
129
139
  {/if}
@@ -0,0 +1,12 @@
1
+ import type { ActionReturn } from "svelte/action";
2
+ type Options = {
3
+ class: string;
4
+ min: number;
5
+ w: boolean;
6
+ enabled: boolean;
7
+ };
8
+ /**
9
+ * Temporary support for container query until svelte supports it
10
+ */
11
+ export declare const cquery: (div: HTMLDivElement, options: Options) => ActionReturn<Options>;
12
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Temporary support for container query until svelte supports it
3
+ */
4
+ export const cquery = (div, options) => {
5
+ let o = options;
6
+ const check = () => div.classList.toggle(o.class, (o.w ? div.clientWidth : div.clientHeight) > o.min);
7
+ const observer = new ResizeObserver(check);
8
+ if (o.enabled) {
9
+ observer.observe(div);
10
+ }
11
+ return {
12
+ update: (options) => {
13
+ if (o.enabled !== options.enabled) {
14
+ if (!o.enabled && options.enabled) {
15
+ observer.observe(div);
16
+ }
17
+ else {
18
+ observer.disconnect();
19
+ }
20
+ }
21
+ o = options;
22
+ check();
23
+ },
24
+ destroy: () => o.enabled && observer.disconnect()
25
+ };
26
+ };
@@ -10,9 +10,9 @@ export type Params = {
10
10
  defaults: Record<string, ValueType>;
11
11
  };
12
12
  export type ControlState = {
13
- expand: boolean;
13
+ hide: boolean;
14
+ position?: "bottom" | "right";
14
15
  };
15
- export declare const initCurrent: () => Writable<number | null>, getCurrent: () => Writable<number | null>;
16
16
  export declare const initParams: () => Writable<Params[]>, getParams: () => Writable<Params[]>;
17
17
  export declare const initControls: () => Writable<Control[]>, getControls: () => Writable<Control[]>;
18
18
  export declare const initDefaults: () => Writable<Record<string, ValueType> | null>, getDefaults: () => Writable<Record<string, ValueType> | null>;
@@ -7,10 +7,9 @@ const create = (defaulter) => {
7
7
  get: () => getContext(symbol)
8
8
  };
9
9
  };
10
- export const { init: initCurrent, get: getCurrent } = create(() => null);
11
10
  export const { init: initParams, get: getParams } = create(() => []);
12
11
  export const { init: initControls, get: getControls } = create(() => []);
13
12
  export const { init: initDefaults, get: getDefaults } = create(() => null);
14
13
  export const { init: initControlsState, get: getControlsState } = create(() => ({
15
- expand: false
14
+ hide: false
16
15
  }));
@@ -0,0 +1,47 @@
1
+ <style>
2
+ svg {
3
+ width: 100%;
4
+ height: 100%;
5
+ fill: transparent;
6
+ stroke: currentColor;
7
+ stroke-width: 4;
8
+ stroke-linejoin: miter;
9
+ cursor: pointer;
10
+ }
11
+ </style>
12
+
13
+ <script>import { tweened } from "svelte/motion";
14
+ const action = (p, options) => {
15
+ const total = p.getTotalLength();
16
+ p.style.strokeDasharray = `${total * options.length} ${total}`;
17
+ return {
18
+ update: (options2) => {
19
+ const total2 = p.getTotalLength();
20
+ p.style.strokeDasharray = `${total2 * options2.length} ${total2}`;
21
+ }
22
+ };
23
+ };
24
+ const d = "M 0 -15 L 15 -15 L 15 0 L 0 0 -9 0 A 6 8 135 0 1 9 0";
25
+ const length = tweened(0);
26
+ let out = false;
27
+ const click = () => {
28
+ if (0 === $length) {
29
+ $length = 1;
30
+ out = false;
31
+ } else if (!out) {
32
+ $length = 0;
33
+ out = true;
34
+ }
35
+ };
36
+ $:
37
+ 0 === $length && click();
38
+ </script>
39
+ <svg viewBox="-35 -35 70 70" on:click={click} on:keypress={null}>
40
+ <g transform="rotate(45 0 0)">
41
+ <path {d} use:action={{ length: $length }} />
42
+ </g>
43
+ <g transform="rotate(225 0 0)">
44
+ <path {d} use:action={{ length: $length }} />
45
+ </g>
46
+ </svg>
47
+
@@ -0,0 +1,14 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export type NilIconProps = typeof __propDef.props;
10
+ export type NilIconEvents = typeof __propDef.events;
11
+ export type NilIconSlots = typeof __propDef.slots;
12
+ export default class NilIcon extends SvelteComponentTyped<NilIconProps, NilIconEvents, NilIconSlots> {
13
+ }
14
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nil-/doc",
3
- "version": "0.2.33",
3
+ "version": "0.2.35",
4
4
  "author": {
5
5
  "email": "njaldea@gmail.com",
6
6
  "name": "Neil Aldea"