Skip to content

Instantly share code, notes, and snippets.

@codedmart
Last active December 3, 2015 15:35
Show Gist options
  • Save codedmart/eca1402f7a25406e61c3 to your computer and use it in GitHub Desktop.
Save codedmart/eca1402f7a25406e61c3 to your computer and use it in GitHub Desktop.
type Action
= Setup Options
| Loaded Bool
| DesignChange (Maybe Design)
| ColorChange String
| OrientationChange Int
| MaterialColorChange String
| BulkPriceChange Int
| VariantChange String
| SliderChange Float
| InputChange (String, String)
| InputBlur (String, String)
| SimpleSizeChange String
| ToggleCustomSize String
| ToggleIsPrivate String
| ToggleProductChooserIsOpen String
actions : Signal Action
actions =
Signal.mergeMany
[ Signal.map Setup setup
, Signal.map Loaded loaded
, Signal.map DesignChange designChange
, Signal.map ColorChange colorChange
, Signal.map OrientationChange orientationChange
, Signal.map MaterialColorChange materialColorChange
, Signal.map BulkPriceChange bulkPricingChange
, Signal.map VariantChange variantChange
, Signal.map SliderChange sliderChange
, Signal.map InputChange inputChange
, Signal.map InputBlur inputBlur
, Signal.map SimpleSizeChange simpleSizeChange
, Signal.map ToggleCustomSize toggleCustomSize
, Signal.map ToggleIsPrivate toggleIsPrivate
, Signal.map ToggleProductChooserIsOpen toggleProductChooserIsOpen
]
modelChanges : Signal Model
modelChanges =
Signal.foldp update initialModel actions
getMakeChanges : Model -> MakeChanges
getMakeChanges model =
let
allowsMockup =
case model.product of
Just p ->
p.showMockup
Nothing ->
False
in
{ svgSize = model.svgSize
, backgroundImage = model.selectedImage
, svgColor = model.selectedColor
, orientation = model.selectedOrientation
, materialColor = model.selectedMaterialColor
, allowsMockup = allowsMockup
, loaded = model.loaded
}
port changes : Signal Model
port changes = Signal.dropRepeats (Signal.map (\m -> m) modelChanges)
port makeChanges : Signal MakeChanges
port makeChanges = Signal.dropRepeats (Signal.map getMakeChanges modelChanges)
port errors : Signal (Maybe String)
port errors = Signal.dropRepeats (Signal.map (\m -> m.error) modelChanges)
port setup : Signal Options
port loaded : Signal Bool
port designChange : Signal (Maybe Design)
port colorChange : Signal String
port orientationChange : Signal Int
port materialColorChange : Signal String
port bulkPricingChange : Signal Int
port variantChange : Signal String
port sliderChange : Signal Float
port inputChange : Signal (String, String)
port inputBlur : Signal (String, String)
port simpleSizeChange : Signal String
port toggleCustomSize : Signal String
port toggleIsPrivate : Signal String
port toggleProductChooserIsOpen : Signal String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment