-
Notifications
You must be signed in to change notification settings - Fork 7
✨ feat(yamaha-01v96): Fixed channel pairing bug in AUX and BUS tabs #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import { useDelayedState } from '../../../hooks/delayed-state' | |
|
|
||
| import { FaderBase } from './fader-base' | ||
| import { FaderButton } from './fader-button' | ||
| import { useEntryState } from '../../../api/state' | ||
|
|
||
| export interface FaderProps { | ||
| value: number | ||
|
|
@@ -19,9 +20,29 @@ export interface FaderProps { | |
| color?: string | ||
| meterRef?: React.RefObject<HTMLDivElement | null> | ||
| onChange: (value: number) => void | ||
| className?: string | ||
| category: string | ||
| id: string | ||
| } | ||
|
|
||
| const pairColors = [ | ||
| '#e6194B', | ||
| '#3cb44b', | ||
| '#ffe119', | ||
| '#4363d8', | ||
| '#f58231', | ||
| '#911eb4', | ||
| '#42d4f4', | ||
| '#f032e6', | ||
| '#bfef45', | ||
| '#fabed4', | ||
| '#469990', | ||
| '#dcbeff', | ||
| '#9A6324', | ||
| '#fffac8', | ||
| '#800000', | ||
| '#aaffc3', | ||
| ] | ||
|
|
||
| export const Fader = ({ | ||
| value, | ||
| min = 0, | ||
|
|
@@ -31,19 +52,25 @@ export const Fader = ({ | |
| subLabel, | ||
| color, | ||
| onChange, | ||
| ...passThrough | ||
| meterRef, | ||
| category, | ||
| id, | ||
| }: FaderProps) => { | ||
| const [localValue, setLocalValue] = useDelayedState<number | null>(null) | ||
| const valueToUse = localValue ?? value | ||
| const state = useEntryState(category, id) | ||
|
|
||
| let pairColor = color | ||
| if (state?.paired) { | ||
| const pairIndex = Math.floor((parseInt(id) - 1) / 2) | ||
| pairColor = pairColors[pairIndex % pairColors.length] | ||
| } | ||
|
Comment on lines
+61
to
+67
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't feel quite right, as How about extracting this into a hook that determines the color for an entry? (maybe in a new file?) export function useEntryColor(
state: StateCategoryEntry | undefined
): string | null | undefined {
if (state?.paired) {
const pairIndex = Math.floor((parseInt(id) - 1) / 2)
return pairColors[pairIndex % pairColors.length]
} else {
return state?.color
}
}And then the places that render the const color = useEntryColor(state)
// ...
return <Fader /* ... */ color={color} />(the hook could also take |
||
|
|
||
| return ( | ||
| <FaderBase | ||
| {...passThrough} | ||
| meterRef={meterRef} | ||
| onTouch={fraction => { | ||
| const newRawValue = fractionToValue(fraction, min, max) | ||
| if (newRawValue === valueToUse) { | ||
| return | ||
| } | ||
| setLocalValue(newRawValue) | ||
| const roundedValue = roundToStep(newRawValue, step) | ||
| onChange(roundedValue) | ||
|
|
@@ -54,7 +81,7 @@ export const Fader = ({ | |
| fraction={valueToFraction(valueToUse, min, max)} | ||
| label={label} | ||
| subLabel={subLabel} | ||
| color={color} | ||
| color={pairColor} | ||
| /> | ||
| </FaderBase> | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this not break the grouping sync, as it is the only place where the groups are requested?