@tremolo-ui/react 0.1.6 → 0.2.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/dist/index.cjs +166 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +109 -71
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +158 -152
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +160 -154
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +167 -145
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Knob/index.css +20 -26
- package/src/components/Knob/index.tsx +7 -7
- package/src/components/NumberInput/index.css +31 -15
- package/src/components/NumberInput/index.tsx +19 -10
- package/src/components/Piano/index.css +7 -14
- package/src/components/Piano/index.tsx +10 -7
- package/src/components/Slider/Thumb.tsx +1 -1
- package/src/components/Slider/Track.tsx +1 -1
- package/src/components/Slider/index.css +33 -8
- package/src/components/Slider/index.tsx +23 -23
- package/src/components/XYPad/Area.tsx +4 -3
- package/src/components/XYPad/Thumb.tsx +8 -4
- package/src/components/XYPad/index.css +18 -4
- package/src/components/XYPad/index.tsx +23 -17
- package/src/index.ts +14 -26
- package/src/styles/global.css +0 -4
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
color: oklch(69.2% 0.17548 266.373);
|
|
15
15
|
|
|
16
16
|
:where(.tremolo-knob:focus, .tremolo-knob:hover) & {
|
|
17
|
-
color:
|
|
17
|
+
color: oklch(59.5% 0.17548 266.373);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
:where(.tremolo-knob[aria-disabled='true']) & {
|
|
@@ -22,43 +22,43 @@
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
color: var(--tremolo-theme-color);
|
|
25
|
+
.tremolo-knob-inactive-line {
|
|
26
|
+
color: oklch(95% 0 0);
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
28
|
+
:where(.tremolo-knob:focus, .tremolo-knob:hover) & {
|
|
29
|
+
color: oklch(90% 0 0);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
.tremolo-knob-
|
|
36
|
-
color: oklch(
|
|
33
|
+
.tremolo-knob-thumb {
|
|
34
|
+
color: oklch(85.7% 0 0);
|
|
37
35
|
|
|
38
36
|
:where(.tremolo-knob:focus, .tremolo-knob:hover) & {
|
|
39
|
-
color: oklch(
|
|
37
|
+
color: oklch(84.5% 0 0);
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
|
|
41
|
+
.tremolo-knob-thumb-line {
|
|
42
|
+
color: oklch(94.2% 0 0);
|
|
43
|
+
}
|
|
44
|
+
|
|
43
45
|
:where(.dark, [data-theme='dark']) {
|
|
44
|
-
.tremolo-knob-
|
|
45
|
-
color: oklch(
|
|
46
|
+
.tremolo-knob-active-line {
|
|
47
|
+
color: oklch(59.5% 0.17548 266.373);
|
|
46
48
|
|
|
47
49
|
:where(.tremolo-knob:focus, .tremolo-knob:hover) & {
|
|
48
|
-
color: oklch(
|
|
50
|
+
color: oklch(65.2% 0.17548 266.373);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
}
|
|
52
53
|
|
|
53
|
-
.tremolo-knob-
|
|
54
|
-
|
|
54
|
+
.tremolo-knob-inactive-line {
|
|
55
|
+
color: oklch(41.7% 0 0);
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
:where(.tremolo-knob:focus, .tremolo-knob:hover) & {
|
|
58
|
+
color: oklch(44.59% 0 0);
|
|
59
|
+
}
|
|
58
60
|
}
|
|
59
|
-
}
|
|
60
61
|
|
|
61
|
-
:where(.dark, [data-theme='dark']) {
|
|
62
62
|
.tremolo-knob-thumb {
|
|
63
63
|
color: oklch(48.6% 0 0);
|
|
64
64
|
|
|
@@ -66,13 +66,7 @@
|
|
|
66
66
|
color: oklch(51.7% 0 0);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
}
|
|
70
69
|
|
|
71
|
-
.tremolo-knob-thumb-line {
|
|
72
|
-
color: oklch(94.2% 0 0);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
:where(.dark, [data-theme='dark']) {
|
|
76
70
|
.tremolo-knob-thumb-line {
|
|
77
71
|
color: oklch(84.2% 0 0);
|
|
78
72
|
}
|
|
@@ -286,13 +286,6 @@ export const Knob = forwardRef<KnobMethods, Props>(
|
|
|
286
286
|
strokeWidth={lineWeight}
|
|
287
287
|
/>
|
|
288
288
|
)}
|
|
289
|
-
<path
|
|
290
|
-
className={clsx('tremolo-knob-active-line', classes?.activeLine)}
|
|
291
|
-
d={`M ${x2} ${y2} A ${center} ${center} -135 ${r3 - r2 > 180 ? 1 : 0} 1 ${x3}, ${y3}`}
|
|
292
|
-
fill="none"
|
|
293
|
-
stroke={activeLine || 'currentColor'}
|
|
294
|
-
strokeWidth={lineWeight}
|
|
295
|
-
/>
|
|
296
289
|
{startValue < max && (
|
|
297
290
|
<path
|
|
298
291
|
className={clsx(
|
|
@@ -305,6 +298,13 @@ export const Knob = forwardRef<KnobMethods, Props>(
|
|
|
305
298
|
strokeWidth={lineWeight}
|
|
306
299
|
/>
|
|
307
300
|
)}
|
|
301
|
+
<path
|
|
302
|
+
className={clsx('tremolo-knob-active-line', classes?.activeLine)}
|
|
303
|
+
d={`M ${x2} ${y2} A ${center} ${center} -135 ${r3 - r2 > 180 ? 1 : 0} 1 ${x3}, ${y3}`}
|
|
304
|
+
fill="none"
|
|
305
|
+
stroke={activeLine || 'currentColor'}
|
|
306
|
+
strokeWidth={lineWeight}
|
|
307
|
+
/>
|
|
308
308
|
{/* thumb */}
|
|
309
309
|
<svg className={clsx('tremolo-knob-thumb', classes?.thumb)}>
|
|
310
310
|
<circle
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
.tremolo-number-input-wrapper {
|
|
2
2
|
--border-radius: 4px;
|
|
3
3
|
--stepper-width: 20px;
|
|
4
|
-
--active-color:
|
|
4
|
+
--active-color: oklch(59.5% 0.17548 266.373);
|
|
5
|
+
--border-color: oklch(81% 0 0);
|
|
5
6
|
|
|
6
7
|
display: inline-flex;
|
|
7
8
|
flex-direction: row;
|
|
@@ -9,13 +10,13 @@
|
|
|
9
10
|
width: 140px;
|
|
10
11
|
height: min-content;
|
|
11
12
|
border-style: solid;
|
|
12
|
-
border-color:
|
|
13
|
+
border-color: var(--border-color);
|
|
13
14
|
border-width: 0px;
|
|
14
15
|
outline: none;
|
|
15
16
|
transition: all 0.1s;
|
|
16
17
|
|
|
17
18
|
&:not(:focus-within):has(> .tremolo-number-input[data-error='true']) {
|
|
18
|
-
border-color:
|
|
19
|
+
border-color: oklch(64.245% 0.21266 25.499);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
&[data-variant='outline'] {
|
|
@@ -23,29 +24,30 @@
|
|
|
23
24
|
border-radius: var(--border-radius);
|
|
24
25
|
|
|
25
26
|
&:hover {
|
|
26
|
-
border-color:
|
|
27
|
+
--border-color: oklch(65.335% 0 0);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
&:focus-within {
|
|
30
|
-
border-color: var(--active-color);
|
|
31
|
+
--border-color: var(--active-color);
|
|
31
32
|
box-shadow: 0px 0px 0px 2px
|
|
32
33
|
color-mix(in srgb, var(--active-color) 10%, transparent);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
&[data-variant='filled'] {
|
|
38
|
+
--bg: oklch(95.88% 0 0);
|
|
37
39
|
border-width: 1px;
|
|
38
40
|
border-radius: var(--border-radius);
|
|
39
41
|
border-color: transparent;
|
|
40
|
-
background-color:
|
|
42
|
+
background-color: var(--bg);
|
|
41
43
|
|
|
42
44
|
&:hover {
|
|
43
|
-
|
|
45
|
+
--bg: oklch(93.166% 0 0);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
&:focus-within {
|
|
47
49
|
background-color: inherit;
|
|
48
|
-
border-color: var(--active-color);
|
|
50
|
+
--border-color: var(--active-color);
|
|
49
51
|
box-shadow: 0px 0px 0px 2px
|
|
50
52
|
color-mix(in srgb, var(--active-color) 10%, transparent);
|
|
51
53
|
}
|
|
@@ -55,11 +57,11 @@
|
|
|
55
57
|
border-bottom-width: 1px;
|
|
56
58
|
|
|
57
59
|
&:hover {
|
|
58
|
-
border-color:
|
|
60
|
+
--border-color: oklch(65.335% 0 0);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
&:focus-within {
|
|
62
|
-
border-color: var(--active-color);
|
|
64
|
+
--border-color: var(--active-color);
|
|
63
65
|
box-shadow: 0px 2px 0px 0px
|
|
64
66
|
color-mix(in srgb, var(--active-color) 10%, transparent);
|
|
65
67
|
}
|
|
@@ -116,7 +118,7 @@
|
|
|
116
118
|
.tremolo-number-input-increment-stepper {
|
|
117
119
|
border-inline-start-width: 1px;
|
|
118
120
|
border-inline-start-style: solid;
|
|
119
|
-
border-inline-start-color:
|
|
121
|
+
border-inline-start-color: oklch(84.522% 0 0);
|
|
120
122
|
font-size: calc(0.75rem);
|
|
121
123
|
display: flex;
|
|
122
124
|
justify-content: center;
|
|
@@ -128,7 +130,7 @@
|
|
|
128
130
|
border-top-right-radius: var(--border-radius);
|
|
129
131
|
|
|
130
132
|
&[aria-disabled='false']:active {
|
|
131
|
-
background-color:
|
|
133
|
+
background-color: oklch(37.798% 0.03812 254.612 / 0.055);
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
&[aria-disabled='true'] {
|
|
@@ -143,8 +145,8 @@
|
|
|
143
145
|
.tremolo-number-input-decrement-stepper {
|
|
144
146
|
border-inline-start-width: 1px;
|
|
145
147
|
border-inline-start-style: solid;
|
|
146
|
-
border-inline-start-color:
|
|
147
|
-
border-top: 1px solid
|
|
148
|
+
border-inline-start-color: oklch(84.522% 0 0);
|
|
149
|
+
border-top: 1px solid oklch(84.522% 0 0);
|
|
148
150
|
font-size: calc(0.75rem);
|
|
149
151
|
display: flex;
|
|
150
152
|
justify-content: center;
|
|
@@ -156,7 +158,7 @@
|
|
|
156
158
|
border-bottom-right-radius: var(--border-radius);
|
|
157
159
|
|
|
158
160
|
&[aria-disabled='false']:active {
|
|
159
|
-
background-color:
|
|
161
|
+
background-color: oklch(37.798% 0.03812 254.612 / 0.055);
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
&[aria-disabled='true'] {
|
|
@@ -167,3 +169,17 @@
|
|
|
167
169
|
cursor: not-allowed;
|
|
168
170
|
}
|
|
169
171
|
}
|
|
172
|
+
|
|
173
|
+
:where(.dark, [data-theme='dark']) {
|
|
174
|
+
.tremolo-number-input-wrapper {
|
|
175
|
+
--border-color: oklch(52% 0 0);
|
|
176
|
+
|
|
177
|
+
&[data-variant='filled'] {
|
|
178
|
+
--bg: oklch(43.5% 0 0);
|
|
179
|
+
|
|
180
|
+
&:hover {
|
|
181
|
+
--bg: oklch(46.6% 0 0);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -4,7 +4,10 @@ import { ComponentPropsWithoutRef, forwardRef, ReactNode } from 'react'
|
|
|
4
4
|
import { InputEventOption } from '@tremolo-ui/functions'
|
|
5
5
|
|
|
6
6
|
import { NumberInputProvider } from './context'
|
|
7
|
+
import { DecrementStepper } from './DecrementStepper'
|
|
8
|
+
import { IncrementStepper } from './IncrementStepper'
|
|
7
9
|
import { InternalInput } from './InternalInput'
|
|
10
|
+
import { Stepper } from './Stepper'
|
|
8
11
|
import { Units } from './type'
|
|
9
12
|
|
|
10
13
|
/*
|
|
@@ -18,11 +21,11 @@ export interface NumberInputProps {
|
|
|
18
21
|
value: number | string
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
24
|
+
* Number.MIN_SAFE_INTEGER
|
|
22
25
|
*/
|
|
23
26
|
min?: number
|
|
24
27
|
/**
|
|
25
|
-
*
|
|
28
|
+
* Number.MAX_SAFE_INTEGER
|
|
26
29
|
*/
|
|
27
30
|
max?: number
|
|
28
31
|
step?: number
|
|
@@ -94,11 +97,7 @@ export interface NumberInputMethods {
|
|
|
94
97
|
type Props = NumberInputProps &
|
|
95
98
|
Omit<ComponentPropsWithoutRef<'input'>, keyof NumberInputProps | 'type'>
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
* Input with some useful functions for entering numerical values.
|
|
99
|
-
* @category NumberInput
|
|
100
|
-
*/
|
|
101
|
-
export const NumberInput = forwardRef<NumberInputMethods, Props>(
|
|
100
|
+
const NumberInputImpl = forwardRef<NumberInputMethods, Props>(
|
|
102
101
|
(
|
|
103
102
|
{
|
|
104
103
|
value,
|
|
@@ -174,7 +173,17 @@ export const NumberInput = forwardRef<NumberInputMethods, Props>(
|
|
|
174
173
|
},
|
|
175
174
|
)
|
|
176
175
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Input with some useful functions for entering numerical values.
|
|
178
|
+
* @category NumberInput
|
|
179
|
+
*/
|
|
180
|
+
export const NumberInput = Object.assign(NumberInputImpl, {
|
|
181
|
+
Stepper,
|
|
182
|
+
IncrementStepper,
|
|
183
|
+
DecrementStepper,
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
export { type StepperProps } from './Stepper'
|
|
187
|
+
export { type IncrementStepperProps } from './IncrementStepper'
|
|
188
|
+
export { type DecrementStepperProps } from './DecrementStepper'
|
|
180
189
|
export { type Units } from './type'
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
.tremolo-piano-white-key {
|
|
10
10
|
--bg: oklch(100% 0 0);
|
|
11
11
|
--color: oklch(0% 0 0);
|
|
12
|
-
--active-bg: oklch(
|
|
12
|
+
--active-bg: oklch(92% 0 0);
|
|
13
13
|
--active-color: oklch(0% 0 0);
|
|
14
14
|
|
|
15
15
|
box-sizing: border-box;
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
|
|
35
35
|
.tremolo-piano-black-key {
|
|
36
36
|
--color: oklch(100% 0 0);
|
|
37
|
-
--bg: oklch(32
|
|
37
|
+
--bg: oklch(32% 0 0);
|
|
38
38
|
--active-color: oklch(100% 0 0);
|
|
39
|
-
--active-bg: oklch(
|
|
39
|
+
--active-bg: oklch(44% 0 0);
|
|
40
40
|
|
|
41
41
|
box-sizing: border-box;
|
|
42
42
|
position: absolute;
|
|
@@ -82,16 +82,9 @@
|
|
|
82
82
|
|
|
83
83
|
:where(.dark, [data-theme='dark']) {
|
|
84
84
|
.tremolo-piano-white-key {
|
|
85
|
-
--bg: oklch(
|
|
86
|
-
--color: oklch(
|
|
87
|
-
--active-bg: oklch(
|
|
88
|
-
--active-color: oklch(
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.tremolo-piano-black-key {
|
|
92
|
-
--color: oklch(100% 0 0);
|
|
93
|
-
--bg: oklch(32.109% 0 0);
|
|
94
|
-
--active-color: oklch(100% 0 0);
|
|
95
|
-
--active-bg: oklch(38.666% 0.00004 271.152);
|
|
85
|
+
--bg: oklch(80% 0 0);
|
|
86
|
+
--color: oklch(0% 0 0);
|
|
87
|
+
--active-bg: oklch(72% 0 0);
|
|
88
|
+
--active-color: oklch(0% 0 0);
|
|
96
89
|
}
|
|
97
90
|
}
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
WhiteKey,
|
|
36
36
|
} from './key'
|
|
37
37
|
import { KeyboardShortcuts } from './keyboardShortcuts'
|
|
38
|
+
import { KeyLabel } from './KeyLabel'
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* [noteRange.first, noteRange.first + 1 ..., noteRange.last]
|
|
@@ -84,11 +85,7 @@ export interface PianoMethods {
|
|
|
84
85
|
type Props = PianoProps &
|
|
85
86
|
Omit<ComponentPropsWithoutRef<'div'>, keyof PianoProps>
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
* Customizable piano component.
|
|
89
|
-
* @category Piano
|
|
90
|
-
*/
|
|
91
|
-
export const Piano = forwardRef<PianoMethods, Props>(
|
|
88
|
+
const PianoImpl = forwardRef<PianoMethods, Props>(
|
|
92
89
|
(
|
|
93
90
|
{
|
|
94
91
|
noteRange,
|
|
@@ -345,6 +342,12 @@ export const Piano = forwardRef<PianoMethods, Props>(
|
|
|
345
342
|
},
|
|
346
343
|
)
|
|
347
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Customizable piano component.
|
|
347
|
+
* @category Piano
|
|
348
|
+
*/
|
|
349
|
+
export const Piano = Object.assign(PianoImpl, { WhiteKey, BlackKey, KeyLabel })
|
|
350
|
+
|
|
348
351
|
export { type KeyboardShortcuts, SHORTCUTS } from './keyboardShortcuts'
|
|
349
|
-
export {
|
|
350
|
-
export {
|
|
352
|
+
export { type KeyProps, type KeyMethods } from './key'
|
|
353
|
+
export { type KeyLabelProps } from './KeyLabel'
|
|
@@ -35,7 +35,7 @@ export interface SliderThumbMethods {
|
|
|
35
35
|
export const defaultThumbSize = 22
|
|
36
36
|
|
|
37
37
|
/** @category Slider */
|
|
38
|
-
export const
|
|
38
|
+
export const Thumb = forwardRef<SliderThumbMethods, SliderThumbProps>(
|
|
39
39
|
(
|
|
40
40
|
{
|
|
41
41
|
size,
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.tremolo-slider-thumb {
|
|
19
|
-
--color:
|
|
19
|
+
--color: oklch(59.5% 0.17548 266.373);
|
|
20
20
|
|
|
21
21
|
background: var(--color);
|
|
22
22
|
border-radius: 50%;
|
|
23
23
|
outline: none;
|
|
24
24
|
|
|
25
25
|
&[aria-disabled='true'] {
|
|
26
|
-
background:
|
|
26
|
+
background: oklch(50.462% 0.03307 270.021);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
&[aria-readonly='false']:focus {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
.tremolo-slider-track {
|
|
36
|
-
--active:
|
|
37
|
-
--inactive:
|
|
36
|
+
--active: oklch(69.212% 0.12903 267.633);
|
|
37
|
+
--inactive: oklch(95% 0 0);
|
|
38
38
|
|
|
39
39
|
position: relative;
|
|
40
40
|
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
&:hover {
|
|
50
|
-
--active:
|
|
50
|
+
--active: oklch(64.276% 0.15244 266.932);
|
|
51
51
|
--inactive: #e0e0e0;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
&[aria-disabled='true'] {
|
|
55
|
-
--active:
|
|
56
|
-
--inactive:
|
|
55
|
+
--active: oklch(75.327% 0.01237 264.547);
|
|
56
|
+
--inactive: oklch(89.755% 0.0001 271.152);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
|
|
65
65
|
.tremolo-slider-scale-option {
|
|
66
66
|
display: flex;
|
|
67
|
-
color:
|
|
67
|
+
color: oklch(25.197% 0.00003 271.152);
|
|
68
68
|
flex-direction: column;
|
|
69
69
|
justify-content: center;
|
|
70
70
|
align-items: center;
|
|
@@ -85,3 +85,28 @@
|
|
|
85
85
|
.tremolo-slider-scale-option-label {
|
|
86
86
|
text-align: right;
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
:where(.dark, [data-theme='dark']) {
|
|
90
|
+
.tremolo-slider-thumb {
|
|
91
|
+
--color: oklch(64.5% 0.17548 266.373);
|
|
92
|
+
|
|
93
|
+
&:hover {
|
|
94
|
+
--color: oklch(67.5% 0.17548 266.373);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.tremolo-slider-track {
|
|
99
|
+
--active: oklch(59.5% 0.17548 266.373);
|
|
100
|
+
--inactive: oklch(41.7% 0 0);
|
|
101
|
+
|
|
102
|
+
&:hover {
|
|
103
|
+
--active: oklch(62.5% 0.17548 266.373);
|
|
104
|
+
--inactive: oklch(44.7% 0 0);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&[aria-disabled='true'] {
|
|
108
|
+
--active: oklch(75.327% 0.01237 264.547);
|
|
109
|
+
--inactive: oklch(89.755% 0.0001 271.152);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -27,8 +27,9 @@ import { addNoSelect, removeNoSelect } from '../_util'
|
|
|
27
27
|
|
|
28
28
|
import { SliderProvider } from './context'
|
|
29
29
|
import { Scale } from './Scale'
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
30
|
+
import { ScaleOption } from './ScaleOption'
|
|
31
|
+
import { Thumb, SliderThumbMethods, SliderThumbProps } from './Thumb'
|
|
32
|
+
import { Track, SliderTrackProps } from './Track'
|
|
32
33
|
|
|
33
34
|
/** @category Slider */
|
|
34
35
|
export interface SliderProps {
|
|
@@ -81,11 +82,7 @@ export interface SliderMethods {
|
|
|
81
82
|
type Props = SliderProps &
|
|
82
83
|
Omit<ComponentPropsWithoutRef<'div'>, keyof SliderProps>
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
* Customizable slider
|
|
86
|
-
* @category Slider
|
|
87
|
-
*/
|
|
88
|
-
export const Slider = forwardRef<SliderMethods, Props>(
|
|
85
|
+
const SliderImpl = forwardRef<SliderMethods, Props>(
|
|
89
86
|
(
|
|
90
87
|
{
|
|
91
88
|
value,
|
|
@@ -138,9 +135,9 @@ export const Slider = forwardRef<SliderMethods, Props>(
|
|
|
138
135
|
if (children != undefined) {
|
|
139
136
|
React.Children.forEach(children, (child) => {
|
|
140
137
|
if (React.isValidElement(child)) {
|
|
141
|
-
if (child.type ==
|
|
138
|
+
if (child.type == Thumb) {
|
|
142
139
|
thumbProps = child.props as SliderThumbProps
|
|
143
|
-
} else if (child.type ==
|
|
140
|
+
} else if (child.type == Track) {
|
|
144
141
|
trackProps = child.props as SliderTrackProps
|
|
145
142
|
} else if (child.type == Scale) {
|
|
146
143
|
scaleComponent = child
|
|
@@ -312,14 +309,10 @@ export const Slider = forwardRef<SliderMethods, Props>(
|
|
|
312
309
|
}}
|
|
313
310
|
>
|
|
314
311
|
<div className="tremolo-slider-track-wrapper" ref={trackElementRef}>
|
|
315
|
-
<
|
|
312
|
+
<Track
|
|
316
313
|
__percent={percent}
|
|
317
314
|
__thumb={
|
|
318
|
-
<
|
|
319
|
-
ref={thumbRef}
|
|
320
|
-
__percent={percent}
|
|
321
|
-
{...thumbProps}
|
|
322
|
-
/>
|
|
315
|
+
<Thumb ref={thumbRef} __percent={percent} {...thumbProps} />
|
|
323
316
|
}
|
|
324
317
|
{...trackProps}
|
|
325
318
|
/>
|
|
@@ -332,13 +325,20 @@ export const Slider = forwardRef<SliderMethods, Props>(
|
|
|
332
325
|
},
|
|
333
326
|
)
|
|
334
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Customizable slider
|
|
330
|
+
* @category Slider
|
|
331
|
+
*/
|
|
332
|
+
export const Slider = Object.assign(SliderImpl, {
|
|
333
|
+
Thumb,
|
|
334
|
+
Track,
|
|
335
|
+
Scale,
|
|
336
|
+
ScaleOption,
|
|
337
|
+
})
|
|
338
|
+
|
|
335
339
|
export { useSliderContext } from './context'
|
|
336
|
-
export {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
} from './Thumb'
|
|
341
|
-
export { SliderTrack, type SliderTrackProps } from './Track'
|
|
342
|
-
export { Scale, type ScaleProps } from './Scale'
|
|
343
|
-
export { ScaleOption, type ScaleOptionProps } from './ScaleOption'
|
|
340
|
+
export { type SliderThumbMethods, type SliderThumbProps } from './Thumb'
|
|
341
|
+
export { type SliderTrackProps } from './Track'
|
|
342
|
+
export { type ScaleProps } from './Scale'
|
|
343
|
+
export { type ScaleOptionProps } from './ScaleOption'
|
|
344
344
|
export { type ScaleOptions, type ScaleType } from './type'
|
|
@@ -2,7 +2,7 @@ import clsx from 'clsx'
|
|
|
2
2
|
import { ComponentPropsWithoutRef, CSSProperties, ReactElement } from 'react'
|
|
3
3
|
|
|
4
4
|
/** @category XYPad */
|
|
5
|
-
export interface
|
|
5
|
+
export interface XYPadAreaProps {
|
|
6
6
|
width?: number | string
|
|
7
7
|
height?: number | string
|
|
8
8
|
color?: string
|
|
@@ -15,7 +15,7 @@ export interface AreaProps {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/** @category XYPad */
|
|
18
|
-
export function
|
|
18
|
+
export function Area({
|
|
19
19
|
width = 120,
|
|
20
20
|
height = 120,
|
|
21
21
|
color,
|
|
@@ -24,7 +24,8 @@ export function XYPadArea({
|
|
|
24
24
|
style,
|
|
25
25
|
__thumb,
|
|
26
26
|
...props
|
|
27
|
-
}:
|
|
27
|
+
}: XYPadAreaProps &
|
|
28
|
+
Omit<ComponentPropsWithoutRef<'div'>, keyof XYPadAreaProps>) {
|
|
28
29
|
return (
|
|
29
30
|
<div
|
|
30
31
|
className={clsx('tremolo-xy-pad-area', className)}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from 'react'
|
|
10
10
|
|
|
11
11
|
/** @category XYPad */
|
|
12
|
-
export interface
|
|
12
|
+
export interface XYPadThumbProps {
|
|
13
13
|
size?: number | string
|
|
14
14
|
width?: number | string
|
|
15
15
|
height?: number | string
|
|
@@ -24,6 +24,8 @@ export interface ThumbProps {
|
|
|
24
24
|
/** @internal */
|
|
25
25
|
__disabled?: boolean
|
|
26
26
|
/** @internal */
|
|
27
|
+
__readonly?: boolean
|
|
28
|
+
/** @internal */
|
|
27
29
|
__css?: CSSProperties
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -33,11 +35,11 @@ export interface XYPadThumbMethods {
|
|
|
33
35
|
blur: () => void
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
type Props =
|
|
37
|
-
Omit<ComponentPropsWithoutRef<'div'>, keyof
|
|
38
|
+
type Props = XYPadThumbProps &
|
|
39
|
+
Omit<ComponentPropsWithoutRef<'div'>, keyof XYPadThumbProps>
|
|
38
40
|
|
|
39
41
|
/** @category XYPad */
|
|
40
|
-
export const
|
|
42
|
+
export const Thumb = forwardRef<XYPadThumbMethods, Props>(
|
|
41
43
|
(
|
|
42
44
|
{
|
|
43
45
|
size,
|
|
@@ -50,6 +52,7 @@ export const XYPadThumb = forwardRef<XYPadThumbMethods, Props>(
|
|
|
50
52
|
className,
|
|
51
53
|
style,
|
|
52
54
|
__disabled,
|
|
55
|
+
__readonly,
|
|
53
56
|
__css,
|
|
54
57
|
...props
|
|
55
58
|
}: Props,
|
|
@@ -87,6 +90,7 @@ export const XYPadThumb = forwardRef<XYPadThumbMethods, Props>(
|
|
|
87
90
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
88
91
|
tabIndex={0}
|
|
89
92
|
aria-disabled={__disabled}
|
|
93
|
+
aria-readonly={__readonly}
|
|
90
94
|
style={{
|
|
91
95
|
...{ '--color': color },
|
|
92
96
|
width: size ?? width,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.tremolo-xy-pad-area {
|
|
7
|
-
--color:
|
|
7
|
+
--color: oklch(95% 0 0);
|
|
8
8
|
|
|
9
9
|
position: relative;
|
|
10
10
|
background-color: var(--color);
|
|
@@ -17,18 +17,32 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.tremolo-xy-pad-thumb {
|
|
20
|
-
--color:
|
|
20
|
+
--color: oklch(59.5% 0.17548 266.373);
|
|
21
21
|
|
|
22
22
|
border-radius: 50%;
|
|
23
23
|
outline: none;
|
|
24
24
|
background-color: var(--color);
|
|
25
25
|
|
|
26
26
|
&[aria-disabled='true'] {
|
|
27
|
-
background-color:
|
|
27
|
+
background-color: oklch(50.462% 0.03307 270.021);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
&[aria-readonly='false']:focus {
|
|
31
31
|
box-shadow: 0px 0px 0px 3px
|
|
32
32
|
color-mix(in srgb, var(--color) 20%, transparent);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
:where(.dark, [data-theme='dark']) {
|
|
37
|
+
.tremolo-xy-pad-area {
|
|
38
|
+
--color: oklch(41.7% 0 0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.tremolo-xy-pad-thumb {
|
|
42
|
+
--color: oklch(64.5% 0.17548 266.373);
|
|
43
|
+
|
|
44
|
+
&:hover {
|
|
45
|
+
--color: oklch(67.5% 0.17548 266.373);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|