2020-04-18 15:58:16 +02:00
|
|
|
module Preferences exposing (render)
|
|
|
|
|
|
|
|
import Html exposing (..)
|
|
|
|
import Html.Attributes exposing (..)
|
|
|
|
import Html.Events exposing (..)
|
|
|
|
import Icon
|
Responsively size UI
TL;DR: scale down UI for non-mobile devices.
I pulled the screen resolution for my phone, the Google Pixel 4, off of the
internet. I created a device profile in Chrome to develop this application
specifically for my phone. To my surprise, when I opened the app on my phone,
many of elements that looked good in Google Chrome, looked askew on my phone. I
needed to troubleshoot.
Here's how I did that:
I used Tailwind to responsively color the bg for each breakpoint to see if my
device was sm, md, lg, xl (according to Tailwind's breakpoint
terminology). After reading Tailwind's documentation and comparing their
breakpoints with my Pixel 4's width (i.e. 1080px), I figured that my device
would be lg. It's not; it's md, which I confirmed by using ngrok to load
localhost:8000 on my phone and see that the background-color was
"md:bg-green-600".
I'm still unsure why my device is not lg, but knowing that my device was md
was enough to fix many of the styling issues. My current theory is that while
my screen's resolution is 1080 wide, the pixel density affects the media query
for the breakpoint.
2020-04-19 14:05:55 +02:00
|
|
|
import Responsive
|
2020-04-18 15:58:16 +02:00
|
|
|
import State
|
2020-04-19 14:40:18 +02:00
|
|
|
import Tailwind
|
2020-04-18 15:58:16 +02:00
|
|
|
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
|
2020-04-18 19:51:23 +02:00
|
|
|
, handleClick = State.ToggleKey relativeMajor
|
2020-04-18 15:58:16 +02:00
|
|
|
, classes = [ "flex-1" ]
|
2020-04-18 19:51:23 +02:00
|
|
|
, toggled = active relativeMajor
|
2020-04-18 15:58:16 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2020-04-19 19:36:22 +02:00
|
|
|
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
|
|
|
|
}
|
2020-04-18 15:58:16 +02:00
|
|
|
]
|
2020-04-19 19:36:22 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
]
|
2020-04-18 15:58:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
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 []
|
Responsively size UI
TL;DR: scale down UI for non-mobile devices.
I pulled the screen resolution for my phone, the Google Pixel 4, off of the
internet. I created a device profile in Chrome to develop this application
specifically for my phone. To my surprise, when I opened the app on my phone,
many of elements that looked good in Google Chrome, looked askew on my phone. I
needed to troubleshoot.
Here's how I did that:
I used Tailwind to responsively color the bg for each breakpoint to see if my
device was sm, md, lg, xl (according to Tailwind's breakpoint
terminology). After reading Tailwind's documentation and comparing their
breakpoints with my Pixel 4's width (i.e. 1080px), I figured that my device
would be lg. It's not; it's md, which I confirmed by using ngrok to load
localhost:8000 on my phone and see that the background-color was
"md:bg-green-600".
I'm still unsure why my device is not lg, but knowing that my device was md
was enough to fix many of the styling issues. My current theory is that while
my screen's resolution is 1080 wide, the pixel density affects the media query
for the breakpoint.
2020-04-19 14:05:55 +02:00
|
|
|
[ h2
|
|
|
|
[ [ "text-gray-500"
|
|
|
|
, "text-center"
|
|
|
|
, "pt-10"
|
|
|
|
, Responsive.h2
|
|
|
|
]
|
2020-04-19 14:40:18 +02:00
|
|
|
|> Tailwind.use
|
Responsively size UI
TL;DR: scale down UI for non-mobile devices.
I pulled the screen resolution for my phone, the Google Pixel 4, off of the
internet. I created a device profile in Chrome to develop this application
specifically for my phone. To my surprise, when I opened the app on my phone,
many of elements that looked good in Google Chrome, looked askew on my phone. I
needed to troubleshoot.
Here's how I did that:
I used Tailwind to responsively color the bg for each breakpoint to see if my
device was sm, md, lg, xl (according to Tailwind's breakpoint
terminology). After reading Tailwind's documentation and comparing their
breakpoints with my Pixel 4's width (i.e. 1080px), I figured that my device
would be lg. It's not; it's md, which I confirmed by using ngrok to load
localhost:8000 on my phone and see that the background-color was
"md:bg-green-600".
I'm still unsure why my device is not lg, but knowing that my device was md
was enough to fix many of the styling issues. My current theory is that while
my screen's resolution is 1080 wide, the pixel density affects the media query
for the breakpoint.
2020-04-19 14:05:55 +02:00
|
|
|
|> class
|
|
|
|
]
|
|
|
|
[ text "Select keys" ]
|
2020-04-18 15:58:16 +02:00
|
|
|
, ul []
|
|
|
|
(circleOfFifths
|
|
|
|
|> List.map
|
|
|
|
(\( major, minor ) ->
|
|
|
|
selectKey model
|
|
|
|
{ relativeMajor = majorKey major
|
|
|
|
, relativeMinor = minorKey minor
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
closePreferences : Html State.Msg
|
|
|
|
closePreferences =
|
|
|
|
button
|
Responsively size UI
TL;DR: scale down UI for non-mobile devices.
I pulled the screen resolution for my phone, the Google Pixel 4, off of the
internet. I created a device profile in Chrome to develop this application
specifically for my phone. To my surprise, when I opened the app on my phone,
many of elements that looked good in Google Chrome, looked askew on my phone. I
needed to troubleshoot.
Here's how I did that:
I used Tailwind to responsively color the bg for each breakpoint to see if my
device was sm, md, lg, xl (according to Tailwind's breakpoint
terminology). After reading Tailwind's documentation and comparing their
breakpoints with my Pixel 4's width (i.e. 1080px), I figured that my device
would be lg. It's not; it's md, which I confirmed by using ngrok to load
localhost:8000 on my phone and see that the background-color was
"md:bg-green-600".
I'm still unsure why my device is not lg, but knowing that my device was md
was enough to fix many of the styling issues. My current theory is that while
my screen's resolution is 1080 wide, the pixel density affects the media query
for the breakpoint.
2020-04-19 14:05:55 +02:00
|
|
|
[ [ "w-48"
|
|
|
|
, "lg:w-32"
|
|
|
|
, "h-48"
|
|
|
|
, "lg:h-32"
|
|
|
|
, "absolute"
|
|
|
|
, "right-0"
|
|
|
|
, "top-0"
|
|
|
|
, "z-10"
|
|
|
|
]
|
2020-04-19 14:40:18 +02:00
|
|
|
|> Tailwind.use
|
Responsively size UI
TL;DR: scale down UI for non-mobile devices.
I pulled the screen resolution for my phone, the Google Pixel 4, off of the
internet. I created a device profile in Chrome to develop this application
specifically for my phone. To my surprise, when I opened the app on my phone,
many of elements that looked good in Google Chrome, looked askew on my phone. I
needed to troubleshoot.
Here's how I did that:
I used Tailwind to responsively color the bg for each breakpoint to see if my
device was sm, md, lg, xl (according to Tailwind's breakpoint
terminology). After reading Tailwind's documentation and comparing their
breakpoints with my Pixel 4's width (i.e. 1080px), I figured that my device
would be lg. It's not; it's md, which I confirmed by using ngrok to load
localhost:8000 on my phone and see that the background-color was
"md:bg-green-600".
I'm still unsure why my device is not lg, but knowing that my device was md
was enough to fix many of the styling issues. My current theory is that while
my screen's resolution is 1080 wide, the pixel density affects the media query
for the breakpoint.
2020-04-19 14:05:55 +02:00
|
|
|
|> class
|
2020-04-18 15:58:16 +02:00
|
|
|
, 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
|
|
|
|
}
|
2020-04-19 19:36:22 +02:00
|
|
|
, inversionCheckboxes model
|
2020-04-19 19:23:01 +02:00
|
|
|
, keyCheckboxes model
|
2020-04-18 15:58:16 +02:00
|
|
|
]
|