diff --git a/src/components/KeySignaturePickerPopup.css b/src/components/KeySignaturePickerPopup.css index bd10e65..88bfedb 100644 --- a/src/components/KeySignaturePickerPopup.css +++ b/src/components/KeySignaturePickerPopup.css @@ -145,16 +145,17 @@ font-size: 11px; } -.key-signature-picker-button.selected { - text-decoration: underline; - text-underline-offset: 3px; -} - .key-signature-picker-label { display: inline-flex; align-items: flex-start; } +.key-signature-picker-label.selected { + text-decoration: underline; + text-underline-offset: 3px; + text-decoration-thickness: 1px; +} + .key-signature-picker-accidental { font-size: 0.58em; line-height: 1; diff --git a/src/components/KeySignaturePickerPopup.tsx b/src/components/KeySignaturePickerPopup.tsx index 38d22a0..bd8b5d3 100644 --- a/src/components/KeySignaturePickerPopup.tsx +++ b/src/components/KeySignaturePickerPopup.tsx @@ -34,21 +34,21 @@ function splitAccidental(label: string): { base: string; accidental: string | nu return { base: label, accidental: null }; } -const KeyLabel: React.FC<{ label: string }> = ({ label }) => { +const KeyLabel: React.FC<{ label: string; selected?: boolean }> = ({ label, selected = false }) => { const { base, accidental } = splitAccidental(label); return ( - + {base} {accidental && {accidental}} ); }; -const CombinedKeyLabel: React.FC<{ labels: string[] }> = ({ labels }) => ( +const CombinedKeyLabel: React.FC<{ labels: string[]; selectedIndex?: number }> = ({ labels, selectedIndex = -1 }) => ( {labels.map((label, index) => ( - + {index < labels.length - 1 && /} ))} @@ -97,7 +97,10 @@ const KeySignaturePickerPopup: React.FC = ({ value aria-label={`Select ${slot.outerItems.map(item => item.keySignature).join(' or ')}`} title={slot.outerItems.map(item => item.keySignature).join(' / ')} > - item.label)} /> + item.label)} + selectedIndex={slot.outerItems.findIndex(item => item.keySignature === value)} + /> ) : (
@@ -105,11 +108,11 @@ const KeySignaturePickerPopup: React.FC = ({ value
))} @@ -128,7 +131,10 @@ const KeySignaturePickerPopup: React.FC = ({ value aria-label={`Select ${slot.innerItems.map(item => item.keySignature).join(' or ')}`} title={slot.innerItems.map(item => item.keySignature).join(' / ')} > - item.label)} /> + item.label)} + selectedIndex={slot.innerItems.findIndex(item => item.keySignature === value)} + /> ) : (
@@ -140,7 +146,7 @@ const KeySignaturePickerPopup: React.FC = ({ value onClick={() => onChange(item.keySignature)} aria-label={`Select ${item.keySignature}`} > - + ))}