Restore support for whitelisted chord inversions
Allow users to include or exclude chord inversions.
This commit is contained in:
parent
14f11823ff
commit
4a8f750ba8
2 changed files with 34 additions and 44 deletions
|
@ -37,42 +37,35 @@ selectKey model { relativeMajor, relativeMinor } =
|
|||
]
|
||||
|
||||
|
||||
chordTypeCheckboxes : List Theory.ChordType -> Html State.Msg
|
||||
chordTypeCheckboxes chordTypes =
|
||||
ul []
|
||||
(Theory.allChordTypes
|
||||
|> List.map
|
||||
(\chordType ->
|
||||
li []
|
||||
[ label [] [ text (Theory.chordTypeName chordType) ]
|
||||
, input
|
||||
[ type_ "checkbox"
|
||||
, onClick (State.ToggleChordType chordType)
|
||||
, checked (List.member chordType chordTypes)
|
||||
inversionCheckboxes : State.Model -> Html State.Msg
|
||||
inversionCheckboxes model =
|
||||
div []
|
||||
[ h2
|
||||
[ [ "text-gray-500"
|
||||
, "text-center"
|
||||
, "pt-10"
|
||||
, Responsive.h2
|
||||
]
|
||||
[]
|
||||
|> Tailwind.use
|
||||
|> class
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
inversionCheckboxes : List Theory.ChordInversion -> Html State.Msg
|
||||
inversionCheckboxes inversions =
|
||||
ul []
|
||||
[ text "Select inversions" ]
|
||||
, ul
|
||||
[ [ "flex", "justify-center" ] |> Tailwind.use |> class ]
|
||||
(Theory.allInversions
|
||||
|> List.map
|
||||
(\inversion ->
|
||||
li []
|
||||
[ label [] [ text (Theory.inversionName inversion) ]
|
||||
, input
|
||||
[ type_ "checkbox"
|
||||
, onClick (State.ToggleInversion inversion)
|
||||
, checked (List.member inversion inversions)
|
||||
]
|
||||
[]
|
||||
[ UI.textToggleButton
|
||||
{ label = Theory.inversionName inversion
|
||||
, handleClick = State.ToggleInversion inversion
|
||||
, classes = []
|
||||
, toggled = List.member inversion model.whitelistedInversions
|
||||
}
|
||||
]
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
keyCheckboxes : State.Model -> Html State.Msg
|
||||
|
@ -150,5 +143,6 @@ render model =
|
|||
{ tempo = model.tempo
|
||||
, handleInput = State.SetTempo
|
||||
}
|
||||
, inversionCheckboxes model
|
||||
, keyCheckboxes model
|
||||
]
|
||||
|
|
|
@ -51,7 +51,7 @@ init =
|
|||
( Theory.C3, Theory.C6 )
|
||||
|
||||
inversions =
|
||||
Theory.allInversions
|
||||
[ Theory.Root ]
|
||||
|
||||
chordTypes =
|
||||
Theory.allChordTypes
|
||||
|
@ -73,7 +73,7 @@ init =
|
|||
, tempo = 10
|
||||
, firstNote = firstNote
|
||||
, lastNote = lastNote
|
||||
, view = Overview
|
||||
, view = Preferences
|
||||
, showFlashCard = True
|
||||
}
|
||||
|
||||
|
@ -158,13 +158,9 @@ update msg model =
|
|||
( { model
|
||||
| whitelistedInversions = inversions
|
||||
, whitelistedChords =
|
||||
Theory.allChords
|
||||
{ start = model.firstNote
|
||||
, end = model.lastNote
|
||||
, inversions = inversions
|
||||
, chordTypes = model.whitelistedChordTypes
|
||||
, pitchClasses = model.whitelistedPitchClasses
|
||||
}
|
||||
model.whitelistedKeys
|
||||
|> List.concatMap Theory.chordsForKey
|
||||
|> List.filter (\chord -> List.member chord.chordInversion inversions)
|
||||
}
|
||||
, Cmd.none
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue