add elm-ui 1.x example

This commit is contained in:
mdgriffith 2020-08-03 22:37:45 -04:00
parent 5adb67ee53
commit 502356c482
4 changed files with 125 additions and 0 deletions

51
testcases/elm-ui/Main.elm Normal file
View File

@ -0,0 +1,51 @@
port module Main exposing (main)
{-| -}
import Benchmark exposing (..)
import Benchmark.Runner exposing (BenchmarkProgram, program)
import Benchmark.Runner.Json
import Element exposing (..)
import Element.Background as Background
import Element.Font as Font
import Html
import Html.Attributes as Attr
import Json.Encode
main : Benchmark.Runner.Json.JsonBenchmark
main =
Benchmark.Runner.Json.program reportResults suite
port reportResults : Json.Encode.Value -> Cmd msg
three =
List.repeat 3 0
suite : Benchmark
suite =
describe "Elm UI"
[ benchmark "create a 4 level nested Elm UI tree" <|
\_ ->
Element.layout []
(Element.column [] (List.map (viewLevels 4) three))
]
blue =
rgb 0 0 1
viewLevels level _ =
if level == 0 then
none
else
Element.row
[ Font.size 16
, Background.color blue
]
(List.map (viewLevels (level - 1)) three)

31
testcases/elm-ui/elm.json Normal file
View File

@ -0,0 +1,31 @@
{
"type": "application",
"source-directories": [
".",
"../benchmark-utilities"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"BrianHicks/elm-trend": "2.1.3",
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0",
"elm/json": "1.1.3",
"elm-explorations/benchmark": "1.0.1",
"mdgriffith/elm-ui": "1.1.8"
},
"indirect": {
"Skinney/murmur3": "2.0.8",
"elm/regex": "1.0.0",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.2",
"mdgriffith/style-elements": "5.0.1"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}

View File

@ -0,0 +1,22 @@
<html>
<head>
<meta charset="UTF-8" />
<title>Main</title>
<script src="output/elm.opt.js"></script>
</head>
<body>
<div id="myapp"></div>
<script>
var app = Elm.Main.init({
node: document.getElementById('myapp'),
});
window.results = [];
app.ports.reportResults.subscribe(function(message) {
window.results = message;
document.title = 'done';
});
</script>
</body>
</html>

View File

@ -0,0 +1,21 @@
<html>
<head>
<meta charset="UTF-8" />
<title>Main</title>
<script src="output/elm.opt.transformed.js"></script>
</head>
<body>
<div id="myapp"></div>
<script>
var app = Elm.Main.init({
node: document.getElementById('myapp'),
});
window.results = [];
app.ports.reportResults.subscribe(function(message) {
window.results = message;
document.title = 'done';
});
</script>
</body>
</html>