Skip to content

Commit

Permalink
Import SSCCE from comment
Browse files Browse the repository at this point in the history
The code in 'src/Main.elm' is taken verbatim from pravdomil's comment 'elm/virtual-dom#178 (comment)'.
  • Loading branch information
bisgardo committed Sep 21, 2022
0 parents commit ed94a72
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
elm-stuff
dist
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
set -eux
elm make ./src/Main.elm --output=./dist/main.js
24 changes: 24 additions & 0 deletions elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0"
},
"indirect": {
"elm/json": "1.1.3",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.3"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<script src="./dist/main.js"></script>
</head>
<body>
<div id="app"></div>
<script>Elm.Main.init({node: document.getElementById('app')})</script>
</body>
</html>
47 changes: 47 additions & 0 deletions src/Main.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module Main exposing (..)

import Browser
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Html.Keyed


main : Program () Bool ()
main =
Browser.sandbox
{ init = False
, view = view
, update = always not
}


view : Bool -> Html ()
view model =
div []
[ Html.Keyed.node "div"
[]
([ input_ "A"
, input_ "B"
]
|> (\x ->
if model then
List.reverse x

else
x
)
)
, text "Type to swaps inputs."
]


input_ a =
( a
, input
[ id a
, value a
, onInput (\_ -> ())
]
[]
)

0 comments on commit ed94a72

Please sign in to comment.