mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-24 06:02:36 +03:00
internal config helper
This commit is contained in:
parent
0d47f37ab9
commit
6d2085a27d
@ -269,27 +269,13 @@ view label attributes =
|
|||||||
eventsAndValues =
|
eventsAndValues =
|
||||||
applyEvents attributes
|
applyEvents attributes
|
||||||
|
|
||||||
config_ : Config
|
config : Config
|
||||||
config_ =
|
config =
|
||||||
applyConfig attributes
|
applyConfig attributes
|
||||||
|
|
||||||
unvalidatedRadioConfig : ( Maybe value, Maybe String, Maybe (value -> String) )
|
|
||||||
unvalidatedRadioConfig =
|
|
||||||
( eventsAndValues.value, config_.name, eventsAndValues.valueToString )
|
|
||||||
in
|
in
|
||||||
case unvalidatedRadioConfig of
|
case makeInternalConfig label config eventsAndValues of
|
||||||
( Just value_, Just name_, Just valueToString_ ) ->
|
Just internalConfig ->
|
||||||
let
|
case config.display of
|
||||||
internalConfig =
|
|
||||||
{ value = value_
|
|
||||||
, name = name_
|
|
||||||
, valueToString = valueToString_
|
|
||||||
, eventsAndValues = eventsAndValues
|
|
||||||
, config = config_
|
|
||||||
, label = label
|
|
||||||
}
|
|
||||||
in
|
|
||||||
case config_.display of
|
|
||||||
Inline ->
|
Inline ->
|
||||||
viewInline internalConfig
|
viewInline internalConfig
|
||||||
|
|
||||||
@ -301,15 +287,35 @@ view label attributes =
|
|||||||
|
|
||||||
|
|
||||||
type alias InternalConfig value msg =
|
type alias InternalConfig value msg =
|
||||||
{ value : value
|
{ -- user specified values
|
||||||
|
value : value
|
||||||
, name : String
|
, name : String
|
||||||
, valueToString : value -> String
|
, valueToString : value -> String
|
||||||
, eventsAndValues : EventsAndValues value msg
|
, eventsAndValues : EventsAndValues value msg
|
||||||
, config : Config
|
, config : Config
|
||||||
, label : String
|
, label : String
|
||||||
|
|
||||||
|
-- TODO: computed values that both view helpers need
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
makeInternalConfig : String -> Config -> EventsAndValues value msg -> Maybe (InternalConfig value msg)
|
||||||
|
makeInternalConfig label config eventsAndValues =
|
||||||
|
case ( eventsAndValues.value, config.name, eventsAndValues.valueToString ) of
|
||||||
|
( Just value_, Just name_, Just valueToString_ ) ->
|
||||||
|
Just
|
||||||
|
{ value = value_
|
||||||
|
, name = name_
|
||||||
|
, valueToString = valueToString_
|
||||||
|
, eventsAndValues = eventsAndValues
|
||||||
|
, config = config
|
||||||
|
, label = label
|
||||||
|
}
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
|
||||||
viewBlock : InternalConfig value msg -> Html msg
|
viewBlock : InternalConfig value msg -> Html msg
|
||||||
viewBlock internalConfig =
|
viewBlock internalConfig =
|
||||||
let
|
let
|
||||||
|
@ -137,12 +137,27 @@ viewVanilla state =
|
|||||||
{ teacherPremiumLevel = PremiumLevel.Premium
|
{ teacherPremiumLevel = PremiumLevel.Premium
|
||||||
, contentPremiumLevel = PremiumLevel.PremiumWithWriting
|
, contentPremiumLevel = PremiumLevel.PremiumWithWriting
|
||||||
}
|
}
|
||||||
|
, RadioButton.value Robots
|
||||||
, RadioButton.name "pets"
|
, RadioButton.name "pets"
|
||||||
, RadioButton.selectedValue state.selectedValue
|
, RadioButton.selectedValue state.selectedValue
|
||||||
, RadioButton.onSelect Select
|
, RadioButton.onSelect Select
|
||||||
, RadioButton.valueToString selectionToString
|
, RadioButton.valueToString selectionToString
|
||||||
, RadioButton.showPennant <| OpenModal "pets-robots"
|
, RadioButton.showPennant <| OpenModal "pets-robots"
|
||||||
, RadioButton.block
|
, RadioButton.inline
|
||||||
|
]
|
||||||
|
, RadioButton.view
|
||||||
|
(selectionToString Robots)
|
||||||
|
[ RadioButton.premium
|
||||||
|
{ teacherPremiumLevel = PremiumLevel.Premium
|
||||||
|
, contentPremiumLevel = PremiumLevel.PremiumWithWriting
|
||||||
|
}
|
||||||
|
, RadioButton.value Robots
|
||||||
|
, RadioButton.name "pets"
|
||||||
|
, RadioButton.selectedValue state.selectedValue
|
||||||
|
, RadioButton.onSelect Select
|
||||||
|
, RadioButton.valueToString selectionToString
|
||||||
|
, RadioButton.showPennant <| OpenModal "pets-robots"
|
||||||
|
, RadioButton.inline
|
||||||
]
|
]
|
||||||
, p
|
, p
|
||||||
[ Attributes.id "dogs-description" ]
|
[ Attributes.id "dogs-description" ]
|
||||||
|
Loading…
Reference in New Issue
Block a user