mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-07-05 02:45:01 -05:00
feat: improved elm template
This commit is contained in:
parent
8545d7c1e8
commit
6b2a601776
22 changed files with 2139 additions and 0 deletions
72
templates/elm/frontend/src/View.elm
Normal file
72
templates/elm/frontend/src/View.elm
Normal file
|
@ -0,0 +1,72 @@
|
|||
module View exposing
|
||||
( View, map
|
||||
, none, fromString
|
||||
, toBrowserDocument
|
||||
)
|
||||
|
||||
{-|
|
||||
|
||||
@docs View, map
|
||||
@docs none, fromString
|
||||
@docs toBrowserDocument
|
||||
|
||||
-}
|
||||
|
||||
import Browser
|
||||
import Html exposing (Html)
|
||||
import Route exposing (Route)
|
||||
import Shared.Model
|
||||
|
||||
|
||||
type alias View msg =
|
||||
{ title : String
|
||||
, body : List (Html msg)
|
||||
}
|
||||
|
||||
|
||||
{-| Used internally by Elm Land to create your application
|
||||
so it works with Elm's expected `Browser.Document msg` type.
|
||||
-}
|
||||
toBrowserDocument :
|
||||
{ shared : Shared.Model.Model
|
||||
, route : Route ()
|
||||
, view : View msg
|
||||
}
|
||||
-> Browser.Document msg
|
||||
toBrowserDocument { view } =
|
||||
{ title = view.title
|
||||
, body = view.body
|
||||
}
|
||||
|
||||
|
||||
{-| Used internally by Elm Land to connect your pages together.
|
||||
-}
|
||||
map : (msg1 -> msg2) -> View msg1 -> View msg2
|
||||
map fn view =
|
||||
{ title = view.title
|
||||
, body = List.map (Html.map fn) view.body
|
||||
}
|
||||
|
||||
|
||||
{-| Used internally by Elm Land whenever transitioning between
|
||||
authenticated pages.
|
||||
-}
|
||||
none : View msg
|
||||
none =
|
||||
{ title = ""
|
||||
, body = []
|
||||
}
|
||||
|
||||
|
||||
{-| If you customize the `View` module, anytime you run `elm-land add page`,
|
||||
the generated page will use this when adding your `view` function.
|
||||
|
||||
That way your app will compile after adding new pages, and you can see
|
||||
the new page working in the web browser!
|
||||
|
||||
-}
|
||||
fromString : String -> View msg
|
||||
fromString moduleName =
|
||||
{ title = moduleName
|
||||
, body = [ Html.text moduleName ]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue