diff options
author | Vincent Ambo <mail@tazj.in> | 2021-12-13T22·51+0300 |
---|---|---|
committer | Vincent Ambo <mail@tazj.in> | 2021-12-13T23·15+0300 |
commit | 019f8fd2113df4c5247c3969c60fd4f0e08f91f7 (patch) | |
tree | 76a857f61aa88f62a30e854651e8439db77fd0ea /users/wpcarro/website/sandbox/learnpianochords/src/Preferences.elm | |
parent | 464bbcb15c09813172c79820bcf526bb10cf4208 (diff) | |
parent | 6123e976928ca3d8d93f0b2006b10b5f659eb74d (diff) |
subtree(users/wpcarro): docking briefcase at '24f5a642' r/3226
git-subtree-dir: users/wpcarro git-subtree-mainline: 464bbcb15c09813172c79820bcf526bb10cf4208 git-subtree-split: 24f5a642af3aa1627bbff977f0a101907a02c69f Change-Id: I6105b3762b79126b3488359c95978cadb3efa789
Diffstat (limited to 'users/wpcarro/website/sandbox/learnpianochords/src/Preferences.elm')
-rw-r--r-- | users/wpcarro/website/sandbox/learnpianochords/src/Preferences.elm | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/users/wpcarro/website/sandbox/learnpianochords/src/Preferences.elm b/users/wpcarro/website/sandbox/learnpianochords/src/Preferences.elm new file mode 100644 index 000000000000..59e6c8234c13 --- /dev/null +++ b/users/wpcarro/website/sandbox/learnpianochords/src/Preferences.elm @@ -0,0 +1,148 @@ +module Preferences exposing (render) + +import Html exposing (..) +import Html.Attributes exposing (..) +import Html.Events exposing (..) +import Icon +import Responsive +import State +import Tailwind +import Tempo +import Theory +import UI + + +selectKey : + State.Model + -> + { relativeMajor : Theory.Key + , relativeMinor : Theory.Key + } + -> Html State.Msg +selectKey model { relativeMajor, relativeMinor } = + let + active key = + List.member key model.whitelistedKeys + + buttonLabel major minor = + Theory.viewKey major ++ ", " ++ Theory.viewKey minor + in + div [ class "flex pt-0" ] + [ UI.textToggleButton + { label = buttonLabel relativeMajor relativeMinor + , handleClick = State.ToggleKey relativeMajor + , classes = [ "flex-1" ] + , toggled = active relativeMajor + } + ] + + +inversionCheckboxes : State.Model -> Html State.Msg +inversionCheckboxes model = + div [] + [ h2 + [ [ "text-gray-500" + , "text-center" + , "pt-10" + , Responsive.h2 + ] + |> Tailwind.use + |> class + ] + [ 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 + } + ] + ) + ) + ] + + +keyCheckboxes : State.Model -> Html State.Msg +keyCheckboxes model = + let + majorKey pitchClass = + { pitchClass = pitchClass, mode = Theory.MajorMode } + + minorKey pitchClass = + { pitchClass = pitchClass, mode = Theory.MinorMode } + + circleOfFifths = + [ ( Theory.C, Theory.A ) + , ( Theory.G, Theory.E ) + , ( Theory.D, Theory.B ) + , ( Theory.A, Theory.F_sharp ) + , ( Theory.E, Theory.C_sharp ) + , ( Theory.B, Theory.G_sharp ) + , ( Theory.F_sharp, Theory.D_sharp ) + , ( Theory.C_sharp, Theory.A_sharp ) + , ( Theory.G_sharp, Theory.F ) + , ( Theory.D_sharp, Theory.C ) + , ( Theory.A_sharp, Theory.G ) + , ( Theory.F, Theory.D ) + ] + in + div [] + [ h2 + [ [ "text-gray-500" + , "text-center" + , "pt-10" + , Responsive.h2 + ] + |> Tailwind.use + |> class + ] + [ text "Select keys" ] + , ul [] + (circleOfFifths + |> List.map + (\( major, minor ) -> + selectKey model + { relativeMajor = majorKey major + , relativeMinor = minorKey minor + } + ) + ) + ] + + +closePreferences : Html State.Msg +closePreferences = + button + [ [ "w-48" + , "lg:w-32" + , "h-48" + , "lg:h-32" + , "absolute" + , "right-0" + , "top-0" + , "z-10" + ] + |> Tailwind.use + |> class + , onClick (State.SetView State.Practice) + ] + [ Icon.close ] + + +render : State.Model -> Html State.Msg +render model = + div [ class "pt-10 pb-20 px-10" ] + [ closePreferences + , Tempo.render + { tempo = model.tempo + , handleInput = State.SetTempo + } + , inversionCheckboxes model + , keyCheckboxes model + ] |