-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.tsx
201 lines (194 loc) · 5.34 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//@ts-ignore
import Nexus from "nexusui";
import * as React from "react";
import { render } from "react-dom";
import {
Button,
Toggle,
Dial,
Number,
Position,
Slider,
Envelope,
Multislider,
Piano,
RadioButton,
Select,
Sequencer,
TextButton,
Tilt,
Pan,
Pan2D
} from "../src/";
function TitleAndChildren({ children, title }) {
return (
<div style={{ margin: 10 }}>
<h2 className={"subtitle"}>{title}</h2>
{children}
</div>
);
}
function Core() {
return (
<section className="section">
<div className="container">
<h2 className="title">Core</h2>
<div style={{ display: "flex", flexWrap: "wrap" }}>
<TitleAndChildren title={"Toggle"}>
<Toggle size={[100, 30]} state={false} />
</TitleAndChildren>
<TitleAndChildren title={"Button"}>
<Button size={[100, 30]} mode={"button"} state={false} />
</TitleAndChildren>
<TitleAndChildren title={"Dial"}>
<Dial
interaction={"radial"}
onChange={console.log}
value={Math.random()}
min={0}
max={10}
/>
</TitleAndChildren>
<TitleAndChildren title={"Button"}>
<Number step={1} min={0} max={10} value={4} />
</TitleAndChildren>
<TitleAndChildren title="Position">
<Position onChange={console.log} />
</TitleAndChildren>
<TitleAndChildren title="Slider">
<Slider size={[120, 20]} onChange={console.log} />
</TitleAndChildren>
</div>
</div>
</section>
);
}
function General() {
const sequencerRef = React.useRef<null | Nexus.Sequencer>(null);
return (
<section className="section">
<div className="container">
<h2 className="title">General</h2>
<div style={{ display: "flex", flexWrap: "wrap" }}>
<TitleAndChildren title="Envelope">
<Envelope points={[{ x: 0.1, y: 0.4 }]} />
</TitleAndChildren>
<TitleAndChildren title="Multislider">
<Multislider
size={[200, 100]}
numberOfSliders={5}
min={0}
max={1}
step={0}
candycane={3}
values={[0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1]}
smoothing={0}
mode={"bar"}
onChange={console.warn}
/>
</TitleAndChildren>
<TitleAndChildren title={"Piano"}>
<Piano
size={[500, 125]}
mode={"button"}
lowNote={24}
highNote={60}
onReady={nexusPiano => {
// console.warn(nexusPiano);
}}
/>
</TitleAndChildren>
<TitleAndChildren title="RadioButton">
<RadioButton
size={[180, 25]}
numberOfButtons={4}
onChange={active => {
console.warn({ active });
}}
/>
</TitleAndChildren>
<TitleAndChildren title="Select">
<Select options={["default", "options"]} value={"options"} />
</TitleAndChildren>
<TitleAndChildren title="Sequencer">
<Sequencer
rows={5}
columns={10}
size={[400, 200]}
onStep={console.warn}
onReady={sequencer => (sequencerRef.current = sequencer)}
/>
<div>
<button
onClick={() => {
sequencerRef.current.start(500);
}}
>
Play Sequencer
</button>
<button
onClick={() => {
sequencerRef.current.stop(500);
}}
>
Stop Sequencer
</button>
</div>
</TitleAndChildren>
<TitleAndChildren title={"TextButton"}>
<TextButton text={"Hi"} state={false} />
<TextButton text={"Hi"} alternateText={"Bye"} state={true} />
</TitleAndChildren>
</div>
</div>
</section>
);
}
function Mobile() {
return (
<section className="section">
<div className="container">
<h2 className="title">Mobile</h2>
<div style={{ display: "flex", flexWrap: "wrap" }}>
<TitleAndChildren title={"Tilt"}>
<Tilt
size={[200, 100]}
active={true}
onChange={tilt => {
console.log("Tilt changed", tilt);
}}
/>
</TitleAndChildren>
</div>
</div>
</section>
);
}
function Spatialization() {
return (
<section className="section">
<div className="container">
<h2 className="title">Spatialization</h2>
<div style={{ display: "flex", flexWrap: "wrap" }}>
<TitleAndChildren title={"Pan"}>
<Pan value={0} />
</TitleAndChildren>
<TitleAndChildren title={"Pan2D"}>
<Pan2D onChange={console.warn} />
</TitleAndChildren>
</div>
</div>
</section>
);
}
function App() {
return (
<React.Fragment>
<Core />
<General />
<Mobile />
<Spatialization />
</React.Fragment>
);
}
render(<App />, document.getElementById("app"));