tweak-ui 0.4.3 → 0.5.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.
- package/LICENSE +7 -7
- package/README.md +32 -32
- package/dist/lib/builder.d.ts +166 -162
- package/dist/lib/builder.d.ts.map +1 -1
- package/dist/lib/builder.js +250 -0
- package/dist/lib/builder.js.map +1 -0
- package/dist/lib/color-formats/array-format.d.ts +8 -8
- package/dist/lib/color-formats/array-format.js +18 -0
- package/dist/lib/color-formats/array-format.js.map +1 -0
- package/dist/lib/color-formats/converter.d.ts +18 -18
- package/dist/lib/color-formats/converter.js +85 -0
- package/dist/lib/color-formats/converter.js.map +1 -0
- package/dist/lib/color-formats/css-string-format.d.ts +7 -7
- package/dist/lib/color-formats/css-string-format.js +28 -0
- package/dist/lib/color-formats/css-string-format.js.map +1 -0
- package/dist/lib/color-formats/formatter.d.ts +8 -8
- package/dist/lib/color-formats/formatter.js +35 -0
- package/dist/lib/color-formats/formatter.js.map +1 -0
- package/dist/lib/color-formats/hex-string-format.d.ts +7 -7
- package/dist/lib/color-formats/hex-string-format.js +28 -0
- package/dist/lib/color-formats/hex-string-format.js.map +1 -0
- package/dist/lib/color-formats/index.d.ts +3 -3
- package/dist/lib/color-formats/index.js +4 -0
- package/dist/lib/color-formats/index.js.map +1 -0
- package/dist/lib/color-formats/number-format.d.ts +8 -8
- package/dist/lib/color-formats/number-format.js +23 -0
- package/dist/lib/color-formats/number-format.js.map +1 -0
- package/dist/lib/color-formats/object-format.d.ts +14 -14
- package/dist/lib/color-formats/object-format.js +23 -0
- package/dist/lib/color-formats/object-format.js.map +1 -0
- package/dist/lib/color-formats/types.d.ts +101 -101
- package/dist/lib/color-formats/types.js +2 -0
- package/dist/lib/color-formats/types.js.map +1 -0
- package/dist/lib/components/button.d.ts +28 -28
- package/dist/lib/components/button.d.ts.map +1 -1
- package/dist/lib/components/button.js +15 -0
- package/dist/lib/components/button.js.map +1 -0
- package/dist/lib/components/content.d.ts +21 -21
- package/dist/lib/components/content.d.ts.map +1 -1
- package/dist/lib/components/content.js +10 -0
- package/dist/lib/components/content.js.map +1 -0
- package/dist/lib/components/controls/angle.d.ts +51 -51
- package/dist/lib/components/controls/angle.d.ts.map +1 -1
- package/dist/lib/components/controls/angle.js +201 -0
- package/dist/lib/components/controls/angle.js.map +1 -0
- package/dist/lib/components/controls/checkbox.d.ts +28 -28
- package/dist/lib/components/controls/checkbox.d.ts.map +1 -1
- package/dist/lib/components/controls/checkbox.js +31 -0
- package/dist/lib/components/controls/checkbox.js.map +1 -0
- package/dist/lib/components/controls/color-picker.d.ts +56 -56
- package/dist/lib/components/controls/color-picker.d.ts.map +1 -1
- package/dist/lib/components/controls/color-picker.js +267 -0
- package/dist/lib/components/controls/color-picker.js.map +1 -0
- package/dist/lib/components/controls/color.d.ts +51 -51
- package/dist/lib/components/controls/color.d.ts.map +1 -1
- package/dist/lib/components/controls/color.js +77 -0
- package/dist/lib/components/controls/color.js.map +1 -0
- package/dist/lib/components/controls/index.d.ts +10 -10
- package/dist/lib/components/controls/index.js +11 -0
- package/dist/lib/components/controls/index.js.map +1 -0
- package/dist/lib/components/controls/number.d.ts +47 -47
- package/dist/lib/components/controls/number.d.ts.map +1 -1
- package/dist/lib/components/controls/number.js +142 -0
- package/dist/lib/components/controls/number.js.map +1 -0
- package/dist/lib/components/controls/point.d.ts +47 -47
- package/dist/lib/components/controls/point.d.ts.map +1 -1
- package/dist/lib/components/controls/point.js +137 -0
- package/dist/lib/components/controls/point.js.map +1 -0
- package/dist/lib/components/controls/position.d.ts +55 -55
- package/dist/lib/components/controls/position.d.ts.map +1 -1
- package/dist/lib/components/controls/position.js +36 -0
- package/dist/lib/components/controls/position.js.map +1 -0
- package/dist/lib/components/controls/select.d.ts +59 -59
- package/dist/lib/components/controls/select.d.ts.map +1 -1
- package/dist/lib/components/controls/select.js +132 -0
- package/dist/lib/components/controls/select.js.map +1 -0
- package/dist/lib/components/controls/spherical.d.ts +74 -74
- package/dist/lib/components/controls/spherical.d.ts.map +1 -1
- package/dist/lib/components/controls/spherical.js +302 -0
- package/dist/lib/components/controls/spherical.js.map +1 -0
- package/dist/lib/components/controls/text.d.ts +35 -35
- package/dist/lib/components/controls/text.d.ts.map +1 -1
- package/dist/lib/components/controls/text.js +24 -0
- package/dist/lib/components/controls/text.js.map +1 -0
- package/dist/lib/components/groups/accordion.d.ts +21 -21
- package/dist/lib/components/groups/accordion.d.ts.map +1 -1
- package/dist/lib/components/groups/accordion.js +34 -0
- package/dist/lib/components/groups/accordion.js.map +1 -0
- package/dist/lib/components/groups/container.d.ts +24 -24
- package/dist/lib/components/groups/container.d.ts.map +1 -1
- package/dist/lib/components/groups/container.js +19 -0
- package/dist/lib/components/groups/container.js.map +1 -0
- package/dist/lib/components/groups/group.d.ts +48 -48
- package/dist/lib/components/groups/group.d.ts.map +1 -1
- package/dist/lib/components/groups/group.js +50 -0
- package/dist/lib/components/groups/group.js.map +1 -0
- package/dist/lib/components/groups/index.d.ts +4 -4
- package/dist/lib/components/groups/index.js +5 -0
- package/dist/lib/components/groups/index.js.map +1 -0
- package/dist/lib/components/groups/tabs.d.ts +21 -21
- package/dist/lib/components/groups/tabs.d.ts.map +1 -1
- package/dist/lib/components/groups/tabs.js +31 -0
- package/dist/lib/components/groups/tabs.js.map +1 -0
- package/dist/lib/components/image.d.ts +36 -36
- package/dist/lib/components/image.d.ts.map +1 -1
- package/dist/lib/components/image.js +46 -0
- package/dist/lib/components/image.js.map +1 -0
- package/dist/lib/components/index.d.ts +5 -5
- package/dist/lib/components/index.js +6 -0
- package/dist/lib/components/index.js.map +1 -0
- package/dist/lib/core/index.d.ts +4 -4
- package/dist/lib/core/index.js +5 -0
- package/dist/lib/core/index.js.map +1 -0
- package/dist/lib/core/registry.d.ts +17 -17
- package/dist/lib/core/registry.js +30 -0
- package/dist/lib/core/registry.js.map +1 -0
- package/dist/lib/core/render.d.ts +9 -9
- package/dist/lib/core/render.d.ts.map +1 -1
- package/dist/lib/core/render.js +19 -0
- package/dist/lib/core/render.js.map +1 -0
- package/dist/lib/core/types.d.ts +87 -87
- package/dist/lib/core/types.d.ts.map +1 -1
- package/dist/lib/core/types.js +2 -0
- package/dist/lib/core/types.js.map +1 -0
- package/dist/lib/core/utils.d.ts +93 -93
- package/dist/lib/core/utils.d.ts.map +1 -1
- package/dist/lib/core/utils.js +193 -0
- package/dist/lib/core/utils.js.map +1 -0
- package/dist/lib/core/value-accessor.d.ts +17 -17
- package/dist/lib/core/value-accessor.js +52 -0
- package/dist/lib/core/value-accessor.js.map +1 -0
- package/dist/lib/index.d.ts +21 -27
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +29 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/mount.d.ts +45 -45
- package/dist/lib/mount.js +85 -0
- package/dist/lib/mount.js.map +1 -0
- package/dist/tweak-ui.css +133 -138
- package/dist/tweak-ui.css.map +1 -1
- package/dist/tweak-ui.min.css +1 -1
- package/dist/tweak-ui.min.css.map +1 -1
- package/dist/tweak-ui.module.js +2733 -2396
- package/dist/tweak-ui.module.js.map +1 -1
- package/dist/tweak-ui.umd.js +1 -4419
- package/dist/tweak-ui.umd.js.map +1 -1
- package/package.json +25 -42
- package/dist/index.html +0 -1063
- package/dist/lib/color-formats/array-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/array-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/converter.spec.d.ts +0 -2
- package/dist/lib/color-formats/converter.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/css-string-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/css-string-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/formatter.spec.d.ts +0 -2
- package/dist/lib/color-formats/formatter.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/hex-string-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/hex-string-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/number-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/number-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/object-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/object-format.spec.d.ts.map +0 -1
- package/dist/scss/_style.scss +0 -120
- package/dist/scss/_themes.scss +0 -23
- package/dist/scss/_utils.scss +0 -24
- package/dist/scss/_variables.scss +0 -30
- package/dist/scss/controls/_angle.scss +0 -64
- package/dist/scss/controls/_button.scss +0 -0
- package/dist/scss/controls/_checkbox.scss +0 -19
- package/dist/scss/controls/_color-picker.scss +0 -124
- package/dist/scss/controls/_color.scss +0 -14
- package/dist/scss/controls/_container.scss +0 -13
- package/dist/scss/controls/_group.scss +0 -69
- package/dist/scss/controls/_image.scss +0 -27
- package/dist/scss/controls/_number.scss +0 -38
- package/dist/scss/controls/_point.scss +0 -36
- package/dist/scss/controls/_position.scss +0 -9
- package/dist/scss/controls/_select.scss +0 -0
- package/dist/scss/controls/_spherical.scss +0 -87
- package/dist/scss/controls/_tabs.scss +0 -38
- package/dist/scss/controls/_text.scss +0 -0
- package/dist/scss/index.scss +0 -21
- package/dist/tweak-ui.umd.min.js +0 -17
- package/dist/tweak-ui.umd.min.js.map +0 -1
package/dist/index.html
DELETED
|
@@ -1,1063 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<head>
|
|
3
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta property="og:type" content="website">
|
|
6
|
-
<meta property="og:title" content="Tweak Ui">
|
|
7
|
-
<meta property="og:site_name" content="Tweak Ui">
|
|
8
|
-
<meta property="og:url" content="https://tweakui.ginie.eu/">
|
|
9
|
-
<meta property="og:description" content="a lightweight js library for building input controls with data binding">
|
|
10
|
-
<title>Tweak UI</title>
|
|
11
|
-
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
|
|
12
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.0/font/bootstrap-icons.css">
|
|
13
|
-
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
|
|
14
|
-
<link rel="stylesheet" href="https://unpkg.com/prismjs@1.16.0/themes/prism.css">
|
|
15
|
-
<script src="https://unpkg.com/prismjs@1.16.0/prism.js" type="text/javascript"></script>
|
|
16
|
-
<style>
|
|
17
|
-
pre[class*="language-"], .token {
|
|
18
|
-
margin: 0;
|
|
19
|
-
background: none !important;
|
|
20
|
-
}
|
|
21
|
-
.container-xxl > section {
|
|
22
|
-
padding-top: 56px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
</style>
|
|
26
|
-
</head>
|
|
27
|
-
<body data-bs-spy="scroll" data-bs-target="nav.navbar" data-bs-offset="56">
|
|
28
|
-
<div class="bg-dark text-light text-center p-4 mb-0">
|
|
29
|
-
<div class="container">
|
|
30
|
-
<h1 class="display-4">Tweak UI</h1>
|
|
31
|
-
<p class="lead">a lightweight js library for building input controls with data binding.</p>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
<nav class="navbar navbar-expand navbar-dark bg-dark sticky-top" style="z-index: 1021;">
|
|
35
|
-
<div class="container-xxl"><a class="navbar-brand" href="#"></a>
|
|
36
|
-
<ul class="navbar-nav">
|
|
37
|
-
<li class="nav-item dropdown d-none d-sm-block"><a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown">How to</a>
|
|
38
|
-
<ul class="dropdown-menu dropdown-menu-dark">
|
|
39
|
-
<li><a class="dropdown-item" href="#install-npm">Install (NPM)</a></li>
|
|
40
|
-
<li><a class="dropdown-item" href="#install-cdn">Install (CDN)</a></li>
|
|
41
|
-
<li><a class="dropdown-item" href="#usage">Usage</a></li>
|
|
42
|
-
</ul>
|
|
43
|
-
</li>
|
|
44
|
-
<li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown">Components</a>
|
|
45
|
-
<ul class="dropdown-menu dropdown-menu-dark">
|
|
46
|
-
<li><a class="dropdown-item" href="#control-number">Number</a></li>
|
|
47
|
-
<li><a class="dropdown-item" href="#control-slider">Slider</a></li>
|
|
48
|
-
<li><a class="dropdown-item" href="#control-text">Text</a></li>
|
|
49
|
-
<li><a class="dropdown-item" href="#control-checkbox">Checkbox</a></li>
|
|
50
|
-
<li><a class="dropdown-item" href="#control-select">Select</a></li>
|
|
51
|
-
<li><a class="dropdown-item" href="#control-angle">Angle</a></li>
|
|
52
|
-
<li><a class="dropdown-item" href="#control-spherical">Spherical</a></li>
|
|
53
|
-
<li><a class="dropdown-item" href="#control-point">Point</a></li>
|
|
54
|
-
<li><a class="dropdown-item" href="#control-position">Position</a></li>
|
|
55
|
-
<li><a class="dropdown-item" href="#control-color">Color</a></li>
|
|
56
|
-
<li><a class="dropdown-item" href="#control-color-picker">Color picker</a></li>
|
|
57
|
-
<li>
|
|
58
|
-
<hr class="dropdown-divider">
|
|
59
|
-
</li>
|
|
60
|
-
<li><a class="dropdown-item" href="#control-button">Button</a></li>
|
|
61
|
-
<li><a class="dropdown-item" href="#control-image">Image</a></li>
|
|
62
|
-
<li><a class="dropdown-item" href="#control-content">Content</a></li>
|
|
63
|
-
<li>
|
|
64
|
-
<hr class="dropdown-divider">
|
|
65
|
-
</li>
|
|
66
|
-
<li><a class="dropdown-item" href="#control-group">Group</a></li>
|
|
67
|
-
<li><a class="dropdown-item" href="#control-tabs">Tabs</a></li>
|
|
68
|
-
<li><a class="dropdown-item" href="#control-accordion">Accordion</a></li>
|
|
69
|
-
<li><a class="dropdown-item" href="#control-container">Container</a></li>
|
|
70
|
-
</ul>
|
|
71
|
-
</li>
|
|
72
|
-
<li class="nav-item dropdown d-none d-sm-block"><a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown">Concepts</a>
|
|
73
|
-
<ul class="dropdown-menu dropdown-menu-dark">
|
|
74
|
-
<li><a class="dropdown-item" href="#concept-layout">Layout & Labels</a></li>
|
|
75
|
-
<li><a class="dropdown-item" href="#concept-input">Input Values</a></li>
|
|
76
|
-
<li><a class="dropdown-item" href="#concept-mithril">Mithril</a></li>
|
|
77
|
-
<li><a class="dropdown-item" href="#custom-controls">Custom controls</a></li>
|
|
78
|
-
<li><a class="dropdown-item" href="#custom-colors">Theme colors</a></li>
|
|
79
|
-
</ul>
|
|
80
|
-
</li>
|
|
81
|
-
<li class="nav-item"><a class="nav-link" href="#" onclick="openPlayground();">Playground</a></li>
|
|
82
|
-
<li class="nav-item"><a class="nav-link" href="https://github.com/giniedp/tweak-ui" target="_blank">Github</a></li>
|
|
83
|
-
</ul>
|
|
84
|
-
</div>
|
|
85
|
-
</nav>
|
|
86
|
-
<div class="container-xxl">
|
|
87
|
-
<section id="install-npm">
|
|
88
|
-
<h2>Installation (NPM)</h2>
|
|
89
|
-
<p>Install library from NPM</p>
|
|
90
|
-
<ul class="nav nav-tabs">
|
|
91
|
-
<li class="nav-item">
|
|
92
|
-
<button class="nav-link active" type="button" data-bs-toggle="tab" data-bs-target="#install-with-npm">NPM</button>
|
|
93
|
-
</li>
|
|
94
|
-
<li class="nav-item">
|
|
95
|
-
<button class="nav-link" type="button" data-bs-toggle="tab" data-bs-target="#install-with-yarn">Yarn</button>
|
|
96
|
-
</li>
|
|
97
|
-
</ul>
|
|
98
|
-
<div class="tab-content">
|
|
99
|
-
<div class="tab-pane fade active show" id="install-with-npm">
|
|
100
|
-
<pre class="language-shell"><code>$ npm install tweak-ui
|
|
101
|
-
</code></pre>
|
|
102
|
-
</div>
|
|
103
|
-
<div class="tab-pane fade" id="install-with-yarn">
|
|
104
|
-
<pre class="language-shell"><code>$ yarn add tweak-ui
|
|
105
|
-
</code></pre>
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
<p class="mt-3">Then import it in your source code</p>
|
|
109
|
-
<ul class="nav nav-tabs">
|
|
110
|
-
<li class="nav-item">
|
|
111
|
-
<button class="nav-link active" type="button" data-bs-toggle="tab" data-bs-target="#tab-import-es6">ES6</button>
|
|
112
|
-
</li>
|
|
113
|
-
<li class="nav-item">
|
|
114
|
-
<button class="nav-link" type="button" data-bs-toggle="tab" data-bs-target="#tab-import-require">require</button>
|
|
115
|
-
</li>
|
|
116
|
-
</ul>
|
|
117
|
-
<div class="tab-content">
|
|
118
|
-
<div class="tab-pane fade active show" id="tab-import-es6">
|
|
119
|
-
<pre class="language-javascript"><code>import * as TweakUi from "tweak-ui"
|
|
120
|
-
</code></pre>
|
|
121
|
-
</div>
|
|
122
|
-
<div class="tab-pane fade" id="tab-import-require">
|
|
123
|
-
<pre class="language-javascript"><code>var TweakUi = require("tweak-ui")
|
|
124
|
-
</code></pre>
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
<p class="mt-3"><span>The stylesheet is located at</span><br><code> node_modules/tweak-ui/tweak-ui.css</code></p>
|
|
128
|
-
<p class="mt-3"><span>If you are building a custom stylesheet then finde the</span><code> SCSS</code><span> files at</span><br><code> node_modules/tweak-ui/scss</code></p>
|
|
129
|
-
</section>
|
|
130
|
-
<section id="install-cdn">
|
|
131
|
-
<h2>Installation (CDN)</h2>
|
|
132
|
-
<p>Reference the library and style sheet</p>
|
|
133
|
-
<aside class="language-html">
|
|
134
|
-
<script src="https://unpkg.com/tweak-ui@x.x.x/dist/tweak-ui.umd.js"></script>
|
|
135
|
-
<link href="https://unpkg.com/tweak-ui@x.x.x/dist/tweak-ui.css" rel="stylesheet">
|
|
136
|
-
</aside>
|
|
137
|
-
<p class="mt-3">Then in your javascript simply use the<code> TweakUI</code> global</p>
|
|
138
|
-
</section>
|
|
139
|
-
<section id="install-cdn">
|
|
140
|
-
<h2>Usage</h2>
|
|
141
|
-
<p class="mt-3">Create an HTML container where Tweak UI should render.</p>
|
|
142
|
-
<aside class="language-html">
|
|
143
|
-
<div class="my-element"></div>
|
|
144
|
-
|
|
145
|
-
</aside>
|
|
146
|
-
<p class="mt-3">Mount the controls. Either by using a builder function</p>
|
|
147
|
-
<pre class="language-javascript"><code>TweakUi.mount(".my-element", (b) => {
|
|
148
|
-
// ... builder function
|
|
149
|
-
})
|
|
150
|
-
</code></pre>
|
|
151
|
-
<p class="mt-3">or an array of control definitions</p>
|
|
152
|
-
<pre class="language-javascript"><code>TweakUi.mount(".my-element", [
|
|
153
|
-
// ... array of control definitions
|
|
154
|
-
])
|
|
155
|
-
</code></pre>
|
|
156
|
-
<p class="mt-3">or a single control definition</p>
|
|
157
|
-
<pre class="language-javascript"><code>TweakUi.mount(".my-element", {
|
|
158
|
-
// ... control definition
|
|
159
|
-
})</code></pre>
|
|
160
|
-
</section>
|
|
161
|
-
<h2 id="controls">Controls</h2>
|
|
162
|
-
<section id="control-number">
|
|
163
|
-
<h3>Number</h3>
|
|
164
|
-
<div class="row justify-content-center mb-3">
|
|
165
|
-
<div class="col gui flex-grow-0 order-last" id="example-number-1"></div>
|
|
166
|
-
<div class="col">
|
|
167
|
-
<script class="language-javascript" type="text/javascript">
|
|
168
|
-
var context = { a: 10, b: 5 }
|
|
169
|
-
TweakUi.mount("#example-number-1", (ui) => {
|
|
170
|
-
ui.number(context, 'a')
|
|
171
|
-
ui.number(context, 'b', { min: 1, max: 100, step: 0.5 })
|
|
172
|
-
})
|
|
173
|
-
</script>
|
|
174
|
-
</div>
|
|
175
|
-
</div>
|
|
176
|
-
</section>
|
|
177
|
-
<section id="control-slider">
|
|
178
|
-
<h3>Slider</h3>
|
|
179
|
-
<div class="row justify-content-center mb-3">
|
|
180
|
-
<div class="col gui flex-grow-0 order-last" id="example-slider-1"></div>
|
|
181
|
-
<div class="col">
|
|
182
|
-
<script class="language-javascript" type="text/javascript">
|
|
183
|
-
var context = { a: 10, b: 5 }
|
|
184
|
-
TweakUi.mount("#example-slider-1", (ui) => {
|
|
185
|
-
ui.slider(context, 'a', { min: 1, max: 100, step: 0.5 })
|
|
186
|
-
ui.slider(context, 'b', { min: 1, max: 100, step: 0.5 })
|
|
187
|
-
})
|
|
188
|
-
</script>
|
|
189
|
-
</div>
|
|
190
|
-
</div>
|
|
191
|
-
</section>
|
|
192
|
-
<section id="control-text">
|
|
193
|
-
<h3>Text</h3>
|
|
194
|
-
<div class="row justify-content-center mb-3">
|
|
195
|
-
<div class="col gui flex-grow-0 order-last" id="example-text-1"></div>
|
|
196
|
-
<div class="col">
|
|
197
|
-
<script class="language-javascript" type="text/javascript">
|
|
198
|
-
var context = { value: 'Helloo World' }
|
|
199
|
-
TweakUi.mount("#example-text-1", (ui) => {
|
|
200
|
-
ui.text(context, 'value', {
|
|
201
|
-
label: "Text",
|
|
202
|
-
onInput: console.log
|
|
203
|
-
})
|
|
204
|
-
})
|
|
205
|
-
</script>
|
|
206
|
-
</div>
|
|
207
|
-
</div>
|
|
208
|
-
</section>
|
|
209
|
-
<section id="control-checkbox">
|
|
210
|
-
<h3>Checkbox</h3>
|
|
211
|
-
<div class="row justify-content-center mb-3">
|
|
212
|
-
<div class="col gui flex-grow-0 order-last" id="example-checkbox"></div>
|
|
213
|
-
<div class="col">
|
|
214
|
-
<script class="language-javascript" type="text/javascript">
|
|
215
|
-
var context = { value: true }
|
|
216
|
-
TweakUi.mount("#example-checkbox", (ui) => {
|
|
217
|
-
ui.checkbox({ value: true, onChange: console.log })
|
|
218
|
-
ui.checkbox(context, 'value')
|
|
219
|
-
ui.checkbox(context, 'value', { label: 'Label' })
|
|
220
|
-
ui.checkbox(context, 'value', { label: '' })
|
|
221
|
-
ui.checkbox(context, 'value', { label: null, text: 'Annotation' })
|
|
222
|
-
})
|
|
223
|
-
</script>
|
|
224
|
-
</div>
|
|
225
|
-
</div>
|
|
226
|
-
</section>
|
|
227
|
-
<section id="control-select">
|
|
228
|
-
<h3>Select</h3>
|
|
229
|
-
<div class="row justify-content-center mb-3">
|
|
230
|
-
<div class="col gui flex-grow-0 order-last" id="example-select-1"></div>
|
|
231
|
-
<div class="col">
|
|
232
|
-
<script class="language-javascript" type="text/javascript">
|
|
233
|
-
TweakUi.mount("#example-select-1", [{
|
|
234
|
-
type: "select",
|
|
235
|
-
label: "Array",
|
|
236
|
-
value: "foo",
|
|
237
|
-
options: ["foo", "bar", "baz", { label: "a label", value: {} }],
|
|
238
|
-
onInput: console.log
|
|
239
|
-
}, {
|
|
240
|
-
type: "select",
|
|
241
|
-
label: "Key Value",
|
|
242
|
-
value: "foo",
|
|
243
|
-
options: { Foo: "foo", Bar: "bar", Baz: "baz", "A Label": {} },
|
|
244
|
-
onInput: console.log
|
|
245
|
-
}])
|
|
246
|
-
|
|
247
|
-
</script>
|
|
248
|
-
</div>
|
|
249
|
-
</div>
|
|
250
|
-
<div class="row justify-content-center mb-3">
|
|
251
|
-
<div class="col gui flex-grow-0 order-last" id="example-select-2"></div>
|
|
252
|
-
<div class="col">
|
|
253
|
-
<script class="language-javascript" type="text/javascript">
|
|
254
|
-
TweakUi.mount("#example-select-2", [{
|
|
255
|
-
type: "select",
|
|
256
|
-
label: "Key Value",
|
|
257
|
-
value: "foo",
|
|
258
|
-
options: { Foo: "foo", Bar: "bar", Baz: "baz", "A Label": {} },
|
|
259
|
-
onInput: console.log
|
|
260
|
-
}])
|
|
261
|
-
|
|
262
|
-
</script>
|
|
263
|
-
</div>
|
|
264
|
-
</div>
|
|
265
|
-
<div class="row justify-content-center mb-3">
|
|
266
|
-
<div class="col gui flex-grow-0 order-last" id="example-select-3"></div>
|
|
267
|
-
<div class="col">
|
|
268
|
-
<script class="language-javascript" type="text/javascript">
|
|
269
|
-
TweakUi.mount("#example-select-3", [{
|
|
270
|
-
type: "select",
|
|
271
|
-
label: "Groups",
|
|
272
|
-
value: "foo",
|
|
273
|
-
options: [{
|
|
274
|
-
label: "Group 1",
|
|
275
|
-
options: { Foo: "foo", Bar: "bar", Baz: "baz" }
|
|
276
|
-
}, {
|
|
277
|
-
label: "Group 2",
|
|
278
|
-
options: [0, 1, 2, 3]
|
|
279
|
-
}, {
|
|
280
|
-
label: "Group 3",
|
|
281
|
-
options: ["A", "B", "C"]
|
|
282
|
-
}, {
|
|
283
|
-
label: "Group 4",
|
|
284
|
-
options: [
|
|
285
|
-
{ label: "X", value: { foo: "x" } },
|
|
286
|
-
{ label: "Y", value: { foo: "y" } },
|
|
287
|
-
{ label: "Z", value: { foo: "z" }, disabled: true }
|
|
288
|
-
]
|
|
289
|
-
}],
|
|
290
|
-
onInput: console.log
|
|
291
|
-
}])
|
|
292
|
-
</script>
|
|
293
|
-
</div>
|
|
294
|
-
</div>
|
|
295
|
-
</section>
|
|
296
|
-
<section id="control-angle">
|
|
297
|
-
<h3>Angle</h3>
|
|
298
|
-
<p></p>
|
|
299
|
-
<div class="row justify-content-center mb-3">
|
|
300
|
-
<div class="col gui flex-grow-0 order-last" id="example-angle-1"></div>
|
|
301
|
-
<div class="col">
|
|
302
|
-
<script class="language-javascript" type="text/javascript">
|
|
303
|
-
var context = { value: 0 }
|
|
304
|
-
TweakUi.mount("#example-angle-1", (ui) => {
|
|
305
|
-
ui.angle(context, 'value')
|
|
306
|
-
})
|
|
307
|
-
</script>
|
|
308
|
-
</div>
|
|
309
|
-
</div>
|
|
310
|
-
</section>
|
|
311
|
-
<section id="control-spherical">
|
|
312
|
-
<h3>Spherical</h3>
|
|
313
|
-
<p>an object with spherical coordinates</p>
|
|
314
|
-
<div class="row justify-content-center mb-3">
|
|
315
|
-
<div class="col gui flex-grow-0 order-last" id="example-spherical-1"></div>
|
|
316
|
-
<div class="col">
|
|
317
|
-
<script class="language-javascript" type="text/javascript">
|
|
318
|
-
var context = { value: { phi: 0, theta: 0 } }
|
|
319
|
-
TweakUi.mount("#example-spherical-1", (ui) => {
|
|
320
|
-
ui.spherical(context, 'value', {
|
|
321
|
-
label: 'Spherical',
|
|
322
|
-
// degree: true,
|
|
323
|
-
onInput: console.log
|
|
324
|
-
})
|
|
325
|
-
})
|
|
326
|
-
|
|
327
|
-
</script>
|
|
328
|
-
</div>
|
|
329
|
-
</div>
|
|
330
|
-
<p>use a codec to map into 3d vector</p>
|
|
331
|
-
<div class="row justify-content-center mb-3">
|
|
332
|
-
<div class="col gui flex-grow-0 order-last" id="example-spherical-2"></div>
|
|
333
|
-
<div class="col">
|
|
334
|
-
<script class="language-javascript" type="text/javascript">
|
|
335
|
-
var context = { value: [0, 0, -1] }
|
|
336
|
-
TweakUi.mount("#example-spherical-2", (ui) => {
|
|
337
|
-
ui.spherical(context, 'value', {
|
|
338
|
-
label: 'Spherical',
|
|
339
|
-
codec: TweakUi.sphericalCodec({
|
|
340
|
-
axes: { 0: 'right', 1: 'up', 2: 'back'},
|
|
341
|
-
length: -1,
|
|
342
|
-
result: () => []
|
|
343
|
-
}),
|
|
344
|
-
onInput: console.log
|
|
345
|
-
})
|
|
346
|
-
})
|
|
347
|
-
</script>
|
|
348
|
-
</div>
|
|
349
|
-
</div>
|
|
350
|
-
</section>
|
|
351
|
-
<section id="control-point">
|
|
352
|
-
<h3>Point</h3>
|
|
353
|
-
<p>an object with 2d coordinates</p>
|
|
354
|
-
<div class="row justify-content-center mb-3">
|
|
355
|
-
<div class="col gui flex-grow-0 order-last" id="example-point-1"></div>
|
|
356
|
-
<div class="col">
|
|
357
|
-
<script class="language-javascript" type="text/javascript">
|
|
358
|
-
var context = { value: { x: 0, y: 0 } }
|
|
359
|
-
TweakUi.mount("#example-point-1", (ui) => {
|
|
360
|
-
ui.point(context, 'value', {
|
|
361
|
-
xRange: [-1, 1],
|
|
362
|
-
yRange: [-1, 1],
|
|
363
|
-
reset: [0, 0],
|
|
364
|
-
snap: 0.1,
|
|
365
|
-
})
|
|
366
|
-
})
|
|
367
|
-
</script>
|
|
368
|
-
</div>
|
|
369
|
-
</div>
|
|
370
|
-
</section>
|
|
371
|
-
<section id="control-position">
|
|
372
|
-
<h3>Position</h3>
|
|
373
|
-
<p>Object with x, y, z components (default)</p>
|
|
374
|
-
<div class="row justify-content-center mb-3">
|
|
375
|
-
<div class="col gui flex-grow-0 order-last" id="example-position-1"></div>
|
|
376
|
-
<div class="col">
|
|
377
|
-
<script class="language-javascript" type="text/javascript">
|
|
378
|
-
var context = { value: { x: 0, y: 1, z: 0 } }
|
|
379
|
-
TweakUi.mount("#example-position-1", (ui) => {
|
|
380
|
-
ui.position(context, 'value', {
|
|
381
|
-
label: 'Vector',
|
|
382
|
-
min: -1, max: 1, step: 0.125,
|
|
383
|
-
onInput: console.log, onChange: console.log
|
|
384
|
-
})
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
</script>
|
|
388
|
-
</div>
|
|
389
|
-
</div>
|
|
390
|
-
<p>2D Vector</p>
|
|
391
|
-
<div class="row justify-content-center mb-3">
|
|
392
|
-
<div class="col gui flex-grow-0 order-last" id="example-position-2"></div>
|
|
393
|
-
<div class="col">
|
|
394
|
-
<script class="language-javascript" type="text/javascript">
|
|
395
|
-
var context = { value: { x: 0, y: 1 } }
|
|
396
|
-
TweakUi.mount("#example-position-2", (ui) => {
|
|
397
|
-
ui.position(context, 'value', {
|
|
398
|
-
label: 'Vector',
|
|
399
|
-
keys: ['x', 'y'],
|
|
400
|
-
min: -1, max: 1, step: 0.125,
|
|
401
|
-
onInput: console.log, onChange: console.log
|
|
402
|
-
})
|
|
403
|
-
})
|
|
404
|
-
|
|
405
|
-
</script>
|
|
406
|
-
</div>
|
|
407
|
-
</div>
|
|
408
|
-
<p>Array</p>
|
|
409
|
-
<div class="row justify-content-center mb-3">
|
|
410
|
-
<div class="col gui flex-grow-0 order-last" id="example-position-4"></div>
|
|
411
|
-
<div class="col">
|
|
412
|
-
<script class="language-javascript" type="text/javascript">
|
|
413
|
-
var context = { value: [3, 2, 1] }
|
|
414
|
-
TweakUi.mount("#example-position-4", (ui) => {
|
|
415
|
-
ui.position(context, 'value', {
|
|
416
|
-
label: 'Vector',
|
|
417
|
-
keys: [0, 1, 2],
|
|
418
|
-
min: -1, max: 1, step: 0.125,
|
|
419
|
-
onInput: console.log, onChange: console.log
|
|
420
|
-
})
|
|
421
|
-
})
|
|
422
|
-
</script>
|
|
423
|
-
</div>
|
|
424
|
-
</div>
|
|
425
|
-
</section>
|
|
426
|
-
<section id="control-color">
|
|
427
|
-
<h3>Color</h3>
|
|
428
|
-
<p>
|
|
429
|
-
The Color control has a <code>format</code> option which describes how the color value
|
|
430
|
-
should be parsed and encoded. It consists of 2 sections. The prefix specifies whether the color value is a
|
|
431
|
-
</p>
|
|
432
|
-
<ul>
|
|
433
|
-
<li><code>#</code> hex string</li>
|
|
434
|
-
<li><code>0x</code> a number</li>
|
|
435
|
-
<li><code>[]</code> an array</li>
|
|
436
|
-
<li><code>{}</code> an object</li>
|
|
437
|
-
</ul>
|
|
438
|
-
<p>
|
|
439
|
-
The suffix specifies the order of the color components. It may be any combinarion of
|
|
440
|
-
<code>r</code>, <code>g</code>, <code>b</code> and <code>a</code> Here are some examples
|
|
441
|
-
</p>
|
|
442
|
-
<table class="table table-borderless table-sm">
|
|
443
|
-
<thead>
|
|
444
|
-
<tr>
|
|
445
|
-
<th>format</th>
|
|
446
|
-
<th>value (r: 255, g: 128, b: 0, a: 1)</th>
|
|
447
|
-
<th>description</th>
|
|
448
|
-
</tr>
|
|
449
|
-
</thead>
|
|
450
|
-
<tbody>
|
|
451
|
-
<tr>
|
|
452
|
-
<td><code>"#rgb"</code></td>
|
|
453
|
-
<td><code>"#FF8000"</code></td>
|
|
454
|
-
<td>Hex string with red green and blue coded from left to right</td>
|
|
455
|
-
</tr>
|
|
456
|
-
<tr>
|
|
457
|
-
<td><code>"#bgr"</code></td>
|
|
458
|
-
<td><code>"#0080FF"</code></td>
|
|
459
|
-
<td>Hex string with red green and blue coded from right to left</td>
|
|
460
|
-
</tr>
|
|
461
|
-
<tr>
|
|
462
|
-
<td><code>"0xrgb"</code></td>
|
|
463
|
-
<td><code>16744448</code></td>
|
|
464
|
-
<td>number Hex string with red green and blue coded from right to left</td>
|
|
465
|
-
</tr>
|
|
466
|
-
<tr>
|
|
467
|
-
<td><code>"[]rgb"</code></td>
|
|
468
|
-
<td><code>[255, 128, 0]</code></td>
|
|
469
|
-
<td>number array with red green and blue coded from right to left</td>
|
|
470
|
-
</tr>
|
|
471
|
-
<tr>
|
|
472
|
-
<td><code>"{}rgb"</code></td>
|
|
473
|
-
<td><code>{ r: 255, g: 128, b: 0 }</code></td>
|
|
474
|
-
<td>object red green and blue components</td>
|
|
475
|
-
</tr>
|
|
476
|
-
<tr>
|
|
477
|
-
<td><code>"[n]rgb"</code></td>
|
|
478
|
-
<td><code>[1, 0.5, 0]</code></td>
|
|
479
|
-
<td>number array with all components normalized to range [0:1]</td>
|
|
480
|
-
</tr>
|
|
481
|
-
<tr>
|
|
482
|
-
<td><code>"{n}rgb"</code></td>
|
|
483
|
-
<td><code>{ r: 1, g: 0.5, b: 0 }</code></td>
|
|
484
|
-
<td>object red green and blue components normalized to range [0:1]</td>
|
|
485
|
-
</tr>
|
|
486
|
-
</tbody>
|
|
487
|
-
</table>
|
|
488
|
-
<div class="row justify-content-center mb-3">
|
|
489
|
-
<div class="col gui flex-grow-0 order-last" id="example-color"></div>
|
|
490
|
-
<div class="col">
|
|
491
|
-
<script class="language-javascript" type="text/javascript">
|
|
492
|
-
var context = { value: [1, 0, 0] }
|
|
493
|
-
TweakUi.mount("#example-color", (ui) => {
|
|
494
|
-
ui.color(context, 'value', {
|
|
495
|
-
label: 'Color',
|
|
496
|
-
format: '[n]rgb',
|
|
497
|
-
onInput: console.log
|
|
498
|
-
})
|
|
499
|
-
})
|
|
500
|
-
</script>
|
|
501
|
-
</div>
|
|
502
|
-
</div>
|
|
503
|
-
</section>
|
|
504
|
-
<section id="control-color">
|
|
505
|
-
<h3-picker>Color picker</h3-picker>
|
|
506
|
-
<div class="row justify-content-center mb-3">
|
|
507
|
-
<div class="col gui flex-grow-0 order-last" id="example-color-picker"></div>
|
|
508
|
-
<div class="col">
|
|
509
|
-
<script class="language-javascript" type="text/javascript">
|
|
510
|
-
var context = { value: '#fff' }
|
|
511
|
-
TweakUi.mount("#example-color-picker", (ui) => {
|
|
512
|
-
ui.colorPicker(context, 'value', {
|
|
513
|
-
label: 'Color',
|
|
514
|
-
onInput: console.log,
|
|
515
|
-
onChange: console.log,
|
|
516
|
-
})
|
|
517
|
-
})
|
|
518
|
-
</script>
|
|
519
|
-
</div>
|
|
520
|
-
</div>
|
|
521
|
-
</section>
|
|
522
|
-
<section id="control-button">
|
|
523
|
-
<h3>Button</h3>
|
|
524
|
-
<div class="row justify-content-center mb-3">
|
|
525
|
-
<div class="col gui flex-grow-0 order-last" id="example-button"></div>
|
|
526
|
-
<div class="col">
|
|
527
|
-
<script class="language-javascript" type="text/javascript">
|
|
528
|
-
TweakUi.mount("#example-button", (ui) => {
|
|
529
|
-
ui.button('Button', { onClick: console.log })
|
|
530
|
-
ui.button('Button', { label: 'With Label' })
|
|
531
|
-
ui.button('Button', { label: '' })
|
|
532
|
-
})
|
|
533
|
-
</script>
|
|
534
|
-
</div>
|
|
535
|
-
</div>
|
|
536
|
-
</section>
|
|
537
|
-
<section id="control-image">
|
|
538
|
-
<h3>Image</h3>
|
|
539
|
-
<p>Display the image as is</p>
|
|
540
|
-
<div class="row justify-content-center mb-3">
|
|
541
|
-
<div class="col gui flex-grow-0 order-last" id="example-image-1"></div>
|
|
542
|
-
<div class="col">
|
|
543
|
-
<script class="language-javascript" type="text/javascript">
|
|
544
|
-
TweakUi.mount("#example-image-1", (ui) => {
|
|
545
|
-
ui.image("Image", {
|
|
546
|
-
src: "https://picsum.photos/id/893/400/300",
|
|
547
|
-
})
|
|
548
|
-
})
|
|
549
|
-
|
|
550
|
-
</script>
|
|
551
|
-
</div>
|
|
552
|
-
</div>
|
|
553
|
-
<p>Constrain the aspect ratio</p>
|
|
554
|
-
<div class="row justify-content-center mb-3">
|
|
555
|
-
<div class="col gui flex-grow-0 order-last" id="example-image-2"></div>
|
|
556
|
-
<div class="col">
|
|
557
|
-
<script class="language-javascript" type="text/javascript">
|
|
558
|
-
TweakUi.mount("#example-image-2", (ui) => {
|
|
559
|
-
ui.image("Image", {
|
|
560
|
-
src: "https://picsum.photos/id/893/400/300",
|
|
561
|
-
aspect: "16x9"
|
|
562
|
-
})
|
|
563
|
-
})
|
|
564
|
-
|
|
565
|
-
</script>
|
|
566
|
-
</div>
|
|
567
|
-
</div>
|
|
568
|
-
<p>Constrain the display width</p>
|
|
569
|
-
<div class="row justify-content-center mb-3">
|
|
570
|
-
<div class="col gui flex-grow-0 order-last" id="example-image-3"></div>
|
|
571
|
-
<div class="col">
|
|
572
|
-
<script class="language-javascript" type="text/javascript">
|
|
573
|
-
TweakUi.mount("#example-image-3", (ui) => {
|
|
574
|
-
ui.image("Image", {
|
|
575
|
-
src: "https://picsum.photos/id/893/400/300",
|
|
576
|
-
aspect: "16x9",
|
|
577
|
-
width: 100
|
|
578
|
-
})
|
|
579
|
-
})
|
|
580
|
-
</script>
|
|
581
|
-
</div>
|
|
582
|
-
</div>
|
|
583
|
-
</section>
|
|
584
|
-
<section id="control-content">
|
|
585
|
-
<h3>Content</h3>
|
|
586
|
-
<p>simple text or html output</p>
|
|
587
|
-
<div class="row justify-content-center mb-3">
|
|
588
|
-
<div class="col gui flex-grow-0 order-last" id="example-content-1"></div>
|
|
589
|
-
<div class="col">
|
|
590
|
-
<script class="language-javascript" type="text/javascript">
|
|
591
|
-
TweakUi.mount("#example-content-1", (ui) => {
|
|
592
|
-
ui.content("Text", `
|
|
593
|
-
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
|
|
594
|
-
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna
|
|
595
|
-
`)
|
|
596
|
-
ui.content("HTML", TweakUi.h.trust(`
|
|
597
|
-
<i onclick="alert('hijacked')">Dont do this for untrusted input</i>
|
|
598
|
-
`))
|
|
599
|
-
ui.content("Mithril", TweakUi.h('a', {
|
|
600
|
-
target: "_blank",
|
|
601
|
-
href: "https://mithril.js.org/"
|
|
602
|
-
}, 'this is a mithril link'))
|
|
603
|
-
})
|
|
604
|
-
</script>
|
|
605
|
-
</div>
|
|
606
|
-
</div>
|
|
607
|
-
</section>
|
|
608
|
-
<section id="control-group">
|
|
609
|
-
<h3>Group</h3>
|
|
610
|
-
<p>A group with a title header</p>
|
|
611
|
-
<div class="row justify-content-center mb-3">
|
|
612
|
-
<div class="col gui flex-grow-0 order-last" id="example-group-1"></div>
|
|
613
|
-
<div class="col">
|
|
614
|
-
<script class="language-javascript" type="text/javascript">
|
|
615
|
-
TweakUi.mount("#example-group-1", (ui) => {
|
|
616
|
-
ui.group("A Group", () => {
|
|
617
|
-
ui.button("Button")
|
|
618
|
-
ui.button("Button")
|
|
619
|
-
ui.button("Button")
|
|
620
|
-
})
|
|
621
|
-
})
|
|
622
|
-
|
|
623
|
-
</script>
|
|
624
|
-
</div>
|
|
625
|
-
</div>
|
|
626
|
-
<p>Groups may be collapsible</p>
|
|
627
|
-
<div class="row justify-content-center mb-3">
|
|
628
|
-
<div class="col gui flex-grow-0 order-last" id="example-group-2"></div>
|
|
629
|
-
<div class="col">
|
|
630
|
-
<script class="language-javascript" type="text/javascript">
|
|
631
|
-
TweakUi.mount("#example-group-2", (ui) => {
|
|
632
|
-
ui.group("A Group", { collapsible: true }, () => {
|
|
633
|
-
ui.button("Button")
|
|
634
|
-
ui.button("Button")
|
|
635
|
-
ui.button("Button")
|
|
636
|
-
})
|
|
637
|
-
})
|
|
638
|
-
|
|
639
|
-
</script>
|
|
640
|
-
</div>
|
|
641
|
-
</div>
|
|
642
|
-
<p>Nested groups</p>
|
|
643
|
-
<div class="row justify-content-center mb-3">
|
|
644
|
-
<div class="col gui flex-grow-0 order-last" id="example-group-3"></div>
|
|
645
|
-
<div class="col">
|
|
646
|
-
<script class="language-javascript" type="text/javascript">
|
|
647
|
-
TweakUi.mount("#example-group-3", (ui) => {
|
|
648
|
-
ui.group("A Group", { collapsible: true }, () => {
|
|
649
|
-
ui.group("Sub group", { collapsible: true }, () => {
|
|
650
|
-
ui.button("Button")
|
|
651
|
-
ui.button("Button")
|
|
652
|
-
ui.button("Button")
|
|
653
|
-
})
|
|
654
|
-
ui.group("Sub group", { collapsible: true }, () => {
|
|
655
|
-
ui.button("Button")
|
|
656
|
-
ui.button("Button")
|
|
657
|
-
ui.button("Button")
|
|
658
|
-
})
|
|
659
|
-
})
|
|
660
|
-
})
|
|
661
|
-
</script>
|
|
662
|
-
</div>
|
|
663
|
-
</div>
|
|
664
|
-
</section>
|
|
665
|
-
<section id="control-tabs">
|
|
666
|
-
<h3>Tabs</h3>
|
|
667
|
-
<p>Renders sub groups as tabs</p>
|
|
668
|
-
<div class="row justify-content-center mb-3">
|
|
669
|
-
<div class="col gui flex-grow-0 order-last" id="example-tabs-1"></div>
|
|
670
|
-
<div class="col">
|
|
671
|
-
<script class="language-javascript" type="text/javascript">
|
|
672
|
-
TweakUi.mount("#example-tabs-1", (ui) => {
|
|
673
|
-
ui.tabs((tabs) => {
|
|
674
|
-
ui.group("Tab 1", () => {
|
|
675
|
-
ui.button("Button")
|
|
676
|
-
})
|
|
677
|
-
ui.group("Tab 2", () => {
|
|
678
|
-
ui.number({ label: "Number" })
|
|
679
|
-
})
|
|
680
|
-
ui.group("Tab 3", () => {
|
|
681
|
-
ui.text({ label: "Text" })
|
|
682
|
-
})
|
|
683
|
-
})
|
|
684
|
-
})
|
|
685
|
-
</script>
|
|
686
|
-
</div>
|
|
687
|
-
</div>
|
|
688
|
-
</section>
|
|
689
|
-
<section id="control-accordion">
|
|
690
|
-
<h3>Accordion</h3>
|
|
691
|
-
<p>Automatically handles the collapse state of sub groups</p>
|
|
692
|
-
<div class="row justify-content-center mb-3">
|
|
693
|
-
<div class="col gui flex-grow-0 order-last" id="example-accordion-1"></div>
|
|
694
|
-
<div class="col">
|
|
695
|
-
<script class="language-javascript" type="text/javascript">
|
|
696
|
-
var person = { name: "John Doe", age: 42, eyes: '#4F8' }
|
|
697
|
-
TweakUi.mount("#example-accordion-1", (ui) => {
|
|
698
|
-
ui.accordion({ expand: 0 }, () => {
|
|
699
|
-
ui.group("Group 1", () => {
|
|
700
|
-
ui.text(person, 'name')
|
|
701
|
-
ui.number(person, 'age')
|
|
702
|
-
})
|
|
703
|
-
ui.group("Group 2", () => {
|
|
704
|
-
ui.color(person, 'eyes')
|
|
705
|
-
})
|
|
706
|
-
})
|
|
707
|
-
})
|
|
708
|
-
</script>
|
|
709
|
-
</div>
|
|
710
|
-
</div>
|
|
711
|
-
</section>
|
|
712
|
-
<section id="control-container">
|
|
713
|
-
<h3>Container</h3>
|
|
714
|
-
<p>A simple flexbox container. Can be either horizontal or vertical. For more flexibility combine nested containers with custom style rules.</p>
|
|
715
|
-
<div class="row justify-content-center mb-3">
|
|
716
|
-
<div class="col gui flex-grow-0 order-last" id="example-container-1"></div>
|
|
717
|
-
<div class="col">
|
|
718
|
-
<script class="language-javascript" type="text/javascript">
|
|
719
|
-
TweakUi.mount("#example-container-1", (ui) => {
|
|
720
|
-
ui.container({ horizontal: true }, () => {
|
|
721
|
-
ui.container({ style: { flex: 'none' } }, () => {
|
|
722
|
-
ui.image("Image", {
|
|
723
|
-
src: "https://picsum.photos/300/300",
|
|
724
|
-
width: '4rem'
|
|
725
|
-
})
|
|
726
|
-
})
|
|
727
|
-
|
|
728
|
-
ui.container(() => {
|
|
729
|
-
ui.button("Button", { label: "Label" })
|
|
730
|
-
ui.button("Button", { label: "Label" })
|
|
731
|
-
ui.button("Button", { label: "Label" })
|
|
732
|
-
})
|
|
733
|
-
})
|
|
734
|
-
})
|
|
735
|
-
</script>
|
|
736
|
-
</div>
|
|
737
|
-
</div>
|
|
738
|
-
</section>
|
|
739
|
-
<h2 id="concepts">Concepts</h2>
|
|
740
|
-
<section id="concept-layout">
|
|
741
|
-
<h3>Layout & Labels</h3>
|
|
742
|
-
<p>
|
|
743
|
-
The main container has a fixed width of <code>20rem</code> which is <code>320px</code> on this page.
|
|
744
|
-
All controlls are stacked vertically. The default stylesheet uses the <code>flex-box</code> layout model
|
|
745
|
-
which should render just fine on <a href="https://caniuse.com/#feat=flexbox" target="_blank"> all modern browsers </a>
|
|
746
|
-
</p>
|
|
747
|
-
<p>
|
|
748
|
-
Almost all controls have a label to their left side. Hhowever this is only rendered if the <code>label</code> option
|
|
749
|
-
is actually set. If you want to alignt the controls vertically you have to set the <code>label</code> option
|
|
750
|
-
at least to an empty string.
|
|
751
|
-
</p>
|
|
752
|
-
<div class="row justify-content-center mb-3">
|
|
753
|
-
<div class="col gui flex-grow-0 order-last" id="example-labels-1"></div>
|
|
754
|
-
<div class="col">
|
|
755
|
-
<script class="language-javascript" type="text/javascript">
|
|
756
|
-
TweakUi.mount("#example-labels-1", [
|
|
757
|
-
{ type: "text", value: "i dont have a label" },
|
|
758
|
-
{ type: "text", label: "My text", value: "i do have a label" },
|
|
759
|
-
{ type: "text", label: "", value: "i have an empty label" }
|
|
760
|
-
])
|
|
761
|
-
</script>
|
|
762
|
-
</div>
|
|
763
|
-
</div>
|
|
764
|
-
</section>
|
|
765
|
-
<section id="concept-input">
|
|
766
|
-
<h3>Input values</h3>
|
|
767
|
-
<p>There are several ways how to provide and retreive input values.</p>
|
|
768
|
-
<p>Use the <code>value</code> property to set the inital value and then listen for change</p>
|
|
769
|
-
<div class="row justify-content-center mb-3">
|
|
770
|
-
<div class="col gui flex-grow-0 order-last" id="example-values-1"></div>
|
|
771
|
-
<div class="col">
|
|
772
|
-
<script class="language-javascript" type="text/javascript">
|
|
773
|
-
TweakUi.mount("#example-values-1", [{
|
|
774
|
-
type: "text",
|
|
775
|
-
label: "My text",
|
|
776
|
-
value: "i have a label",
|
|
777
|
-
onInput: (it, value) => { console.log(it, value) }
|
|
778
|
-
}])
|
|
779
|
-
|
|
780
|
-
</script>
|
|
781
|
-
</div>
|
|
782
|
-
</div>
|
|
783
|
-
<p class="mt-3">Use getters and setters (ECMAScript 5 and above)</p>
|
|
784
|
-
<div class="row justify-content-center mb-3">
|
|
785
|
-
<div class="col gui flex-grow-0 order-last" id="example-values-2"></div>
|
|
786
|
-
<div class="col">
|
|
787
|
-
<script class="language-javascript" type="text/javascript">
|
|
788
|
-
TweakUi.mount("#example-values-2", [{
|
|
789
|
-
type: "text",
|
|
790
|
-
label: "Page Title",
|
|
791
|
-
get value() { return window.document.title },
|
|
792
|
-
set value(v) { window.document.title = v },
|
|
793
|
-
onInput: (it, value) => { console.log(it, value) }
|
|
794
|
-
}])
|
|
795
|
-
|
|
796
|
-
</script>
|
|
797
|
-
</div>
|
|
798
|
-
</div>
|
|
799
|
-
<p class="mt-3">Use a <code>target</code> object and provide a <code>property</code> name to get and set the value</p>
|
|
800
|
-
<div class="row justify-content-center mb-3">
|
|
801
|
-
<div class="col gui flex-grow-0 order-last" id="example-values-3"></div>
|
|
802
|
-
<div class="col">
|
|
803
|
-
<script class="language-javascript" type="text/javascript">
|
|
804
|
-
TweakUi.mount("#example-values-3", [{
|
|
805
|
-
type: "text",
|
|
806
|
-
label: "Page Title",
|
|
807
|
-
target: window.document,
|
|
808
|
-
property: "title"
|
|
809
|
-
}])
|
|
810
|
-
</script>
|
|
811
|
-
</div>
|
|
812
|
-
</div>
|
|
813
|
-
</section>
|
|
814
|
-
<section id="concept-mithril">
|
|
815
|
-
<h3>Mithril</h3>
|
|
816
|
-
<p>
|
|
817
|
-
This library is based on <a href="https://mithril.js.org/">mithril</a>. All key concepts of mithril
|
|
818
|
-
also apply to this library. So if you are about to write your own controls for Tweak UI dont forget
|
|
819
|
-
to check mithrils documentation.
|
|
820
|
-
</p>
|
|
821
|
-
</section>
|
|
822
|
-
<section id="custom-controls">
|
|
823
|
-
<h3>Custom controls</h3>
|
|
824
|
-
<p>
|
|
825
|
-
Register your custom controls by using the <code>component</code> function.
|
|
826
|
-
The argument must be a unique name and a component class or component factory.
|
|
827
|
-
Consult the documentation of <a href="https://mithril.js.org/components.html" target="_blank">mithriljs</a>
|
|
828
|
-
for how the components work. Take a look at the source code for how Tweak Ui components are
|
|
829
|
-
implemented.
|
|
830
|
-
|
|
831
|
-
</p>
|
|
832
|
-
<div class="row justify-content-center mb-3">
|
|
833
|
-
<div class="col gui flex-grow-0 order-last" id="example-register-1"></div>
|
|
834
|
-
<div class="col">
|
|
835
|
-
<script class="language-javascript" type="text/javascript">
|
|
836
|
-
TweakUi.component("embed", (node) => {
|
|
837
|
-
return {
|
|
838
|
-
view: () => {
|
|
839
|
-
return TweakUi.h('embed', {
|
|
840
|
-
src: node.attrs.data.src,
|
|
841
|
-
width: node.attrs.data.width,
|
|
842
|
-
height: node.attrs.data.height
|
|
843
|
-
})
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
})
|
|
847
|
-
|
|
848
|
-
TweakUi.mount("#example-register-1", [{
|
|
849
|
-
type: "embed",
|
|
850
|
-
label: "Youtube",
|
|
851
|
-
width: 220,
|
|
852
|
-
src: [
|
|
853
|
-
"https://www.youtube.com/embed/QH2-TGUlwu4",
|
|
854
|
-
"?rel=0&autoplay=0&mute=1"
|
|
855
|
-
].join("")
|
|
856
|
-
}])
|
|
857
|
-
</script>
|
|
858
|
-
</div>
|
|
859
|
-
</div>
|
|
860
|
-
</section>
|
|
861
|
-
<section id="custom-colors">
|
|
862
|
-
<h3>Change Theme colors</h3>
|
|
863
|
-
<p>
|
|
864
|
-
Tweak ui comes with a default theme and the alternatives <code>.twui-dark</code> and <code>.twui-light</code>.
|
|
865
|
-
Add one of these classes to the root element to change the look.
|
|
866
|
-
</p>
|
|
867
|
-
<div class="row justify-content-center mb-3">
|
|
868
|
-
<div class="col gui flex-grow-0 order-last" id="example-theme-1"></div>
|
|
869
|
-
<div class="col"><span>this is default</span>
|
|
870
|
-
<script type="text/javascript">
|
|
871
|
-
TweakUi.mount("#example-theme-1", [{
|
|
872
|
-
type: "button",
|
|
873
|
-
text: "Button",
|
|
874
|
-
label: ""
|
|
875
|
-
}, {
|
|
876
|
-
type: "number",
|
|
877
|
-
label: "Number",
|
|
878
|
-
value: 0
|
|
879
|
-
}, {
|
|
880
|
-
type: "text",
|
|
881
|
-
label: "Text",
|
|
882
|
-
value: "Hello World"
|
|
883
|
-
}, {
|
|
884
|
-
type: "color",
|
|
885
|
-
label: "Color",
|
|
886
|
-
value: "#ff00ff"
|
|
887
|
-
}])
|
|
888
|
-
|
|
889
|
-
</script>
|
|
890
|
-
</div>
|
|
891
|
-
</div>
|
|
892
|
-
<div class="row justify-content-center mb-3">
|
|
893
|
-
<div class="col gui flex-grow-0 order-last twui-dark" id="example-theme-2"></div>
|
|
894
|
-
<div class="col"><code>.twui-dark</code>
|
|
895
|
-
<script type="text/javascript">
|
|
896
|
-
TweakUi.mount("#example-theme-2", [{
|
|
897
|
-
type: "button",
|
|
898
|
-
text: "Button",
|
|
899
|
-
label: ""
|
|
900
|
-
}, {
|
|
901
|
-
type: "number",
|
|
902
|
-
label: "Number",
|
|
903
|
-
value: 0
|
|
904
|
-
}, {
|
|
905
|
-
type: "text",
|
|
906
|
-
label: "Text",
|
|
907
|
-
value: "Hello World"
|
|
908
|
-
}, {
|
|
909
|
-
type: "color",
|
|
910
|
-
label: "Color",
|
|
911
|
-
value: "#ff00ff"
|
|
912
|
-
}])
|
|
913
|
-
|
|
914
|
-
</script>
|
|
915
|
-
</div>
|
|
916
|
-
</div>
|
|
917
|
-
<div class="row justify-content-center mb-3">
|
|
918
|
-
<div class="col gui flex-grow-0 order-last twui-light" id="example-theme-3"></div>
|
|
919
|
-
<div class="col"><code>.twui-light</code>
|
|
920
|
-
<script type="text/javascript">
|
|
921
|
-
TweakUi.mount("#example-theme-3", [{
|
|
922
|
-
type: "button",
|
|
923
|
-
text: "Button",
|
|
924
|
-
label: ""
|
|
925
|
-
}, {
|
|
926
|
-
type: "number",
|
|
927
|
-
label: "Number",
|
|
928
|
-
value: 0
|
|
929
|
-
}, {
|
|
930
|
-
type: "text",
|
|
931
|
-
label: "Text",
|
|
932
|
-
value: "Hello World"
|
|
933
|
-
}, {
|
|
934
|
-
type: "color",
|
|
935
|
-
label: "Color",
|
|
936
|
-
value: "#ff00ff"
|
|
937
|
-
}])
|
|
938
|
-
|
|
939
|
-
</script>
|
|
940
|
-
</div>
|
|
941
|
-
</div>
|
|
942
|
-
<p>
|
|
943
|
-
Another quick and easy way is to change the CSS variables for the root element.
|
|
944
|
-
However <a href="https://caniuse.com/#feat=css-variables" target="_blank">not all browsers</a> support that.
|
|
945
|
-
Read more about CSS variables
|
|
946
|
-
<a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties">here </a>,
|
|
947
|
-
<a target="_blank" href="https://www.w3schools.com/css/css3_variables.asp">here </a> or
|
|
948
|
-
<a target="_blank" href="https://medium.freecodecamp.org/learn-css-variables-in-5-minutes-80cf63b4025d">here </a>
|
|
949
|
-
|
|
950
|
-
</p>
|
|
951
|
-
<div class="row justify-content-center mb-3">
|
|
952
|
-
<div class="col gui flex-grow-0 order-last" id="example-theme-4"></div>
|
|
953
|
-
<div class="col">
|
|
954
|
-
<style class="language-css">
|
|
955
|
-
#example-theme-4 {
|
|
956
|
-
--twui-color-primary: #263238;
|
|
957
|
-
--twui-color-primary-dark: #000a12;
|
|
958
|
-
--twui-color-primary-light: #4f5b62;
|
|
959
|
-
--twui-color-secondary: #37474f;
|
|
960
|
-
--twui-color-secondary-dark: #102027;
|
|
961
|
-
--twui-color-secondary-light: #62727b;
|
|
962
|
-
--twui-color-on-primary: #fff;
|
|
963
|
-
--twui-color-on-secondary: #fff;
|
|
964
|
-
--twui-color-accent: #f9AA33;
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
</style>
|
|
968
|
-
<script type="text/javascript">
|
|
969
|
-
TweakUi.mount("#example-theme-4", [{
|
|
970
|
-
type: "button",
|
|
971
|
-
text: "Button",
|
|
972
|
-
label: ""
|
|
973
|
-
}, {
|
|
974
|
-
type: "number",
|
|
975
|
-
label: "Number",
|
|
976
|
-
value: 0
|
|
977
|
-
}, {
|
|
978
|
-
type: "text",
|
|
979
|
-
label: "Text",
|
|
980
|
-
value: "Hello World"
|
|
981
|
-
}, {
|
|
982
|
-
type: "color",
|
|
983
|
-
label: "Color",
|
|
984
|
-
value: "#ff00ff"
|
|
985
|
-
}])
|
|
986
|
-
</script>
|
|
987
|
-
</div>
|
|
988
|
-
</div>
|
|
989
|
-
</section>
|
|
990
|
-
<script type="text/javascript">function formatText(text) {
|
|
991
|
-
var lines = text.split(/\n/gi).filter((it) => it.trim())
|
|
992
|
-
var indent = Number.MAX_VALUE
|
|
993
|
-
for (var i = 0; i < lines.length; i++) {
|
|
994
|
-
if (lines[i].trim()) {
|
|
995
|
-
indent = Math.min(indent, lines[i].match(/^\s*/)[0].length)
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
for (var i = 0; i < lines.length; i++) {
|
|
999
|
-
if (lines[i].trim()) {
|
|
1000
|
-
lines[i] = lines[i].substr(indent)
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
return lines.join("\n")
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
document.querySelectorAll("aside.language-html,script.language-javascript,style.language-css").forEach((node) => {
|
|
1007
|
-
let pre = document.createElement('pre')
|
|
1008
|
-
let code = document.createElement('code')
|
|
1009
|
-
pre.appendChild(code)
|
|
1010
|
-
code.textContent = formatText(node.innerHTML)
|
|
1011
|
-
code.setAttribute("class", node.getAttribute("class"))
|
|
1012
|
-
node.parentNode.insertBefore(pre, node.nextSibling)
|
|
1013
|
-
})
|
|
1014
|
-
|
|
1015
|
-
</script>
|
|
1016
|
-
<section id="comments">
|
|
1017
|
-
<h3>Comments</h3>
|
|
1018
|
-
<section id="disqus_thread"></section>
|
|
1019
|
-
<script type="text/javascript">
|
|
1020
|
-
var disqus_shortname = 'tweak-ui';
|
|
1021
|
-
var disqus_url = 'https://tweak-ui.ginie.eu';
|
|
1022
|
-
(function(){
|
|
1023
|
-
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
|
1024
|
-
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
|
|
1025
|
-
(document.getElementsByTagName('body')[0]).appendChild(dsq);
|
|
1026
|
-
})();
|
|
1027
|
-
</script>
|
|
1028
|
-
</section>
|
|
1029
|
-
<section>
|
|
1030
|
-
<script src="https://unpkg.com/@stackblitz/sdk/bundles/sdk.umd.js" async></script>
|
|
1031
|
-
<script type="text/javascript">
|
|
1032
|
-
function openPlayground() {
|
|
1033
|
-
StackBlitzSDK.openProject({
|
|
1034
|
-
files: {
|
|
1035
|
-
"index.ts": formatText(document.querySelector('script.playground-ts').text),
|
|
1036
|
-
"index.html": formatText(document.querySelector('script.playground-html').text)
|
|
1037
|
-
},
|
|
1038
|
-
title: "Tweak UI Playground",
|
|
1039
|
-
description: "Tweak UI Playground",
|
|
1040
|
-
template: "typescript",
|
|
1041
|
-
tags: ["tweakui"],
|
|
1042
|
-
dependencies: {
|
|
1043
|
-
"tweak-ui": "*"
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
</script>
|
|
1050
|
-
<script class="playground-html" type="text/plain">
|
|
1051
|
-
<div class="tweak-ui"></div>
|
|
1052
|
-
|
|
1053
|
-
</script>
|
|
1054
|
-
<script class="playground-ts" type="text/plain">
|
|
1055
|
-
import 'tweak-ui/dist/tweak-ui.css'
|
|
1056
|
-
import * as TweakUI from 'tweak-ui'
|
|
1057
|
-
TweakUI.mount('.tweak-ui', (t) => {
|
|
1058
|
-
t.button('Hello World')
|
|
1059
|
-
})
|
|
1060
|
-
</script>
|
|
1061
|
-
</section>
|
|
1062
|
-
</div>
|
|
1063
|
-
</body>
|