Restore support for whitelisted chord inversions

Allow users to include or exclude chord inversions.
This commit is contained in:
William Carroll 2020-04-19 18:36:22 +01:00
parent 14f11823ff
commit 4a8f750ba8
2 changed files with 34 additions and 44 deletions

View file

@ -37,42 +37,35 @@ selectKey model { relativeMajor, relativeMinor } =
] ]
chordTypeCheckboxes : List Theory.ChordType -> Html State.Msg inversionCheckboxes : State.Model -> Html State.Msg
chordTypeCheckboxes chordTypes = inversionCheckboxes model =
ul [] div []
(Theory.allChordTypes [ h2
|> List.map [ [ "text-gray-500"
(\chordType -> , "text-center"
li [] , "pt-10"
[ label [] [ text (Theory.chordTypeName chordType) ] , Responsive.h2
, input ]
[ type_ "checkbox" |> Tailwind.use
, onClick (State.ToggleChordType chordType) |> class
, checked (List.member chordType chordTypes) ]
[ text "Select inversions" ]
, ul
[ [ "flex", "justify-center" ] |> Tailwind.use |> class ]
(Theory.allInversions
|> List.map
(\inversion ->
li []
[ UI.textToggleButton
{ label = Theory.inversionName inversion
, handleClick = State.ToggleInversion inversion
, classes = []
, toggled = List.member inversion model.whitelistedInversions
}
] ]
[] )
] )
) ]
)
inversionCheckboxes : List Theory.ChordInversion -> Html State.Msg
inversionCheckboxes inversions =
ul []
(Theory.allInversions
|> List.map
(\inversion ->
li []
[ label [] [ text (Theory.inversionName inversion) ]
, input
[ type_ "checkbox"
, onClick (State.ToggleInversion inversion)
, checked (List.member inversion inversions)
]
[]
]
)
)
keyCheckboxes : State.Model -> Html State.Msg keyCheckboxes : State.Model -> Html State.Msg
@ -150,5 +143,6 @@ render model =
{ tempo = model.tempo { tempo = model.tempo
, handleInput = State.SetTempo , handleInput = State.SetTempo
} }
, inversionCheckboxes model
, keyCheckboxes model , keyCheckboxes model
] ]

View file

@ -51,7 +51,7 @@ init =
( Theory.C3, Theory.C6 ) ( Theory.C3, Theory.C6 )
inversions = inversions =
Theory.allInversions [ Theory.Root ]
chordTypes = chordTypes =
Theory.allChordTypes Theory.allChordTypes
@ -73,7 +73,7 @@ init =
, tempo = 10 , tempo = 10
, firstNote = firstNote , firstNote = firstNote
, lastNote = lastNote , lastNote = lastNote
, view = Overview , view = Preferences
, showFlashCard = True , showFlashCard = True
} }
@ -158,13 +158,9 @@ update msg model =
( { model ( { model
| whitelistedInversions = inversions | whitelistedInversions = inversions
, whitelistedChords = , whitelistedChords =
Theory.allChords model.whitelistedKeys
{ start = model.firstNote |> List.concatMap Theory.chordsForKey
, end = model.lastNote |> List.filter (\chord -> List.member chord.chordInversion inversions)
, inversions = inversions
, chordTypes = model.whitelistedChordTypes
, pitchClasses = model.whitelistedPitchClasses
}
} }
, Cmd.none , Cmd.none
) )