elm-pages-v3-beta/examples/docs/app/Route/Showcase.elm

311 lines
7.7 KiB
Elm
Raw Normal View History

2022-05-12 01:27:37 +03:00
module Route.Showcase exposing (ActionData, Data, Model, Msg, route)
2023-01-02 01:44:11 +03:00
import BackendTask exposing (BackendTask)
2021-05-10 23:48:20 +03:00
import Css
2023-01-17 21:54:01 +03:00
import FatalError exposing (FatalError)
import Head
import Head.Seo as Seo
2021-05-10 23:48:20 +03:00
import Html.Styled exposing (..)
import Html.Styled.Attributes as Attr exposing (css, href)
2022-05-19 19:38:15 +03:00
import Pages.Msg
2021-05-24 21:17:34 +03:00
import Pages.PageUrl exposing (PageUrl)
import Pages.Url
import Path
2022-03-05 20:50:01 +03:00
import RouteBuilder exposing (StatefulRoute, StaticPayload)
import Shared
import Showcase
2021-05-10 23:48:20 +03:00
import Tailwind.Breakpoints as Bp
import Tailwind.Utilities as Tw
2021-05-23 19:00:20 +03:00
import View exposing (View)
2020-08-27 07:14:52 +03:00
type alias Model =
{}
2020-08-27 07:14:52 +03:00
2020-09-24 19:04:15 +03:00
type alias Msg =
()
2021-04-24 22:47:22 +03:00
type alias RouteParams =
{}
2022-05-12 01:27:37 +03:00
route : StatefulRoute RouteParams Data ActionData Model Msg
route =
2022-03-05 20:50:01 +03:00
RouteBuilder.single
2020-09-24 19:04:15 +03:00
{ head = head
2021-04-24 22:47:22 +03:00
, data = data
}
2022-03-05 20:50:01 +03:00
|> RouteBuilder.buildNoState { view = view }
2023-01-17 02:22:44 +03:00
data : BackendTask FatalError Data
2021-04-24 02:22:23 +03:00
data =
2021-04-03 01:47:07 +03:00
Showcase.staticRequest
2021-04-01 05:55:28 +03:00
2021-04-24 02:22:23 +03:00
type alias Data =
2021-04-03 01:47:07 +03:00
List Showcase.Entry
2020-05-24 18:52:09 +03:00
2022-05-12 01:27:37 +03:00
type alias ActionData =
{}
2020-08-25 07:56:38 +03:00
view :
2021-05-24 21:17:34 +03:00
Maybe PageUrl
-> Shared.Model
2022-05-12 01:27:37 +03:00
-> StaticPayload Data ActionData {}
2022-05-19 19:38:15 +03:00
-> View (Pages.Msg.Msg Msg)
view maybeUrl sharedModel static =
2020-05-24 18:52:09 +03:00
{ title = "elm-pages blog"
, body =
2021-05-10 23:48:20 +03:00
[ div
[ css
[ Tw.flex
, Tw.flex_col
2021-05-10 23:52:14 +03:00
, Tw.pt_8
2021-05-11 00:00:52 +03:00
, Tw.px_4
, Bp.lg
[ Tw.px_8
]
, Bp.sm
[ Tw.py_20
, Tw.px_6
]
2021-05-10 23:48:20 +03:00
]
]
[ topSection
, div
[ css
[ Tw.pt_8
, Tw.flex
, Tw.justify_around
]
]
2021-05-12 17:38:09 +03:00
[ showcaseEntries static.data ]
2020-05-24 18:52:09 +03:00
]
]
}
2022-05-12 01:27:37 +03:00
head : StaticPayload Data ActionData {} -> List Head.Tag
2020-09-06 22:42:05 +03:00
head staticPayload =
2020-05-24 18:52:09 +03:00
Seo.summary
{ canonicalUrlOverride = Nothing
, siteName = "elm-pages"
, image =
{ url = [ "images", "icon-png.png" ] |> Path.join |> Pages.Url.fromPath
2020-05-24 18:52:09 +03:00
, alt = "elm-pages logo"
, dimensions = Nothing
, mimeType = Nothing
}
, description = "See some neat sites built using elm-pages! (Or submit yours!)"
, locale = Nothing
, title = "elm-pages sites showcase"
}
|> Seo.website
2021-05-10 23:48:20 +03:00
showcaseEntries : List Showcase.Entry -> Html msg
showcaseEntries items =
ul
[ Attr.attribute "role" "list"
, css
[ Tw.grid
, Tw.grid_cols_2
, Tw.gap_x_4
, Tw.gap_y_8
, Tw.w_full
, Tw.max_w_screen_lg
--, Bp.lg
-- [ Tw.grid_cols_4
-- ]
, Bp.sm
[ Tw.grid_cols_3
, Tw.gap_x_6
]
, Bp.xl
[ Tw.gap_x_8
]
]
]
(items
|> List.map showcaseItem
)
showcaseItem : Showcase.Entry -> Html msg
showcaseItem item =
li
[ css
[ Tw.relative
]
]
[ div
[ css
[ --Tw.group
Tw.block
--, Tw.w_full
, Tw.aspect_w_10
, Tw.aspect_h_7
, Tw.rounded_lg
, Tw.bg_gray_100
, Tw.overflow_hidden
--, Bp.focus-within
-- [ Tw.ring_2
-- , Tw.ring_offset_2
-- , Tw.ring_offset_gray_100
-- , Tw.ring_indigo_500
-- ]
]
]
[ a
[ href item.liveUrl
, Attr.target "_blank"
, Attr.rel "noopener"
]
[ img
[ Attr.src <| "https://image.thum.io/get/width/800/crop/800/" ++ item.screenshotUrl
, Attr.alt ""
, Attr.attribute "loading" "lazy"
, css
[ Tw.object_cover
, Tw.pointer_events_none
2021-05-10 23:48:20 +03:00
--, Bp.group
--- hover
-- [ Tw.opacity_75
-- ]
]
2021-05-10 23:48:20 +03:00
]
[]
2021-05-10 23:48:20 +03:00
]
--, button
-- [ Attr.type_ "button"
-- , css
-- [ Tw.absolute
-- , Tw.inset_0
-- , Css.focus
-- [ Tw.outline_none
-- ]
-- ]
-- ]
-- [ span
-- [ css
-- [ Tw.sr_only
-- ]
-- ]
-- [ text "View details for IMG_4985.HEIC" ]
-- ]
]
, a
[ href item.liveUrl
, Attr.target "_blank"
, Attr.rel "noopener"
2021-05-10 23:48:20 +03:00
, css
[ Tw.mt_2
, Tw.block
, Tw.text_sm
, Tw.font_medium
, Tw.text_gray_900
, Tw.truncate
--, Tw.pointer_events_none
]
]
[ text item.displayName ]
, a
[ href item.authorUrl
, Attr.target "_blank"
, Attr.rel "noopener"
2021-05-10 23:48:20 +03:00
, css
[ Tw.block
, Tw.text_sm
, Tw.font_medium
, Tw.text_gray_500
--, Tw.pointer_events_none
]
]
[ text item.authorName ]
]
topSection : Html msg
topSection =
div
[ css
[]
]
[ div
[ css
[ Tw.max_w_2xl
, Tw.mx_auto
, Tw.text_center
, Tw.py_16
, Bp.sm
[ Tw.py_20
]
]
]
[ h2
[ css
[ Tw.text_3xl
, Tw.font_extrabold
, Bp.sm
[ Tw.text_4xl
]
]
]
[ span
[ css
[ Tw.block
]
]
[ text "elm-pages Showcase" ]
]
, p
[ css
[ Tw.mt_4
, Tw.text_lg
, Tw.leading_6
, Tw.text_gray_500
]
]
[ text "Check out some projects from the elm-pages community." ]
, a
[ Attr.href "https://airtable.com/shrPSenIW2EQqJ083"
, Attr.target "_blank"
, Attr.rel "noopener"
2021-05-10 23:48:20 +03:00
, css
[ Tw.mt_8
, Tw.w_full
, Tw.inline_flex
, Tw.items_center
, Tw.justify_center
, Tw.px_5
, Tw.py_3
, Tw.border
, Tw.border_transparent
, Tw.text_white
, Tw.font_medium
, Tw.rounded_md
, Tw.bg_blue_800
, Css.hover
[ Tw.bg_blue_600
]
, Bp.sm
[ Tw.w_auto
]
]
]
[ text "Submit your site to the showcase" ]
]
]