-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d13f18
commit d631a61
Showing
8 changed files
with
90 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { AbsoluteCenter, Box, Button, Divider } from '@chakra-ui/react'; | ||
import { ChordType, chordTypes as allChords } from '../config'; | ||
import { useChordSettingsContext } from '../hooks'; | ||
|
||
export const ChordSelector = () => { | ||
const { availableChordTypes, setAvailableChordTypes } = useChordSettingsContext(); | ||
|
||
const handleRemoveChordType = (chord: ChordType) => { | ||
if (availableChordTypes.length !== 1) { | ||
setAvailableChordTypes(availableChordTypes.filter((n) => n !== chord)); | ||
} | ||
}; | ||
|
||
const handleAddChordType = (chord: ChordType) => { | ||
setAvailableChordTypes([chord, ...availableChordTypes]); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Box position="relative" padding="2"> | ||
<Divider /> | ||
<AbsoluteCenter bg="white" px="4"> | ||
Chords selector | ||
</AbsoluteCenter> | ||
</Box> | ||
<div className="flex flex-row flex-wrap justify-center gap-1"> | ||
{allChords.map((chord) => { | ||
const chordIsActive = availableChordTypes.includes(chord); | ||
return ( | ||
<Button | ||
key={chord} | ||
variant="outline" | ||
size="sm" | ||
isActive={chordIsActive} | ||
colorScheme={chordIsActive ? 'green' : 'gray'} | ||
onClick={() => { | ||
if (chordIsActive) { | ||
handleRemoveChordType(chord); | ||
} else { | ||
handleAddChordType(chord); | ||
} | ||
}} | ||
> | ||
{chord} | ||
</Button> | ||
); | ||
})} | ||
</div> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters