From d908d8d01c8950c8c4c949a9ec0a4ca0eb963937 Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Sun, 23 May 2021 09:00:20 -0700 Subject: [PATCH] Rename Document -> View. --- examples/docs/content/docs.md | 2 +- examples/docs/content/docs/06-page-modules.md | 2 +- examples/docs/src/Document.elm | 35 ----- examples/docs/src/Page/Blog.elm | 5 +- examples/docs/src/Page/Blog/Slug_.elm | 63 ++++---- examples/docs/src/Page/Docs/Section__.elm | 147 +++++++++--------- examples/docs/src/Page/Index.elm | 7 +- examples/docs/src/Page/Projects.elm | 27 ++-- examples/docs/src/Page/Showcase.elm | 5 +- examples/docs/src/Page/Time.elm | 5 +- examples/docs/src/Shared.elm | 22 ++- examples/docs/src/View.elm | 23 +++ examples/repos/src/Page/Index.elm | 15 +- examples/repos/src/Shared.elm | 4 +- examples/repos/src/{Document.elm => View.elm} | 8 +- examples/routing/src/Page/Cats/Name__.elm | 4 +- examples/routing/src/Page/Date/SPLAT_.elm | 4 +- examples/routing/src/Page/SPLAT__.elm | 4 +- examples/routing/src/Page/Slide.elm | 4 +- examples/routing/src/Page/Slide/Number_.elm | 4 +- examples/routing/src/Shared.elm | 4 +- .../routing/src/{Document.elm => View.elm} | 8 +- examples/slides/src/Page/Cats/Name__.elm | 4 +- examples/slides/src/Page/Slide.elm | 4 +- examples/slides/src/Page/Slide/Number_.elm | 4 +- examples/slides/src/Shared.elm | 4 +- .../slides/src/{Document.elm => View.elm} | 8 +- generator/src/Page.elm | 10 +- generator/src/SharedTemplate.elm | 4 +- generator/src/codegen-template-module.js | 4 +- .../src/generate-template-module-connector.js | 4 +- generator/template/src/Document.elm | 6 +- generator/template/src/Page/Index.elm | 4 +- generator/template/src/Shared.elm | 4 +- 34 files changed, 221 insertions(+), 241 deletions(-) delete mode 100644 examples/docs/src/Document.elm create mode 100644 examples/docs/src/View.elm rename examples/repos/src/{Document.elm => View.elm} (63%) rename examples/routing/src/{Document.elm => View.elm} (64%) rename examples/slides/src/{Document.elm => View.elm} (64%) diff --git a/examples/docs/content/docs.md b/examples/docs/content/docs.md index c9c5cb29..5e3f1d42 100644 --- a/examples/docs/content/docs.md +++ b/examples/docs/content/docs.md @@ -92,7 +92,7 @@ You build the `template` using a builder chain, adding complexity as needed. You module Template.Hello.Name_ exposing (Model, Msg, StaticData, template) import DataSource -import Document exposing (Document) +import View exposing (View) import Head import Head.Seo as Seo import Html exposing (text) diff --git a/examples/docs/content/docs/06-page-modules.md b/examples/docs/content/docs/06-page-modules.md index 2ee7b9e4..114100a0 100644 --- a/examples/docs/content/docs/06-page-modules.md +++ b/examples/docs/content/docs/06-page-modules.md @@ -8,7 +8,7 @@ You build the `template` using a builder chain, adding complexity as needed. You module Template.Hello.Name_ exposing (Model, Msg, StaticData, template) import DataSource -import Document exposing (Document) +import View exposing (View) import Head import Head.Seo as Seo import Html exposing (text) diff --git a/examples/docs/src/Document.elm b/examples/docs/src/Document.elm deleted file mode 100644 index 23bb564c..00000000 --- a/examples/docs/src/Document.elm +++ /dev/null @@ -1,35 +0,0 @@ -module Document exposing (Document, View(..), map, placeholder) - -import Html.Styled as Html exposing (Html) - - -type alias Document msg = - { title : String - , body : View msg - } - - -map : (msg1 -> msg2) -> Document msg1 -> Document msg2 -map fn doc = - { title = doc.title - , body = mapView fn doc.body - } - - -type View msg - = ElmCssView (List (Html msg)) - - -mapView : (msg1 -> msg2) -> View msg1 -> View msg2 -mapView fn view = - case view of - ElmCssView elements -> - List.map (Html.map fn) elements - |> ElmCssView - - -placeholder : String -> Document msg -placeholder moduleName = - { title = "Placeholder" - , body = ElmCssView [ Html.text moduleName ] - } diff --git a/examples/docs/src/Page/Blog.elm b/examples/docs/src/Page/Blog.elm index 4d3c3a34..84069f40 100644 --- a/examples/docs/src/Page/Blog.elm +++ b/examples/docs/src/Page/Blog.elm @@ -3,7 +3,6 @@ module Page.Blog exposing (Data, Model, Msg, page) import Article import DataSource import Date -import Document exposing (Document) import Head import Head.Seo as Seo import Html.Styled exposing (..) @@ -15,6 +14,7 @@ import Shared import SiteOld import Tailwind.Breakpoints as Bp import Tailwind.Utilities as Tw +import View exposing (View) type Msg @@ -73,7 +73,7 @@ view : Model -> Shared.Model -> StaticPayload Data {} - -> Document Msg + -> View Msg view thing model staticPayload = { title = "elm-pages blog" , body = @@ -171,7 +171,6 @@ view thing model staticPayload = ] ] ] - |> Document.ElmCssView } diff --git a/examples/docs/src/Page/Blog/Slug_.elm b/examples/docs/src/Page/Blog/Slug_.elm index a9e4f16e..1a4bb306 100644 --- a/examples/docs/src/Page/Blog/Slug_.elm +++ b/examples/docs/src/Page/Blog/Slug_.elm @@ -8,7 +8,6 @@ import DataSource import DataSource.File as StaticFile import DataSource.Glob as Glob import Date exposing (Date) -import Document exposing (Document) import Head import Head.Seo as Seo import Html.Styled exposing (..) @@ -25,6 +24,7 @@ import StructuredData import Tailwind.Breakpoints as Bp import Tailwind.Utilities as Tw import TailwindMarkdownRenderer +import View exposing (View) type alias Model = @@ -72,7 +72,7 @@ routes = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = { title = static.data.metadata.title , body = @@ -80,51 +80,50 @@ view static = author = Author.dillon in - Document.ElmCssView + [ div + [ css + [ Tw.min_h_screen + , Tw.w_full + , Tw.relative + ] + ] [ div [ css - [ Tw.min_h_screen - , Tw.w_full - , Tw.relative + [ Tw.pt_32 + , Tw.pb_16 + , Tw.px_8 + , Tw.flex + , Tw.flex_col ] ] [ div [ css - [ Tw.pt_32 - , Tw.pb_16 - , Tw.px_8 - , Tw.flex - , Tw.flex_col + [ Bp.md [ Tw.mx_auto ] ] ] - [ div + [ h1 [ css - [ Bp.md [ Tw.mx_auto ] + [ Tw.text_center + , Tw.text_4xl + , Tw.font_bold + , Tw.tracking_tight + , Tw.mt_2 + , Tw.mb_8 ] ] - [ h1 - [ css - [ Tw.text_center - , Tw.text_4xl - , Tw.font_bold - , Tw.tracking_tight - , Tw.mt_2 - , Tw.mb_8 - ] - ] - [ text static.data.metadata.title - ] - , authorView author static.data - , div - [ css - [ Tw.prose - ] - ] - static.data.body + [ text static.data.metadata.title ] + , authorView author static.data + , div + [ css + [ Tw.prose + ] + ] + static.data.body ] ] ] + ] } diff --git a/examples/docs/src/Page/Docs/Section__.elm b/examples/docs/src/Page/Docs/Section__.elm index 492a6541..df528dfe 100644 --- a/examples/docs/src/Page/Docs/Section__.elm +++ b/examples/docs/src/Page/Docs/Section__.elm @@ -6,7 +6,6 @@ import DataSource exposing (DataSource) import DataSource.File import DataSource.Glob as Glob exposing (Glob) import DocsSection exposing (Section) -import Document exposing (Document) import Head import Head.Seo as Seo import Heroicon @@ -25,6 +24,7 @@ import TableOfContents import Tailwind.Breakpoints as Bp import Tailwind.Utilities as Tw import TailwindMarkdownRenderer +import View exposing (View) type alias Model = @@ -193,85 +193,84 @@ view : Model -> Shared.Model -> StaticPayload Data RouteParams - -> Document Msg + -> View Msg view model sharedModel static = { title = static.data.titles.title ++ " - elm-pages docs" , body = - Document.ElmCssView - [ Css.Global.global - [ Css.Global.selector ".anchor-icon" - [ Css.opacity Css.zero - ] - , Css.Global.selector "h2:hover .anchor-icon" - [ Css.opacity (Css.num 100) - ] + [ Css.Global.global + [ Css.Global.selector ".anchor-icon" + [ Css.opacity Css.zero ] - , Html.div - [ css - [ Tw.flex - , Tw.flex_1 - , Tw.h_full - ] - ] - [ TableOfContents.view sharedModel.showMobileMenu True static.routeParams.section static.data.toc - , Html.article - [ css - [ Tw.prose - , Tw.max_w_xl - - --, Tw.whitespace_normal - --, Tw.mx_auto - , Tw.relative - , Tw.pt_20 - , Tw.pb_16 - , Tw.px_6 - , Tw.w_full - , Tw.max_w_full - , Tw.overflow_x_hidden - , Bp.md - [ Tw.px_8 - ] - ] - ] - [ Html.div - [ css - [ Tw.max_w_screen_md - , Tw.mx_auto - , Bp.xl [ Tw.pr_36 ] - ] - ] - ((static.data.body - |> Markdown.Renderer.render TailwindMarkdownRenderer.renderer - |> Result.withDefault [ Html.text "" ] - ) - ++ [ NextPrevious.view static.data.titles.previousAndNext - , Html.hr [] [] - , Html.footer - [ css [ Tw.text_right ] - ] - [ Html.a - [ Attr.href static.data.editUrl - , Attr.target "_blank" - , css - [ Tw.text_sm - , Css.hover - [ Tw.text_gray_800 |> Css.important - ] - , Tw.text_gray_500 |> Css.important - , Tw.flex - , Tw.items_center - , Tw.float_right - ] - ] - [ Html.span [ css [ Tw.pr_1 ] ] [ Html.text "Suggest an edit on GitHub" ] - , Heroicon.edit - ] - ] - ] - ) - ] + , Css.Global.selector "h2:hover .anchor-icon" + [ Css.opacity (Css.num 100) ] ] + , Html.div + [ css + [ Tw.flex + , Tw.flex_1 + , Tw.h_full + ] + ] + [ TableOfContents.view sharedModel.showMobileMenu True static.routeParams.section static.data.toc + , Html.article + [ css + [ Tw.prose + , Tw.max_w_xl + + --, Tw.whitespace_normal + --, Tw.mx_auto + , Tw.relative + , Tw.pt_20 + , Tw.pb_16 + , Tw.px_6 + , Tw.w_full + , Tw.max_w_full + , Tw.overflow_x_hidden + , Bp.md + [ Tw.px_8 + ] + ] + ] + [ Html.div + [ css + [ Tw.max_w_screen_md + , Tw.mx_auto + , Bp.xl [ Tw.pr_36 ] + ] + ] + ((static.data.body + |> Markdown.Renderer.render TailwindMarkdownRenderer.renderer + |> Result.withDefault [ Html.text "" ] + ) + ++ [ NextPrevious.view static.data.titles.previousAndNext + , Html.hr [] [] + , Html.footer + [ css [ Tw.text_right ] + ] + [ Html.a + [ Attr.href static.data.editUrl + , Attr.target "_blank" + , css + [ Tw.text_sm + , Css.hover + [ Tw.text_gray_800 |> Css.important + ] + , Tw.text_gray_500 |> Css.important + , Tw.flex + , Tw.items_center + , Tw.float_right + ] + ] + [ Html.span [ css [ Tw.pr_1 ] ] [ Html.text "Suggest an edit on GitHub" ] + , Heroicon.edit + ] + ] + ] + ) + ] + ] + ] } diff --git a/examples/docs/src/Page/Index.elm b/examples/docs/src/Page/Index.elm index 16d5ca87..f1062900 100644 --- a/examples/docs/src/Page/Index.elm +++ b/examples/docs/src/Page/Index.elm @@ -2,7 +2,6 @@ module Page.Index exposing (Data, Model, Msg, page) import Css import DataSource exposing (DataSource) -import Document exposing (Document) import Head import Head.Seo as Seo import Html.Styled exposing (..) @@ -16,6 +15,7 @@ import Svg.Styled exposing (path, svg) import Svg.Styled.Attributes as SvgAttr import Tailwind.Breakpoints as Bp import Tailwind.Utilities as Tw +import View exposing (View) import View.CodeTab as CodeTab @@ -86,14 +86,13 @@ head static = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = { title = "elm-pages - a statically typed site generator" -- metadata.title -- TODO , body = [ landingView , gradientFeatures ] - |> Document.ElmCssView } @@ -158,7 +157,7 @@ data routeParams = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = { title = static.routeParams.name , body = diff --git a/examples/docs/src/Page/Projects.elm b/examples/docs/src/Page/Projects.elm index b5a68287..05dad467 100644 --- a/examples/docs/src/Page/Projects.elm +++ b/examples/docs/src/Page/Projects.elm @@ -4,7 +4,6 @@ import DataSource exposing (DataSource) import DataSource.File import DataSource.Glob as Glob import DataSource.Http -import Document exposing (Document) import Head import Head.Seo as Seo import Html.Styled exposing (div, text) @@ -14,6 +13,7 @@ import Page exposing (Page, PageWithState, StaticPayload) import Pages.ImagePath as ImagePath import Secrets import Tailwind.Utilities as Tw +import View exposing (View) type alias Model = @@ -134,22 +134,21 @@ type alias Data = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = { title = "Projects" , body = - Document.ElmCssView - [ div - [ css - [ Tw.pt_32 - , Tw.px_16 - ] + [ div + [ css + [ Tw.pt_32 + , Tw.px_16 ] - (static.data - |> List.map - (\project -> - text (project.name ++ ": " ++ project.description) - ) - ) ] + (static.data + |> List.map + (\project -> + text (project.name ++ ": " ++ project.description) + ) + ) + ] } diff --git a/examples/docs/src/Page/Showcase.elm b/examples/docs/src/Page/Showcase.elm index 5c223783..51110494 100644 --- a/examples/docs/src/Page/Showcase.elm +++ b/examples/docs/src/Page/Showcase.elm @@ -2,7 +2,6 @@ module Page.Showcase exposing (Data, Model, Msg, page) import Css import DataSource -import Document exposing (Document) import Head import Head.Seo as Seo import Html.Styled exposing (..) @@ -13,6 +12,7 @@ import Showcase import Tailwind.Breakpoints as Bp import Tailwind.Utilities as Tw import Url +import View exposing (View) type alias Model = @@ -47,7 +47,7 @@ type alias Data = view : StaticPayload Data {} - -> Document Msg + -> View Msg view static = { title = "elm-pages blog" , body = @@ -77,7 +77,6 @@ view static = [ showcaseEntries static.data ] ] ] - |> Document.ElmCssView } diff --git a/examples/docs/src/Page/Time.elm b/examples/docs/src/Page/Time.elm index 608b6fd4..d97f5f5c 100644 --- a/examples/docs/src/Page/Time.elm +++ b/examples/docs/src/Page/Time.elm @@ -2,7 +2,6 @@ module Page.Time exposing (Data, Model, Msg, page) import DataSource import DataSource.Http -import Document exposing (Document) import Head import Head.Seo as Seo import Html.Styled as Html @@ -11,6 +10,7 @@ import Page exposing (Page, PageWithState, StaticPayload) import Pages.ImagePath as ImagePath import Secrets import Shared +import View exposing (View) type alias Model = @@ -67,11 +67,10 @@ head static = view : StaticPayload Data {} - -> Document msg + -> View msg view static = { title = "TODO title" , body = [ Html.text static.data ] - |> Document.ElmCssView } diff --git a/examples/docs/src/Shared.elm b/examples/docs/src/Shared.elm index b924e7f6..df0c4da8 100644 --- a/examples/docs/src/Shared.elm +++ b/examples/docs/src/Shared.elm @@ -3,7 +3,6 @@ module Shared exposing (Data, Model, Msg, SharedMsg(..), template) import Browser.Navigation import DataSource import DocsSection -import Document exposing (Document) import Html exposing (Html) import Html.Styled import Json.Decode @@ -11,6 +10,7 @@ import Pages.Flags import Pages.PagePath exposing (PagePath) import SharedTemplate exposing (SharedTemplate) import TableOfContents +import View exposing (View) import View.Header @@ -119,19 +119,17 @@ view : } -> Model -> (Msg -> msg) - -> Document msg + -> View msg -> { body : Html msg, title : String } view tableOfContents page model toMsg pageView = { body = - case pageView.body of - Document.ElmCssView elements -> - ((View.Header.view ToggleMobileMenu 123 page.path - |> Html.Styled.map toMsg - ) - :: TableOfContents.view model.showMobileMenu False Nothing tableOfContents - :: elements - ) - |> Html.Styled.div [] - |> Html.Styled.toUnstyled + ((View.Header.view ToggleMobileMenu 123 page.path + |> Html.Styled.map toMsg + ) + :: TableOfContents.view model.showMobileMenu False Nothing tableOfContents + :: pageView.body + ) + |> Html.Styled.div [] + |> Html.Styled.toUnstyled , title = pageView.title } diff --git a/examples/docs/src/View.elm b/examples/docs/src/View.elm new file mode 100644 index 00000000..c47fb63b --- /dev/null +++ b/examples/docs/src/View.elm @@ -0,0 +1,23 @@ +module View exposing (View, map, placeholder) + +import Html.Styled as Html exposing (Html) + + +type alias View msg = + { title : String + , body : List (Html msg) + } + + +map : (msg1 -> msg2) -> View msg1 -> View msg2 +map fn view = + { title = view.title + , body = List.map (Html.map fn) view.body + } + + +placeholder : String -> View msg +placeholder moduleName = + { title = "Placeholder" + , body = [ Html.text moduleName ] + } diff --git a/examples/repos/src/Page/Index.elm b/examples/repos/src/Page/Index.elm index 1c6456bf..d890618e 100644 --- a/examples/repos/src/Page/Index.elm +++ b/examples/repos/src/Page/Index.elm @@ -1,13 +1,13 @@ -module Page.Index exposing (Model, Msg, Data, page) +module Page.Index exposing (Data, Model, Msg, page) +import DataSource exposing (DataSource) import Element exposing (Element) -import Document exposing (Document) -import Pages.ImagePath as ImagePath import Head import Head.Seo as Seo -import DataSource exposing (DataSource) +import Page exposing (Page, PageWithState, StaticPayload) +import Pages.ImagePath as ImagePath import Shared -import Page exposing (StaticPayload, Page, PageWithState) +import View exposing (View) type alias Model = @@ -17,9 +17,11 @@ type alias Model = type alias Msg = Never + type alias RouteParams = {} + page : Page RouteParams Data page = Page.singleRoute @@ -34,7 +36,6 @@ data = DataSource.succeed () - head : StaticPayload Data RouteParams -> List Head.Tag @@ -61,6 +62,6 @@ type alias Data = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = Document.placeholder "Index" diff --git a/examples/repos/src/Shared.elm b/examples/repos/src/Shared.elm index ae90ee2e..1886cf39 100644 --- a/examples/repos/src/Shared.elm +++ b/examples/repos/src/Shared.elm @@ -2,11 +2,11 @@ module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template) import Browser.Navigation import DataSource -import Document exposing (Document) import Html exposing (Html) import Pages.Flags import Pages.PagePath exposing (PagePath) import SharedTemplate exposing (SharedTemplate) +import View exposing (View) template : SharedTemplate Msg Model Data SharedMsg msg @@ -90,7 +90,7 @@ view : } -> Model -> (Msg -> msg) - -> Document msg + -> View Msg -> { body : Html msg, title : String } view sharedData page model toMsg pageView = { body = Html.div [] pageView.body diff --git a/examples/repos/src/Document.elm b/examples/repos/src/View.elm similarity index 63% rename from examples/repos/src/Document.elm rename to examples/repos/src/View.elm index aa26f026..06be9240 100644 --- a/examples/repos/src/Document.elm +++ b/examples/repos/src/View.elm @@ -1,22 +1,22 @@ -module Document exposing (Document, map, placeholder) +module View exposing (View, map, placeholder) import Html exposing (Html) -type alias Document msg = +type alias View msg = { title : String , body : List (Html msg) } -map : (msg1 -> msg2) -> Document msg1 -> Document msg2 +map : (msg1 -> msg2) -> View msg1 -> View msg2 map fn doc = { title = doc.title , body = List.map (Html.map fn) doc.body } -placeholder : String -> Document msg +placeholder : String -> View msg placeholder moduleName = { title = "Placeholder - " ++ moduleName , body = [ Html.text moduleName ] diff --git a/examples/routing/src/Page/Cats/Name__.elm b/examples/routing/src/Page/Cats/Name__.elm index e0ae7661..323804d6 100644 --- a/examples/routing/src/Page/Cats/Name__.elm +++ b/examples/routing/src/Page/Cats/Name__.elm @@ -1,7 +1,6 @@ module Page.Cats.Name__ exposing (Data, Model, Msg, page) import DataSource -import Document exposing (Document) import Element exposing (Element) import Head import Head.Seo as Seo @@ -9,6 +8,7 @@ import Html.Styled exposing (text) import Page exposing (Page, PageWithState, StaticPayload) import Pages.ImagePath as ImagePath import Shared +import View exposing (View) type alias Model = @@ -74,7 +74,7 @@ type alias Data = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = { body = [ text (static.routeParams.name |> Maybe.withDefault "NOTHING") diff --git a/examples/routing/src/Page/Date/SPLAT_.elm b/examples/routing/src/Page/Date/SPLAT_.elm index 244cac35..16de810f 100644 --- a/examples/routing/src/Page/Date/SPLAT_.elm +++ b/examples/routing/src/Page/Date/SPLAT_.elm @@ -1,7 +1,6 @@ module Page.Date.SPLAT_ exposing (Data, Model, Msg, page) import DataSource -import Document exposing (Document) import Element exposing (Element) import Head import Head.Seo as Seo @@ -9,6 +8,7 @@ import Html.Styled exposing (text) import Page exposing (Page, PageWithState, StaticPayload) import Pages.ImagePath as ImagePath import Shared +import View exposing (View) type alias Model = @@ -63,7 +63,7 @@ type alias Data = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = { body = [ Debug.toString static.routeParams |> text diff --git a/examples/routing/src/Page/SPLAT__.elm b/examples/routing/src/Page/SPLAT__.elm index a13a3ff3..364e2eed 100644 --- a/examples/routing/src/Page/SPLAT__.elm +++ b/examples/routing/src/Page/SPLAT__.elm @@ -1,7 +1,6 @@ module Page.SPLAT__ exposing (Data, Model, Msg, page) import DataSource -import Document exposing (Document) import Element exposing (Element) import Head import Head.Seo as Seo @@ -9,6 +8,7 @@ import Html.Styled exposing (text) import Page exposing (Page, PageWithState, StaticPayload) import Pages.ImagePath as ImagePath import Shared +import View exposing (View) type alias Model = @@ -53,7 +53,7 @@ type alias Data = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = { body = [ Debug.toString static.routeParams |> text diff --git a/examples/routing/src/Page/Slide.elm b/examples/routing/src/Page/Slide.elm index 73fab89f..ddbb64fe 100644 --- a/examples/routing/src/Page/Slide.elm +++ b/examples/routing/src/Page/Slide.elm @@ -1,12 +1,12 @@ module Page.Slide exposing (Data, Model, Msg, page) import DataSource -import Document exposing (Document) import Head import Head.Seo as Seo import Page exposing (Page, PageWithState, StaticPayload) import Pages.ImagePath as ImagePath import Shared +import View exposing (View) type alias Model = @@ -56,7 +56,7 @@ type alias Data = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = { title = "TODO title" , body = [] diff --git a/examples/routing/src/Page/Slide/Number_.elm b/examples/routing/src/Page/Slide/Number_.elm index 35a6253e..b1c3c4a0 100644 --- a/examples/routing/src/Page/Slide/Number_.elm +++ b/examples/routing/src/Page/Slide/Number_.elm @@ -4,7 +4,6 @@ import Browser.Events import Browser.Navigation import DataSource import DataSource.File -import Document exposing (Document) import Head import Head.Seo as Seo import Html.Styled as Html @@ -19,6 +18,7 @@ import Page exposing (Page, StaticPayload) import Pages.ImagePath as ImagePath import Shared import Tailwind.Utilities as Tw +import View exposing (View) type alias Model = @@ -237,7 +237,7 @@ view : Model -> Shared.Model -> StaticPayload Data RouteParams - -> Document Msg + -> View Msg view model sharedModel static = { title = "TODO title" , body = diff --git a/examples/routing/src/Shared.elm b/examples/routing/src/Shared.elm index 43992e8f..ebcaccba 100644 --- a/examples/routing/src/Shared.elm +++ b/examples/routing/src/Shared.elm @@ -4,7 +4,6 @@ import Browser.Navigation import Css.Global import DataSource import DataSource.Http -import Document exposing (Document) import Html exposing (Html) import Html.Styled import OptimizedDecoder as D @@ -13,6 +12,7 @@ import Pages.PagePath exposing (PagePath) import Secrets import SharedTemplate exposing (SharedTemplate) import Tailwind.Utilities +import View exposing (View) template : SharedTemplate Msg Model Data SharedMsg msg @@ -97,7 +97,7 @@ view : } -> Model -> (Msg -> msg) - -> Document msg + -> View msg -> { body : Html msg, title : String } view stars page model toMsg pageView = { body = diff --git a/examples/routing/src/Document.elm b/examples/routing/src/View.elm similarity index 64% rename from examples/routing/src/Document.elm rename to examples/routing/src/View.elm index 45172837..50056772 100644 --- a/examples/routing/src/Document.elm +++ b/examples/routing/src/View.elm @@ -1,22 +1,22 @@ -module Document exposing (Document, map, placeholder) +module View exposing (View, map, placeholder) import Html.Styled exposing (text) -type alias Document msg = +type alias View msg = { title : String , body : List (Html.Styled.Html msg) } -map : (msg1 -> msg2) -> Document msg1 -> Document msg2 +map : (msg1 -> msg2) -> View msg1 -> View msg2 map fn doc = { title = doc.title , body = List.map (Html.Styled.map fn) doc.body } -placeholder : String -> Document msg +placeholder : String -> View msg placeholder moduleName = { title = "Placeholder - " ++ moduleName , body = [ text moduleName ] diff --git a/examples/slides/src/Page/Cats/Name__.elm b/examples/slides/src/Page/Cats/Name__.elm index e0ae7661..323804d6 100644 --- a/examples/slides/src/Page/Cats/Name__.elm +++ b/examples/slides/src/Page/Cats/Name__.elm @@ -1,7 +1,6 @@ module Page.Cats.Name__ exposing (Data, Model, Msg, page) import DataSource -import Document exposing (Document) import Element exposing (Element) import Head import Head.Seo as Seo @@ -9,6 +8,7 @@ import Html.Styled exposing (text) import Page exposing (Page, PageWithState, StaticPayload) import Pages.ImagePath as ImagePath import Shared +import View exposing (View) type alias Model = @@ -74,7 +74,7 @@ type alias Data = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = { body = [ text (static.routeParams.name |> Maybe.withDefault "NOTHING") diff --git a/examples/slides/src/Page/Slide.elm b/examples/slides/src/Page/Slide.elm index 73fab89f..ddbb64fe 100644 --- a/examples/slides/src/Page/Slide.elm +++ b/examples/slides/src/Page/Slide.elm @@ -1,12 +1,12 @@ module Page.Slide exposing (Data, Model, Msg, page) import DataSource -import Document exposing (Document) import Head import Head.Seo as Seo import Page exposing (Page, PageWithState, StaticPayload) import Pages.ImagePath as ImagePath import Shared +import View exposing (View) type alias Model = @@ -56,7 +56,7 @@ type alias Data = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = { title = "TODO title" , body = [] diff --git a/examples/slides/src/Page/Slide/Number_.elm b/examples/slides/src/Page/Slide/Number_.elm index 35a6253e..b1c3c4a0 100644 --- a/examples/slides/src/Page/Slide/Number_.elm +++ b/examples/slides/src/Page/Slide/Number_.elm @@ -4,7 +4,6 @@ import Browser.Events import Browser.Navigation import DataSource import DataSource.File -import Document exposing (Document) import Head import Head.Seo as Seo import Html.Styled as Html @@ -19,6 +18,7 @@ import Page exposing (Page, StaticPayload) import Pages.ImagePath as ImagePath import Shared import Tailwind.Utilities as Tw +import View exposing (View) type alias Model = @@ -237,7 +237,7 @@ view : Model -> Shared.Model -> StaticPayload Data RouteParams - -> Document Msg + -> View Msg view model sharedModel static = { title = "TODO title" , body = diff --git a/examples/slides/src/Shared.elm b/examples/slides/src/Shared.elm index 6eef34f2..f92abeae 100644 --- a/examples/slides/src/Shared.elm +++ b/examples/slides/src/Shared.elm @@ -3,13 +3,13 @@ module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template) import Browser.Navigation import Css.Global import DataSource -import Document exposing (Document) import Html exposing (Html) import Html.Styled import Pages.Flags import Pages.PagePath exposing (PagePath) import SharedTemplate exposing (SharedTemplate) import Tailwind.Utilities +import View exposing (View) template : SharedTemplate Msg Model Data SharedMsg msg @@ -93,7 +93,7 @@ view : } -> Model -> (Msg -> msg) - -> Document msg + -> View Msg -> { body : Html msg, title : String } view stars page model toMsg pageView = { body = diff --git a/examples/slides/src/Document.elm b/examples/slides/src/View.elm similarity index 64% rename from examples/slides/src/Document.elm rename to examples/slides/src/View.elm index 45172837..50056772 100644 --- a/examples/slides/src/Document.elm +++ b/examples/slides/src/View.elm @@ -1,22 +1,22 @@ -module Document exposing (Document, map, placeholder) +module View exposing (View, map, placeholder) import Html.Styled exposing (text) -type alias Document msg = +type alias View msg = { title : String , body : List (Html.Styled.Html msg) } -map : (msg1 -> msg2) -> Document msg1 -> Document msg2 +map : (msg1 -> msg2) -> View msg1 -> View msg2 map fn doc = { title = doc.title , body = List.map (Html.Styled.map fn) doc.body } -placeholder : String -> Document msg +placeholder : String -> View msg placeholder moduleName = { title = "Placeholder - " ++ moduleName , body = [ text moduleName ] diff --git a/generator/src/Page.elm b/generator/src/Page.elm index aa4c99cd..96d0889e 100644 --- a/generator/src/Page.elm +++ b/generator/src/Page.elm @@ -46,7 +46,7 @@ But before the user even requests the page, we have the following data: import Browser.Navigation import DataSource exposing (DataSource) -import Document exposing (Document) +import View exposing (View) import Head import Pages.PagePath exposing (PagePath) import ServerRequest exposing (ServerRequest) @@ -61,7 +61,7 @@ type alias PageWithState routeParams templateData templateModel templateMsg = templateModel -> Shared.Model -> StaticPayload templateData routeParams - -> Document templateMsg + -> View templateMsg , head : StaticPayload templateData routeParams -> List Head.Tag @@ -103,7 +103,7 @@ type Builder routeParams templateData buildNoState : { view : StaticPayload templateData routeParams - -> Document Never + -> View Never } -> Builder routeParams templateData -> PageWithState routeParams templateData () Never @@ -127,7 +127,7 @@ buildWithLocalState : templateModel -> Shared.Model -> StaticPayload templateData routeParams - -> Document templateMsg + -> View templateMsg , init : StaticPayload templateData routeParams -> ( templateModel, Cmd templateMsg ) , update : DynamicContext Shared.Model -> StaticPayload templateData routeParams -> templateMsg -> templateModel -> ( templateModel, Cmd templateMsg ) , subscriptions : routeParams -> PagePath -> templateModel -> Sub templateMsg @@ -177,7 +177,7 @@ buildWithSharedState : templateModel -> Shared.Model -> StaticPayload templateData routeParams - -> Document templateMsg + -> View templateMsg , init : StaticPayload templateData routeParams -> ( templateModel, Cmd templateMsg ) , update : DynamicContext Shared.Model -> StaticPayload templateData routeParams -> templateMsg -> templateModel -> ( templateModel, Cmd templateMsg, Maybe Shared.SharedMsg ) , subscriptions : routeParams -> PagePath -> templateModel -> Shared.Model -> Sub templateMsg diff --git a/generator/src/SharedTemplate.elm b/generator/src/SharedTemplate.elm index 02d5291d..faf4eab2 100644 --- a/generator/src/SharedTemplate.elm +++ b/generator/src/SharedTemplate.elm @@ -2,7 +2,7 @@ module SharedTemplate exposing (SharedTemplate) import Browser.Navigation import DataSource -import Document exposing (Document) +import View exposing (View) import Html exposing (Html) import Pages.Flags exposing (Flags) import Pages.PagePath exposing (PagePath) @@ -32,7 +32,7 @@ type alias SharedTemplate msg sharedModel sharedData sharedMsg mappedMsg = } -> sharedModel -> (msg -> mappedMsg) - -> Document mappedMsg + -> View mappedMsg -> { body : Html mappedMsg, title : String } , data : DataSource.DataSource sharedData , subscriptions : PagePath -> sharedModel -> Sub msg diff --git a/generator/src/codegen-template-module.js b/generator/src/codegen-template-module.js index 2a97f281..74aa9245 100755 --- a/generator/src/codegen-template-module.js +++ b/generator/src/codegen-template-module.js @@ -31,7 +31,7 @@ function fileContent(pageModuleName) { function fileContentWithParams(pageModuleName) { return `module Page.${pageModuleName} exposing (Model, Msg, Data, page) -import Document exposing (Document) +import View exposing (View) import Pages.ImagePath as ImagePath import Head import Head.Seo as Seo @@ -109,7 +109,7 @@ view static = function fileContentWithoutParams(pageModuleName) { return `module Page.${pageModuleName} exposing (Model, Msg, Data, page) -import Document exposing (Document) +import View exposing (View) import Pages.ImagePath as ImagePath import Head import Head.Seo as Seo diff --git a/generator/src/generate-template-module-connector.js b/generator/src/generate-template-module-connector.js index 7784d005..b31184c4 100644 --- a/generator/src/generate-template-module-connector.js +++ b/generator/src/generate-template-module-connector.js @@ -43,7 +43,7 @@ import Api import ApiRoute import Browser.Navigation import Route exposing (Route) -import Document +import View import Json.Decode import Json.Encode import Pages.Flags @@ -154,7 +154,7 @@ view page globalData pageData = model.global MsgGlobal ({ title = title, body = body } - |> Document.map Msg${pathNormalizedName( + |> View.map Msg${pathNormalizedName( name )} ) diff --git a/generator/template/src/Document.elm b/generator/template/src/Document.elm index aa26f026..a181853b 100644 --- a/generator/template/src/Document.elm +++ b/generator/template/src/Document.elm @@ -3,20 +3,20 @@ module Document exposing (Document, map, placeholder) import Html exposing (Html) -type alias Document msg = +type alias View Msg = { title : String , body : List (Html msg) } -map : (msg1 -> msg2) -> Document msg1 -> Document msg2 +map : (msg1 -> msg2) -> View Msg1 -> View Msg2 map fn doc = { title = doc.title , body = List.map (Html.map fn) doc.body } -placeholder : String -> Document msg +placeholder : String -> View Msg placeholder moduleName = { title = "Placeholder - " ++ moduleName , body = [ Html.text moduleName ] diff --git a/generator/template/src/Page/Index.elm b/generator/template/src/Page/Index.elm index e4f53083..ef85c655 100644 --- a/generator/template/src/Page/Index.elm +++ b/generator/template/src/Page/Index.elm @@ -1,7 +1,7 @@ module Page.Index exposing (Data, Model, Msg, page) import DataSource exposing (DataSource) -import Document exposing (Document) +import View exposing (View) import Head import Head.Seo as Seo import Page exposing (Page, StaticPayload) @@ -60,6 +60,6 @@ type alias Data = view : StaticPayload Data RouteParams - -> Document Msg + -> View Msg view static = Document.placeholder "Index" diff --git a/generator/template/src/Shared.elm b/generator/template/src/Shared.elm index f7b25f64..4c66d3bb 100644 --- a/generator/template/src/Shared.elm +++ b/generator/template/src/Shared.elm @@ -2,7 +2,7 @@ module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template) import Browser.Navigation import DataSource -import Document exposing (Document) +import View exposing (View) import Html exposing (Html) import Pages.Flags import Pages.PagePath exposing (PagePath) @@ -90,7 +90,7 @@ view : } -> Model -> (Msg -> msg) - -> Document msg + -> View Msg -> { body : Html msg, title : String } view sharedData page model toMsg pageView = { body = Html.div [] pageView.body