Remove outdated examples.

This commit is contained in:
Dillon Kearns 2021-04-05 16:17:04 -07:00
parent 5c2c3b1cbb
commit 1a1ba2e4a3
57 changed files with 0 additions and 28014 deletions

View File

@ -1 +0,0 @@
/gen/Pages.elm

View File

@ -1 +0,0 @@
loglevel=warn

View File

@ -1 +0,0 @@
# elm-pages external data example

View File

@ -1,2 +0,0 @@
---
---

View File

@ -1,3 +0,0 @@
---
title: "Hello!"
---

View File

@ -1,54 +0,0 @@
{
"type": "application",
"source-directories": [
"src",
"../../src",
"gen"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"avh4/elm-color": "1.0.0",
"danyx23/elm-mimetype": "4.0.1",
"dillonkearns/elm-markdown": "1.1.3",
"dillonkearns/elm-oembed": "1.0.0",
"elm/browser": "1.0.1",
"elm/core": "1.0.2",
"elm/html": "1.0.0",
"elm/http": "2.0.0",
"elm/json": "1.1.3",
"elm/parser": "1.1.0",
"elm/svg": "1.0.1",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm-community/dict-extra": "2.4.0",
"elm-community/list-extra": "8.2.2",
"elm-community/result-extra": "2.2.1",
"elm-community/string-extra": "4.0.1",
"elm-explorations/markdown": "1.0.0",
"justinmimbs/date": "3.1.2",
"lukewestby/elm-string-interpolate": "1.0.4",
"mdgriffith/elm-ui": "1.1.5",
"mgold/elm-nonempty-list": "4.0.2",
"miniBill/elm-codec": "1.2.0",
"noahzgordon/elm-color-extra": "1.0.2",
"rtfeldman/elm-hex": "1.0.0",
"tripokey/elm-fuzzy": "5.2.1",
"zwilias/json-decode-exploration": "6.0.0"
},
"indirect": {
"elm/bytes": "1.0.8",
"elm/file": "1.0.5",
"elm/random": "1.0.0",
"elm/regex": "1.0.0",
"elm/virtual-dom": "1.0.2",
"fredcy/elm-parseint": "2.0.1"
}
},
"test-dependencies": {
"direct": {
"elm-explorations/test": "1.2.2"
},
"indirect": {}
}
}

View File

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 323.141 322.95" enable-background="new 0 0 323.141 322.95" xml:space="preserve">
<g>
<polygon
fill="#F0AD00"
points="161.649,152.782 231.514,82.916 91.783,82.916"/>
<polygon
fill="#7FD13B"
points="8.867,0 79.241,70.375 232.213,70.375 161.838,0"/>
<rect
fill="#7FD13B"
x="192.99"
y="107.392"
transform="matrix(0.7071 0.7071 -0.7071 0.7071 186.4727 -127.2386)"
width="107.676"
height="108.167"/>
<polygon
fill="#60B5CC"
points="323.298,143.724 323.298,0 179.573,0"/>
<polygon
fill="#5A6378"
points="152.781,161.649 0,8.868 0,314.432"/>
<polygon
fill="#F0AD00"
points="255.522,246.655 323.298,314.432 323.298,178.879"/>
<polygon
fill="#60B5CC"
points="161.649,170.517 8.869,323.298 314.43,323.298"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1 +0,0 @@
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub icon</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>

Before

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 B

View File

@ -1,2 +0,0 @@
<svg version="1.1" viewBox="251.0485 144.52063 56.114286 74.5" width="50px" height="74.5"><defs><linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="10%" style="stop-color:rgba(1.96%,45.88%,90.2%,1);stop-opacity:1"></stop><stop offset="100%" style="stop-color:rgba(0%,94.9%,37.65%,1);stop-opacity:1"></stop></linearGradient></defs><metadata></metadata><g id="Canvas_11" stroke="none" fill="url(#grad1)" stroke-opacity="1" fill-opacity="1" stroke-dasharray="none"><g id="Canvas_11: Layer 1"><g id="Group_38"><g id="Graphic_32"><path d="M 252.5485 146.02063 L 252.5485 217.52063 L 305.66277 217.52063 L 305.66277 161.68254 L 290.00087 146.02063 Z" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="3"></path></g><g id="Line_34"><line x1="266.07286" y1="182.8279" x2="290.75465" y2="183.00997" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></line></g><g id="Line_35"><line x1="266.07286" y1="191.84156" x2="290.75465" y2="192.02363" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></line></g><g id="Line_36"><line x1="266.07286" y1="200.85522" x2="290.75465" y2="201.0373" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></line></g><g id="Line_37"><line x1="266.07286" y1="164.80058" x2="278.3874" y2="164.94049" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></line></g></g></g></g></svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,9 +0,0 @@
import "elm-oembed";
import "./style.css";
// @ts-ignore
const { Elm } = require("./src/Main.elm");
const pagesInit = require("../../index.js");
pagesInit({
mainElmModule: Elm.Main
});

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
{
"name": "elm-pages-example",
"version": "1.0.0",
"description": "Example site built with elm-pages.",
"scripts": {
"start": "elm-pages develop",
"serve": "npm run build && http-server ./dist -a localhost -p 3000 -c-1",
"build": "elm-pages build"
},
"author": "Dillon Kearns",
"license": "BSD-3",
"dependencies": {
"node-sass": "^4.12.0",
"prismjs": "^1.17.1"
},
"devDependencies": {
"elm": "^0.19.1-3",
"elm-oembed": "0.0.6",
"elm-pages": "file:../..",
"http-server": "^0.11.1"
}
}

View File

@ -1,343 +0,0 @@
module Main exposing (main)
import Color
import Element exposing (Element)
import Element.Background
import Element.Border
import Element.Font as Font
import Element.Region
import Head
import Head.Seo as Seo
import Html exposing (Html)
import Html.Attributes as Attr
import Json.Decode as JD exposing (Decoder)
import Json.Decode.Exploration as Decode
import Pages exposing (images, pages)
import Pages.Directory as Directory exposing (Directory)
import Pages.ImagePath as ImagePath exposing (ImagePath)
import Pages.Manifest as Manifest
import Pages.Manifest.Category
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.Platform exposing (Page)
import Pages.StaticHttp as StaticHttp
import Palette
import Secrets
import Time
--type alias CreatePage body =
-- { path : List String
-- , content : Result String body
-- }
--
--
--createPages : StaticHttp.Request (List (CreatePage body))
manifest : Manifest.Config Pages.PathKey
manifest =
{ backgroundColor = Just Color.white
, categories = [ Pages.Manifest.Category.education ]
, displayMode = Manifest.Standalone
, orientation = Manifest.Portrait
, description = "elm-pages - A statically typed site generator."
, iarcRatingId = Nothing
, name = "elm-pages docs"
, themeColor = Just Color.white
, startUrl = pages.index
, shortName = Just "elm-pages"
, sourceIcon = images.iconPng
}
type alias View =
()
type alias Metadata =
()
main : Pages.Platform.Program Model Msg Metadata View
main =
Pages.Platform.init
{ init = init
, view = view
, update = update
, documents =
[ { extension = "md"
, metadata = JD.succeed ()
, body = \_ -> Ok ()
}
]
, manifest = manifest
, canonicalSiteUrl = canonicalSiteUrl
, internals = Pages.internals
}
|> Pages.Platform.withPageChangeMsg OnPageChange
|> Pages.Platform.withSubscriptions subscriptions
|> Pages.Platform.toProgram
type alias Model =
{}
init :
Maybe
{ path : PagePath Pages.PathKey
, query : Maybe String
, fragment : Maybe String
}
-> ( Model, Cmd Msg )
init maybePagePath =
( Model, Cmd.none )
type Msg
= OnPageChange
{ path : PagePath Pages.PathKey
, query : Maybe String
, fragment : Maybe String
}
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
OnPageChange page ->
( model, Cmd.none )
subscriptions : Model -> Sub Msg
subscriptions _ =
Sub.none
type alias Company =
{ name : String
, logoUrl : String
, loc : String
}
companyView : Company -> Element msg
companyView company =
Element.column []
[ Element.el [] (Element.text company.name)
, Element.el [] (Element.text <| "Lines of code: " ++ company.loc)
, Element.image []
{ src = company.logoUrl
, description = company.name ++ " logo"
}
]
type alias Pokemon =
{ name : String, sprite : String }
get url decoder =
StaticHttp.get (Secrets.succeed url)
decoder
pokemonDetailRequest : StaticHttp.Request (List Pokemon)
pokemonDetailRequest =
get
"https://pokeapi.co/api/v2/pokemon/?limit=3"
(Decode.field "results"
(Decode.list
(Decode.map2 Tuple.pair
(Decode.field "name" Decode.string)
(Decode.field "url" Decode.string)
|> Decode.map
(\( name, url ) ->
get url
(Decode.at [ "sprites", "front_default" ] Decode.string
|> Decode.map (Pokemon name)
)
)
)
)
)
|> StaticHttp.andThen StaticHttp.combine
view :
List ( PagePath Pages.PathKey, Metadata )
->
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
}
->
StaticHttp.Request
{ view : Model -> View -> { title : String, body : Html Msg }
, head : List (Head.Tag Pages.PathKey)
}
view siteMetadata page =
case page.frontmatter of
() ->
StaticHttp.map2
(\starCount pokemon ->
{ view =
\model viewForPage ->
{ title = "Landing Page"
, body =
[ header page starCount
, Element.text "Built at: "
, Element.text <| String.fromInt <| Time.posixToMillis Pages.builtAt
, pokemon
|> List.map pokemonView
|> Element.column
[ Element.spacing 10
, Element.padding 30
, Element.centerX
]
]
|> Element.column [ Element.width Element.fill ]
|> layout
}
, head = head page.frontmatter
}
)
(get "https://api.github.com/repos/dillonkearns/elm-pages"
(Decode.field "stargazers_count" Decode.int)
)
pokemonDetailRequest
pokemonView : Pokemon -> Element msg
pokemonView pokemon =
Element.row []
[ Element.image [] { src = pokemon.sprite, description = pokemon.name ++ " sprite" }
, Element.text pokemon.name
]
layout body =
body
|> Element.layout
[ Element.width Element.fill
, Font.size 20
, Font.family [ Font.typeface "Roboto" ]
, Font.color (Element.rgba255 0 0 0 0.8)
]
articleImageView : ImagePath Pages.PathKey -> Element msg
articleImageView articleImage =
Element.image [ Element.width Element.fill ]
{ src = ImagePath.toString articleImage
, description = "Article cover photo"
}
header : { path : PagePath Pages.PathKey, frontmatter : Metadata } -> Int -> Element msg
header currentPage starCount =
Element.column [ Element.width Element.fill ]
[ Element.el
[ Element.height (Element.px 4)
, Element.width Element.fill
, Element.Background.gradient
{ angle = 0.2
, steps =
[ Element.rgb255 0 242 96
, Element.rgb255 5 117 230
]
}
]
Element.none
, Element.row
[ Element.paddingXY 25 4
, Element.spaceEvenly
, Element.width Element.fill
, Element.Region.navigation
, Element.Border.widthEach { bottom = 1, left = 0, right = 0, top = 0 }
, Element.Border.color (Element.rgba255 40 80 40 0.4)
]
[ Element.link []
{ url =
if currentPage.path == pages.index then
PagePath.toString pages.otherPage
else
PagePath.toString pages.index
, label =
Element.row
[ Font.size 30
, Element.spacing 16
, Element.htmlAttribute (Attr.id "navbar-title")
]
[ Element.text "elm-pages static data"
]
}
, Element.row [ Element.spacing 15 ]
[ elmDocsLink
, githubRepoLink starCount
]
]
]
{-| <https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/abouts-cards>
<https://htmlhead.dev>
<https://html.spec.whatwg.org/multipage/semantics.html#standard-metadata-names>
<https://ogp.me/>
-}
head : () -> List (Head.Tag Pages.PathKey)
head () =
Seo.summaryLarge
{ canonicalUrlOverride = Nothing
, siteName = "elm-pages external data example"
, image =
{ url = images.iconPng
, alt = "elm-pages logo"
, dimensions = Nothing
, mimeType = Nothing
}
, description = siteTagline
, locale = Nothing
, title = "External Data Example"
}
|> Seo.website
canonicalSiteUrl : String
canonicalSiteUrl =
"https://elm-pages.com"
siteTagline : String
siteTagline =
"A statically typed site generator - elm-pages"
githubRepoLink : Int -> Element msg
githubRepoLink starCount =
Element.newTabLink []
{ url = "https://github.com/dillonkearns/elm-pages"
, label =
Element.row [ Element.spacing 5 ]
[ Element.image
[ Element.width (Element.px 22)
, Font.color Palette.color.primary
]
{ src = ImagePath.toString Pages.images.github, description = "Github repo" }
, Element.text <| String.fromInt starCount
]
}
elmDocsLink : Element msg
elmDocsLink =
Element.newTabLink []
{ url = "https://package.elm-lang.org/packages/dillonkearns/elm-pages/latest/"
, label =
Element.image
[ Element.width (Element.px 22)
, Font.color Palette.color.primary
]
{ src = ImagePath.toString Pages.images.elmLogo, description = "Elm Package Docs" }
}

View File

@ -1,44 +0,0 @@
module Palette exposing (blogHeading, color, heading)
import Element exposing (Element)
import Element.Font as Font
import Element.Region
color =
{ primary = Element.rgb255 5 117 230
, secondary = Element.rgb255 0 242 96
}
heading : Int -> List (Element msg) -> Element msg
heading level content =
Element.paragraph
([ Font.bold
, Font.family [ Font.typeface "Montserrat" ]
, Element.Region.heading level
]
++ (case level of
1 ->
[ Font.size 36 ]
2 ->
[ Font.size 24 ]
_ ->
[ Font.size 20 ]
)
)
content
blogHeading : String -> Element msg
blogHeading title =
Element.paragraph
[ Font.bold
, Font.family [ Font.typeface "Montserrat" ]
, Element.Region.heading 1
, Font.size 36
, Font.center
]
[ Element.text title ]

View File

@ -1,13 +0,0 @@
@import url("https://fonts.googleapis.com/css?family=Montserrat:400,700|Roboto&display=swap");
.avatar img {
border-radius: 50%;
}
@media all and (max-width: 600px) {
#navbar-title {
font-size: 20px !important;
}
#navbar-title svg {
width: 20px;
}
}

View File

@ -1,2 +0,0 @@
gen/

View File

@ -1,9 +0,0 @@
export default function (elmLoaded) {
console.log("Hello outside of promise!");
elmLoaded.then((elmPagesApp) => {
console.log("Inside of promise");
elmPagesApp.ports.example.subscribe((message) => {
console.log("Elm port message: ", message);
});
});
}

View File

@ -1,3 +0,0 @@
h1 {
color: red;
}

View File

@ -1,7 +0,0 @@
---
title: Hello from another page.
type: page
repo: elm-markdown
---
This is another page

View File

@ -1,8 +0,0 @@
---
title: elm-pages - a statically typed site generator
type: page
repo: elm-pages
---
Hello!

View File

@ -1,64 +0,0 @@
{
"type": "application",
"source-directories": [
"src",
"../../src",
"vendor/elm-ui",
"gen",
"../../plugins"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"ThinkAlexandria/elm-html-in-elm": "1.0.1",
"avh4/elm-color": "1.0.0",
"billstclair/elm-xml-eeue56": "1.0.1",
"danyx23/elm-mimetype": "4.0.1",
"dillonkearns/elm-markdown": "4.0.2",
"dillonkearns/elm-oembed": "1.0.0",
"dillonkearns/elm-rss": "1.0.1",
"dillonkearns/elm-sitemap": "1.0.1",
"dmy/elm-imf-date-time": "1.0.1",
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0",
"elm/http": "2.0.0",
"elm/json": "1.1.3",
"elm/parser": "1.1.0",
"elm/svg": "1.0.1",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.2",
"elm-community/dict-extra": "2.4.0",
"elm-community/list-extra": "8.2.4",
"elm-community/result-extra": "2.4.0",
"elm-community/string-extra": "4.0.1",
"elm-explorations/markdown": "1.0.0",
"justinmimbs/date": "3.2.0",
"lukewestby/elm-string-interpolate": "1.0.4",
"miniBill/elm-codec": "1.2.0",
"noahzgordon/elm-color-extra": "1.0.2",
"pablohirafuji/elm-syntax-highlight": "3.3.0",
"rtfeldman/elm-hex": "1.0.0",
"tripokey/elm-fuzzy": "5.2.1",
"zwilias/json-decode-exploration": "6.0.0"
},
"indirect": {
"elm/bytes": "1.0.8",
"elm/file": "1.0.5",
"elm/random": "1.0.0",
"elm/regex": "1.0.0",
"fredcy/elm-parseint": "2.0.1",
"justinmimbs/time-extra": "1.1.0",
"lazamar/dict-parser": "1.0.2",
"mgold/elm-nonempty-list": "4.1.0",
"ryannhg/date-format": "2.3.0"
}
},
"test-dependencies": {
"direct": {
"elm-explorations/test": "1.2.2"
},
"indirect": {}
}
}

View File

@ -1,7 +0,0 @@
#!/bin/bash
cd content
for i in {1..1000}
do
echo -e "---\ntitle: Post Number\ntype: page\n---\n\n## Page $i\n\nWelcome to page $i" > "page-$i.md"
done

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 B

View File

@ -1,49 +0,0 @@
/**
* @license
* Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
/**
* This shim allows elements written in, or compiled to, ES5 to work on native
* implementations of Custom Elements v1. It sets new.target to the value of
* this.constructor so that the native HTMLElement constructor can access the
* current under-construction element's definition.
*/
(function() {
if (
// No Reflect, no classes, no need for shim because native custom elements
// require ES2015 classes or Reflect.
window.Reflect === undefined ||
window.customElements === undefined ||
// The webcomponentsjs custom elements polyfill doesn't require
// ES2015-compatible construction (`super()` or `Reflect.construct`).
window.customElements.polyfillWrapFlushCallback
) {
return;
}
const BuiltInHTMLElement = HTMLElement;
/**
* With jscompiler's RECOMMENDED_FLAGS the function name will be optimized away.
* However, if we declare the function as a property on an object literal, and
* use quotes for the property name, then closure will leave that much intact,
* which is enough for the JS VM to correctly set Function.prototype.name.
*/
const wrapperForTheName = {
HTMLElement: /** @this {!Object} */ function HTMLElement() {
return Reflect.construct(
BuiltInHTMLElement,
[],
/** @type {!Function} */ (this.constructor)
);
}
};
window.HTMLElement = wrapperForTheName["HTMLElement"];
HTMLElement.prototype = BuiltInHTMLElement.prototype;
HTMLElement.prototype.constructor = HTMLElement;
Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);
})();

View File

@ -1,21 +0,0 @@
{
"name": "elm-pages-example",
"version": "1.0.0",
"description": "Example site built with elm-pages.",
"scripts": {
"start": "elm-pages develop --port 1234",
"serve": "npm run build && http-server ./dist -a localhost -p 3000 -c-1",
"build": "elm-pages build"
},
"author": "Dillon Kearns",
"license": "BSD-3",
"dependencies": {
"node-sass": "^4.12.0"
},
"devDependencies": {
"elm": "^0.19.1-3",
"elm-oembed": "0.0.6",
"elm-pages": "file:../..",
"http-server": "^0.11.1"
}
}

View File

@ -1,48 +0,0 @@
module Data.Author exposing (Author, all, decoder, view)
import Element exposing (Element)
import Html.Attributes as Attr
import Json.Decode as Decode exposing (Decoder)
import List.Extra
import Pages
import Pages.ImagePath as ImagePath exposing (ImagePath)
type alias Author =
{ name : String
, avatar : ImagePath Pages.PathKey
, bio : String
}
all : List Author
all =
[ { name = "Dillon Kearns"
, avatar = Pages.images.author.dillon
, bio = "Elm developer and educator. Founder of Incremental Elm Consulting."
}
]
decoder : Decoder Author
decoder =
Decode.string
|> Decode.andThen
(\lookupName ->
case List.Extra.find (\currentAuthor -> currentAuthor.name == lookupName) all of
Just author ->
Decode.succeed author
Nothing ->
Decode.fail ("Couldn't find author with name " ++ lookupName ++ ". Options are " ++ String.join ", " (List.map .name all))
)
view : List (Element.Attribute msg) -> Author -> Element msg
view attributes author =
Element.image
(Element.width (Element.px 70)
:: Element.htmlAttribute (Attr.class "avatar")
:: attributes
)
{ src = ImagePath.toString author.avatar, description = author.name }

View File

@ -1,70 +0,0 @@
module DocSidebar exposing (view)
import Element exposing (Element)
import Element.Border as Border
import Element.Font
import Metadata exposing (Metadata)
import Pages
import Pages.PagePath as PagePath exposing (PagePath)
import Palette
view :
PagePath Pages.PathKey
-> List ( PagePath Pages.PathKey, Metadata )
-> Element msg
view currentPage posts =
Element.column
[ Element.spacing 10
, Border.widthEach { bottom = 0, left = 0, right = 1, top = 0 }
, Border.color (Element.rgba255 40 80 40 0.4)
, Element.padding 12
, Element.height Element.fill
]
(posts
|> List.filterMap
(\( path, metadata ) ->
case metadata of
Metadata.Doc meta ->
Just ( currentPage == path, path, meta )
_ ->
Nothing
)
|> List.map postSummary
)
postSummary :
( Bool, PagePath Pages.PathKey, { title : String } )
-> Element msg
postSummary ( isCurrentPage, postPath, post ) =
[ Element.text post.title ]
|> Element.paragraph
([ Element.Font.size 18
, Element.Font.family [ Element.Font.typeface "Roboto" ]
, Element.Font.semiBold
, Element.padding 16
]
++ (if isCurrentPage then
[ Element.Font.underline
, Element.Font.color Palette.color.primary
]
else
[]
)
)
|> linkToPost postPath
linkToPost : PagePath Pages.PathKey -> Element msg -> Element msg
linkToPost postPath content =
Element.link [ Element.width Element.fill ]
{ url = PagePath.toString postPath, label = content }
docUrl : List String -> String
docUrl postPath =
"/"
++ String.join "/" postPath

View File

@ -1,91 +0,0 @@
module DocumentSvg exposing (view)
import Color
import Element exposing (Element)
import Svg exposing (..)
import Svg.Attributes exposing (..)
strokeColor =
-- "url(#grad1)"
"black"
pageTextColor =
"black"
fillColor =
"url(#grad1)"
-- "none"
fillGradient =
gradient
(Color.rgb255 5 117 230)
(Color.rgb255 0 242 96)
-- (Color.rgb255 252 0 255)
-- (Color.rgb255 0 219 222)
-- (Color.rgb255 255 93 194)
-- (Color.rgb255 255 150 250)
gradient color1 color2 =
linearGradient [ id "grad1", x1 "0%", y1 "0%", x2 "100%", y2 "0%" ]
[ stop
[ offset "10%"
, Svg.Attributes.style ("stop-color:" ++ Color.toCssString color1 ++ ";stop-opacity:1")
]
[]
, stop [ offset "100%", Svg.Attributes.style ("stop-color:" ++ Color.toCssString color2 ++ ";stop-opacity:1") ] []
]
view : Element msg
view =
svg
[ version "1.1"
, viewBox "251.0485 144.52063 56.114286 74.5"
, width "56.114286"
, height "74.5"
, Svg.Attributes.width "30px"
]
[ defs []
[ fillGradient ]
, metadata [] []
, g
[ id "Canvas_11"
, stroke "none"
, fill fillColor
, strokeOpacity "1"
, fillOpacity "1"
, strokeDasharray "none"
]
[ g [ id "Canvas_11: Layer 1" ]
[ g [ id "Group_38" ]
[ g [ id "Graphic_32" ]
[ Svg.path
[ d "M 252.5485 146.02063 L 252.5485 217.52063 L 305.66277 217.52063 L 305.66277 161.68254 L 290.00087 146.02063 Z"
, stroke strokeColor
, strokeLinecap "round"
, strokeLinejoin "round"
, strokeWidth "3"
]
[]
]
, g [ id "Line_34" ] [ line [ x1 "266.07286", y1 "182.8279", x2 "290.75465", y2 "183.00997", stroke pageTextColor, strokeLinecap "round", strokeLinejoin "round", strokeWidth "2" ] [] ]
, g [ id "Line_35" ] [ line [ x1 "266.07286", y1 "191.84156", x2 "290.75465", y2 "192.02363", stroke pageTextColor, strokeLinecap "round", strokeLinejoin "round", strokeWidth "2" ] [] ]
, g [ id "Line_36" ] [ line [ x1 "266.07286", y1 "200.85522", x2 "290.75465", y2 "201.0373", stroke pageTextColor, strokeLinecap "round", strokeLinejoin "round", strokeWidth "2" ] [] ]
, g [ id "Line_37" ] [ line [ x1 "266.07286", y1 "164.80058", x2 "278.3874", y2 "164.94049", stroke pageTextColor, strokeLinecap "round", strokeLinejoin "round", strokeWidth "2" ] [] ]
]
]
]
]
|> Element.html
|> Element.el []

View File

