Skip to content

Commit c771fa2

Browse files
committed
update
1 parent 120edd0 commit c771fa2

File tree

8 files changed

+64
-21
lines changed

8 files changed

+64
-21
lines changed

apps/bplan-client/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ https://github.com/Tonejs/Tone.js/issues/1034
3636
### youtube to mp3
3737
https://ezmp3.cc/v4
3838

39+
### midi format
40+
https://www.audiolabs-erlangen.de/resources/MIR/FMP/C1/C1S2_MIDI.html
41+
3942
### load and play mid
4043
https://github.com/cifkao/html-midi-player
4144
https://github.com/surikov/webaudiofont

apps/bplan-client/src/components/instruments/HKey.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {createSignal, JSX, splitProps, useContext} from 'solid-js'
1+
import {createSignal, JSX, Show, splitProps, useContext} from 'solid-js'
22
import {HRealButton, HRealButtonProps} from 'src/components/real-button/HRealButton'
33
import {KeyContext} from './key-context'
44
import {PianoContext} from './piano-context'
@@ -9,13 +9,20 @@ export interface HKeyProps extends HRealButtonProps {
99
effectClass?: string
1010
key?: string | number
1111
name?: string
12+
showKeyName?: boolean
1213
}
1314

1415
// instrument key
1516
export const HKey = (props: HKeyProps) => {
1617
const {onDown: onKeyDown, onUp: onKeyUp, down} = useContext(PianoContext)
17-
const [innerProps, restProps] = splitProps(props, ['key', 'name'])
18-
const {key, disabled} = useContext(KeyContext)
18+
const [innerProps, restProps] = splitProps(props, [
19+
'key',
20+
'name',
21+
'effectClass',
22+
'children',
23+
'showKeyName',
24+
])
25+
const {key, disabled, name} = useContext(KeyContext)
1926

2027
function handleDown() {
2128
const _key = key ?? innerProps.key
@@ -53,12 +60,14 @@ export const HKey = (props: HKeyProps) => {
5360
>
5461
<SKeyEffect
5562
class={cx(
56-
'absolute top--20px left-0 w-full h-full pointer-events-none',
57-
props.effectClass,
63+
'absolute top--4 left-0 w-full h-full pointer-events-none',
64+
innerProps.effectClass,
5865
)}
59-
>
60-
{props.children}
61-
</SKeyEffect>
66+
/>
67+
<Show when={innerProps.showKeyName}>
68+
<span class="mb-2">{name}</span>
69+
</Show>
70+
{innerProps.children}
6271
</HRealButton>
6372
)
6473
}

apps/bplan-client/src/components/instruments/HPianoFlatSet.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ const flatSet = flatten(
2020
{key: 10, name: 'F'},
2121
{key: 12, name: 'G'},
2222
])
23-
.map((item, index) => {
24-
return item.map(({key, name}) => ({key: keyCount * index + key - keyOffset, name}))
23+
.map((item, setIndex) => {
24+
return item.map(({key, name}) => {
25+
const _key = keyCount * setIndex + key - keyOffset
26+
const setName = `${name} ${setIndex - 1}`
27+
28+
return {key: _key, name: setName}
29+
})
2530
}),
2631
)
2732
const lastDeleteCount = 4

apps/bplan-client/src/components/instruments/SPiano.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ import {
1111
} from 'src/components/instruments/SPianoParts'
1212
import {splitProps} from 'solid-js'
1313

14-
export type SPianoProps = SPianoBodyProps & SPianoRootProps
14+
export type SPianoProps = SPianoBodyProps &
15+
SPianoRootProps & {
16+
showKeyName?: boolean
17+
}
1518

1619
export const SPiano = (props: SPianoProps) => {
17-
const [innerProps, restProps] = splitProps(props, ['onDown', 'onUp', 'down'])
20+
const [innerProps, restProps] = splitProps(props, [
21+
'onDown',
22+
'onUp',
23+
'down',
24+
'showKeyName',
25+
])
1826

1927
return (
2028
<SPianoRoot onDown={innerProps.onDown} onUp={innerProps.onUp} down={innerProps.down}>
@@ -23,15 +31,20 @@ export const SPiano = (props: SPianoProps) => {
2331
class={`relative h-486px relative visible min-w-max ${props.class ?? ''}`}
2432
>
2533
<SPianoFlatSet class="inline-flex relative w-max h-[calc(100%-10px)]">
26-
<SPianoFlatKey class="w-80px h-full bg-#f7f7f7" effectClass="from-indigo-500" />
34+
<SPianoFlatKey
35+
class="w-80px h-full bg-#f7f7f7 flex items-end justify-center c-gray-400 text-4"
36+
effectClass="from-purple-500"
37+
showKeyName={innerProps.showKeyName}
38+
/>
2739
</SPianoFlatSet>
2840
<SPianoSharpSet
2941
emptyChildren={<SPianoSharpEmpty class="w-50px mr-30px" />}
3042
class="flex absolute w-auto h-259px left-55px top-0 left-0"
3143
>
3244
<SPianoSharpKey
33-
class="w-50px h-full bg-black mr-30px flex-shrink-0"
45+
class="w-50px h-full bg-black mr-30px flex flex-shrink-0 justify-center items-end c-gray-300 text-4"
3446
effectClass="from-indigo-300"
47+
showKeyName={innerProps.showKeyName}
3548
/>
3649
</SPianoSharpSet>
3750
</SPianoBody>

apps/bplan-client/src/components/midi-player/SMidiFileInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const SMidiFileInput = (props: HMidiFileInputProps) => {
106106

107107
return (
108108
<div class={cx(rootStyle, innerProps.class)}>
109-
<label class="inline-flex" for={id}>
109+
<label class="inline-flex text-inherit" for={id}>
110110
<span class="text-nowrap md:text-6 text-4 pt-1">Click or Drop </span>
111111
<span class="block i-tabler:file-plus text-6 px-1 pt-2" />
112112
<span class="text-nowrap md:inline hidden md:text-6 text-4 pt-1">Your files</span>

apps/bplan-client/src/components/midi-player/SSetting.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {HUNDRED} from '@winter-love/utils'
88
export interface SettingData {
99
keepPlayList?: boolean
1010
pianoSize?: number
11+
showKeyName?: boolean
1112
}
1213

1314
export interface SSettingProps extends JSX.HTMLAttributes<HTMLDivElement> {
@@ -54,15 +55,25 @@ export const SSetting = (props: SSettingProps) => {
5455
handleSettingData({...innerProps.settingData, keepPlayList: value})
5556
}
5657

58+
const handleSettingShowKeyName = (value: boolean) => {
59+
handleSettingData({...innerProps.settingData, showKeyName: value})
60+
}
61+
5762
return (
5863
<div
5964
{...restProps}
6065
class={cx(
61-
'bg-white rd-2 p-2 box-border flex flex-col justify-end',
66+
'flex flex-col gap-2 bg-white rd-2 p-2 box-border flex flex-col justify-end',
6267
innerProps.class,
6368
)}
6469
>
65-
<SSettingItem label="reset PWA" type="button" onClick={unregisterServiceWorker} />
70+
<SSettingItem
71+
label="Show key name"
72+
type="switch"
73+
value={innerProps.settingData?.showKeyName}
74+
onValueChange={handleSettingShowKeyName}
75+
/>
76+
<SSettingItem label="Reset PWA" type="button" onClick={unregisterServiceWorker} />
6677
<SSettingItem
6778
label="Piano Size"
6879
type="slider"
@@ -82,7 +93,7 @@ export const SSetting = (props: SSettingProps) => {
8293
onValueChange={handleSettingKeepPlayList}
8394
/>
8495
<div class="flex justify-end w-full gap-2">
85-
<span class="text-7 text-gray-500 flex-grow-1 pt-3 leading-6">
96+
<span class="text-5 md:text-7 text-gray-500 flex-grow-1 pt-3 leading-6">
8697
The world goes round with LOVE.
8798
</span>
8899
<SPlayerButton class="min-w-11 min-h-9 bg-gray-100" onClick={handleClose}>

apps/bplan-client/src/routes/(main-layout)/(home)/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ export default function HomePage(props: HomePageProps) {
2323
const [splendidGrandPiano, splendidGrandPianoController] = createSplendidGrandPiano({
2424
onEmitInstrument: emitAllIds,
2525
})
26-
const [settingData, setSettingData] = useCookie('coong__piano-setting', {
26+
const [settingData, setSettingData] = useCookie<SettingData>('coong__piano-setting', {
2727
keepPlayList: true,
2828
pianoSize: 100,
29+
showKeyName: false,
2930
})
3031
const initMusics = untrack(() => props.initMusics)
3132
const [musics, setMusics, updateActive] = useStorage<MusicInfo[]>(
@@ -62,12 +63,13 @@ export default function HomePage(props: HomePageProps) {
6263
<main class="relative h-full overflow-y-hidden pt-0 px-2 flex flex-col overflow-x-auto inline-block">
6364
<SScale
6465
class="h-full w-max origin-top-left"
65-
size={settingData().pianoSize / HUNDRED}
66+
size={(settingData().pianoSize ?? HUNDRED) / HUNDRED}
6667
>
6768
<SPiano
6869
ref={setPianoElement}
6970
onDown={splendidGrandPianoController.down}
7071
onUp={splendidGrandPianoController.up}
72+
showKeyName={settingData().showKeyName}
7173
/>
7274
</SScale>
7375
</main>

packages/unocss-config/uno.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export default defineConfig({
110110
],
111111
'key-piano-flat': [
112112
'block b-solid b-#ccc rd-t-0 inline-flex flex-shrink-0 overflow-hidden b-b-2px',
113-
'p-0 relative rd-b-3px b-1px shadow-flat-up data-[state="down"]:shadow-flat-down b-b-#ddd',
113+
'p-0 relative rd-b-3px b-l-1px b-r-1px b-t-0 shadow-flat-up data-[state="down"]:shadow-flat-down b-b-#ddd',
114114
'data-[state="down"]-shadow-[0_2px_2px_rgba(0,0,0,0.4)] data-[state="down"]:scale-x-100',
115115
'data-[state="down"]:scale-y-99 data-[state="down"]:origin-top data-[state="down"]:b-b-1px',
116116
'data-[state="down"]:after:content-[""] data-[state="down"]:after:bg-black data-[state="down"]:after:h-full',

0 commit comments

Comments
 (0)