fragment-tools 0.1.0

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.
Files changed (192) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +101 -0
  3. package/bin/index.js +19 -0
  4. package/docs/README.md +18 -0
  5. package/docs/api/CLI.md +44 -0
  6. package/docs/api/renderers.md +80 -0
  7. package/docs/api/sketch.md +216 -0
  8. package/docs/api/triggers.md +101 -0
  9. package/docs/guide/about.md +16 -0
  10. package/docs/guide/exports.md +86 -0
  11. package/docs/guide/external-dependencies.md +22 -0
  12. package/docs/guide/getting-started.md +113 -0
  13. package/docs/guide/hot-shader-reloading.md +20 -0
  14. package/docs/guide/shortcuts.md +12 -0
  15. package/docs/guide/triggers.png +0 -0
  16. package/docs/guide/using-triggers.md +39 -0
  17. package/examples/cube-three.js +34 -0
  18. package/examples/ellipse-p5.js +26 -0
  19. package/examples/icon.fs +96 -0
  20. package/examples/icon.js +63 -0
  21. package/examples/icon.png +0 -0
  22. package/examples/icon.transparent.png +0 -0
  23. package/examples/package-lock.json +40 -0
  24. package/examples/package.json +15 -0
  25. package/examples/shape-2d.js +45 -0
  26. package/examples/shape-three.js +49 -0
  27. package/examples/shape-tree.fs +3 -0
  28. package/package.json +37 -0
  29. package/screenshot.png +0 -0
  30. package/src/cli/db.js +17 -0
  31. package/src/cli/index.js +198 -0
  32. package/src/cli/log.js +26 -0
  33. package/src/cli/plugins/check-dependencies.js +77 -0
  34. package/src/cli/plugins/db.js +12 -0
  35. package/src/cli/plugins/hot-shader-reload.js +86 -0
  36. package/src/cli/plugins/hot-sketch-reload.js +39 -0
  37. package/src/cli/plugins/screenshot.js +31 -0
  38. package/src/cli/server.js +140 -0
  39. package/src/cli/templates/2d.js +15 -0
  40. package/src/cli/templates/fragment.fs +10 -0
  41. package/src/cli/templates/fragment.js +18 -0
  42. package/src/cli/templates/index.js +24 -0
  43. package/src/cli/templates/p5.js +13 -0
  44. package/src/cli/templates/three-fragment.js +53 -0
  45. package/src/cli/templates/three-orthographic.js +23 -0
  46. package/src/cli/templates/three-perspective.js +20 -0
  47. package/src/cli/ws.js +92 -0
  48. package/src/client/app/App.svelte +8 -0
  49. package/src/client/app/client.js +68 -0
  50. package/src/client/app/components/IconCross.svelte +29 -0
  51. package/src/client/app/components/Init.svelte +13 -0
  52. package/src/client/app/components/KeyBinding.svelte +32 -0
  53. package/src/client/app/inputs/Input.js +15 -0
  54. package/src/client/app/inputs/Keyboard.js +21 -0
  55. package/src/client/app/inputs/MIDI.js +144 -0
  56. package/src/client/app/inputs/Mouse.js +5 -0
  57. package/src/client/app/inputs/Webcam.js +98 -0
  58. package/src/client/app/lib/canvas-recorder/CanvasRecorder.js +88 -0
  59. package/src/client/app/lib/canvas-recorder/FFMPEGRecorder.js +56 -0
  60. package/src/client/app/lib/canvas-recorder/FrameRecorder.js +40 -0
  61. package/src/client/app/lib/canvas-recorder/GIFRecorder.js +52 -0
  62. package/src/client/app/lib/canvas-recorder/MP4Recorder.js +46 -0
  63. package/src/client/app/lib/canvas-recorder/WebMRecorder.js +30 -0
  64. package/src/client/app/lib/canvas-recorder/mp4.js +20 -0
  65. package/src/client/app/lib/canvas-recorder/mp4.wasm +0 -0
  66. package/src/client/app/lib/canvas-recorder/utils.js +22 -0
  67. package/src/client/app/lib/gl/Geometry.js +39 -0
  68. package/src/client/app/lib/gl/Program.js +130 -0
  69. package/src/client/app/lib/gl/Renderer.js +148 -0
  70. package/src/client/app/lib/gl/Texture.js +114 -0
  71. package/src/client/app/lib/gl/index.js +109 -0
  72. package/src/client/app/lib/gl/utils.js +5 -0
  73. package/src/client/app/lib/helpers/frameDebounce.js +40 -0
  74. package/src/client/app/lib/loader/index.js +20 -0
  75. package/src/client/app/lib/loader/loadImage.js +19 -0
  76. package/src/client/app/lib/loader/loadScript.js +14 -0
  77. package/src/client/app/lib/paper-sizes.js +104 -0
  78. package/src/client/app/lib/presets.js +12 -0
  79. package/src/client/app/lib/tempo/Analyser.js +165 -0
  80. package/src/client/app/lib/tempo/Range.js +97 -0
  81. package/src/client/app/lib/tempo/index.js +138 -0
  82. package/src/client/app/modules/AudioAnalyser/Range.svelte +93 -0
  83. package/src/client/app/modules/AudioAnalyser/Spectrum.svelte +31 -0
  84. package/src/client/app/modules/AudioAnalyser.svelte +70 -0
  85. package/src/client/app/modules/Console/ConsoleLine.svelte +254 -0
  86. package/src/client/app/modules/Console.svelte +82 -0
  87. package/src/client/app/modules/Exports.svelte +105 -0
  88. package/src/client/app/modules/MidiPanel.svelte +106 -0
  89. package/src/client/app/modules/Monitor.svelte +62 -0
  90. package/src/client/app/modules/Params.svelte +112 -0
  91. package/src/client/app/renderers/2DRenderer.js +5 -0
  92. package/src/client/app/renderers/FragmentRenderer.js +62 -0
  93. package/src/client/app/renderers/OGLRenderer.js +0 -0
  94. package/src/client/app/renderers/P5Renderer.js +39 -0
  95. package/src/client/app/renderers/THREERenderer.js +128 -0
  96. package/src/client/app/stores/audioAnalysis.js +10 -0
  97. package/src/client/app/stores/console.js +76 -0
  98. package/src/client/app/stores/errors.js +25 -0
  99. package/src/client/app/stores/exports.js +28 -0
  100. package/src/client/app/stores/index.js +2 -0
  101. package/src/client/app/stores/layout.js +187 -0
  102. package/src/client/app/stores/multisampling.js +16 -0
  103. package/src/client/app/stores/props.js +44 -0
  104. package/src/client/app/stores/renderers.js +60 -0
  105. package/src/client/app/stores/rendering.js +111 -0
  106. package/src/client/app/stores/sketches.js +40 -0
  107. package/src/client/app/stores/time.js +27 -0
  108. package/src/client/app/stores/utils.js +66 -0
  109. package/src/client/app/transitions/fade.js +17 -0
  110. package/src/client/app/transitions/index.js +12 -0
  111. package/src/client/app/transitions/splitX.js +16 -0
  112. package/src/client/app/transitions/splitY.js +16 -0
  113. package/src/client/app/triggers/Keyboard.js +95 -0
  114. package/src/client/app/triggers/MIDI.js +122 -0
  115. package/src/client/app/triggers/Mouse.js +96 -0
  116. package/src/client/app/triggers/Trigger.js +71 -0
  117. package/src/client/app/triggers/index.js +19 -0
  118. package/src/client/app/triggers/shared.js +37 -0
  119. package/src/client/app/ui/Build.svelte +96 -0
  120. package/src/client/app/ui/ErrorOverlay.svelte +130 -0
  121. package/src/client/app/ui/Field.svelte +262 -0
  122. package/src/client/app/ui/FieldGroup.svelte +103 -0
  123. package/src/client/app/ui/FieldSection.svelte +123 -0
  124. package/src/client/app/ui/FieldSpace.svelte +37 -0
  125. package/src/client/app/ui/FieldTrigger.svelte +263 -0
  126. package/src/client/app/ui/FieldTriggers.svelte +58 -0
  127. package/src/client/app/ui/FloatingParams.svelte +49 -0
  128. package/src/client/app/ui/Layout.svelte +50 -0
  129. package/src/client/app/ui/LayoutColumn.svelte +9 -0
  130. package/src/client/app/ui/LayoutComponent.svelte +279 -0
  131. package/src/client/app/ui/LayoutResizer.svelte +218 -0
  132. package/src/client/app/ui/LayoutRoot.svelte +11 -0
  133. package/src/client/app/ui/LayoutRow.svelte +9 -0
  134. package/src/client/app/ui/LayoutToolbar.svelte +264 -0
  135. package/src/client/app/ui/Module.svelte +154 -0
  136. package/src/client/app/ui/ModuleHeaderAction.svelte +87 -0
  137. package/src/client/app/ui/ModuleHeaderButton.svelte +21 -0
  138. package/src/client/app/ui/ModuleHeaderSelect.svelte +50 -0
  139. package/src/client/app/ui/ModuleRenderer.svelte +38 -0
  140. package/src/client/app/ui/OutputRenderer.svelte +149 -0
  141. package/src/client/app/ui/ParamsMultisampling.svelte +109 -0
  142. package/src/client/app/ui/ParamsOutput.svelte +139 -0
  143. package/src/client/app/ui/Preview.svelte +15 -0
  144. package/src/client/app/ui/SelectChevrons.svelte +25 -0
  145. package/src/client/app/ui/SketchRenderer.svelte +672 -0
  146. package/src/client/app/ui/SketchSelect.svelte +49 -0
  147. package/src/client/app/ui/fields/ButtonInput.svelte +54 -0
  148. package/src/client/app/ui/fields/CheckboxInput.svelte +70 -0
  149. package/src/client/app/ui/fields/ColorInput.svelte +187 -0
  150. package/src/client/app/ui/fields/FieldInputRow.svelte +13 -0
  151. package/src/client/app/ui/fields/ImageInput.svelte +145 -0
  152. package/src/client/app/ui/fields/Input.svelte +120 -0
  153. package/src/client/app/ui/fields/ListInput.svelte +106 -0
  154. package/src/client/app/ui/fields/NumberInput.svelte +114 -0
  155. package/src/client/app/ui/fields/ProgressInput.svelte +90 -0
  156. package/src/client/app/ui/fields/Select.svelte +116 -0
  157. package/src/client/app/ui/fields/TextInput.svelte +18 -0
  158. package/src/client/app/ui/fields/Vec2Input.svelte +5 -0
  159. package/src/client/app/ui/fields/Vec3Input.svelte +6 -0
  160. package/src/client/app/ui/fields/VectorInput.svelte +102 -0
  161. package/src/client/app/utils/canvas.utils.js +229 -0
  162. package/src/client/app/utils/color.utils.js +427 -0
  163. package/src/client/app/utils/file.utils.js +77 -0
  164. package/src/client/app/utils/glsl.utils.js +14 -0
  165. package/src/client/app/utils/glslErrors.js +154 -0
  166. package/src/client/app/utils/index.js +39 -0
  167. package/src/client/app/utils/math.utils.js +23 -0
  168. package/src/client/app/utils/props.utils.js +53 -0
  169. package/src/client/index.html +18 -0
  170. package/src/client/main.js +9 -0
  171. package/src/client/public/css/global.css +115 -0
  172. package/src/client/public/favicon.ico +0 -0
  173. package/src/client/public/fonts/Inter-Bold.woff2 +0 -0
  174. package/src/client/public/fonts/Inter-Italic.woff2 +0 -0
  175. package/src/client/public/fonts/Inter-Regular.woff2 +0 -0
  176. package/src/client/public/fonts/Inter-SemiBold.woff2 +0 -0
  177. package/src/client/public/fonts/JetBrainsMono-Regular.woff2 +0 -0
  178. package/src/client/public/icons/chevron-bottom.svg +3 -0
  179. package/src/client/public/icons/chevron-right.svg +3 -0
  180. package/src/client/public/icons/chevron-top.svg +3 -0
  181. package/src/client/public/icons/columns-horizontal.svg +4 -0
  182. package/src/client/public/icons/columns-vertical.svg +4 -0
  183. package/src/client/public/icons/folder-plus.svg +6 -0
  184. package/src/client/public/icons/lock.svg +4 -0
  185. package/src/client/public/icons/picture-in-picture.svg +4 -0
  186. package/src/client/public/icons/trash.svg +5 -0
  187. package/src/client/public/icons/trigger.svg +8 -0
  188. package/src/client/public/icons/unlock.svg +4 -0
  189. package/src/client/public/js/ffmpeg.min.js +2 -0
  190. package/src/client/public/js/ffmpeg.min.js.map +1 -0
  191. package/src/client/public/js/gif.js +2 -0
  192. package/src/client/public/js/gif.worker.js +2 -0