@ -1,54 +0,0 @@
module Dotted exposing (lines)
import Element
import Svg
import Svg.Attributes as Attr
{-
.css-m2heu9 {
stroke: #8a4baf;
stroke-width: 3;
stroke-linecap: round;
stroke-dasharray: 0.5 10;
-webkit-animation: animation-yweh2o 400ms linear infinite;
animation: animation-yweh2o 400ms linear infinite;
}
-}
{-
<svg width="20" height="30" viewBox="0 0 20 30" class="css-p2euw5">
<path d="M10 40 L10 -10" class="css-m2heu9"></path>
</svg>
-}
lines =
Svg.svg
[ Attr.width "20"
, Attr.height "30"
, Attr.viewBox "0 0 20 30"
]
[ Svg.path
[ Attr.stroke "#2a75ff"
, Attr.strokeWidth "4"
, Attr.strokeLinecap "round"
, Attr.strokeDasharray "0.5 10"
, Attr.d "M10 40 L10 -10"
, Attr.class "dotted-line"
]
[]
]
|> Element.html
|> Element.el
[ Element.centerX
]
-- rgb(0, 36, 71)
-- #002447
{-
.css-m2heu9{stroke:#8a4baf;stroke-width:3;stroke-linecap:round;stroke-dasharray:0.5 10;-webkit-animation:animation-yweh2o 400ms linear infinite;animation:animation-yweh2o 400ms linear infinite;}@-webkit-keyframes animation-yweh2o{to{stroke-dashoffset:10;}}@keyframes animation-yweh2o{to{stroke-dashoffset:10;}}
-}

View File

@ -1,20 +0,0 @@
module Ellie exposing (outputTab)
import Element exposing (Element)
import Html
import Html.Attributes as Attr
outputTab : String -> Element msg
outputTab ellieId =
Html.iframe
[ Attr.src <| "https://ellie-app.com/embed/" ++ ellieId ++ "?panel=output"
, Attr.style "width" "100%"
, Attr.style "height" "400px"
, Attr.style "border" "0"
, Attr.style "overflow" "hidden"
, Attr.attribute "sandbox" "allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
]
[]
|> Element.html
|> Element.el [ Element.width Element.fill ]

View File

@ -1,76 +0,0 @@
module Feed exposing (fileToGenerate)
import Metadata exposing (Metadata(..))
import Pages
import Pages.PagePath as PagePath exposing (PagePath)
import Rss
fileToGenerate :
{ siteTagline : String
, siteUrl : String
}
->
List
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
, body : String
}
->
{ path : List String
, content : String
}
fileToGenerate config siteMetadata =
{ path = [ "blog", "feed.xml" ]
, content = generate config siteMetadata
}
generate :
{ siteTagline : String
, siteUrl : String
}
->
List
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
, body : String
}
-> String
generate { siteTagline, siteUrl } siteMetadata =
Rss.generate
{ title = "elm-pages Blog"
, description = siteTagline
, url = "https://elm-pages.com/blog"
, lastBuildTime = Pages.builtAt
, generator = Just "elm-pages"
, items = siteMetadata |> List.filterMap metadataToRssItem
, siteUrl = siteUrl
}
metadataToRssItem :
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
, body : String
}
-> Maybe Rss.Item
metadataToRssItem page =
case page.frontmatter of
Article article ->
if article.draft then
Nothing
else
Just
{ title = article.title
, description = article.description
, url = PagePath.toString page.path
, categories = []
, author = article.author.name
, pubDate = Rss.Date article.published
, content = Nothing
}
_ ->
Nothing

View File

@ -1,18 +0,0 @@
module FontAwesome exposing (icon, styledIcon)
import Element exposing (Element)
import Html
import Html.Attributes
styledIcon : String -> List (Element.Attribute msg) -> Element msg
styledIcon classString styles =
Html.i [ Html.Attributes.class classString ] []
|> Element.html
|> Element.el styles
icon : String -> Element msg
icon classString =
Html.i [ Html.Attributes.class classString ] []
|> Element.html

View File

@ -1,116 +0,0 @@
module Index exposing (view)
import Data.Author
import Date
import Element exposing (Element)
import Element.Border
import Element.Font
import Metadata exposing (Metadata)
import Pages
import Pages.ImagePath as ImagePath exposing (ImagePath)
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.Platform exposing (Page)
view :
List ( PagePath Pages.PathKey, Metadata )
-> Element msg
view posts =
Element.column [ Element.spacing 20 ]
(posts
|> List.filterMap
(\( path, metadata ) ->
case metadata of
Metadata.Article meta ->
if meta.draft then
Nothing
else
Just ( path, meta )
_ ->
Nothing
)
|> List.sortBy
(\( path, metadata ) ->
metadata.published
|> Date.toRataDie
)
|> List.reverse
|> List.map postSummary
)
postSummary :
( PagePath Pages.PathKey, Metadata.ArticleMetadata )
-> Element msg
postSummary ( postPath, post ) =
articleIndex post |> linkToPost postPath
linkToPost : PagePath Pages.PathKey -> Element msg -> Element msg
linkToPost postPath content =
Element.link [ Element.width Element.fill ]
{ url = PagePath.toString postPath, label = content }
title : String -> Element msg
title text =
[ Element.text text ]
|> Element.paragraph
[ Element.Font.size 36
, Element.Font.center
, Element.Font.family [ Element.Font.typeface "Montserrat" ]
, Element.Font.semiBold
, Element.padding 16
]
articleIndex : Metadata.ArticleMetadata -> Element msg
articleIndex metadata =
Element.el
[ Element.centerX
, Element.width (Element.maximum 600 Element.fill)
, Element.padding 40
, Element.spacing 10
, Element.Border.width 1
, Element.Border.color (Element.rgba255 0 0 0 0.1)
, Element.mouseOver
[ Element.Border.color (Element.rgba255 0 0 0 1)
]
]
(postPreview metadata)
grey =
Element.Font.color (Element.rgba255 0 0 0 0.5)
postPreview : Metadata.ArticleMetadata -> Element msg
postPreview post =
Element.textColumn
[ Element.centerX
, Element.width Element.fill
, Element.spacing 30
, Element.Font.size 18
]
[ title post.title
, Element.image [ Element.width Element.fill ] { src = post.image |> ImagePath.toString, description = "Blog post cover photo" }
, Element.row
[ Element.spacing 10
, Element.centerX
, grey
]
[ Data.Author.view [ Element.width (Element.px 40) ] post.author
, Element.text post.author.name
, Element.text ""
, Element.text (post.published |> Date.format "MMMM ddd, yyyy")
]
, post.description
|> Element.text
|> List.singleton
|> Element.paragraph
[ Element.Font.size 22
, Element.Font.center
]
]

View File

@ -1,289 +0,0 @@
port module Main exposing (main)
import Color
import Element exposing (Element)
import Element.Font as Font
import Head
import Head.Seo as Seo
import Html exposing (Html)
import Html.Attributes
import MarkdownRenderer
import Metadata exposing (Metadata)
import MimeType
import OptimizedDecoder as D
import Pages exposing (images, pages)
import Pages.ImagePath as ImagePath exposing (ImagePath)
import Pages.Manifest as Manifest
import Pages.Manifest.Category
import Pages.PagePath exposing (PagePath)
import Pages.Platform exposing (Page)
import Pages.StaticHttp as StaticHttp
import Secrets
import Time
port example : String -> Cmd msg
manifest : Manifest.Config Pages.PathKey
manifest =
{ backgroundColor = Just Color.white
, categories = [ Pages.Manifest.Category.education ]
, displayMode = Manifest.Standalone
, orientation = Manifest.Portrait
, description = "elm-pages - A statically typed site generator."
, iarcRatingId = Nothing
, name = "elm-pages docs"
, themeColor = Just Color.white
, startUrl = pages.index
, shortName = Just "elm-pages"
, sourceIcon = images.iconPng
, icons =
[ icon webp 192
, icon webp 512
, icon MimeType.Png 192
, icon MimeType.Png 512
]
}
webp : MimeType.MimeImage
webp =
MimeType.OtherImage "webp"
icon :
MimeType.MimeImage
-> Int
-> Manifest.Icon pathKey
icon format width =
{ src = cloudinaryIcon format width
, sizes = [ ( width, width ) ]
, mimeType = format |> Just
, purposes = []
}
cloudinaryIcon :
MimeType.MimeImage
-> Int
-> ImagePath pathKey
cloudinaryIcon format width =
let
base =
"https://res.cloudinary.com/dillonkearns/image/upload"
asset =
"v1603234028/elm-pages/elm-pages-icon"
fetch_format =
case format of
MimeType.Png ->
"png"
MimeType.OtherImage "webp" ->
"webp"
_ ->
"auto"
transforms =
[ "c_pad"
, "w_" ++ String.fromInt width
, "h_" ++ String.fromInt width
, "q_auto"
, "f_" ++ fetch_format
]
|> String.join ","
in
ImagePath.external (base ++ "/" ++ transforms ++ "/" ++ asset)
type alias View =
( MarkdownRenderer.TableOfContents, List (Element Msg) )
main : Pages.Platform.Program Model Msg Metadata View Pages.PathKey
main =
Pages.Platform.init
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
, documents =
[ { extension = "md"
, metadata = Metadata.decoder
, body = MarkdownRenderer.view
}
]
, onPageChange = Nothing
, manifest = manifest
, canonicalSiteUrl = canonicalSiteUrl
, internals = Pages.internals
}
|> Pages.Platform.withFileGenerator fileGenerator
|> Pages.Platform.withGlobalHeadTags
[ Head.icon [ ( 32, 32 ) ] MimeType.Png (cloudinaryIcon MimeType.Png 32)
, Head.icon [ ( 16, 16 ) ] MimeType.Png (cloudinaryIcon MimeType.Png 16)
, Head.appleTouchIcon (Just 180) (cloudinaryIcon MimeType.Png 180)
, Head.appleTouchIcon (Just 192) (cloudinaryIcon MimeType.Png 192)
]
|> Pages.Platform.toProgram
fileGenerator :
List { path : PagePath Pages.PathKey, frontmatter : metadata, body : String }
->
StaticHttp.Request
(List
(Result String
{ path : List String
, content : String
}
)
)
fileGenerator siteMetadata =
StaticHttp.succeed
[ Ok { path = [ "hello.txt" ], content = "Hello there!" }
, Ok { path = [ "goodbye.txt" ], content = "Goodbye there!" }
]
type alias Model =
{ showMobileMenu : Bool
, counter : Int
}
init :
Maybe
{ path :
{ path : PagePath Pages.PathKey
, query : Maybe String
, fragment : Maybe String
}
, metadata : Metadata
}
-> ( Model, Cmd Msg )
init maybePagePath =
( Model False 0, example "Whyyyyy hello there!" )
type Msg
= OnPageChange
{ path : PagePath Pages.PathKey
, query : Maybe String
, fragment : Maybe String
}
| ToggleMobileMenu
| Tick
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
OnPageChange page ->
( { model | showMobileMenu = False }, Cmd.none )
ToggleMobileMenu ->
( { model | showMobileMenu = not model.showMobileMenu }, Cmd.none )
Tick ->
( { model | counter = model.counter + 1 }, Cmd.none )
subscriptions : Metadata -> PagePath Pages.PathKey -> Model -> Sub Msg
subscriptions _ _ _ =
Time.every 1000 (\_ -> Tick)
view :
List ( PagePath Pages.PathKey, Metadata )
->
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
}
->
StaticHttp.Request
{ view : Model -> View -> { title : String, body : Html Msg }
, head : List (Head.Tag Pages.PathKey)
}
view siteMetadata page =
case page.frontmatter of
Metadata.Page meta ->
StaticHttp.get
(Secrets.succeed <| "https://api.github.com/repos/dillonkearns/" ++ meta.repo)
(D.field "stargazers_count" D.int)
|> StaticHttp.map
(\stars ->
{ view =
\model _ ->
{ title = "Title"
, body =
Html.div []
[ Html.h1 [] [ Html.text meta.repo ]
, Html.div []
[ Html.text <| "GitHub Stars: " ++ String.fromInt stars ]
, Html.div []
[ Html.text <| "Counter: " ++ String.fromInt model.counter ]
, Html.div []
[ Html.a [ Html.Attributes.href "/" ] [ Html.text "elm-pages" ]
, Html.a [ Html.Attributes.href "/elm-markdown" ] [ Html.text "elm-markdown" ]
]
]
}
, head = head page.path page.frontmatter
}
)
{-| <https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/abouts-cards>
<https://htmlhead.dev>
<https://html.spec.whatwg.org/multipage/semantics.html#standard-metadata-names>
<https://ogp.me/>
-}
head : PagePath Pages.PathKey -> Metadata -> List (Head.Tag Pages.PathKey)
head currentPath metadata =
case metadata of
Metadata.Page meta ->
Seo.summary
{ canonicalUrlOverride = Nothing
, siteName = "elm-pages"
, image =
{ url = images.iconPng
, alt = "elm-pages logo"
, dimensions = Nothing
, mimeType = Nothing
}
, description = siteTagline
, locale = Nothing
, title = meta.title
}
|> Seo.website
canonicalSiteUrl : String
canonicalSiteUrl =
"https://elm-pages.com"
siteTagline : String
siteTagline =
"A statically typed site generator - elm-pages"
tocView : MarkdownRenderer.TableOfContents -> Element msg
tocView toc =
Element.column [ Element.alignTop, Element.spacing 20 ]
[ Element.el [ Font.bold, Font.size 22 ] (Element.text "Table of Contents")
, Element.column [ Element.spacing 10 ]
(toc
|> List.map
(\heading ->
Element.link [ Font.color (Element.rgb255 100 100 100) ]
{ url = "#" ++ heading.anchorId
, label = Element.text heading.name
}
)
)
]

View File

@ -1,317 +0,0 @@
module MarkdownRenderer exposing (TableOfContents, view)
import Dotted
import Element exposing (Element)
import Element.Background
import Element.Border
import Element.Font as Font
import Element.Input
import Element.Region
import Ellie
import Html exposing (Attribute, Html)
import Html.Attributes exposing (property)
import Json.Encode as Encode exposing (Value)
import Markdown.Block as Block exposing (Block, Inline, ListItem(..), Task(..))
import Markdown.Html
import Markdown.Parser
import Markdown.Renderer
import Oembed
import Palette
import SyntaxHighlight
buildToc : List Block.Block -> TableOfContents
buildToc blocks =
let
headings =
gatherHeadings blocks
in
headings
|> List.map Tuple.second
|> List.map
(\styledList ->
{ anchorId = styledToString styledList |> rawTextToId
, name = styledToString styledList
, level = 1
}
)
type alias TableOfContents =
List { anchorId : String, name : String, level : Int }
view : String -> Result String ( TableOfContents, List (Element msg) )
view markdown =
case
markdown
|> Markdown.Parser.parse
of
Ok okAst ->
case Markdown.Renderer.render renderer okAst of
Ok rendered ->
Ok ( buildToc okAst, rendered )
Err errors ->
Err errors
Err error ->
Err (error |> List.map Markdown.Parser.deadEndToString |> String.join "\n")
renderer : Markdown.Renderer.Renderer (Element msg)
renderer =
{ heading = heading
, paragraph =
Element.paragraph
[ Element.spacing 15 ]
, thematicBreak = Element.none
, text = \value -> Element.paragraph [] [ Element.text value ]
, strong = \content -> Element.paragraph [ Font.bold ] content
, emphasis = \content -> Element.paragraph [ Font.italic ] content
, codeSpan = code
, link =
\{ title, destination } body ->
Element.newTabLink []
{ url = destination
, label =
Element.paragraph
[ Font.color (Element.rgb255 0 0 255)
, Element.htmlAttribute (Html.Attributes.style "overflow-wrap" "break-word")
, Element.htmlAttribute (Html.Attributes.style "word-break" "break-word")
]
body
}
, hardLineBreak = Html.br [] [] |> Element.html
, image =
\image ->
case image.title of
Just title ->
Element.image [ Element.width Element.fill ] { src = image.src, description = image.alt }
Nothing ->
Element.image [ Element.width Element.fill ] { src = image.src, description = image.alt }
, blockQuote =
\children ->
Element.column
[ Element.Border.widthEach { top = 0, right = 0, bottom = 0, left = 10 }
, Element.padding 10
, Element.Border.color (Element.rgb255 145 145 145)
, Element.Background.color (Element.rgb255 245 245 245)
]
children
, unorderedList =
\items ->
Element.column [ Element.spacing 15 ]
(items
|> List.map
(\(ListItem task children) ->
Element.paragraph [ Element.spacing 5 ]
[ Element.row
[ Element.alignTop ]
((case task of
IncompleteTask ->
Element.Input.defaultCheckbox False
CompletedTask ->
Element.Input.defaultCheckbox True
NoTask ->
Element.text ""
)
:: Element.text " "
:: children
)
]
)
)
, orderedList =
\startingIndex items ->
Element.column [ Element.spacing 15 ]
(items
|> List.indexedMap
(\index itemBlocks ->
Element.row [ Element.spacing 5 ]
[ Element.row [ Element.alignTop ]
(Element.text (String.fromInt (index + startingIndex) ++ " ") :: itemBlocks)
]
)
)
, codeBlock = codeBlock
, table = Element.column []
, tableHeader = Element.column []
, tableBody = Element.column []
, tableRow = Element.row []
, tableHeaderCell =
\maybeAlignment children ->
Element.paragraph [] children
, tableCell = Element.paragraph []
, html =
Markdown.Html.oneOf
[ Markdown.Html.tag "banner"
(\children ->
Element.paragraph
[ Font.center
, Font.size 47
, Font.family [ Font.typeface "Montserrat" ]
, Font.color Palette.color.primary
]
children
)
, Markdown.Html.tag "boxes"
(\children ->
children
|> List.indexedMap
(\index aBox ->
let
isLast =
index == (List.length children - 1)
in
[ Just aBox
, if isLast then
Nothing
else
Just Dotted.lines
]
|> List.filterMap identity
)
|> List.concat
|> List.reverse
|> Element.column [ Element.centerX ]
)
, Markdown.Html.tag "box"
(\children ->
Element.textColumn
[ Element.centerX
, Font.center
, Element.padding 30
, Element.Border.shadow { offset = ( 2, 2 ), size = 3, blur = 3, color = Element.rgba255 40 80 80 0.1 }
, Element.spacing 15
]
children
)
, Markdown.Html.tag "values"
(\children ->
Element.row
[ Element.spacing 30
, Element.htmlAttribute (Html.Attributes.style "flex-wrap" "wrap")
]
children
)
, Markdown.Html.tag "value"
(\children ->
Element.column
[ Element.width Element.fill
, Element.padding 20
, Element.spacing 20
, Element.height Element.fill
, Element.centerX
]
children
)
, Markdown.Html.tag "oembed"
(\url children ->
Oembed.view [] Nothing url
|> Maybe.map Element.html
|> Maybe.withDefault Element.none
|> Element.el [ Element.centerX ]
)
|> Markdown.Html.withAttribute "url"
, Markdown.Html.tag "ellie-output"
(\ellieId children ->
-- Oembed.view [] Nothing url
-- |> Maybe.map Element.html
-- |> Maybe.withDefault Element.none
-- |> Element.el [ Element.centerX ]
Ellie.outputTab ellieId
)
|> Markdown.Html.withAttribute "id"
]
}
styledToString : List Inline -> String
styledToString inlines =
--List.map .string list
--|> String.join "-"
-- TODO do I need to hyphenate?
inlines
|> Block.extractInlineText
gatherHeadings : List Block -> List ( Block.HeadingLevel, List Inline )
gatherHeadings blocks =
List.filterMap
(\block ->
case block of
Block.Heading level content ->
Just ( level, content )
_ ->
Nothing
)
blocks
rawTextToId : String -> String
rawTextToId rawText =
rawText
|> String.split " "
|> String.join "-"
|> String.toLower
heading : { level : Block.HeadingLevel, rawText : String, children : List (Element msg) } -> Element msg
heading { level, rawText, children } =
Element.paragraph
[ Font.size
(case level of
Block.H1 ->
36
Block.H2 ->
24
_ ->
20
)
, Font.bold
, Font.family [ Font.typeface "Montserrat" ]
, Element.Region.heading (Block.headingLevelToInt level)
, Element.htmlAttribute
(Html.Attributes.attribute "name" (rawTextToId rawText))
, Element.htmlAttribute
(Html.Attributes.id (rawTextToId rawText))
]
children
code : String -> Element msg
code snippet =
Element.el
[ Element.Background.color
(Element.rgba255 50 50 50 0.07)
, Element.Border.rounded 2
, Element.paddingXY 5 3
, Font.family [ Font.typeface "Roboto Mono", Font.monospace ]
]
(Element.text snippet)
codeBlock : { body : String, language : Maybe String } -> Element msg
codeBlock details =
SyntaxHighlight.elm details.body
|> Result.map (SyntaxHighlight.toBlockHtml (Just 1))
|> Result.withDefault
(Html.pre [] [ Html.code [] [ Html.text details.body ] ])
|> Element.html
|> Element.el [ Element.width Element.fill ]
editorValue : String -> Attribute msg
editorValue value =
value
|> String.trim
|> Encode.string
|> property "editorValue"

View File

@ -1,51 +0,0 @@
module Metadata exposing (Metadata(..), PageMetadata, decoder)
import Json.Decode as Decode exposing (Decoder)
import List.Extra
import Pages
import Pages.ImagePath as ImagePath exposing (ImagePath)
type Metadata
= Page PageMetadata
type alias PageMetadata =
{ title : String, repo : String }
decoder =
Decode.field "type" Decode.string
|> Decode.andThen
(\pageType ->
case pageType of
"page" ->
Decode.map2 PageMetadata
(Decode.field "title" Decode.string)
(Decode.field "repo" Decode.string)
|> Decode.map Page
_ ->
Decode.fail <| "Unexpected page \"type\" " ++ pageType
)
imageDecoder : Decoder (ImagePath Pages.PathKey)
imageDecoder =
Decode.string
|> Decode.andThen
(\imageAssetPath ->
case findMatchingImage imageAssetPath of
Nothing ->
Decode.fail "Couldn't find image."
Just imagePath ->
Decode.succeed imagePath
)
findMatchingImage : String -> Maybe (ImagePath Pages.PathKey)
findMatchingImage imageAssetPath =
List.Extra.find
(\image -> ImagePath.toString image == imageAssetPath)
Pages.allImages

View File

@ -1,34 +0,0 @@
module MySitemap exposing (install)
import Head
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.Platform exposing (Builder)
import Pages.StaticHttp as StaticHttp
import Sitemap
install :
{ siteUrl : String
}
->
(List
{ path : PagePath pathKey
, frontmatter : metadata
, body : String
}
-> List { path : String, lastMod : Maybe String }
)
-> Builder pathKey userModel userMsg metadata view
-> Builder pathKey userModel userMsg metadata view
install config toSitemapEntry builder =
builder
|> Pages.Platform.withGlobalHeadTags [ Head.sitemapLink "/sitemap.xml" ]
|> Pages.Platform.withFileGenerator
(\siteMetadata ->
StaticHttp.succeed
[ Ok
{ path = [ "sitemap.xml" ]
, content = Sitemap.build config (toSitemapEntry siteMetadata)
}
]
)

View File

@ -1,44 +0,0 @@
module Palette exposing (blogHeading, color, heading)
import Element exposing (Element)
import Element.Font as Font
import Element.Region
color =
{ primary = Element.rgb255 0 6 255
, secondary = Element.rgb255 0 242 96
}
heading : Int -> List (Element msg) -> Element msg
heading level content =
Element.paragraph
([ Font.bold
, Font.family [ Font.typeface "Montserrat" ]
, Element.Region.heading level
]
++ (case level of
1 ->
[ Font.size 36 ]
2 ->
[ Font.size 24 ]
_ ->
[ Font.size 20 ]
)
)
content
blogHeading : String -> Element msg
blogHeading title =
Element.paragraph
[ Font.bold
, Font.family [ Font.typeface "Montserrat" ]
, Element.Region.heading 1
, Font.size 36
, Font.center
]
[ Element.text title ]

View File

@ -1,56 +0,0 @@
module RssPlugin exposing (generate)
import Head
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.Platform exposing (Builder)
import Pages.StaticHttp as StaticHttp
import Rss
import Time
generate :
{ siteTagline : String
, siteUrl : String
, title : String
, builtAt : Time.Posix
, indexPage : PagePath pathKey
}
->
({ path : PagePath pathKey
, frontmatter : metadata
, body : String
}
-> Maybe Rss.Item
)
-> Builder pathKey userModel userMsg metadata view
-> Builder pathKey userModel userMsg metadata view
generate options metadataToRssItem builder =
let
feedFilePath =
(options.indexPage
|> PagePath.toPath
)
++ [ "feed.xml" ]
in
builder
|> Pages.Platform.withFileGenerator
(\siteMetadata ->
{ path = feedFilePath
, content =
Rss.generate
{ title = options.title
, description = options.siteTagline
-- TODO make sure you don't add an extra "/"
, url = options.siteUrl ++ "/" ++ PagePath.toString options.indexPage
, lastBuildTime = options.builtAt
, generator = Just "elm-pages"
, items = siteMetadata |> List.filterMap metadataToRssItem
, siteUrl = options.siteUrl
}
}
|> Ok
|> List.singleton
|> StaticHttp.succeed
)
|> Pages.Platform.withGlobalHeadTags [ Head.rssLink (feedFilePath |> String.join "/") ]

