mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
initial elm app
This commit is contained in:
parent
6496c52336
commit
4cd2717a45
5 changed files with 156 additions and 0 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -59,3 +59,6 @@ tags
|
|||
rever/
|
||||
# Allow the lib
|
||||
!/xonsh/lib
|
||||
|
||||
# elm
|
||||
xonsh/webconfig/elm-stuff/
|
43
xonsh/webconfig/elm-compile.xsh
Executable file
43
xonsh/webconfig/elm-compile.xsh
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env xonsh
|
||||
"""script for compiling elm source and dumping it to the js folder."""
|
||||
import os
|
||||
from xonsh.tools import print_color
|
||||
|
||||
|
||||
SOURCES = [
|
||||
'App.elm',
|
||||
]
|
||||
$RAISE_SUBPROC_ERROR = True
|
||||
$XONSH_SHOW_TRACEBACK = False
|
||||
with ${...}.swap(RAISE_SUBPROC_ERROR=False):
|
||||
HAVE_UGLIFY = bool(!(which uglifyjs e>o))
|
||||
|
||||
UGLIFY_FLAGS = ('pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",'
|
||||
'pure_getters,keep_fargs=false,unsafe_comps,unsafe')
|
||||
|
||||
|
||||
for source in SOURCES:
|
||||
base = os.path.splitext(source.lower())[0]
|
||||
src = os.path.join('elm-src', source)
|
||||
js_target = os.path.join('js', base + '.js')
|
||||
print_color('Compiling {YELLOW}' + src + '{NO_COLOR} -> {GREEN}' +
|
||||
js_target + '{NO_COLOR}')
|
||||
$XONSH_SHOW_TRACEBACK = False
|
||||
try:
|
||||
![elm make --optimize --output @(js_target) @(src)]
|
||||
except Exception:
|
||||
import sys
|
||||
sys.exit(1)
|
||||
new_files = [js_target]
|
||||
min_target = os.path.join('js', base + '.min.js')
|
||||
if os.path.exists(min_target):
|
||||
![rm -v @(min_target)]
|
||||
if HAVE_UGLIFY:
|
||||
print_color('Minifying {YELLOW}' + js_target + '{NO_COLOR} -> {GREEN}' +
|
||||
min_target + '{NO_COLOR}')
|
||||
![uglifyjs @(js_target) --compress @(UGLIFY_FLAGS) |
|
||||
uglifyjs --mangle --output @(min_target)]
|
||||
new_files.append(min_target)
|
||||
![ls -l @(new_files)]
|
||||
|
||||
|
58
xonsh/webconfig/elm-src/App.elm
Normal file
58
xonsh/webconfig/elm-src/App.elm
Normal file
|
@ -0,0 +1,58 @@
|
|||
module Main exposing (main)
|
||||
|
||||
import Html exposing (..)
|
||||
import Bootstrap.Tab as Tab
|
||||
import Bootstrap.CDN as CDN
|
||||
import Bootstrap.Grid as Grid
|
||||
|
||||
-- example with animation, you can drop the subscription part when not using animations
|
||||
type alias Model =
|
||||
{ tabState : Tab.State }
|
||||
|
||||
init : ( Model, Cmd Msg )
|
||||
init =
|
||||
( { tabState = Tab.initialState }, Cmd.none )
|
||||
|
||||
type Msg
|
||||
= TabMsg Tab.State
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
TabMsg state ->
|
||||
( { model | tabState = state }
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
view : Model -> Html msg
|
||||
view model =
|
||||
Tab.config TabMsg
|
||||
--|> Tab.withAnimation
|
||||
-- remember to wire up subscriptions when using this option
|
||||
|> Tab.right
|
||||
|> Tab.items
|
||||
[ Tab.item
|
||||
{ id = "tabItem1"
|
||||
, link = Tab.link [] [ text "Tab 1" ]
|
||||
, pane = Tab.pane [] [ text "Tab 1 Content" ]
|
||||
}
|
||||
, Tab.item
|
||||
{ id = "tabItem2"
|
||||
, link = Tab.link [] [ text "Tab 2" ]
|
||||
, pane = Tab.pane [] [ text "Tab 2 Content" ]
|
||||
}
|
||||
]
|
||||
|> Tab.view model.tabState
|
||||
|
||||
--main =
|
||||
-- Grid.container []
|
||||
-- [ CDN.stylesheet -- creates an inline style node with the Bootstrap CSS
|
||||
-- , view
|
||||
--Grid.row []
|
||||
-- [ Grid.col []
|
||||
-- [ text "Some content for my view here..."]
|
||||
-- , Grid.col [] [view tabState]
|
||||
-- ]
|
||||
-- ]
|
||||
|
||||
main = view
|
29
xonsh/webconfig/elm.json
Normal file
29
xonsh/webconfig/elm.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"type": "application",
|
||||
"source-directories": [
|
||||
"elm-src"
|
||||
],
|
||||
"elm-version": "0.19.0",
|
||||
"dependencies": {
|
||||
"direct": {
|
||||
"rundis/elm-bootstrap": "5.2.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.2",
|
||||
"elm/url": "1.0.0"
|
||||
},
|
||||
"indirect": {
|
||||
"avh4/elm-color": "1.0.0",
|
||||
"elm/bytes": "1.0.7",
|
||||
"elm/file": "1.0.3",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/virtual-dom": "1.0.2"
|
||||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
"direct": {},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
23
xonsh/webconfig/index.html
Normal file
23
xonsh/webconfig/index.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Xonsh Web Config</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
<script src="js/app.js"></script>
|
||||
<!--
|
||||
<link rel="stylesheet" href="css/theme.css">
|
||||
<script src="js/app.min.js"></script>
|
||||
-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="elm"></div>
|
||||
<script>
|
||||
var app = Elm.Main.init({
|
||||
node: document.getElementById('elm')
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Reference in a new issue