@tremolo-ui/react 0.0.7 → 0.0.8
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/cjs/index.js +674 -253
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/AnimationCanvas/index.d.ts +16 -9
- package/dist/cjs/types/components/AnimationCanvas/index.d.ts.map +1 -1
- package/dist/cjs/types/components/AnimationKnob/index.d.ts +53 -0
- package/dist/cjs/types/components/AnimationKnob/index.d.ts.map +1 -0
- package/dist/cjs/types/components/DragObserver/index.d.ts +19 -0
- package/dist/cjs/types/components/DragObserver/index.d.ts.map +1 -0
- package/dist/cjs/types/components/Knob/index.d.ts +26 -26
- package/dist/cjs/types/components/Knob/index.d.ts.map +1 -1
- package/dist/cjs/types/components/NumberInput/index.d.ts +2 -5
- package/dist/cjs/types/components/NumberInput/index.d.ts.map +1 -1
- package/dist/cjs/types/components/Piano/BlackKey.d.ts +3 -3
- package/dist/cjs/types/components/Piano/BlackKey.d.ts.map +1 -1
- package/dist/cjs/types/components/Piano/KeyLabel.d.ts +5 -8
- package/dist/cjs/types/components/Piano/KeyLabel.d.ts.map +1 -1
- package/dist/cjs/types/components/Piano/WhiteKey.d.ts +3 -3
- package/dist/cjs/types/components/Piano/WhiteKey.d.ts.map +1 -1
- package/dist/cjs/types/components/Piano/index.d.ts +3 -4
- package/dist/cjs/types/components/Piano/index.d.ts.map +1 -1
- package/dist/cjs/types/components/Piano/key.d.ts +4 -7
- package/dist/cjs/types/components/Piano/key.d.ts.map +1 -1
- package/dist/cjs/types/components/Piano/keyboardShortcuts.d.ts.map +1 -1
- package/dist/cjs/types/components/Slider/Scale.d.ts +11 -0
- package/dist/cjs/types/components/Slider/Scale.d.ts.map +1 -0
- package/dist/cjs/types/components/Slider/ScaleOption.d.ts +25 -0
- package/dist/cjs/types/components/Slider/ScaleOption.d.ts.map +1 -0
- package/dist/cjs/types/components/Slider/Thumb.d.ts +5 -13
- package/dist/cjs/types/components/Slider/Thumb.d.ts.map +1 -1
- package/dist/cjs/types/components/Slider/Track.d.ts +10 -21
- package/dist/cjs/types/components/Slider/Track.d.ts.map +1 -1
- package/dist/cjs/types/components/Slider/context.d.ts +21 -0
- package/dist/cjs/types/components/Slider/context.d.ts.map +1 -0
- package/dist/cjs/types/components/Slider/index.d.ts +18 -12
- package/dist/cjs/types/components/Slider/index.d.ts.map +1 -1
- package/dist/cjs/types/components/WheelObserver/index.d.ts +24 -0
- package/dist/cjs/types/components/WheelObserver/index.d.ts.map +1 -0
- package/dist/cjs/types/components/XYPad/Area.d.ts +13 -0
- package/dist/cjs/types/components/XYPad/Area.d.ts.map +1 -0
- package/dist/cjs/types/components/XYPad/Thumb.d.ts +19 -0
- package/dist/cjs/types/components/XYPad/Thumb.d.ts.map +1 -0
- package/dist/cjs/types/components/XYPad/index.d.ts +39 -0
- package/dist/cjs/types/components/XYPad/index.d.ts.map +1 -0
- package/dist/cjs/types/hooks/useCallbackRef.d.ts.map +1 -1
- package/dist/cjs/types/index.d.ts +10 -0
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/esm/index.js +657 -254
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/AnimationCanvas/index.d.ts +16 -9
- package/dist/esm/types/components/AnimationCanvas/index.d.ts.map +1 -1
- package/dist/esm/types/components/AnimationKnob/index.d.ts +53 -0
- package/dist/esm/types/components/AnimationKnob/index.d.ts.map +1 -0
- package/dist/esm/types/components/DragObserver/index.d.ts +19 -0
- package/dist/esm/types/components/DragObserver/index.d.ts.map +1 -0
- package/dist/esm/types/components/Knob/index.d.ts +26 -26
- package/dist/esm/types/components/Knob/index.d.ts.map +1 -1
- package/dist/esm/types/components/NumberInput/index.d.ts +2 -5
- package/dist/esm/types/components/NumberInput/index.d.ts.map +1 -1
- package/dist/esm/types/components/Piano/BlackKey.d.ts +3 -3
- package/dist/esm/types/components/Piano/BlackKey.d.ts.map +1 -1
- package/dist/esm/types/components/Piano/KeyLabel.d.ts +5 -8
- package/dist/esm/types/components/Piano/KeyLabel.d.ts.map +1 -1
- package/dist/esm/types/components/Piano/WhiteKey.d.ts +3 -3
- package/dist/esm/types/components/Piano/WhiteKey.d.ts.map +1 -1
- package/dist/esm/types/components/Piano/index.d.ts +3 -4
- package/dist/esm/types/components/Piano/index.d.ts.map +1 -1
- package/dist/esm/types/components/Piano/key.d.ts +4 -7
- package/dist/esm/types/components/Piano/key.d.ts.map +1 -1
- package/dist/esm/types/components/Piano/keyboardShortcuts.d.ts.map +1 -1
- package/dist/esm/types/components/Slider/Scale.d.ts +11 -0
- package/dist/esm/types/components/Slider/Scale.d.ts.map +1 -0
- package/dist/esm/types/components/Slider/ScaleOption.d.ts +25 -0
- package/dist/esm/types/components/Slider/ScaleOption.d.ts.map +1 -0
- package/dist/esm/types/components/Slider/Thumb.d.ts +5 -13
- package/dist/esm/types/components/Slider/Thumb.d.ts.map +1 -1
- package/dist/esm/types/components/Slider/Track.d.ts +10 -21
- package/dist/esm/types/components/Slider/Track.d.ts.map +1 -1
- package/dist/esm/types/components/Slider/context.d.ts +21 -0
- package/dist/esm/types/components/Slider/context.d.ts.map +1 -0
- package/dist/esm/types/components/Slider/index.d.ts +18 -12
- package/dist/esm/types/components/Slider/index.d.ts.map +1 -1
- package/dist/esm/types/components/WheelObserver/index.d.ts +24 -0
- package/dist/esm/types/components/WheelObserver/index.d.ts.map +1 -0
- package/dist/esm/types/components/XYPad/Area.d.ts +13 -0
- package/dist/esm/types/components/XYPad/Area.d.ts.map +1 -0
- package/dist/esm/types/components/XYPad/Thumb.d.ts +19 -0
- package/dist/esm/types/components/XYPad/Thumb.d.ts.map +1 -0
- package/dist/esm/types/components/XYPad/index.d.ts +39 -0
- package/dist/esm/types/components/XYPad/index.d.ts.map +1 -0
- package/dist/esm/types/hooks/useCallbackRef.d.ts.map +1 -1
- package/dist/esm/types/index.d.ts +10 -0
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/styles/index.css +241 -0
- package/package.json +2 -5
- package/src/components/AnimationCanvas/index.tsx +87 -57
- package/src/components/AnimationKnob/index.tsx +305 -0
- package/src/components/DragObserver/index.tsx +94 -0
- package/src/components/Knob/index.css +48 -0
- package/src/components/Knob/index.tsx +152 -165
- package/src/components/NumberInput/index.css +25 -0
- package/src/components/NumberInput/index.tsx +8 -41
- package/src/components/Piano/BlackKey.tsx +104 -98
- package/src/components/Piano/KeyLabel.tsx +18 -40
- package/src/components/Piano/WhiteKey.tsx +92 -87
- package/src/components/Piano/index.css +63 -0
- package/src/components/Piano/index.tsx +76 -59
- package/src/components/Piano/key.ts +4 -7
- package/src/components/Piano/keyboardShortcuts.ts +23 -4
- package/src/components/Slider/Scale.tsx +55 -0
- package/src/components/Slider/ScaleOption.tsx +103 -0
- package/src/components/Slider/Thumb.tsx +69 -76
- package/src/components/Slider/Track.tsx +37 -48
- package/src/components/Slider/context.tsx +66 -0
- package/src/components/Slider/index.css +76 -0
- package/src/components/Slider/index.tsx +256 -298
- package/src/components/WheelObserver/index.tsx +47 -0
- package/src/components/XYPad/Area.tsx +40 -0
- package/src/components/XYPad/Thumb.tsx +92 -0
- package/src/components/XYPad/index.css +24 -0
- package/src/components/XYPad/index.tsx +317 -0
- package/src/hooks/useCallbackRef.ts +1 -0
- package/src/hooks/useRefCallbackEvent.ts +1 -0
- package/src/index.ts +11 -0
- package/dist/cjs/types/components/Slider/type.d.ts +0 -7
- package/dist/cjs/types/components/Slider/type.d.ts.map +0 -1
- package/dist/cjs/types/system/pseudo.d.ts +0 -14
- package/dist/cjs/types/system/pseudo.d.ts.map +0 -1
- package/dist/esm/types/components/Slider/type.d.ts +0 -7
- package/dist/esm/types/components/Slider/type.d.ts.map +0 -1
- package/dist/esm/types/system/pseudo.d.ts +0 -14
- package/dist/esm/types/system/pseudo.d.ts.map +0 -1
- package/src/components/Slider/type.ts +0 -16
- package/src/system/pseudo.ts +0 -55
|
@@ -1,108 +1,114 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, {
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import React, {
|
|
3
|
+
ComponentPropsWithoutRef,
|
|
4
|
+
forwardRef,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react'
|
|
3
8
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
9
|
+
import { KeyMethods, KeyProps } from './key'
|
|
10
|
+
import { KeyLabel, KeyLabelProps } from './KeyLabel'
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
width = 40 * 0.65,
|
|
9
|
-
height = '60%',
|
|
10
|
-
bg = '#333',
|
|
11
|
-
activeBg = '#666',
|
|
12
|
-
style,
|
|
13
|
-
children,
|
|
14
|
-
__glissando,
|
|
15
|
-
__position,
|
|
16
|
-
__note,
|
|
17
|
-
__disabled,
|
|
18
|
-
__index,
|
|
19
|
-
__fill,
|
|
20
|
-
__width,
|
|
21
|
-
__playNote,
|
|
22
|
-
__stopNote,
|
|
23
|
-
__label,
|
|
24
|
-
}: KeyProps, ref) => {
|
|
25
|
-
const [played, setPlayed] = useState(false)
|
|
12
|
+
type Props = KeyProps & Omit<ComponentPropsWithoutRef<'div'>, keyof KeyProps>
|
|
26
13
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
14
|
+
export const BlackKey = forwardRef<KeyMethods, Props>(
|
|
15
|
+
(
|
|
16
|
+
{
|
|
17
|
+
width = 40 * 0.65,
|
|
18
|
+
height = '60%',
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
children,
|
|
22
|
+
__glissando,
|
|
23
|
+
__position,
|
|
24
|
+
__note,
|
|
25
|
+
__disabled,
|
|
26
|
+
__index,
|
|
27
|
+
__fill,
|
|
28
|
+
__width,
|
|
29
|
+
__playNote,
|
|
30
|
+
__stopNote,
|
|
31
|
+
__label,
|
|
32
|
+
...props
|
|
33
|
+
}: Props,
|
|
34
|
+
ref,
|
|
35
|
+
) => {
|
|
36
|
+
const [played, setPlayed] = useState(false)
|
|
37
|
+
|
|
38
|
+
useImperativeHandle(ref, () => {
|
|
39
|
+
return {
|
|
40
|
+
play() {
|
|
41
|
+
if (__disabled) return
|
|
42
|
+
setPlayed(true)
|
|
43
|
+
if (__playNote) __playNote(__note!)
|
|
44
|
+
},
|
|
45
|
+
stop() {
|
|
46
|
+
setPlayed(false)
|
|
47
|
+
if (__stopNote) __stopNote(__note!)
|
|
48
|
+
},
|
|
49
|
+
played() {
|
|
50
|
+
return played
|
|
51
|
+
},
|
|
40
52
|
}
|
|
41
|
-
}
|
|
42
|
-
}, [])
|
|
53
|
+
}, [__disabled, __note, __playNote, __stopNote, played])
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
let keyLabelProps: KeyLabelProps = {}
|
|
56
|
+
if (children != undefined) {
|
|
57
|
+
React.Children.forEach(children, (child) => {
|
|
58
|
+
if (React.isValidElement(child)) {
|
|
59
|
+
if (child.type == KeyLabel) {
|
|
60
|
+
keyLabelProps = child.props as KeyLabelProps
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error('only <KeyLabel>')
|
|
63
|
+
}
|
|
51
64
|
} else {
|
|
52
|
-
throw new Error('
|
|
65
|
+
throw new Error('children is an invalid element.')
|
|
53
66
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
}
|
|
67
|
+
})
|
|
68
|
+
}
|
|
59
69
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
cursor: __disabled ? 'not-allowed' : 'pointer',
|
|
74
|
-
zIndex: 2,
|
|
75
|
-
...style,
|
|
76
|
-
})}
|
|
77
|
-
onPointerDown={() => {
|
|
78
|
-
if (__disabled) return
|
|
79
|
-
setPlayed(true)
|
|
80
|
-
if (__playNote) __playNote(__note!)
|
|
81
|
-
}}
|
|
82
|
-
onPointerEnter={() => {
|
|
83
|
-
if (__disabled) return
|
|
84
|
-
if (__glissando) {
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
className={clsx(`tremolo-piano-black-key`, className)}
|
|
73
|
+
aria-disabled={__disabled}
|
|
74
|
+
data-active={played}
|
|
75
|
+
style={{
|
|
76
|
+
left: __position,
|
|
77
|
+
width: __fill ? __width : (width ?? __width),
|
|
78
|
+
height: height,
|
|
79
|
+
...style,
|
|
80
|
+
}}
|
|
81
|
+
onPointerDown={() => {
|
|
82
|
+
if (__disabled) return
|
|
85
83
|
setPlayed(true)
|
|
86
84
|
if (__playNote) __playNote(__note!)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
85
|
+
}}
|
|
86
|
+
onPointerEnter={() => {
|
|
87
|
+
if (__disabled) return
|
|
88
|
+
if (__glissando) {
|
|
89
|
+
setPlayed(true)
|
|
90
|
+
if (__playNote) __playNote(__note!)
|
|
91
|
+
}
|
|
92
|
+
}}
|
|
93
|
+
onPointerUp={() => {
|
|
94
|
+
if (__disabled) return
|
|
95
|
+
setPlayed(false)
|
|
96
|
+
if (__stopNote) __stopNote(__note!)
|
|
97
|
+
}}
|
|
98
|
+
onPointerLeave={() => {
|
|
99
|
+
if (__disabled) return
|
|
100
|
+
setPlayed(false)
|
|
101
|
+
if (__stopNote) __stopNote(__note!)
|
|
102
|
+
}}
|
|
103
|
+
{...props}
|
|
104
|
+
>
|
|
105
|
+
<KeyLabel
|
|
106
|
+
__note={__note}
|
|
107
|
+
__label={__label}
|
|
108
|
+
__index={__index}
|
|
109
|
+
{...keyLabelProps}
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
)
|
|
113
|
+
},
|
|
114
|
+
)
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { ReactNode } from "react"
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import { ComponentPropsWithoutRef, CSSProperties, ReactNode } from 'react'
|
|
4
3
|
|
|
5
|
-
interface
|
|
4
|
+
export interface KeyLabelProps {
|
|
6
5
|
/**
|
|
7
6
|
* override Piano.label
|
|
8
7
|
*/
|
|
9
8
|
label?: (note: number, index: number) => ReactNode
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
wrapperStyle?: CSSObject
|
|
10
|
+
wrapperClassName?: string
|
|
11
|
+
wrapperStyle?: CSSProperties
|
|
14
12
|
|
|
15
13
|
/** @internal */
|
|
16
14
|
__note?: number
|
|
@@ -23,47 +21,27 @@ interface Props {
|
|
|
23
21
|
export function KeyLabel({
|
|
24
22
|
label,
|
|
25
23
|
className,
|
|
26
|
-
|
|
24
|
+
wrapperClassName,
|
|
27
25
|
wrapperStyle,
|
|
28
26
|
__note,
|
|
29
27
|
__index,
|
|
30
28
|
__label,
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
...props
|
|
30
|
+
}: KeyLabelProps & Omit<ComponentPropsWithoutRef<'div'>, keyof KeyLabelProps>) {
|
|
31
|
+
const content = label
|
|
32
|
+
? label(__note!, __index!)
|
|
33
|
+
: __label && __label(__note!, __index!)
|
|
33
34
|
|
|
34
35
|
return (
|
|
35
|
-
(content != undefined || content != null) &&
|
|
36
|
-
<div
|
|
37
|
-
className='tremolo-piano-key-label-wrapper'
|
|
38
|
-
css={css({
|
|
39
|
-
display: 'flex',
|
|
40
|
-
justifyContent: 'center',
|
|
41
|
-
alignItems: 'end',
|
|
42
|
-
height: '100%',
|
|
43
|
-
...wrapperStyle
|
|
44
|
-
})}
|
|
45
|
-
>
|
|
36
|
+
(content != undefined || content != null) && (
|
|
46
37
|
<div
|
|
47
|
-
className={clsx('tremolo-piano-key-label',
|
|
48
|
-
|
|
49
|
-
display: 'flex',
|
|
50
|
-
justifyContent: 'center',
|
|
51
|
-
alignItems: 'center',
|
|
52
|
-
fontSize: '0.6rem',
|
|
53
|
-
height: 10,
|
|
54
|
-
marginBottom: 10,
|
|
55
|
-
padding: 4,
|
|
56
|
-
borderRadius: 4,
|
|
57
|
-
borderStyle: 'solid',
|
|
58
|
-
borderWidth: 1,
|
|
59
|
-
borderColor: '#888',
|
|
60
|
-
aspectRatio: 1,
|
|
61
|
-
maxWidth: 'calc(100% - 16px)',
|
|
62
|
-
...style
|
|
63
|
-
})}
|
|
38
|
+
className={clsx('tremolo-piano-key-label-wrapper', wrapperClassName)}
|
|
39
|
+
style={wrapperStyle}
|
|
64
40
|
>
|
|
65
|
-
{
|
|
41
|
+
<div className={clsx('tremolo-piano-key-label', className)} {...props}>
|
|
42
|
+
{content}
|
|
43
|
+
</div>
|
|
66
44
|
</div>
|
|
67
|
-
|
|
45
|
+
)
|
|
68
46
|
)
|
|
69
47
|
}
|
|
@@ -1,31 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import React, {
|
|
3
|
+
ComponentPropsWithoutRef,
|
|
4
|
+
forwardRef,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react'
|
|
6
8
|
|
|
9
|
+
import { KeyMethods, KeyProps } from './key'
|
|
10
|
+
import { KeyLabel, KeyLabelProps } from './KeyLabel'
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
width = 40,
|
|
10
|
-
height = '100%',
|
|
11
|
-
bg = 'white',
|
|
12
|
-
activeBg = '#ccc',
|
|
13
|
-
style,
|
|
14
|
-
children,
|
|
15
|
-
__glissando,
|
|
16
|
-
__position,
|
|
17
|
-
__note,
|
|
18
|
-
__disabled,
|
|
19
|
-
__index,
|
|
20
|
-
__fill,
|
|
21
|
-
__width,
|
|
22
|
-
__playNote,
|
|
23
|
-
__stopNote,
|
|
24
|
-
__label,
|
|
25
|
-
}: KeyProps, ref) => {
|
|
26
|
-
const [played, setPlayed] = useState(false)
|
|
12
|
+
type Props = KeyProps & Omit<ComponentPropsWithoutRef<'div'>, keyof KeyProps>
|
|
27
13
|
|
|
28
|
-
|
|
14
|
+
export const WhiteKey = forwardRef<KeyMethods, Props>(
|
|
15
|
+
(
|
|
16
|
+
{
|
|
17
|
+
width = 40,
|
|
18
|
+
height = '100%',
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
children,
|
|
22
|
+
__glissando,
|
|
23
|
+
__position,
|
|
24
|
+
__note,
|
|
25
|
+
__disabled,
|
|
26
|
+
__index,
|
|
27
|
+
__fill,
|
|
28
|
+
__width,
|
|
29
|
+
__playNote,
|
|
30
|
+
__stopNote,
|
|
31
|
+
__label,
|
|
32
|
+
...props
|
|
33
|
+
}: Props,
|
|
34
|
+
ref,
|
|
35
|
+
) => {
|
|
36
|
+
const [played, setPlayed] = useState(false)
|
|
37
|
+
|
|
38
|
+
useImperativeHandle(ref, () => {
|
|
29
39
|
return {
|
|
30
40
|
play() {
|
|
31
41
|
if (__disabled) return
|
|
@@ -38,72 +48,67 @@ export const WhiteKey = forwardRef<KeyMethods, KeyProps>(({
|
|
|
38
48
|
},
|
|
39
49
|
played() {
|
|
40
50
|
return played
|
|
41
|
-
}
|
|
51
|
+
},
|
|
42
52
|
}
|
|
43
|
-
}, [])
|
|
53
|
+
}, [__disabled, __note, __playNote, __stopNote, played])
|
|
44
54
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
let keyLabelProps: KeyLabelProps = {}
|
|
56
|
+
if (children != undefined) {
|
|
57
|
+
React.Children.forEach(children, (child) => {
|
|
58
|
+
if (React.isValidElement(child)) {
|
|
59
|
+
if (child.type == KeyLabel) {
|
|
60
|
+
keyLabelProps = child.props as KeyLabelProps
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error('only <KeyLabel>')
|
|
63
|
+
}
|
|
52
64
|
} else {
|
|
53
|
-
throw new Error('
|
|
65
|
+
throw new Error('children is an invalid element.')
|
|
54
66
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
}
|
|
67
|
+
})
|
|
68
|
+
}
|
|
60
69
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
cursor: __disabled ? 'not-allowed' : 'pointer',
|
|
75
|
-
zIndex: 1,
|
|
76
|
-
...style,
|
|
77
|
-
})}
|
|
78
|
-
onPointerDown={() => {
|
|
79
|
-
if (__disabled) return
|
|
80
|
-
setPlayed(true)
|
|
81
|
-
if (__playNote) __playNote(__note!)
|
|
82
|
-
}}
|
|
83
|
-
onPointerEnter={() => {
|
|
84
|
-
if (__disabled) return
|
|
85
|
-
if (__glissando) {
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
className={clsx(`tremolo-piano-white-key`, className)}
|
|
73
|
+
aria-disabled={__disabled}
|
|
74
|
+
data-active={played}
|
|
75
|
+
style={{
|
|
76
|
+
left: __position,
|
|
77
|
+
width: __fill ? __width : (width ?? __width),
|
|
78
|
+
height: height,
|
|
79
|
+
...style,
|
|
80
|
+
}}
|
|
81
|
+
onPointerDown={() => {
|
|
82
|
+
if (__disabled) return
|
|
86
83
|
setPlayed(true)
|
|
87
84
|
if (__playNote) __playNote(__note!)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
85
|
+
}}
|
|
86
|
+
onPointerEnter={() => {
|
|
87
|
+
if (__disabled) return
|
|
88
|
+
if (__glissando) {
|
|
89
|
+
setPlayed(true)
|
|
90
|
+
if (__playNote) __playNote(__note!)
|
|
91
|
+
}
|
|
92
|
+
}}
|
|
93
|
+
onPointerUp={() => {
|
|
94
|
+
if (__disabled) return
|
|
95
|
+
setPlayed(false)
|
|
96
|
+
if (__stopNote) __stopNote(__note!)
|
|
97
|
+
}}
|
|
98
|
+
onPointerLeave={() => {
|
|
99
|
+
if (__disabled) return
|
|
100
|
+
setPlayed(false)
|
|
101
|
+
if (__stopNote) __stopNote(__note!)
|
|
102
|
+
}}
|
|
103
|
+
{...props}
|
|
104
|
+
>
|
|
105
|
+
<KeyLabel
|
|
106
|
+
__note={__note}
|
|
107
|
+
__label={__label}
|
|
108
|
+
__index={__index}
|
|
109
|
+
{...keyLabelProps}
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
)
|
|
113
|
+
},
|
|
114
|
+
)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
.tremolo-piano {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
user-select: none;
|
|
5
|
+
position: relative;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.tremolo-piano-white-key {
|
|
9
|
+
position: absolute;
|
|
10
|
+
background-color: white;
|
|
11
|
+
color: black;
|
|
12
|
+
border: 1px solid #555;
|
|
13
|
+
border-radius: 0px 0px 8px 8px;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
z-index: 1;
|
|
16
|
+
|
|
17
|
+
&[data-active='true'] {
|
|
18
|
+
background-color: #ccc;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&[aria-disabled='true'] {
|
|
22
|
+
cursor: not-allowed;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tremolo-piano-black-key {
|
|
27
|
+
position: absolute;
|
|
28
|
+
background-color: #333;
|
|
29
|
+
color: white;
|
|
30
|
+
border: 1px solid #555;
|
|
31
|
+
border-radius: 0px 0px 8px 8px;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
z-index: 2;
|
|
34
|
+
|
|
35
|
+
&[data-active='true'] {
|
|
36
|
+
background-color: #666;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&[aria-disabled='true'] {
|
|
40
|
+
cursor: not-allowed;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.tremolo-piano-key-label-wrapper {
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
align-items: end;
|
|
48
|
+
height: 100%;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.tremolo-piano-key-label {
|
|
52
|
+
display: flex;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
align-items: center;
|
|
55
|
+
font-size: 0.6rem;
|
|
56
|
+
height: 10px;
|
|
57
|
+
margin-bottom: 10px;
|
|
58
|
+
padding: 4px;
|
|
59
|
+
border-radius: 4px;
|
|
60
|
+
border: 1px solid #888;
|
|
61
|
+
aspect-ratio: 1;
|
|
62
|
+
max-width: calc(100% - 16px);
|
|
63
|
+
}
|