View File

@ -1,161 +0,0 @@
module Showcase exposing (..)
import Element
import Element.Border
import Element.Font
import FontAwesome
import OptimizedDecoder as Decode
import Pages.Secrets as Secrets
import Pages.StaticHttp as StaticHttp
import Palette
import Url.Builder
view : List Entry -> Element.Element msg
view entries =
Element.column
[ Element.spacing 30
]
(submitShowcaseItemButton
:: List.map entryView entries
)
submitShowcaseItemButton =
Element.newTabLink
[ Element.Font.color Palette.color.primary
, Element.Font.underline
]
{ url = "https://airtable.com/shrPSenIW2EQqJ083"
, label = Element.text "Submit your site to the showcase"
}
entryView : Entry -> Element.Element msg
entryView entry =
Element.column
[ Element.spacing 15
, Element.Border.shadow { offset = ( 2, 2 ), size = 3, blur = 3, color = Element.rgba255 40 80 80 0.1 }
, Element.padding 40
, Element.width (Element.maximum 700 Element.fill)
]
[ Element.newTabLink [ Element.Font.size 14, Element.Font.color Palette.color.primary ]
{ url = entry.liveUrl
, label =
Element.image [ Element.width Element.fill ]
{ src = "https://image.thum.io/get/width/800/crop/800/" ++ entry.screenshotUrl
, description = "Site Screenshot"
}
}
, Element.text entry.displayName |> Element.el [ Element.Font.extraBold ]
, Element.newTabLink [ Element.Font.size 14, Element.Font.color Palette.color.primary ]
{ url = entry.liveUrl
, label = Element.text entry.liveUrl
}
, Element.paragraph [ Element.Font.size 14 ]
[ Element.text "By "
, Element.newTabLink [ Element.Font.color Palette.color.primary ]
{ url = entry.authorUrl
, label = Element.text entry.authorName
}
]
, Element.row [ Element.width Element.fill ]
[ categoriesView entry.categories
, Element.row [ Element.alignRight ]
[ case entry.repoUrl of
Just repoUrl ->
Element.newTabLink []
{ url = repoUrl
, label = FontAwesome.icon "fas fa-code-branch"
}
Nothing ->
Element.none
]
]
]
categoriesView : List String -> Element.Element msg
categoriesView categories =
categories
|> List.map
(\category ->
Element.text category
)
|> Element.wrappedRow
[ Element.spacing 7
, Element.Font.size 14
, Element.Font.color (Element.rgba255 0 0 0 0.6)
, Element.width (Element.fillPortion 8)
]
type alias Entry =
{ screenshotUrl : String
, displayName : String
, liveUrl : String
, authorName : String
, authorUrl : String
, categories : List String
, repoUrl : Maybe String
}
decoder : Decode.Decoder (List Entry)
decoder =
Decode.field "records" <|
Decode.list entryDecoder
entryDecoder : Decode.Decoder Entry
entryDecoder =
Decode.field "fields" <|
Decode.map7 Entry
(Decode.field "Screenshot URL" Decode.string)
(Decode.field "Site Display Name" Decode.string)
(Decode.field "Live URL" Decode.string)
(Decode.field "Author" Decode.string)
(Decode.field "Author URL" Decode.string)
(Decode.field "Categories" (Decode.list Decode.string))
(Decode.maybe (Decode.field "Repository URL" Decode.string))
staticRequest : StaticHttp.Request (List Entry)
staticRequest =
StaticHttp.request
(Secrets.succeed
(\airtableToken ->
{ url = "https://api.airtable.com/v0/appDykQzbkQJAidjt/elm-pages%20showcase?maxRecords=100&view=Grid%202"
, method = "GET"
, headers = [ ( "Authorization", "Bearer " ++ airtableToken ), ( "view", "viwayJBsr63qRd7q3" ) ]
, body = StaticHttp.emptyBody
}
)
|> Secrets.with "AIRTABLE_TOKEN"
)
decoder
allCategroies : List String
allCategroies =
[ "Documentation"
, "eCommerce"
, "Conference"
, "Consulting"
, "Education"
, "Entertainment"
, "Event"
, "Food"
, "Freelance"
, "Gallery"
, "Landing Page"
, "Music"
, "Nonprofit"
, "Podcast"
, "Portfolio"
, "Programming"
, "Sports"
, "Travel"
, "Blog"
]

View File

@ -1,46 +0,0 @@
backend:
name: git-gateway
media_folder: "examples/docs/images" # Folder where user uploaded files should go
public_folder: "examples/docs/images"
publish_mode: "editorial_workflow" # see https://www.netlifycms.org/docs/open-authoring/
collections: # A list of collections the CMS should be able to edit
- name: "post" # Used in routes, ie.: /admin/collections/:slug/edit
label: "Post" # Used in the UI, ie.: "New Post"
folder: "examples/docs/content/blog" # The path to the folder where the documents are stored
filter: {field: "type", value: "blog"}
create: true # Allow users to create new documents in this collection
fields: # The fields each document in this collection have
- { label: "Title", name: "title", widget: "string" }
- { label: "Publish Date", name: "published", widget: "date" }
- { label: "Intro Blurb", name: "description", widget: "text" }
- { label: "Image", name: "image", widget: "image", required: true }
- label: "Author"
name: "author"
widget: "select"
options: ["Dillon Kearns"]
default: "Dillon Kearns"
- { label: "Body", name: "body", widget: "markdown" }
- {
label: "Type",
name: "type",
widget: "hidden",
default: "blog",
required: false,
}
- name: "docs" # Used in routes, ie.: /admin/collections/:slug/edit
label: "Docs" # Used in the UI, ie.: "New Post"
folder: "examples/docs/content/docs" # The path to the folder where the documents are stored
filter: {field: "type", value: "doc"}
create: true # Allow users to create new documents in this collection
fields: # The fields each document in this collection have
- { label: "Title", name: "title", widget: "string" }
- { label: "Body", name: "body", widget: "markdown" }
- {
label: "Type",
name: "type",
widget: "hidden",
default: "doc",
required: false,
}

View File

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Content Manager</title>
</head>
<body>
<script src="https://identity-js.netlify.com/v1/netlify-identity-widget.js"></script>
<!-- Include the script that builds the page and powers Netlify CMS -->
<script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script>
</body>
</html>

View File

