diff --git a/frontend/src/Body.elm b/frontend/src/Body.elm index db7cadc..3cdc0f3 100644 --- a/frontend/src/Body.elm +++ b/frontend/src/Body.elm @@ -1,4 +1,4 @@ -module Body exposing (Msg(..), Model(..), init, update, view, handleRoute) +module Body exposing (Msg(..), Model(..), init, update, view, handleRoute, subscriptions) import Element @@ -28,6 +28,16 @@ type Model init : () -> Model init flags = ModelLanding (Page.Landing.init flags) +subscriptions : Model -> Sub Msg +subscriptions model = + case model of + ModelLanding m -> Page.Landing.subscriptions m |> Sub.map MsgLanding + ModelProducts m -> Page.Products.subscriptions m |> Sub.map MsgProducts + ModelResources m -> Page.Resources.subscriptions m |> Sub.map MsgResources + ModelAbout m -> Page.About.subscriptions m |> Sub.map MsgAbout + ModelContact m -> Page.Contact.subscriptions m |> Sub.map MsgContact + ModelNotFound m -> Page.NotFound.subscriptions m |> Sub.map MsgNotFound + handleRoute : String -> Model handleRoute path = let @@ -74,11 +84,11 @@ view : Model -> Element.Element Msg view model = let content = case model of - ModelLanding m -> Page.Landing.view m |> Element.map MsgLanding - ModelProducts m -> Page.Products.view m |> Element.map MsgProducts - ModelResources m -> Page.Resources.view m |> Element.map MsgResources - ModelAbout m -> Page.About.view m |> Element.map MsgAbout - ModelContact m -> Page.Contact.view m |> Element.map MsgContact - ModelNotFound m -> Page.NotFound.view m |> Element.map MsgNotFound + ModelLanding m -> Page.Landing.view m |> Element.map MsgLanding + ModelProducts m -> Page.Products.view m |> Element.map MsgProducts + ModelResources m -> Page.Resources.view m |> Element.map MsgResources + ModelAbout m -> Page.About.view m |> Element.map MsgAbout + ModelContact m -> Page.Contact.view m |> Element.map MsgContact + ModelNotFound m -> Page.NotFound.view m |> Element.map MsgNotFound in Element.el [Element.centerY ,Element.centerX] content diff --git a/frontend/src/Header.elm b/frontend/src/Header.elm index 9c7c8db..82e2e72 100644 --- a/frontend/src/Header.elm +++ b/frontend/src/Header.elm @@ -1,4 +1,11 @@ -module Header exposing (Model, Msg, view, init, update) +module Header exposing + ( Model + , Msg + , view + , init + , subscriptions + , update + ) import Element exposing (Element) import Element.Events import Element.Border @@ -9,6 +16,9 @@ type alias Msg = {} init : () -> Model init flags = {} +subscriptions : Model -> Sub Msg +subscriptions _ = Sub.none + update : Msg -> Model -> (Model, Cmd Msg) update msg model = (model, Cmd.none) diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm index b99b58c..15057fd 100644 --- a/frontend/src/Main.elm +++ b/frontend/src/Main.elm @@ -60,8 +60,10 @@ update msg model = _ -> (model, Cmd.none) subscriptions : Model -> Sub Msg -subscriptions _ = - Sub.none +subscriptions model = Sub.batch + [ model.header |> Header.subscriptions |> Sub.map Header + , model.page |> Body.subscriptions |> Sub.map Body + ] view : Model -> Browser.Document Msg diff --git a/frontend/src/Page/About.elm b/frontend/src/Page/About.elm index 8b544e1..8df3cbc 100644 --- a/frontend/src/Page/About.elm +++ b/frontend/src/Page/About.elm @@ -5,7 +5,6 @@ module Page.About exposing , init , update , subscriptions - , cleanupSubcriptions ) import Element exposing (Element) @@ -15,9 +14,6 @@ type alias Msg = {} init : () -> Model init flags = {} -cleanupSubcriptions : Model -> Cmd Msg -cleanupSubcriptions _ = Cmd.none - subscriptions : Model -> Sub Msg subscriptions _ = Sub.none diff --git a/frontend/src/Page/Contact.elm b/frontend/src/Page/Contact.elm index eb0a201..32fc41d 100644 --- a/frontend/src/Page/Contact.elm +++ b/frontend/src/Page/Contact.elm @@ -5,7 +5,6 @@ module Page.Contact exposing , init , update , subscriptions - , cleanupSubcriptions ) import Element exposing (Element) @@ -15,9 +14,6 @@ type alias Msg = {} init : () -> Model init flags = {} -cleanupSubcriptions : Model -> Cmd Msg -cleanupSubcriptions _ = Cmd.none - subscriptions : Model -> Sub Msg subscriptions _ = Sub.none diff --git a/frontend/src/Page/Landing.elm b/frontend/src/Page/Landing.elm index 47ddc9d..d36ee12 100644 --- a/frontend/src/Page/Landing.elm +++ b/frontend/src/Page/Landing.elm @@ -5,7 +5,6 @@ module Page.Landing exposing , init , update , subscriptions - , cleanupSubcriptions ) import Element exposing (Element) @@ -15,9 +14,6 @@ type alias Msg = {} init : () -> Model init flags = {} -cleanupSubcriptions : Model -> Cmd Msg -cleanupSubcriptions _ = Cmd.none - subscriptions : Model -> Sub Msg subscriptions _ = Sub.none diff --git a/frontend/src/Page/NotFound.elm b/frontend/src/Page/NotFound.elm index 0b7badd..c68f107 100644 --- a/frontend/src/Page/NotFound.elm +++ b/frontend/src/Page/NotFound.elm @@ -5,7 +5,6 @@ module Page.NotFound exposing , init , update , subscriptions - , cleanupSubcriptions ) import Element exposing (Element) @@ -15,9 +14,6 @@ type alias Msg = {} init : () -> Model init flags = {} -cleanupSubcriptions : Model -> Cmd Msg -cleanupSubcriptions _ = Cmd.none - subscriptions : Model -> Sub Msg subscriptions _ = Sub.none diff --git a/frontend/src/Page/Products.elm b/frontend/src/Page/Products.elm index ea6d547..d7ebdc1 100644 --- a/frontend/src/Page/Products.elm +++ b/frontend/src/Page/Products.elm @@ -5,7 +5,6 @@ module Page.Products exposing , init , update , subscriptions - , cleanupSubcriptions ) import Element exposing (Element) @@ -15,9 +14,6 @@ type alias Msg = {} init : () -> Model init flags = {} -cleanupSubcriptions : Model -> Cmd Msg -cleanupSubcriptions _ = Cmd.none - subscriptions : Model -> Sub Msg subscriptions _ = Sub.none diff --git a/frontend/src/Page/Resources.elm b/frontend/src/Page/Resources.elm index 84c32f9..93e8a48 100644 --- a/frontend/src/Page/Resources.elm +++ b/frontend/src/Page/Resources.elm @@ -5,7 +5,6 @@ module Page.Resources exposing , init , update , subscriptions - , cleanupSubcriptions ) import Element exposing (Element) @@ -15,9 +14,6 @@ type alias Msg = {} init : () -> Model init flags = {} -cleanupSubcriptions : Model -> Cmd Msg -cleanupSubcriptions _ = Cmd.none - subscriptions : Model -> Sub Msg subscriptions _ = Sub.none