mirror of
https://gitlab.com/upRootNutrition/website.git
synced 2025-06-17 12:55:12 -05:00
chore: push for isaac
This commit is contained in:
parent
a5151ef112
commit
45ca7a9718
62 changed files with 385 additions and 55 deletions
104
frontend/src/Shared.elm
Normal file
104
frontend/src/Shared.elm
Normal file
|
@ -0,0 +1,104 @@
|
|||
module Shared exposing
|
||||
( Flags, decoder
|
||||
, Model, Msg
|
||||
, init, update, subscriptions
|
||||
)
|
||||
|
||||
{-|
|
||||
|
||||
@docs Flags, decoder
|
||||
@docs Model, Msg
|
||||
@docs init, update, subscriptions
|
||||
|
||||
-}
|
||||
|
||||
import Effect exposing (Effect)
|
||||
import Element as E exposing (..)
|
||||
import Json.Decode exposing (..)
|
||||
import Route exposing (Route)
|
||||
import Route.Path
|
||||
import Shared.Model
|
||||
import Shared.Msg
|
||||
|
||||
|
||||
|
||||
-- FLAGS
|
||||
|
||||
|
||||
type alias Flags =
|
||||
{ height : Int
|
||||
, width : Int
|
||||
}
|
||||
|
||||
|
||||
decoder : Json.Decode.Decoder Flags
|
||||
decoder =
|
||||
Json.Decode.map2
|
||||
(\height width ->
|
||||
{ height = height
|
||||
, width = width
|
||||
}
|
||||
)
|
||||
(field "height" int)
|
||||
(field "width" int)
|
||||
|
||||
|
||||
|
||||
-- INIT
|
||||
|
||||
|
||||
type alias Model =
|
||||
Shared.Model.Model
|
||||
|
||||
|
||||
init : Result Json.Decode.Error Flags -> Route () -> ( Model, Effect Msg )
|
||||
init flagsResult route =
|
||||
( modelFromFlagsResult flagsResult
|
||||
, Effect.none
|
||||
)
|
||||
|
||||
|
||||
modelFromFlagsResult : Result Error Flags -> Model
|
||||
modelFromFlagsResult f =
|
||||
case f of
|
||||
Ok flags ->
|
||||
{ device = E.classifyDevice flags
|
||||
, height = flags.height
|
||||
, width = flags.width
|
||||
}
|
||||
|
||||
Err _ ->
|
||||
{ device =
|
||||
E.classifyDevice
|
||||
{ height = 0
|
||||
, width = 0
|
||||
}
|
||||
, height = 10
|
||||
, width = 10
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- UPDATE
|
||||
|
||||
|
||||
type alias Msg =
|
||||
Shared.Msg.Msg
|
||||
|
||||
|
||||
update : Route () -> Msg -> Model -> ( Model, Effect Msg )
|
||||
update route msg model =
|
||||
case msg of
|
||||
Shared.Msg.NoOp ->
|
||||
( model
|
||||
, Effect.none
|
||||
)
|
||||
|
||||
|
||||
|
||||
-- SUBSCRIPTIONS
|
||||
|
||||
|
||||
subscriptions : Route () -> Model -> Sub Msg
|
||||
subscriptions route model =
|
||||
Sub.none
|
Loading…
Add table
Add a link
Reference in a new issue