mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-23 11:55:41 +03:00
Update starter template.
This commit is contained in:
parent
56a4abf2fb
commit
55ac3da02d
@ -7,6 +7,7 @@ import Html
|
||||
import Html.Attributes as Attr
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
import Pages.Url
|
||||
import Path
|
||||
import RouteBuilder exposing (StatelessRoute, StaticPayload)
|
||||
import Shared
|
||||
import View exposing (View)
|
||||
@ -50,7 +51,7 @@ head static =
|
||||
{ canonicalUrlOverride = Nothing
|
||||
, siteName = "elm-pages"
|
||||
, image =
|
||||
{ url = Pages.Url.external "TODO"
|
||||
{ url = [ "images", "icon-png.png" ] |> Path.join |> Pages.Url.fromPath
|
||||
, alt = "elm-pages logo"
|
||||
, dimensions = Nothing
|
||||
, mimeType = Nothing
|
||||
|
@ -3,6 +3,7 @@ module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template)
|
||||
import Browser.Navigation
|
||||
import DataSource
|
||||
import Html exposing (Html)
|
||||
import Html.Events
|
||||
import Pages.Flags
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
import Path exposing (Path)
|
||||
@ -18,17 +19,13 @@ template =
|
||||
, view = view
|
||||
, data = data
|
||||
, subscriptions = subscriptions
|
||||
, onPageChange = Just OnPageChange
|
||||
, onPageChange = Nothing
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= OnPageChange
|
||||
{ path : Path
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
| SharedMsg SharedMsg
|
||||
= SharedMsg SharedMsg
|
||||
| MenuClicked
|
||||
|
||||
|
||||
type alias Data =
|
||||
@ -40,7 +37,7 @@ type SharedMsg
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ showMobileMenu : Bool
|
||||
{ showMenu : Bool
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +56,7 @@ init :
|
||||
}
|
||||
-> ( Model, Cmd Msg )
|
||||
init navigationKey flags maybePagePath =
|
||||
( { showMobileMenu = False }
|
||||
( { showMenu = False }
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
@ -67,12 +64,12 @@ init navigationKey flags maybePagePath =
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
OnPageChange _ ->
|
||||
( { model | showMobileMenu = False }, Cmd.none )
|
||||
|
||||
SharedMsg globalMsg ->
|
||||
( model, Cmd.none )
|
||||
|
||||
MenuClicked ->
|
||||
( { model | showMenu = not model.showMenu }, Cmd.none )
|
||||
|
||||
|
||||
subscriptions : Path -> Model -> Sub Msg
|
||||
subscriptions _ _ =
|
||||
@ -95,6 +92,30 @@ view :
|
||||
-> View msg
|
||||
-> { body : Html msg, title : String }
|
||||
view sharedData page model toMsg pageView =
|
||||
{ body = Html.div [] pageView.body
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.nav []
|
||||
[ Html.button
|
||||
[ Html.Events.onClick MenuClicked ]
|
||||
[ Html.text
|
||||
(if model.showMenu then
|
||||
"Close Menu"
|
||||
|
||||
else
|
||||
"Open Menu"
|
||||
)
|
||||
]
|
||||
, if model.showMenu then
|
||||
Html.ul []
|
||||
[ Html.li [] [ Html.text "Menu item 1" ]
|
||||
, Html.li [] [ Html.text "Menu item 2" ]
|
||||
]
|
||||
|
||||
else
|
||||
Html.text ""
|
||||
]
|
||||
|> Html.map toMsg
|
||||
, Html.main_ [] pageView.body
|
||||
]
|
||||
, title = pageView.title
|
||||
}
|
||||
|
BIN
examples/hello/public/images/icon-png.png
Normal file
BIN
examples/hello/public/images/icon-png.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 976 B |
@ -7,6 +7,7 @@ import Html
|
||||
import Html.Attributes as Attr
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
import Pages.Url
|
||||
import Path
|
||||
import RouteBuilder exposing (StatelessRoute, StaticPayload)
|
||||
import Shared
|
||||
import View exposing (View)
|
||||
@ -50,7 +51,7 @@ head static =
|
||||
{ canonicalUrlOverride = Nothing
|
||||
, siteName = "elm-pages"
|
||||
, image =
|
||||
{ url = Pages.Url.external "TODO"
|
||||
{ url = [ "images", "icon-png.png" ] |> Path.join |> Pages.Url.fromPath
|
||||
, alt = "elm-pages logo"
|
||||
, dimensions = Nothing
|
||||
, mimeType = Nothing
|
||||
|
@ -3,6 +3,7 @@ module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template)
|
||||
import Browser.Navigation
|
||||
import DataSource
|
||||
import Html exposing (Html)
|
||||
import Html.Events
|
||||
import Pages.Flags
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
import Path exposing (Path)
|
||||
@ -18,17 +19,13 @@ template =
|
||||
, view = view
|
||||
, data = data
|
||||
, subscriptions = subscriptions
|
||||
, onPageChange = Just OnPageChange
|
||||
, onPageChange = Nothing
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= OnPageChange
|
||||
{ path : Path
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
| SharedMsg SharedMsg
|
||||
= SharedMsg SharedMsg
|
||||
| MenuClicked
|
||||
|
||||
|
||||
type alias Data =
|
||||
@ -40,7 +37,7 @@ type SharedMsg
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ showMobileMenu : Bool
|
||||
{ showMenu : Bool
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +56,7 @@ init :
|
||||
}
|
||||
-> ( Model, Cmd Msg )
|
||||
init navigationKey flags maybePagePath =
|
||||
( { showMobileMenu = False }
|
||||
( { showMenu = False }
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
@ -67,12 +64,12 @@ init navigationKey flags maybePagePath =
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
OnPageChange _ ->
|
||||
( { model | showMobileMenu = False }, Cmd.none )
|
||||
|
||||
SharedMsg globalMsg ->
|
||||
( model, Cmd.none )
|
||||
|
||||
MenuClicked ->
|
||||
( { model | showMenu = not model.showMenu }, Cmd.none )
|
||||
|
||||
|
||||
subscriptions : Path -> Model -> Sub Msg
|
||||
subscriptions _ _ =
|
||||
@ -95,6 +92,30 @@ view :
|
||||
-> View msg
|
||||
-> { body : Html msg, title : String }
|
||||
view sharedData page model toMsg pageView =
|
||||
{ body = Html.div [] pageView.body
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.nav []
|
||||
[ Html.button
|
||||
[ Html.Events.onClick MenuClicked ]
|
||||
[ Html.text
|
||||
(if model.showMenu then
|
||||
"Close Menu"
|
||||
|
||||
else
|
||||
"Open Menu"
|
||||
)
|
||||
]
|
||||
, if model.showMenu then
|
||||
Html.ul []
|
||||
[ Html.li [] [ Html.text "Menu item 1" ]
|
||||
, Html.li [] [ Html.text "Menu item 2" ]
|
||||
]
|
||||
|
||||
else
|
||||
Html.text ""
|
||||
]
|
||||
|> Html.map toMsg
|
||||
, Html.main_ [] pageView.body
|
||||
]
|
||||
, title = pageView.title
|
||||
}
|
||||
|
BIN
generator/template/public/images/icon-png.png
Normal file
BIN
generator/template/public/images/icon-png.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 976 B |
Loading…
Reference in New Issue
Block a user