@@ -0,0 +1,262 @@
1
+ <script>
2
+ import { createEventDispatcher } from "svelte";
3
+
4
+ import Select from "./fields/Select.svelte";
5
+ import NumberInput from "./fields/NumberInput.svelte";
6
+ import CheckboxInput from "./fields/CheckboxInput.svelte";
7
+ import Vec2Input from "./fields/Vec2Input.svelte";
8
+ import Vec3Input from "./fields/Vec3Input.svelte";
9
+ import TextInput from "./fields/TextInput.svelte";
10
+ import ColorInput from "./fields/ColorInput.svelte";
11
+ import ListInput from "./fields/ListInput.svelte";
12
+ import ButtonInput from "./fields/ButtonInput.svelte";
13
+ import ImageInput from "./fields/ImageInput.svelte";
14
+ import FieldSection from "./FieldSection.svelte";
15
+ import FieldTriggers from "./FieldTriggers.svelte";
16
+ import { inferFromParams, inferFromValue } from "../utils/props.utils.js";
17
+ import { download } from "../utils/file.utils.js";
18
+ import { map } from "../utils/math.utils";
19
+ import frameDebounce from "../lib/helpers/frameDebounce.js";
20
+ import { getStore } from "../stores/utils";
21
+ import { writable } from "svelte/store";
22
+
23
+ export let key = '';
24
+ export let value = null;
25
+ export let context = null;
26
+ export let params = {};
27
+ export let type = null;
28
+
29
+ let offsetWidth;
30
+ let showTriggers = false;
31
+
32
+ const store = getStore(context, { props: {}}, {
33
+ persist: context !== null,
34
+ });
35
+
36
+ if (!$store.props[key]) {
37
+ $store.props[key] = { triggers: [] };
38
+ }
39
+
40
+ let triggers = writable($store.props[key].triggers.filter((trigger) => trigger.inputType !== undefined));
41
+ triggers.subscribe((all) => {
42
+ store.update((curr) => {
43
+ curr.props[key].triggers = all;
44
+
45
+ return curr;
46
+ });
47
+ })
48
+
49
+ const dispatch = createEventDispatcher();
50
+ const fields = {
51
+ "select": Select,
52
+ "number": NumberInput,
53
+ "vec2": Vec2Input,
54
+ "vec3": Vec3Input,
55
+ "checkbox": CheckboxInput,
56
+ "text": TextInput,
57
+ "list": ListInput,
58
+ "color": ColorInput,
59
+ "button": ButtonInput,
60
+ "download": ButtonInput,
61
+ "image": ImageInput,
62
+ };
63
+
64
+ const onTriggers = {
65
+ 'checkbox': () => {
66
+ value = !value;
67
+
68
+ dispatch('change', value);
69
+ },
70
+ 'button': (event) => {
71
+ value(event);
72
+ dispatch('click', event);
73
+ },
74
+ 'download': (event) => {
75
+ let [data, filename] = value(event);
76
+
77
+ download(data, filename);
78
+ },
79
+ 'number': (event = {}) => {
80
+ const isValueInRange = event.value >= 0 && event.value <= 1;
81
+
82
+ if (isValueInRange && isFinite(params.min) && isFinite(params.max)) {
83
+ let v = map(event.value, 0, 1, params.min, params.max);
84
+ let step = params.step ? params.step : 1;
85
+ let value = Math.round(v * (1 / step)) / (1 / step);
86
+
87
+ dispatch('change', value);
88
+ }
89
+ },
90
+ };
91
+
92
+ $: fieldType = type ? type : (inferFromParams(params) || inferFromValue(value));
93
+ $: fieldProps = composeFieldProps(params);
94
+ $: onTrigger = frameDebounce(onTriggers[fieldType]);
95
+ $: input = fields[fieldType];
96
+ $: label = params.label !== undefined && typeof value !== "function" ? params.label : key;
97
+ $: disabled = params.disabled;
98
+ $: triggerable = params.triggerable !== false && (
99
+ (fieldType === "number" && isFinite(params.min) && isFinite(params.max)) ||
100
+ (fieldType === "button")
101
+ );
102
+ $: {
103
+ if (fieldType === "download" || fieldType === "button") {
104
+ if (params.label === undefined) {
105
+ fieldProps.label = fieldType === "download" ? "download" : "run";
106
+ }
107
+ }
108
+ }
109
+ $: xxsmall = offsetWidth < 200;
110
+ $: xsmall = !xxsmall && offsetWidth < 260;
111
+ $: small = !xxsmall && !xsmall && offsetWidth < 320;
112
+ $: triggersActive = $triggers.length > 0;
113
+
114
+ function toggleTriggers(event) {
115
+ event.preventDefault();
116
+
117
+ showTriggers = !showTriggers;
118
+ }
119
+
120
+ function composeFieldProps(params) {
121
+ const { triggerable, controllable, ...rest } = params;
122
+
123
+ return rest;
124
+ }
125
+
126
+ </script>
127
+
128
+ <div class="field"
129
+ class:disabled={disabled}
130
+ class:xxsmall={xxsmall}
131
+ class:xsmall={xsmall}
132
+ class:small={small}
133
+ bind:offsetWidth={offsetWidth}
134
+ >
135
+ <FieldSection name={key} label={label} interactive={triggerable} on:click={toggleTriggers}>
136
+ <div slot="infos" class="field__actions">
137
+ {#if triggerable && !disabled }
138
+ <button
139
+ on:click={toggleTriggers}
140
+ class="field__action field__action--triggers"
141
+ class:active={triggersActive}>
142
+ <svg width="16" height="16" fill="none" viewBox="0 0 24 24">
143
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4.75 8H7.25"/>
144
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12.75 8H19.25"/>
145
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4.75 16H12.25"/>
146
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M17.75 16H19.25"/>
147
+ <circle cx="10" cy="8" r="2.25" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
148
+ <circle cx="15" cy="16" r="2.25" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
149
+ </svg>
150
+ </button>
151
+ {/if}
152
+ {#if (fieldType === "vec2" || fieldType === "vec3") && !disabled }
153
+ <button class="field__action field__action--lock" on:click={() => params.locked = !params.locked}>
154
+ {#if params.locked}
155
+ <svg class="action__icon" width="16" height="16" fill="none" viewBox="0 0 24 24">
156
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M5.75 11.75C5.75 11.1977 6.19772 10.75 6.75 10.75H17.25C17.8023 10.75 18.25 11.1977 18.25 11.75V17.25C18.25 18.3546 17.3546 19.25 16.25 19.25H7.75C6.64543 19.25 5.75 18.3546 5.75 17.25V11.75Z"></path>
157
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M7.75 10.5V10.3427C7.75 8.78147 7.65607 7.04125 8.74646 5.9239C9.36829 5.2867 10.3745 4.75 12 4.75C13.6255 4.75 14.6317 5.2867 15.2535 5.9239C16.3439 7.04125 16.25 8.78147 16.25 10.3427V10.5"></path>
158
+ </svg>
159
+ {:else}
160
+ <svg class="action__icon" width="16" height="16" fill="none" viewBox="0 0 24 24">
161
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M5.75 11.75C5.75 11.1977 6.19772 10.75 6.75 10.75H17.25C17.8023 10.75 18.25 11.1977 18.25 11.75V17.25C18.25 18.3546 17.3546 19.25 16.25 19.25H7.75C6.64543 19.25 5.75 18.3546 5.75 17.25V11.75Z"></path>
162
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M7.75 10.5V9.84343C7.75 8.61493 7.70093 7.29883 8.42416 6.30578C8.99862 5.51699 10.0568 4.75 12 4.75C14 4.75 15.25 6.25 15.25 6.25"></path>
163
+ </svg>
164
+ {/if}
165
+ </button>
166
+ {/if}
167
+ </div>
168
+ <svelte:component
169
+ this={input}
170
+ {value}
171
+ {...fieldProps}
172
+ on:change
173
+ on:click={onTrigger}
174
+ />
175
+ <slot></slot>
176
+ </FieldSection>
177
+ {#if triggerable }
178
+ <FieldSection visible={showTriggers} secondary>
179
+ <FieldTriggers
180
+ {triggers}
181
+ {onTrigger}
182
+ {context}
183
+ triggerable={fieldType === "button"}
184
+ controllable={fieldType === "number"}
185
+ />
186
+ </FieldSection>
187
+ {/if}
188
+ </div>
189
+
190
+ <style>
191
+ .field {
192
+ --column-gap: 3px;
193
+ --padding: 6px;
194
+
195
+ width: 100%;
196
+
197
+ padding: 3px 6px 3px 12px;
198
+ border-bottom: 1px solid var(--color-spacing);
199
+ }
200
+
201
+ :global(.field__input .field) {
202
+ padding-left: 0px !important;
203
+ }
204
+
205
+ :global(.field__input .field:last-child) {
206
+ border-bottom: 0px solid #323233 !important;
207
+ padding-bottom: 0px !important;
208
+ }
209
+
210
+ .field.disabled {
211
+ pointer-events: none;
212
+ }
213
+
214
+ .field__actions {
215
+ display: flex;
216
+ align-items: center;
217
+ }
218
+
219
+ .field__action {
220
+ display: flex;
221
+ align-items: center;
222
+
223
+ background: transparent;
224
+ transition: opacity 0.1s ease;
225
+ }
226
+
227
+ .field__action:hover {
228
+ opacity: 1;
229
+ }
230
+
231
+ .field__action--triggers {
232
+ --background-color: rgba(255, 255, 255, 0.5);
233
+
234
+ position: relative;
235
+
236
+ width: 16px;
237
+ height: 16px;
238
+
239
+ background-color: transparent;
240
+ cursor: pointer;
241
+ }
242
+
243
+ .field__action--triggers:not(.active) {
244
+ display: none;
245
+ }
246
+
247
+ .field__action {
248
+ color: var(--color-text);
249
+
250
+ opacity: 0.6;
251
+ background-color: transparent;
252
+ transition: opacity 0.1s ease;
253
+ }
254
+
255
+ .field__action--triggers svg {
256
+ transform: rotate(90deg);
257
+ }
258
+
259
+ .field__action:hover {
260
+ opacity: 1;
261
+ }
262
+ </style>
@@ -0,0 +1,103 @@
1
+ <script>
2
+ export let name;
3
+
4
+ export let collapsed = false;
5
+
6
+ function handleClick() {
7
+ collapsed = !collapsed;
8
+ }
9
+
10
+ </script>
11
+
12
+ <div class="field-group {collapsed ? "collapsed" : ""}">
13
+ <header class="header">
14
+ <button class="header__action" on:click={handleClick}>
15
+ <svg class="header__icon" width="24" height="24" fill="none" viewBox="0 0 24 24">
16
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M10.75 8.75L14.25 12L10.75 15.25"/>
17
+ </svg>
18
+ <span class="field-group__name">{name}</span>
19
+ </button>
20
+ </header>
21
+ <div class="content">
22
+ <slot></slot>
23
+ </div>
24
+ </div>
25
+
26
+ <style>
27
+ .field-group {
28
+ position: relative;
29
+
30
+ display: grid;
31
+ width: 100%;
32
+
33
+ }
34
+
35
+ .field-group:after {
36
+ content: "";
37
+
38
+ position: absolute;
39
+ left: 0;
40
+ bottom: 0px;
41
+
42
+ width: 12px;
43
+ height: 1px;
44
+
45
+ background-color: #323233;
46
+ }
47
+
48
+ .header {
49
+ padding: 3px 6px;
50
+ border-bottom: 1px solid #323233;
51
+ }
52
+
53
+ .header__action {
54
+ display: flex;
55
+ align-items: center;
56
+ width: 100%;
57
+ text-align: left;
58
+
59
+ background: transparent;
60
+ cursor: pointer;
61
+ }
62
+
63
+ .header__icon {
64
+ padding-bottom: 1px;
65
+
66
+ color: #f0f0f0;
67
+ transform: rotate(90deg);
68
+ opacity: 0.5;
69
+ transition: opacity 0.1s ease;
70
+ }
71
+
72
+ .header__action:hover .header__icon {
73
+ opacity: 1;
74
+ }
75
+
76
+ .field-group.collapsed .header__icon {
77
+ transform: rotate(0deg);
78
+ }
79
+
80
+ .field-group__name {
81
+ color: #f0f0f0;
82
+
83
+ font-size: 11px;
84
+ font-weight: 700;
85
+ /* text-transform: uppercase; */
86
+
87
+ opacity: 0.75;
88
+ transition: opacity 0.1s ease;
89
+ }
90
+
91
+ .header__action:hover .field-group__name {
92
+ opacity: 1;
93
+ }
94
+
95
+ .content {
96
+ margin-left: 12px;
97
+ border-left: 1px solid #323233;
98
+ }
99
+
100
+ .field-group.collapsed .content {
101
+ display: none;
102
+ }
103
+ </style>
@@ -0,0 +1,123 @@
1
+ <script>
2
+ export let visible = true;
3
+ export let secondary = false;
4
+ export let interactive = false;
5
+ export let label = "";
6
+ export let name = "";
7
+ </script>
8
+
9
+ <div class="field__section" class:visible={visible} class:secondary={secondary} class:no-label={label === null}>
10
+ <div class="field__infos">
11
+ {#if label !== null}
12
+ {#if interactive}
13
+ <button class="field__label" on:click>{label}</button>
14
+ {:else}
15
+ <span class="field__label">{label}</span>
16
+ {/if}
17
+ {/if}
18
+ <slot name="infos"></slot>
19
+ </div>
20
+ <div class="field__input">
21
+ <slot></slot>
22
+ </div>
23
+ </div>
24
+
25
+ <style>
26
+ .field__section {
27
+ position: relative;
28
+
29
+ display: grid;
30
+ grid-template-columns: 0.5fr 1fr;
31
+ column-gap: 10px;
32
+ }
33
+
34
+ .field__section.no-label {
35
+ grid-template-columns: 1fr;
36
+ }
37
+
38
+ .field__section:hover .field__label, .field__section:focus-within .field__label {
39
+ opacity: 1;
40
+ }
41
+
42
+ .field__section:not(.visible) {
43
+ display: none;
44
+ }
45
+
46
+ .field__section.secondary {
47
+ --margin: 15px;
48
+
49
+ grid-template-columns: 0.25fr 1fr;
50
+ margin-top: var(--margin);
51
+ }
52
+
53
+ .field__section.secondary:before {
54
+ content: '';
55
+
56
+ position: absolute;
57
+ left: 10px;
58
+ top: calc(var(--margin) * -1);
59
+
60
+ width: 1px;
61
+ height: var(--margin);
62
+
63
+ background-color: var(--color-spacing);
64
+ }
65
+
66
+ .field__infos {
67
+ position: relative;
68
+
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: space-between;
72
+
73
+ color: var(--color-text);
74
+ }
75
+
76
+ .field__label {
77
+ color: inherit;
78
+ font-size: var(--font-size-input);
79
+ user-select: none;
80
+
81
+ opacity: 0.6;
82
+ background-color: transparent;
83
+ transition: opacity 0.1s ease;
84
+ }
85
+
86
+ button.field__label {
87
+ cursor: pointer;
88
+ }
89
+
90
+ .field__label:focus-visible {
91
+ outline: 0;
92
+ box-shadow: 0 0 0 2px var(--color-text);
93
+ border-radius: 2px;
94
+ }
95
+
96
+ .field__section.secondary {
97
+ grid-template-columns: 1fr;
98
+ }
99
+
100
+ .field__section.secondary .field__infos {
101
+ display: none;
102
+ }
103
+
104
+ .field__section.secondary .field__label {
105
+ position: relative;
106
+
107
+ padding-left: 5px;
108
+
109
+ background-color: #242425;
110
+ }
111
+
112
+ .field__input {
113
+ display: flex;
114
+ flex-direction: column;
115
+ justify-content: center;
116
+ align-items: flex-start;
117
+ }
118
+
119
+ .field__section.secondary .field__input {
120
+ padding: var(--column-gap);
121
+ border: 1px solid var(--color-spacing);
122
+ }
123
+ </style>
@@ -0,0 +1,37 @@
1
+ <script>
2
+ export let height = 20;
3
+ </script>
4
+
5
+ <div class="field-space" style="height: {height}px"></div>
6
+
7
+ <style>
8
+ .field-space {
9
+ position: relative;
10
+
11
+ border-bottom: 1px solid var(--color-spacing);
12
+ overflow: hidden;
13
+ }
14
+
15
+ .field-space:before, .field-space:after {
16
+ /* content: ''; */
17
+ position: absolute;
18
+ top: 50%;
19
+ left: 0;
20
+
21
+ width: 100%;
22
+ height: 1px;
23
+
24
+ background-color: var(--color-spacing);
25
+ }
26
+
27
+ .field-space:before {
28
+ transform: rotate(3deg);
29
+ }
30
+
31
+ .field-space:after {
32
+ content: none;
33
+ transform: rotate(-3deg);
34
+ }
35
+
36
+
37
+ </style>