elm-pages-v3-beta/examples/docs/src/Page/Showcase.elm

305 lines
7.5 KiB
Elm
Raw Normal View History

2021-04-24 02:22:23 +03:00
module Page.Showcase exposing (Data, Model, Msg, page)
2021-05-10 23:48:20 +03:00
import Css
2021-04-20 17:31:19 +03:00
import DataSource
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)
import Page exposing (PageWithState, StaticPayload)
2021-05-24 21:17:34 +03:00
import Pages.PageUrl exposing (PageUrl)
import Pages.Url
import Path
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-09-24 19:04:15 +03:00
type alias Msg =
Never
2021-04-24 22:47:22 +03:00
type alias RouteParams =
{}
page : PageWithState RouteParams Data () Msg
page =
2021-06-24 20:05:16 +03:00
Page.single
2020-09-24 19:04:15 +03:00
{ head = head
2021-04-24 22:47:22 +03:00
, data = data
}
|> Page.buildNoState { view = view }
2021-04-24 02:22:23 +03:00
data : DataSource.DataSource Data
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
2020-08-25 07:56:38 +03:00
view :
2021-05-24 21:17:34 +03:00
Maybe PageUrl
-> Shared.Model
2021-05-24 21:17:34 +03:00
-> StaticPayload Data {}
2021-05-23 19:00:20 +03:00
-> View 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
]
]
}
2021-04-24 02:22:23 +03:00
head : StaticPayload Data {} -> 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" ]
]
]