@ -1,43 +0,0 @@
pre.elmsh {
padding: 10px;
margin: 0;
text-align: left;
overflow: auto;
padding: 20px !important;
}
code.elmsh {
padding: 0;
}
code {
font-family: 'Roboto Mono' !important;
font-size: 20px !important;
line-height: 28px;
}
.elmsh-line:before {
/* content: attr(data-elmsh-lc); */
display: inline-block;
text-align: right;
width: 40px;
padding: 0 20px 0 0;
opacity: 0.3;
}
.elmsh {
color: #f8f8f2;
background: #000;
}
.elmsh-hl {background: #343434;}
.elmsh-add {background: #003800;}
.elmsh-del {background: #380000;}
.elmsh-comm {color: #75715e;}
.elmsh1 {color: #ae81ff;}
.elmsh2 {color: #e6db74;}
.elmsh3 {color: #66d9ef;}
.elmsh4 {color: #f92672;}
.elmsh5 {color: #a6e22e;}
.elmsh6 {color: #ae81ff;}
.elmsh7 {color: #fd971f;}

File diff suppressed because it is too large Load Diff

View File

@ -1,226 +0,0 @@
module Element.Background exposing
( color, gradient
, image, uncropped, tiled, tiledX, tiledY
)
{-|
@docs color, gradient
# Images
@docs image, uncropped, tiled, tiledX, tiledY
**Note** if you want more control over a background image than is provided here, you should try just using a normal `Element.image` with something like `Element.behindContent`.
-}
import Element exposing (Attr, Attribute, Color)
import Internal.Flag as Flag
import Internal.Model as Internal
import VirtualDom
{-| -}
color : Color -> Attr decorative msg
color clr =
Internal.StyleClass Flag.bgColor (Internal.Colored ("bg-" ++ Internal.formatColorClass clr) "background-color" clr)
{-| Resize the image to fit the containing element while maintaining proportions and cropping the overflow.
-}
image : String -> Attribute msg
image src =
Internal.Attr (VirtualDom.style "background" ("url(\"" ++ src ++ "\") center / cover no-repeat"))
{-| A centered background image that keeps its natural proportions, but scales to fit the space.
-}
uncropped : String -> Attribute msg
uncropped src =
Internal.Attr (VirtualDom.style "background" ("url(\"" ++ src ++ "\") center / contain no-repeat"))
{-| Tile an image in the x and y axes.
-}
tiled : String -> Attribute msg
tiled src =
Internal.Attr (VirtualDom.style "background" ("url(\"" ++ src ++ "\") repeat"))
{-| Tile an image in the x axis.
-}
tiledX : String -> Attribute msg
tiledX src =
Internal.Attr (VirtualDom.style "background" ("url(\"" ++ src ++ "\") repeat-x"))
{-| Tile an image in the y axis.
-}
tiledY : String -> Attribute msg
tiledY src =
Internal.Attr (VirtualDom.style "background" ("url(\"" ++ src ++ "\") repeat-y"))
type Direction
= ToUp
| ToDown
| ToRight
| ToTopRight
| ToBottomRight
| ToLeft
| ToTopLeft
| ToBottomLeft
| ToAngle Float
type Step
= ColorStep Color
| PercentStep Float Color
| PxStep Int Color
{-| -}
step : Color -> Step
step =
ColorStep
{-| -}
percent : Float -> Color -> Step
percent =
PercentStep
{-| -}
px : Int -> Color -> Step
px =
PxStep
{-| A linear gradient.
First you need to specify what direction the gradient is going by providing an angle in radians. `0` is up and `pi` is down.
The colors will be evenly spaced.
-}
gradient :
{ angle : Float
, steps : List Color
}
-> Attr decorative msg
gradient { angle, steps } =
case steps of
[] ->
Internal.NoAttribute
clr :: [] ->
Internal.StyleClass Flag.bgColor
(Internal.Colored ("bg-" ++ Internal.formatColorClass clr) "background-color" clr)
_ ->
Internal.StyleClass Flag.bgGradient <|
Internal.Single ("bg-grad-" ++ (String.join "-" <| Internal.floatClass angle :: List.map Internal.formatColorClass steps))
"background-image"
("linear-gradient(" ++ (String.join ", " <| (String.fromFloat angle ++ "rad") :: List.map Internal.formatColor steps) ++ ")")
-- {-| -}
-- gradientWith : { direction : Direction, steps : List Step } -> Attribute msg
-- gradientWith { direction, steps } =
-- StyleClass <|
-- Single ("bg-gradient-" ++ (String.join "-" <| renderDirectionClass direction :: List.map renderStepClass steps))
-- "background"
-- ("linear-gradient(" ++ (String.join ", " <| renderDirection direction :: List.map renderStep steps) ++ ")")
-- {-| -}
-- renderStep : Step -> String
-- renderStep step =
-- case step of
-- ColorStep color ->
-- formatColor color
-- PercentStep percent color ->
-- formatColor color ++ " " ++ toString percent ++ "%"
-- PxStep px color ->
-- formatColor color ++ " " ++ toString px ++ "px"
-- {-| -}
-- renderStepClass : Step -> String
-- renderStepClass step =
-- case step of
-- ColorStep color ->
-- formatColorClass color
-- PercentStep percent color ->
-- formatColorClass color ++ "-" ++ floatClass percent ++ "p"
-- PxStep px color ->
-- formatColorClass color ++ "-" ++ toString px ++ "px"
-- toUp : Direction
-- toUp =
-- ToUp
-- toDown : Direction
-- toDown =
-- ToDown
-- toRight : Direction
-- toRight =
-- ToRight
-- toTopRight : Direction
-- toTopRight =
-- ToTopRight
-- toBottomRight : Direction
-- toBottomRight =
-- ToBottomRight
-- toLeft : Direction
-- toLeft =
-- ToLeft
-- toTopLeft : Direction
-- toTopLeft =
-- ToTopLeft
-- toBottomLeft : Direction
-- toBottomLeft =
-- ToBottomLeft
-- angle : Float -> Direction
-- angle rad =
-- ToAngle rad
-- renderDirection : Direction -> String
-- renderDirection dir =
-- case dir of
-- ToUp ->
-- "to top"
-- ToDown ->
-- "to bottom"
-- ToRight ->
-- "to right"
-- ToTopRight ->
-- "to top right"
-- ToBottomRight ->
-- "to bottom right"
-- ToLeft ->
-- "to left"
-- ToTopLeft ->
-- "to top left"
-- ToBottomLeft ->
-- "to bottom left"
-- ToAngle angle ->
-- toString angle ++ "rad"
-- renderDirectionClass : Direction -> String
-- renderDirectionClass dir =
-- case dir of
-- ToUp ->
-- "to-top"
-- ToDown ->
-- "to-bottom"
-- ToRight ->
-- "to-right"
-- ToTopRight ->
-- "to-top-right"
-- ToBottomRight ->
-- "to-bottom-right"
-- ToLeft ->
-- "to-left"
-- ToTopLeft ->
-- "to-top-left"
-- ToBottomLeft ->
-- "to-bottom-left"
-- ToAngle angle ->
-- floatClass angle ++ "rad"

View File

@ -1,281 +0,0 @@
module Element.Border exposing
( color
, width, widthXY, widthEach
, solid, dashed, dotted
, rounded, roundEach
, glow, innerGlow, shadow, innerShadow
)
{-|
@docs color
## Border Widths
@docs width, widthXY, widthEach
## Border Styles
@docs solid, dashed, dotted
## Rounded Corners
@docs rounded, roundEach
## Shadows
@docs glow, innerGlow, shadow, innerShadow
-}
import Element exposing (Attr, Attribute, Color)
import Internal.Flag as Flag
import Internal.Model as Internal
import Internal.Style as Style exposing (classes)
{-| -}
color : Color -> Attr decorative msg
color clr =
Internal.StyleClass
Flag.borderColor
(Internal.Colored
("bc-" ++ Internal.formatColorClass clr)
"border-color"
clr
)
{-| -}
width : Int -> Attribute msg
width v =
Internal.StyleClass
Flag.borderWidth
(Internal.BorderWidth
("b-" ++ String.fromInt v)
v
v
v
v
)
{-| Set horizontal and vertical borders.
-}
widthXY : Int -> Int -> Attribute msg
widthXY x y =
Internal.StyleClass
Flag.borderWidth
(Internal.BorderWidth
("b-"
++ String.fromInt x
++ "-"
++ String.fromInt y
)
y
x
y
x
)
{-| -}
widthEach :
{ bottom : Int
, left : Int
, right : Int
, top : Int
}
-> Attribute msg
widthEach { bottom, top, left, right } =
if top == bottom && left == right then
if top == right then
width top
else
widthXY left top
else
Internal.StyleClass Flag.borderWidth
(Internal.BorderWidth
("b-"
++ String.fromInt top
++ "-"
++ String.fromInt right
++ "-"
++ String.fromInt bottom
++ "-"
++ String.fromInt left
)
top
right
bottom
left
)
-- {-| No Borders
-- -}
-- none : Attribute msg
-- none =
-- Class "border" "border-none"
{-| -}
solid : Attribute msg
solid =
Internal.Class Flag.borderStyle classes.borderSolid
{-| -}
dashed : Attribute msg
dashed =
Internal.Class Flag.borderStyle classes.borderDashed
{-| -}
dotted : Attribute msg
dotted =
Internal.Class Flag.borderStyle classes.borderDotted
{-| Round all corners.
-}
rounded : Int -> Attribute msg
rounded radius =
Internal.StyleClass
Flag.borderRound
(Internal.Single
("br-" ++ String.fromInt radius)
"border-radius"
(String.fromInt radius ++ "px")
)
{-| -}
roundEach :
{ topLeft : Int
, topRight : Int
, bottomLeft : Int
, bottomRight : Int
}
-> Attribute msg
roundEach { topLeft, topRight, bottomLeft, bottomRight } =
Internal.StyleClass Flag.borderRound
(Internal.Single
("br-"
++ String.fromInt topLeft
++ "-"
++ String.fromInt topRight
++ String.fromInt bottomLeft
++ "-"
++ String.fromInt bottomRight
)
"border-radius"
(String.fromInt topLeft
++ "px "
++ String.fromInt topRight
++ "px "
++ String.fromInt bottomRight
++ "px "
++ String.fromInt bottomLeft
++ "px"
)
)
{-| A simple glow by specifying the color and size.
-}
glow : Color -> Float -> Attr decorative msg
glow clr size =
shadow
{ offset = ( 0, 0 )
, size = size
, blur = size * 2
, color = clr
}
{-| -}
innerGlow : Color -> Float -> Attr decorative msg
innerGlow clr size =
innerShadow
{ offset = ( 0, 0 )
, size = size
, blur = size * 2
, color = clr
}
{-| -}
shadow :
{ offset : ( Float, Float )
, size : Float
, blur : Float
, color : Color
}
-> Attr decorative msg
shadow almostShade =
let
shade =
{ inset = False
, offset = almostShade.offset
, size = almostShade.size
, blur = almostShade.blur
, color = almostShade.color
}
in
Internal.StyleClass Flag.shadows <|
Internal.Single
(Internal.boxShadowClass shade)
"box-shadow"
(Internal.formatBoxShadow shade)
{-| -}
innerShadow :
{ offset : ( Float, Float )
, size : Float
, blur : Float
, color : Color
}
-> Attr decorative msg
innerShadow almostShade =
let
shade =
{ inset = True
, offset = almostShade.offset
, size = almostShade.size
, blur = almostShade.blur
, color = almostShade.color
}
in
Internal.StyleClass Flag.shadows <|
Internal.Single
(Internal.boxShadowClass shade)
"box-shadow"
(Internal.formatBoxShadow shade)
-- {-| -}
-- shadow :
-- { offset : ( Float, Float )
-- , blur : Float
-- , size : Float
-- , color : Color
-- }
-- -> Attr decorative msg
-- shadow shade =
-- Internal.BoxShadow
-- { inset = False
-- , offset = shade.offset
-- , size = shade.size
-- , blur = shade.blur
-- , color = shade.color
-- }

View File

@ -1,265 +0,0 @@
module Element.Events exposing
( onClick, onDoubleClick, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onMouseMove
, onFocus, onLoseFocus
-- , onClickCoords
-- , onClickPageCoords
-- , onClickScreenCoords
-- , onMouseCoords
-- , onMousePageCoords
-- , onMouseScreenCoords
)
{-|
## Mouse Events
@docs onClick, onDoubleClick, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onMouseMove
## Focus Events
@docs onFocus, onLoseFocus
-}
import Element exposing (Attribute)
import Html.Events
import Internal.Model as Internal
import Json.Decode as Json
import VirtualDom
-- MOUSE EVENTS
{-| -}
onMouseDown : msg -> Attribute msg
onMouseDown =
Internal.Attr << Html.Events.onMouseDown
{-| -}
onMouseUp : msg -> Attribute msg
onMouseUp =
Internal.Attr << Html.Events.onMouseUp
{-| -}
onClick : msg -> Attribute msg
onClick =
Internal.Attr << Html.Events.onClick
{-| -}
onDoubleClick : msg -> Attribute msg
onDoubleClick =
Internal.Attr << Html.Events.onDoubleClick
{-| -}
onMouseEnter : msg -> Attribute msg
onMouseEnter =
Internal.Attr << Html.Events.onMouseEnter
{-| -}
onMouseLeave : msg -> Attribute msg
onMouseLeave =
Internal.Attr << Html.Events.onMouseLeave
{-| -}
onMouseMove : msg -> Attribute msg
onMouseMove msg =
on "mousemove" (Json.succeed msg)
-- onClickWith
-- { button = primary
-- , send = localCoords Button
-- }
-- type alias Click =
-- { button : Button
-- , send : Track
-- }
-- type Button = Primary | Secondary
-- type Track
-- = ElementCoords
-- | PageCoords
-- | ScreenCoords
-- |
{-| -}
onClickCoords : (Coords -> msg) -> Attribute msg
onClickCoords msg =
on "click" (Json.map msg localCoords)
{-| -}
onClickScreenCoords : (Coords -> msg) -> Attribute msg
onClickScreenCoords msg =
on "click" (Json.map msg screenCoords)
{-| -}
onClickPageCoords : (Coords -> msg) -> Attribute msg
onClickPageCoords msg =
on "click" (Json.map msg pageCoords)
{-| -}
onMouseCoords : (Coords -> msg) -> Attribute msg
onMouseCoords msg =
on "mousemove" (Json.map msg localCoords)
{-| -}
onMouseScreenCoords : (Coords -> msg) -> Attribute msg
onMouseScreenCoords msg =
on "mousemove" (Json.map msg screenCoords)
{-| -}
onMousePageCoords : (Coords -> msg) -> Attribute msg
onMousePageCoords msg =
on "mousemove" (Json.map msg pageCoords)
type alias Coords =
{ x : Int
, y : Int
}
screenCoords : Json.Decoder Coords
screenCoords =
Json.map2 Coords
(Json.field "screenX" Json.int)
(Json.field "screenY" Json.int)
{-| -}
localCoords : Json.Decoder Coords
localCoords =
Json.map2 Coords
(Json.field "offsetX" Json.int)
(Json.field "offsetY" Json.int)
pageCoords : Json.Decoder Coords
pageCoords =
Json.map2 Coords
(Json.field "pageX" Json.int)
(Json.field "pageY" Json.int)
-- FOCUS EVENTS
{-| -}
onLoseFocus : msg -> Attribute msg
onLoseFocus =
Internal.Attr << Html.Events.onBlur
{-| -}
onFocus : msg -> Attribute msg
onFocus =
Internal.Attr << Html.Events.onFocus
-- CUSTOM EVENTS
{-| Create a custom event listener. Normally this will not be necessary, but
you have the power! Here is how `onClick` is defined for example:
import Json.Decode as Json
onClick : msg -> Attribute msg
onClick message =
on "click" (Json.succeed message)
The first argument is the event name in the same format as with JavaScript's
[`addEventListener`][aEL] function.
The second argument is a JSON decoder. Read more about these [here][decoder].
When an event occurs, the decoder tries to turn the event object into an Elm
value. If successful, the value is routed to your `update` function. In the
case of `onClick` we always just succeed with the given `message`.
If this is confusing, work through the [Elm Architecture Tutorial][tutorial].
It really does help!
[aEL]: <https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener>
[decoder]: <http://package.elm-lang.org/packages/elm-lang/core/latest/Json-Decode>
[tutorial]: <https://github.com/evancz/elm-architecture-tutorial/>
-}
on : String -> Json.Decoder msg -> Attribute msg
on event decode =
Internal.Attr <| Html.Events.on event decode
-- {-| Same as `on` but you can set a few options.
-- -}
-- onWithOptions : String -> Html.Events.Options -> Json.Decoder msg -> Attribute msg
-- onWithOptions event options decode =
-- Internal.Attr <| Html.Events.onWithOptions event options decode
-- COMMON DECODERS
{-| A `Json.Decoder` for grabbing `event.target.value`. We use this to define
`onInput` as follows:
import Json.Decode as Json
onInput : (String -> msg) -> Attribute msg
onInput tagger =
on "input" (Json.map tagger targetValue)
You probably will never need this, but hopefully it gives some insights into
how to make custom event handlers.
-}
targetValue : Json.Decoder String
targetValue =
Json.at [ "target", "value" ] Json.string
{-| A `Json.Decoder` for grabbing `event.target.checked`. We use this to define
`onCheck` as follows:
import Json.Decode as Json
onCheck : (Bool -> msg) -> Attribute msg
onCheck tagger =
on "input" (Json.map tagger targetChecked)
-}
targetChecked : Json.Decoder Bool
targetChecked =
Json.at [ "target", "checked" ] Json.bool
{-| A `Json.Decoder` for grabbing `event.keyCode`. This helps you define
keyboard listeners like this:
import Json.Decode as Json
onKeyUp : (Int -> msg) -> Attribute msg
onKeyUp tagger =
on "keyup" (Json.map tagger keyCode)
**Note:** It looks like the spec is moving away from `event.keyCode` and
towards `event.key`. Once this is supported in more browsers, we may add
helpers here for `onKeyUp`, `onKeyDown`, `onKeyPress`, etc.
-}
keyCode : Json.Decoder Int
keyCode =
Json.field "keyCode" Json.int

View File

@ -1,525 +0,0 @@
module Element.Font exposing
( color, size
, family, Font, typeface, serif, sansSerif, monospace
, external
, alignLeft, alignRight, center, justify, letterSpacing, wordSpacing
, underline, strike, italic, unitalicized
, heavy, extraBold, bold, semiBold, medium, regular, light, extraLight, hairline
, Variant, variant, variantList, smallCaps, slashedZero, ligatures, ordinal, tabularNumbers, stackedFractions, diagonalFractions, swash, feature, indexed
, glow, shadow
)
{-|
import Element
import Element.Font as Font
view =
Element.el
[ Font.color (Element.rgb 0 0 1)
, Font.size 18
, Font.family
[ Font.typeface "Open Sans"
, Font.sansSerif
]
]
(Element.text "Woohoo, I'm stylish text")
**Note:** `Font.color`, `Font.size`, and `Font.family` are inherited, meaning you can set them at the top of your view and all subsequent nodes will have that value.
**Other Note:** If you're looking for something like `line-height`, it's handled by `Element.spacing` on a `paragraph`.
@docs color, size
## Typefaces
@docs family, Font, typeface, serif, sansSerif, monospace
@docs external
## Alignment and Spacing
@docs alignLeft, alignRight, center, justify, letterSpacing, wordSpacing
## Font Styles
@docs underline, strike, italic, unitalicized
## Font Weight
@docs heavy, extraBold, bold, semiBold, medium, regular, light, extraLight, hairline
## Variants
@docs Variant, variant, variantList, smallCaps, slashedZero, ligatures, ordinal, tabularNumbers, stackedFractions, diagonalFractions, swash, feature, indexed
## Shadows
@docs glow, shadow
-}
import Element exposing (Attr, Attribute, Color)
import Internal.Flag as Flag
import Internal.Model as Internal
import Internal.Style exposing (classes)
{-| -}
type alias Font =
Internal.Font
{-| -}
color : Color -> Attr decorative msg
color fontColor =
Internal.StyleClass
Flag.fontColor
(Internal.Colored
("fc-" ++ Internal.formatColorClass fontColor)
"color"
fontColor
)
{-|
import Element
import Element.Font as Font
myElement =
Element.el
[ Font.family
[ Font.typeface "Helvetica"
, Font.sansSerif
]
]
(text "")
-}
family : List Font -> Attribute msg
family families =
Internal.StyleClass
Flag.fontFamily
(Internal.FontFamily
(List.foldl Internal.renderFontClassName "ff-" families)
families
)
{-| -}
serif : Font
serif =
Internal.Serif
{-| -}
sansSerif : Font
sansSerif =
Internal.SansSerif
{-| -}
monospace : Font
monospace =
Internal.Monospace
{-| -}
typeface : String -> Font
typeface =
Internal.Typeface
{-| -}
type alias Adjustment =
{ capital : Float
, lowercase : Float
, baseline : Float
, descender : Float
}
{-| -}
with :
{ name : String
, adjustment : Maybe Adjustment
, variants : List Variant
}
-> Font
with =
Internal.FontWith
{-| -}
sizeByCapital : Attribute msg
sizeByCapital =
Internal.htmlClass classes.sizeByCapital
{-| -}
full : Attribute msg
full =
Internal.htmlClass classes.fullSize
{-| **Note** it's likely that `Font.external` will cause a flash on your page on loading.
To bypass this, import your fonts using a separate stylesheet and just use `Font.typeface`.
It's likely that `Font.external` will be removed or redesigned in the future to avoid the flashing.
`Font.external` can be used to import font files. Let's say you found a neat font on <http://fonts.google.com>:
import Element
import Element.Font as Font
view =
Element.el
[ Font.family
[ Font.external
{ name = "Roboto"
, url = "https://fonts.googleapis.com/css?family=Roboto"
}
, Font.sansSerif
]
]
(Element.text "Woohoo, I'm stylish text")
-}
external : { url : String, name : String } -> Font
external { url, name } =
Internal.ImportFont name url
{-| Font sizes are always given as `px`.
-}
size : Int -> Attr decorative msg
size i =
Internal.StyleClass Flag.fontSize (Internal.FontSize i)
{-| In `px`.
-}
letterSpacing : Float -> Attribute msg
letterSpacing offset =
Internal.StyleClass Flag.letterSpacing <|
Internal.Single
("ls-" ++ Internal.floatClass offset)
"letter-spacing"
(String.fromFloat offset ++ "px")
{-| In `px`.
-}
wordSpacing : Float -> Attribute msg
wordSpacing offset =
Internal.StyleClass Flag.wordSpacing <|
Internal.Single ("ws-" ++ Internal.floatClass offset) "word-spacing" (String.fromFloat offset ++ "px")
{-| Align the font to the left.
-}
alignLeft : Attribute msg
alignLeft =
Internal.Class Flag.fontAlignment classes.textLeft
{-| Align the font to the right.
-}
alignRight : Attribute msg
alignRight =
Internal.Class Flag.fontAlignment classes.textRight
{-| Center align the font.
-}
center : Attribute msg
center =
Internal.Class Flag.fontAlignment classes.textCenter
{-| -}
justify : Attribute msg
justify =
Internal.Class Flag.fontAlignment classes.textJustify
-- {-| -}
-- justifyAll : Attribute msg
-- justifyAll =
-- Internal.class classesTextJustifyAll
{-| -}
underline : Attribute msg
underline =
Internal.htmlClass classes.underline
{-| -}
strike : Attribute msg
strike =
Internal.htmlClass classes.strike
{-| -}
italic : Attribute msg
italic =
Internal.htmlClass classes.italic
{-| -}
bold : Attribute msg
bold =
Internal.Class Flag.fontWeight classes.bold
{-| -}
light : Attribute msg
light =
Internal.Class Flag.fontWeight classes.textLight
{-| -}
hairline : Attribute msg
hairline =
Internal.Class Flag.fontWeight classes.textThin
{-| -}
extraLight : Attribute msg
extraLight =
Internal.Class Flag.fontWeight classes.textExtraLight
{-| -}
regular : Attribute msg
regular =
Internal.Class Flag.fontWeight classes.textNormalWeight
{-| -}
semiBold : Attribute msg
semiBold =
Internal.Class Flag.fontWeight classes.textSemiBold
{-| -}
medium : Attribute msg
medium =
Internal.Class Flag.fontWeight classes.textMedium
{-| -}
extraBold : Attribute msg
extraBold =
Internal.Class Flag.fontWeight classes.textExtraBold
{-| -}
heavy : Attribute msg
heavy =
Internal.Class Flag.fontWeight classes.textHeavy
{-| This will reset bold and italic.
-}
unitalicized : Attribute msg
unitalicized =
Internal.htmlClass classes.textUnitalicized
{-| -}
shadow :
{ offset : ( Float, Float )
, blur : Float
, color : Color
}
-> Attr decorative msg
shadow shade =
Internal.StyleClass Flag.txtShadows <|
Internal.Single (Internal.textShadowClass shade) "text-shadow" (Internal.formatTextShadow shade)
{-| A glow is just a simplified shadow.
-}
glow : Color -> Float -> Attr decorative msg
glow clr i =
let
shade =
{ offset = ( 0, 0 )
, blur = i * 2
, color = clr
}
in
Internal.StyleClass Flag.txtShadows <|
Internal.Single (Internal.textShadowClass shade) "text-shadow" (Internal.formatTextShadow shade)
{- Variants -}
{-| -}
type alias Variant =
Internal.Variant
{-| You can use this to set a single variant on an element itself such as:
el
[ Font.variant Font.smallCaps
]
(text "rendered with smallCaps")
**Note** These will **not** stack. If you want multiple variants, you should use `Font.variantList`.
-}
variant : Variant -> Attribute msg
variant var =
case var of
Internal.VariantActive name ->
Internal.Class Flag.fontVariant ("v-" ++ name)
Internal.VariantOff name ->
Internal.Class Flag.fontVariant ("v-" ++ name ++ "-off")
Internal.VariantIndexed name index ->
Internal.StyleClass Flag.fontVariant <|
Internal.Single ("v-" ++ name ++ "-" ++ String.fromInt index)
"font-feature-settings"
("\"" ++ name ++ "\" " ++ String.fromInt index)
isSmallCaps x =
case x of
Internal.VariantActive feat ->
feat == "smcp"
_ ->
False
{-| -}
variantList : List Variant -> Attribute msg
variantList vars =
let
features =
vars
|> List.map Internal.renderVariant
hasSmallCaps =
List.any isSmallCaps vars
name =
if hasSmallCaps then
vars
|> List.map Internal.variantName
|> String.join "-"
|> (\x -> x ++ "-sc")
else
vars
|> List.map Internal.variantName
|> String.join "-"
featureString =
String.join ", " features
in
Internal.StyleClass Flag.fontVariant <|
Internal.Style ("v-" ++ name)
[ Internal.Property "font-feature-settings" featureString
, Internal.Property "font-variant"
(if hasSmallCaps then
"small-caps"
else
"normal"
)
]
{-| [Small caps](https://en.wikipedia.org/wiki/Small_caps) are rendered using uppercase glyphs, but at the size of lowercase glyphs.
-}
smallCaps : Variant
smallCaps =
Internal.VariantActive "smcp"
{-| Add a slash when rendering `0`
-}
slashedZero : Variant
slashedZero =
Internal.VariantActive "zero"
{-| -}
ligatures : Variant
ligatures =
Internal.VariantActive "liga"
{-| Oridinal markers like `1st` and `2nd` will receive special glyphs.
-}
ordinal : Variant
ordinal =
Internal.VariantActive "ordn"
{-| Number figures will each take up the same space, allowing them to be easily aligned, such as in tables.
-}
tabularNumbers : Variant
tabularNumbers =
Internal.VariantActive "tnum"
{-| Render fractions with the numerator stacked on top of the denominator.
-}
stackedFractions : Variant
stackedFractions =
Internal.VariantActive "afrc"
{-| Render fractions
-}
diagonalFractions : Variant
diagonalFractions =
Internal.VariantActive "frac"
{-| -}
swash : Int -> Variant
swash =
Internal.VariantIndexed "swsh"
{-| Set a feature by name and whether it should be on or off.
Feature names are four-letter names as defined in the [OpenType specification](https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist).
-}
feature : String -> Bool -> Variant
feature name on =
if on then
Internal.VariantIndexed name 1
else
Internal.VariantIndexed name 0
{-| A font variant might have multiple versions within the font.
In these cases we need to specify the index of the version we want.
-}
indexed : String -> Int -> Variant
indexed name on =
Internal.VariantIndexed name on

File diff suppressed because it is too large Load Diff

View File

@ -1,70 +0,0 @@
module Element.Keyed exposing (el, column, row)
{-| Notes from the `Html.Keyed` on how keyed works:
---
A keyed node helps optimize cases where children are getting added, moved, removed, etc. Common examples include:
- The user can delete items from a list.
- The user can create new items in a list.
- You can sort a list based on name or date or whatever.
When you use a keyed node, every child is paired with a string identifier. This makes it possible for the underlying diffing algorithm to reuse nodes more efficiently.
This means if a key is changed between renders, then the diffing step will be skipped and the node will be forced to rerender.
---
@docs el, column, row
-}
import Element exposing (Attribute, Element, fill, height, shrink, width)
import Internal.Model as Internal
import Internal.Style exposing (classes)
{-| -}
el : List (Attribute msg) -> ( String, Element msg ) -> Element msg
el attrs child =
Internal.element
Internal.asEl
Internal.div
(width shrink
:: height shrink
:: attrs
)
(Internal.Keyed [ child ])
{-| -}
row : List (Attribute msg) -> List ( String, Element msg ) -> Element msg
row attrs children =
Internal.element
Internal.asRow
Internal.div
(Internal.htmlClass (classes.contentLeft ++ " " ++ classes.contentCenterY)
:: width shrink
:: height shrink
:: attrs
)
(Internal.Keyed children)
{-| -}
column : List (Attribute msg) -> List ( String, Element msg ) -> Element msg
column attrs children =
Internal.element
Internal.asColumn
Internal.div
(Internal.htmlClass
(classes.contentTop
++ " "
++ classes.contentLeft
)
:: height shrink
:: width shrink
:: attrs
)
(Internal.Keyed children)

View File

@ -1,117 +0,0 @@
module Element.Lazy exposing (lazy, lazy2, lazy3, lazy4, lazy5)
{-| Same as `Html.lazy`. In case you're unfamiliar, here's a note from the `Html` library!
---
Since all Elm functions are pure we have a guarantee that the same input
will always result in the same output. This module gives us tools to be lazy
about building `Html` that utilize this fact.
Rather than immediately applying functions to their arguments, the `lazy`
functions just bundle the function and arguments up for later. When diffing
the old and new virtual DOM, it checks to see if all the arguments are equal
by reference. If so, it skips calling the function!
This is a really cheap test and often makes things a lot faster, but definitely
benchmark to be sure!
---
@docs lazy, lazy2, lazy3, lazy4, lazy5
-}
import Internal.Model exposing (..)
import VirtualDom
{-| -}
lazy : (a -> Element msg) -> a -> Element msg
lazy fn a =
Unstyled <| VirtualDom.lazy3 apply1 fn a
{-| -}
lazy2 : (a -> b -> Element msg) -> a -> b -> Element msg
lazy2 fn a b =
Unstyled <| VirtualDom.lazy4 apply2 fn a b
{-| -}
lazy3 : (a -> b -> c -> Element msg) -> a -> b -> c -> Element msg
lazy3 fn a b c =
Unstyled <| VirtualDom.lazy5 apply3 fn a b c
{-| -}
lazy4 : (a -> b -> c -> d -> Element msg) -> a -> b -> c -> d -> Element msg
lazy4 fn a b c d =
Unstyled <| VirtualDom.lazy6 apply4 fn a b c d
{-| -}
lazy5 : (a -> b -> c -> d -> e -> Element msg) -> a -> b -> c -> d -> e -> Element msg
lazy5 fn a b c d e =
Unstyled <| VirtualDom.lazy7 apply5 fn a b c d e
apply1 fn a =
embed (fn a)
apply2 fn a b =
embed (fn a b)
apply3 fn a b c =
embed (fn a b c)
apply4 fn a b c d =
embed (fn a b c d)
apply5 fn a b c d e =
embed (fn a b c d e)
{-| -}
embed : Element msg -> LayoutContext -> VirtualDom.Node msg
embed x =
case x of
Unstyled html ->
html
Styled styled ->
styled.html
(Internal.Model.OnlyDynamic
{ hover = AllowHover
, focus =
{ borderColor = Nothing
, shadow = Nothing
, backgroundColor = Nothing
}
, mode = Layout
}
styled.styles
)
-- -- (Just
-- -- (toStyleSheetString
-- { hover = AllowHover
-- , focus =
-- { borderColor = Nothing
-- , shadow = Nothing
-- , backgroundColor = Nothing
-- }
-- , mode = Layout
-- }
-- -- styled.styles
-- -- )
-- -- )
Text text ->
always (VirtualDom.text text)
Empty ->
always (VirtualDom.text "")

View File

@ -1,107 +0,0 @@
module Element.Region exposing
( mainContent, navigation, heading, aside, footer
, description
, announce, announceUrgently
)
{-| This module is meant to make accessibility easy!
These are sign posts that accessibility software like screen readers can use to navigate your app.
All you have to do is add them to elements in your app where you see fit.
Here's an example of annotating your navigation region:
import Element.Region as Region
myNavigation =
Element.row [ Region.navigation ]
[-- ..your navigation links
]
@docs mainContent, navigation, heading, aside, footer
@docs description
@docs announce, announceUrgently
-}
import Element exposing (Attribute)
import Internal.Model as Internal exposing (Description(..))
{-| -}
mainContent : Attribute msg
mainContent =
Internal.Describe Main
{-| -}
aside : Attribute msg
aside =
Internal.Describe Complementary
{-| -}
navigation : Attribute msg
navigation =
Internal.Describe Navigation
-- form : Attribute msg
-- form =
-- Internal.Describe Form
-- search : Attribute msg
-- search =
-- Internal.Describe Search
{-| -}
footer : Attribute msg
footer =
Internal.Describe ContentInfo
{-| This will mark an element as `h1`, `h2`, etc where possible.
Though it's also smart enough to not conflict with existing nodes.
So, this code
link [ Region.heading 1 ]
{ url = "http://fruits.com"
, label = text "Best site ever"
}
will generate
<a href="http://fruits.com">
<h1>Best site ever</h1>
</a>
-}
heading : Int -> Attribute msg
heading =
Internal.Describe << Heading
{-| Screen readers will announce changes to this element and potentially interrupt any other announcement.
-}
announceUrgently : Attribute msg
announceUrgently =
Internal.Describe LiveAssertive
{-| Screen readers will announce when changes to this element are made.
-}
announce : Attribute msg
announce =
Internal.Describe LivePolite
{-| -}
description : String -> Attribute msg
description =
Internal.Describe << Internal.Label

View File

@ -1,325 +0,0 @@
module Internal.Flag exposing
( Field(..)
, Flag(..)
, active
, add
, alignBottom
, alignRight
, behind
, bgColor
, bgGradient
, bgImage
, borderColor
, borderRound
, borderStyle
, borderWidth
, centerX
, centerY
, cursor
, flag
, focus
, fontAlignment
, fontColor
, fontFamily
, fontSize
, fontVariant
, fontWeight
, gridPosition
, gridTemplate
, height
, heightBetween
, heightContent
, heightFill
, heightTextAreaContent
, hover
, letterSpacing
, merge
, moveX
, moveY
, none
, overflow
, padding
, present
, rotate
, scale
, shadows
, spacing
, transparency
, txtShadows
, value
, width
, widthBetween
, widthContent
, widthFill
, wordSpacing
, xAlign
, yAlign
)
{-| -}
import Bitwise
type Field
= Field Int Int
type Flag
= Flag Int
| Second Int
none : Field
none =
Field 0 0
value myFlag =
case myFlag of
Flag first ->
round (logBase 2 (toFloat first))
Second second ->
round (logBase 2 (toFloat second)) + 32
{-| If the query is in the truth, return True
-}
present : Flag -> Field -> Bool
present myFlag (Field fieldOne fieldTwo) =
case myFlag of
Flag first ->
Bitwise.and first fieldOne == first
Second second ->
Bitwise.and second fieldTwo == second
{-| Add a flag to a field.
-}
add : Flag -> Field -> Field
add myFlag (Field one two) =
case myFlag of
Flag first ->
Field (Bitwise.or first one) two
Second second ->
Field one (Bitwise.or second two)
{-| Generally you want to use `add`, which keeps a distinction between Fields and Flags.
Merging will combine two fields
-}
merge : Field -> Field -> Field
merge (Field one two) (Field three four) =
Field (Bitwise.or one three) (Bitwise.or two four)
flag : Int -> Flag
flag i =
if i > 31 then
Second
(Bitwise.shiftLeftBy (i - 32) 1)
else
Flag
(Bitwise.shiftLeftBy i 1)
{- Used for Style invalidation -}
transparency =
flag 0
padding =
flag 2
spacing =
flag 3
fontSize =
flag 4
fontFamily =
flag 5
width =
flag 6
height =
flag 7
bgColor =
flag 8
bgImage =
flag 9
bgGradient =
flag 10
borderStyle =
flag 11
fontAlignment =
flag 12
fontWeight =
flag 13
fontColor =
flag 14
wordSpacing =
flag 15
letterSpacing =
flag 16
borderRound =
flag 17
txtShadows =
flag 18
shadows =
flag 19
overflow =
flag 20
cursor =
flag 21
scale =
flag 23
rotate =
flag 24
moveX =
flag 25
moveY =
flag 26
borderWidth =
flag 27
borderColor =
flag 28
yAlign =
flag 29
xAlign =
flag 30
focus =
flag 31
active =
flag 32
hover =
flag 33
gridTemplate =
flag 34
gridPosition =
flag 35
{- Notes -}
heightContent =
flag 36
heightFill =
flag 37
widthContent =
flag 38
widthFill =
flag 39
alignRight =
flag 40
alignBottom =
flag 41
centerX =
flag 42
centerY =
flag 43
widthBetween =
flag 44
heightBetween =
flag 45
behind =
flag 46
heightTextAreaContent =
flag 47
fontVariant =
flag 48

View File

@ -1,270 +0,0 @@
module Internal.Grid exposing (Around, Layout(..), PositionedElement, RelativePosition(..), build, createGrid, getWidth, relative)
{-| Relative positioning within a grid.
A relatively positioned grid, means a 3x3 grid with the primary element in the center.
-}
import Element
import Internal.Flag as Flag
import Internal.Model as Internal
type RelativePosition
= OnRight
| OnLeft
| Above
| Below
| InFront
type Layout
= GridElement
| Row
| Column
type alias Around alignment msg =
{ right : Maybe (PositionedElement alignment msg)
, left : Maybe (PositionedElement alignment msg)
, primary : ( Maybe String, List (Internal.Attribute alignment msg), List (Internal.Element msg) )
-- , primaryWidth : Internal.Length
, defaultWidth : Internal.Length
, below : Maybe (PositionedElement alignment msg)
, above : Maybe (PositionedElement alignment msg)
, inFront : Maybe (PositionedElement alignment msg)
}
type alias PositionedElement alignment msg =
{ layout : Layout
, child : List (Internal.Element msg)
, attrs : List (Internal.Attribute alignment msg)
, width : Int
, height : Int
}
relative : Maybe String -> List (Internal.Attribute alignment msg) -> Around alignment msg -> Internal.Element msg
relative node attributes around =
let
( sX, sY ) =
Internal.getSpacing attributes ( 7, 7 )
make positioned =
Internal.element Internal.noStyleSheet
Internal.asEl
Nothing
positioned.attrs
(Internal.Unkeyed positioned.child)
( template, children ) =
createGrid ( sX, sY ) around
in
Internal.element Internal.noStyleSheet
Internal.asGrid
node
(template ++ attributes)
(Internal.Unkeyed
children
)
createGrid : ( Int, Int ) -> Around alignment msg -> ( List (Internal.Attribute alignment msg1), List (Element.Element msg) )
createGrid ( spacingX, spacingY ) nearby =
let
rowCount =
List.sum
[ 1
, if Nothing == nearby.above then
0
else
1
, if Nothing == nearby.below then
0
else
1
]
colCount =
List.sum
[ 1
, if Nothing == nearby.left then
0
else
1
, if Nothing == nearby.right then
0
else
1
]
rows =
if nearby.above == Nothing then
{ above = 0
, primary = 1
, below = 2
}
else
{ above = 1
, primary = 2
, below = 3
}
columns =
if Nothing == nearby.left then
{ left = 0
, primary = 1
, right = 2
}
else
{ left = 1
, primary = 2
, right = 3
}
rowCoord pos =
case pos of
Above ->
rows.above
Below ->
rows.below
OnRight ->
rows.primary
OnLeft ->
rows.primary
InFront ->
rows.primary
colCoord pos =
case pos of
Above ->
columns.primary
Below ->
columns.primary
OnRight ->
columns.right
OnLeft ->
columns.left
InFront ->
columns.primary
place pos el =
build (rowCoord pos) (colCoord pos) spacingX spacingY el
in
( [ Internal.StyleClass Flag.gridTemplate
(Internal.GridTemplateStyle
{ spacing = ( Internal.Px spacingX, Internal.Px spacingY )
, columns =
List.filterMap identity
[ nearby.left
|> Maybe.map (\el -> Maybe.withDefault nearby.defaultWidth (getWidth el.attrs))
, nearby.primary
|> (\( node, attrs, el ) -> getWidth attrs)
|> Maybe.withDefault nearby.defaultWidth
|> Just
, nearby.right
|> Maybe.map (\el -> Maybe.withDefault nearby.defaultWidth (getWidth el.attrs))
]
, rows = List.map (always Internal.Content) (List.range 1 rowCount)
}
)
]
, List.filterMap identity
[ Just <|
case nearby.primary of
( primaryNode, primaryAttrs, primaryChildren ) ->
Internal.element Internal.noStyleSheet
Internal.asEl
primaryNode
(Internal.StyleClass Flag.gridPosition
(Internal.GridPosition
{ row = rows.primary
, col = columns.primary
, width = 1
, height = 1
}
)
:: primaryAttrs
)
(Internal.Unkeyed primaryChildren)
, Maybe.map (place OnLeft) nearby.left
, Maybe.map (place OnRight) nearby.right
, Maybe.map (place Above) nearby.above
, Maybe.map (place Below) nearby.below
, Maybe.map (place InFront) nearby.inFront
]
)
build : Int -> Int -> Int -> Int -> { a | attrs : List (Internal.Attribute alignment msg), height : Int, layout : Layout, width : Int, child : List (Internal.Element msg) } -> Internal.Element msg
build rowCoord colCoord spacingX spacingY positioned =
let
attributes =
Internal.StyleClass Flag.gridPosition
(Internal.GridPosition
{ row = rowCoord
, col = colCoord
, width = positioned.width
, height = positioned.height
}
)
:: Internal.StyleClass Flag.spacing (Internal.SpacingStyle spacingX spacingY)
:: positioned.attrs
in
case positioned.layout of
GridElement ->
Internal.element Internal.noStyleSheet
Internal.asEl
Nothing
attributes
(Internal.Unkeyed <| positioned.child)
Row ->
Internal.element Internal.noStyleSheet
Internal.asRow
Nothing
attributes
(Internal.Unkeyed positioned.child)
Column ->
Internal.element Internal.noStyleSheet
Internal.asColumn
Nothing
attributes
(Internal.Unkeyed positioned.child)
getWidth : List (Internal.Attribute align msg) -> Maybe Internal.Length
getWidth attrs =
let
widthPlease attr found =
case found of
Just x ->
Just x
Nothing ->
case attr of
Internal.Width w ->
Just w
_ ->
Nothing
in
List.foldr widthPlease Nothing attrs

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff