mirror of
https://github.com/Orasund/elm-ui-widgets.git
synced 2024-10-05 18:17:20 +03:00
explorer: save the dark mode current setting in localstorage
This commit is contained in:
parent
bfc6df731a
commit
8eacde7e29
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,3 +2,5 @@
|
|||||||
elm-stuff
|
elm-stuff
|
||||||
# elm-repl generated files
|
# elm-repl generated files
|
||||||
repl-temp-*
|
repl-temp-*
|
||||||
|
# elm-live && build generated file
|
||||||
|
explorer/main.js
|
||||||
|
3
build-doc.sh
Normal file
3
build-doc.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
(cd explorer && elm make src/Main.elm --optimize --output main.js) &&
|
||||||
|
cp explorer/main.js docs/ &&
|
||||||
|
cp explorer/main.js docs/3.0.0
|
@ -1,50 +1,20 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Main</title>
|
<title>Main</title>
|
||||||
<script src="main.js"></script>
|
<style>body { padding: 0; margin: 0; }</style>
|
||||||
<style>
|
<script src="/3.0.0/main.js"></script>
|
||||||
body {
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="elm"></div>
|
<script>
|
||||||
|
(function(){
|
||||||
<!-- Start Single Page Apps for GitHub Pages -->
|
var settings = localStorage.getItem("settings");
|
||||||
<script type="text/javascript">
|
const app = Elm.Main.init({flags: { relativePath : "elm-ui-widgets/3.0.0", settings: settings } });
|
||||||
// Single Page Apps for GitHub Pages
|
app.ports.saveSettings.subscribe(function(settings){
|
||||||
// MIT License
|
localStorage.setItem("settings", settings);
|
||||||
// https://github.com/rafgraph/spa-github-pages
|
});
|
||||||
// This script checks to see if a redirect is present in the query string,
|
}());
|
||||||
// converts it back into the correct url and adds it to the
|
</script>
|
||||||
// browser's history using window.history.replaceState(...),
|
|
||||||
// which won't cause the browser to attempt to load the new url.
|
|
||||||
// When the single page app is loaded further down in this file,
|
|
||||||
// the correct url will be waiting in the browser's history for
|
|
||||||
// the single page app to route accordingly.
|
|
||||||
(function (l) {
|
|
||||||
if (l.search[1] === '/') {
|
|
||||||
var decoded = l.search.slice(1).split('&').map(function (s) {
|
|
||||||
return s.replace(/~and~/g, '&')
|
|
||||||
}).join('?');
|
|
||||||
window.history.replaceState(null, null,
|
|
||||||
l.pathname.slice(0, -1) + decoded + l.hash
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}(window.location))
|
|
||||||
</script>
|
|
||||||
<!-- End Single Page Apps for GitHub Pages -->
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var app = Elm.Main.init({
|
|
||||||
node: document.getElementById('elm')
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
</html>
|
||||||
</html>
|
|
||||||
|
8007
docs/3.0.0/main.js
8007
docs/3.0.0/main.js
File diff suppressed because it is too large
Load Diff
@ -1,50 +1,26 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Main</title>
|
<title>Main</title>
|
||||||
<script src="main.js"></script>
|
<style>body { padding: 0; margin: 0; }</style>
|
||||||
<style>
|
<script src="/main.js"></script>
|
||||||
body {
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="elm"></div>
|
<script>
|
||||||
|
(function(){
|
||||||
<!-- Start Single Page Apps for GitHub Pages -->
|
var settings = localStorage.getItem("settings");
|
||||||
<script type="text/javascript">
|
const app = Elm.Main.init({
|
||||||
// Single Page Apps for GitHub Pages
|
flags: {
|
||||||
// MIT License
|
settings: settings,
|
||||||
// https://github.com/rafgraph/spa-github-pages
|
config: { relativeUrlPath: ["elm-ui-widgets"] }
|
||||||
// This script checks to see if a redirect is present in the query string,
|
}
|
||||||
// converts it back into the correct url and adds it to the
|
});
|
||||||
// browser's history using window.history.replaceState(...),
|
app.ports.saveSettings.subscribe(function(settings){
|
||||||
// which won't cause the browser to attempt to load the new url.
|
localStorage.setItem("settings", settings);
|
||||||
// When the single page app is loaded further down in this file,
|
});
|
||||||
// the correct url will be waiting in the browser's history for
|
}());
|
||||||
// the single page app to route accordingly.
|
</script>
|
||||||
(function (l) {
|
|
||||||
if (l.search[1] === '/') {
|
|
||||||
var decoded = l.search.slice(1).split('&').map(function (s) {
|
|
||||||
return s.replace(/~and~/g, '&')
|
|
||||||
}).join('?');
|
|
||||||
window.history.replaceState(null, null,
|
|
||||||
l.pathname.slice(0, -1) + decoded + l.hash
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}(window.location))
|
|
||||||
</script>
|
|
||||||
<!-- End Single Page Apps for GitHub Pages -->
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var app = Elm.Main.init({
|
|
||||||
node: document.getElementById('elm')
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
</html>
|
||||||
</html>
|
|
||||||
|
8007
docs/main.js
8007
docs/main.js
File diff suppressed because it is too large
Load Diff
21
explorer/index.html
Normal file
21
explorer/index.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Main</title>
|
||||||
|
<style>body { padding: 0; margin: 0; }</style>
|
||||||
|
<script src="/main.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
(function(){
|
||||||
|
var settings = localStorage.getItem("settings");
|
||||||
|
const app = Elm.Main.init({flags: { settings: settings } });
|
||||||
|
app.ports.saveSettings.subscribe(function(settings){
|
||||||
|
localStorage.setItem("settings", settings);
|
||||||
|
});
|
||||||
|
}());
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,6 +1,7 @@
|
|||||||
module Main exposing (main)
|
module Main exposing (main)
|
||||||
|
|
||||||
import Element
|
import Element
|
||||||
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
import Page.AppBar
|
import Page.AppBar
|
||||||
import Page.Button
|
import Page.Button
|
||||||
import Page.Dialog
|
import Page.Dialog
|
||||||
@ -37,13 +38,26 @@ pages =
|
|||||||
|> UIExplorer.nextPage "Dialog" Page.Dialog.page
|
|> UIExplorer.nextPage "Dialog" Page.Dialog.page
|
||||||
|
|
||||||
|
|
||||||
|
type alias Flags =
|
||||||
|
{ settings : UIExplorer.Settings
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
decodeFlags : Decoder Flags
|
||||||
|
decodeFlags =
|
||||||
|
Decode.map Flags
|
||||||
|
(Decode.field "settings" UIExplorer.decodeSettings)
|
||||||
|
|
||||||
|
|
||||||
|
config : UIExplorer.ApplicationConfig msg Flags
|
||||||
|
config =
|
||||||
|
{ flagsDecoder = decodeFlags
|
||||||
|
, layoutOptions = []
|
||||||
|
, layoutAttributes = []
|
||||||
|
, relativeUrlPath = [ "elm-ui-widgets" ]
|
||||||
|
, sidebarTitle = Element.text "Elm UI Widgets"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
main =
|
main =
|
||||||
let
|
UIExplorer.application config pages
|
||||||
config =
|
|
||||||
UIExplorer.defaultConfig
|
|
||||||
in
|
|
||||||
UIExplorer.application
|
|
||||||
{ config
|
|
||||||
| sidebarTitle = Element.text "Elm UI Widgets"
|
|
||||||
}
|
|
||||||
pages
|
|
||||||
|
@ -16,10 +16,10 @@ import Widget.Material.Typography as Typography
|
|||||||
create :
|
create :
|
||||||
{ title : String
|
{ title : String
|
||||||
, description : String
|
, description : String
|
||||||
, book : Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
, book : Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
, demo : Tile model msg ()
|
, demo : Tile model msg flags
|
||||||
}
|
}
|
||||||
-> Page ( ( ( (), () ), model ), ( StorySelectorModel, () ) ) (TileMsg (TileMsg (TileMsg () msg1) msg) (TileMsg StorySelectorMsg ())) ()
|
-> Page ( ( ( (), () ), model ), ( StorySelectorModel, () ) ) (TileMsg (TileMsg (TileMsg () msg1) msg) (TileMsg StorySelectorMsg ())) flags
|
||||||
create config =
|
create config =
|
||||||
Tile.static []
|
Tile.static []
|
||||||
(\_ _ ->
|
(\_ _ ->
|
||||||
|
@ -101,7 +101,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
@ -489,7 +489,7 @@ view { palette } { snackbar, searchText, selected, showDialog, active } =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -81,7 +81,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
@ -273,7 +273,7 @@ view { palette } model =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -59,7 +59,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
@ -190,7 +190,7 @@ view { palette } (IsOpen isOpen) =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -135,7 +135,7 @@ view { palette } () =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -62,7 +62,7 @@ viewDividerFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
dividerBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
dividerBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
dividerBook =
|
dividerBook =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewDividerFunctions
|
viewDividerFunctions
|
||||||
@ -116,7 +116,7 @@ viewHeaderFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
headerBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
headerBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
headerBook =
|
headerBook =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewHeaderFunctions
|
viewHeaderFunctions
|
||||||
@ -170,7 +170,7 @@ viewFullBleedItemFunctions =
|
|||||||
Story.initStaticTiles
|
Story.initStaticTiles
|
||||||
|
|
||||||
|
|
||||||
fullBleedItemBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
fullBleedItemBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
fullBleedItemBook =
|
fullBleedItemBook =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFullBleedItemFunctions
|
viewFullBleedItemFunctions
|
||||||
@ -239,7 +239,7 @@ viewInsetItemFunctions =
|
|||||||
Story.initStaticTiles
|
Story.initStaticTiles
|
||||||
|
|
||||||
|
|
||||||
insetItemBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
insetItemBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
insetItemBook =
|
insetItemBook =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewInsetItemFunctions
|
viewInsetItemFunctions
|
||||||
@ -319,7 +319,7 @@ viewMultiLineItemFunctions =
|
|||||||
Story.initStaticTiles
|
Story.initStaticTiles
|
||||||
|
|
||||||
|
|
||||||
multiLineItemBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
multiLineItemBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
multiLineItemBook =
|
multiLineItemBook =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewMultiLineItemFunctions
|
viewMultiLineItemFunctions
|
||||||
@ -422,7 +422,7 @@ viewMExpansionItemFunctions =
|
|||||||
Story.initStaticTiles
|
Story.initStaticTiles
|
||||||
|
|
||||||
|
|
||||||
expansionItemBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
expansionItemBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
expansionItemBook =
|
expansionItemBook =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewMExpansionItemFunctions
|
viewMExpansionItemFunctions
|
||||||
@ -479,7 +479,7 @@ viewSelectItemFunctions =
|
|||||||
Story.initStaticTiles
|
Story.initStaticTiles
|
||||||
|
|
||||||
|
|
||||||
selectItemBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
selectItemBook : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
selectItemBook =
|
selectItemBook =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewSelectItemFunctions
|
viewSelectItemFunctions
|
||||||
@ -740,7 +740,7 @@ view { palette } model =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -126,7 +126,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
@ -257,7 +257,7 @@ view { palette } (IsEnabled isEnabled) =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -105,7 +105,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
@ -233,7 +233,7 @@ view { palette } (Selected selected) =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -171,7 +171,7 @@ view { palette } model =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -44,7 +44,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
@ -118,7 +118,7 @@ view { palette } (MaybeProgress maybeProgress) =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -92,7 +92,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
|
@ -53,7 +53,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
@ -198,7 +198,7 @@ view { palette } model =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -49,7 +49,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
@ -225,7 +225,7 @@ view { palette } model =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -47,7 +47,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
@ -134,7 +134,7 @@ view { palette } (IsButtonEnabled isButtonEnabled) =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -67,7 +67,7 @@ viewFunctions =
|
|||||||
{-| Let's you play around with the options.
|
{-| Let's you play around with the options.
|
||||||
Note that the order of these stories must follow the order of the arguments from the view functions.
|
Note that the order of these stories must follow the order of the arguments from the view functions.
|
||||||
-}
|
-}
|
||||||
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) ()
|
book : Tile.Group ( StorySelectorModel, () ) (TileMsg StorySelectorMsg ()) flags
|
||||||
book =
|
book =
|
||||||
Story.book (Just "Options")
|
Story.book (Just "Options")
|
||||||
viewFunctions
|
viewFunctions
|
||||||
@ -190,7 +190,7 @@ view { palette } (Selected selected) =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
@ -192,7 +192,7 @@ view { palette } model =
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
demo : Tile Model Msg ()
|
demo : Tile Model Msg flags
|
||||||
demo =
|
demo =
|
||||||
{ init = always init
|
{ init = always init
|
||||||
, update = update
|
, update = update
|
||||||
|
6
explorer/src/Ports.elm
Normal file
6
explorer/src/Ports.elm
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
port module Ports exposing (saveSettings)
|
||||||
|
|
||||||
|
import Json.Encode
|
||||||
|
|
||||||
|
|
||||||
|
port saveSettings : String -> Cmd msg
|
@ -1,6 +1,7 @@
|
|||||||
module UIExplorer exposing
|
module UIExplorer exposing
|
||||||
( application, defaultConfig, ApplicationConfig, Model, Msg, PageMsg
|
( application, defaultConfig, ApplicationConfig, Model, Msg, PageMsg
|
||||||
, firstPage, nextPage, groupPages, static, Page, PageSize, PageBuilder
|
, firstPage, nextPage, groupPages, static, Page, PageSize, PageBuilder
|
||||||
|
, Settings, decodeSettings
|
||||||
)
|
)
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
@ -43,7 +44,9 @@ import Element.Region
|
|||||||
import Html exposing (Html)
|
import Html exposing (Html)
|
||||||
import Html.Attributes
|
import Html.Attributes
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
|
import Json.Encode as Encode
|
||||||
import Pixels exposing (Pixels)
|
import Pixels exposing (Pixels)
|
||||||
|
import Ports
|
||||||
import Quantity exposing (Quantity)
|
import Quantity exposing (Quantity)
|
||||||
import Set exposing (Set)
|
import Set exposing (Set)
|
||||||
import Svg
|
import Svg
|
||||||
@ -58,6 +61,41 @@ import Widget.Material as Material
|
|||||||
import Widget.Material.Typography as Typography
|
import Widget.Material.Typography as Typography
|
||||||
|
|
||||||
|
|
||||||
|
{-| The Settings. Must be the type of the 'settings' attribute of the flags
|
||||||
|
-}
|
||||||
|
type alias Settings =
|
||||||
|
{ dark : Bool }
|
||||||
|
|
||||||
|
|
||||||
|
decodeSettings : Decode.Decoder Settings
|
||||||
|
decodeSettings =
|
||||||
|
Decode.string
|
||||||
|
|> Decode.andThen
|
||||||
|
(\s ->
|
||||||
|
case
|
||||||
|
Decode.decodeString
|
||||||
|
(Decode.map Settings
|
||||||
|
(Decode.field "dark" Decode.bool)
|
||||||
|
)
|
||||||
|
s
|
||||||
|
of
|
||||||
|
Ok settings ->
|
||||||
|
Decode.succeed settings
|
||||||
|
|
||||||
|
Err _ ->
|
||||||
|
Decode.succeed { dark = False }
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
saveSettings : Settings -> Cmd msg
|
||||||
|
saveSettings settings =
|
||||||
|
Encode.object
|
||||||
|
[ ( "dark", Encode.bool settings.dark )
|
||||||
|
]
|
||||||
|
|> Encode.encode 0
|
||||||
|
|> Ports.saveSettings
|
||||||
|
|
||||||
|
|
||||||
{-| The first page in your UI explorer. This is the default page if the user doesn't specify a url path.
|
{-| The first page in your UI explorer. This is the default page if the user doesn't specify a url path.
|
||||||
|
|
||||||
import Element
|
import Element
|
||||||
@ -421,12 +459,12 @@ uiUrl path pageId =
|
|||||||
|
|
||||||
|
|
||||||
init :
|
init :
|
||||||
ApplicationConfig (Msg pageMsg) flags
|
ApplicationConfig (Msg pageMsg) { flags | settings : Settings }
|
||||||
-> PageBuilder pageModel pageMsg flags
|
-> PageBuilder pageModel pageMsg { flags | settings : Settings }
|
||||||
-> Decode.Value
|
-> Decode.Value
|
||||||
-> Url
|
-> Url
|
||||||
-> Browser.Navigation.Key
|
-> Browser.Navigation.Key
|
||||||
-> ( Model pageModel flags, Cmd (Msg pageMsg) )
|
-> ( Model pageModel { flags | settings : Settings }, Cmd (Msg pageMsg) )
|
||||||
init config (PageBuilder pages) flagsJson url key =
|
init config (PageBuilder pages) flagsJson url key =
|
||||||
let
|
let
|
||||||
( page, navigationCmd ) =
|
( page, navigationCmd ) =
|
||||||
@ -453,7 +491,7 @@ init config (PageBuilder pages) flagsJson url key =
|
|||||||
, pageSizeOption = Native
|
, pageSizeOption = Native
|
||||||
, expandColorBlindOptions = False
|
, expandColorBlindOptions = False
|
||||||
, colorBlindOption = Nothing
|
, colorBlindOption = Nothing
|
||||||
, darkThemeEnabled = False
|
, darkThemeEnabled = flags.settings.dark
|
||||||
}
|
}
|
||||||
, Cmd.batch
|
, Cmd.batch
|
||||||
[ navigationCmd
|
[ navigationCmd
|
||||||
@ -622,7 +660,7 @@ updateSuccess (PageBuilder pages) config msg model =
|
|||||||
)
|
)
|
||||||
|
|
||||||
ChangeDarkTheme enabled ->
|
ChangeDarkTheme enabled ->
|
||||||
( { model | darkThemeEnabled = enabled }, Cmd.none )
|
( { model | darkThemeEnabled = enabled }, saveSettings { dark = enabled } )
|
||||||
|
|
||||||
Load string ->
|
Load string ->
|
||||||
( model, Browser.Navigation.pushUrl model.key string )
|
( model, Browser.Navigation.pushUrl model.key string )
|
||||||
@ -1560,9 +1598,9 @@ Instead it's best to just let the compiler infer it automatically.
|
|||||||
|
|
||||||
-}
|
-}
|
||||||
application :
|
application :
|
||||||
ApplicationConfig (Msg pageMsg) flags
|
ApplicationConfig (Msg pageMsg) { flags | settings : Settings }
|
||||||
-> PageBuilder pageModel pageMsg flags
|
-> PageBuilder pageModel pageMsg { flags | settings : Settings }
|
||||||
-> Platform.Program Decode.Value (Model pageModel flags) (Msg pageMsg)
|
-> Platform.Program Decode.Value (Model pageModel { flags | settings : Settings }) (Msg pageMsg)
|
||||||
application config pages =
|
application config pages =
|
||||||
Browser.application
|
Browser.application
|
||||||
{ init = init config pages
|
{ init = init config pages
|
||||||
|
@ -175,7 +175,7 @@ addTile view tilelist =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
initStaticTiles : Group view () () ()
|
initStaticTiles : Group view () () flags
|
||||||
initStaticTiles =
|
initStaticTiles =
|
||||||
{ init = always ( (), Cmd.none )
|
{ init = always ( (), Cmd.none )
|
||||||
, update = \_ _ -> ( (), Cmd.none )
|
, update = \_ _ -> ( (), Cmd.none )
|
||||||
|
@ -371,7 +371,7 @@ page (Builder config) =
|
|||||||
|
|
||||||
{-| render a markdown text into a simple panel
|
{-| render a markdown text into a simple panel
|
||||||
-}
|
-}
|
||||||
markdown : List (Attribute ()) -> String -> Tile () () ()
|
markdown : List (Attribute msg) -> String -> Tile () msg flags
|
||||||
markdown attributes text =
|
markdown attributes text =
|
||||||
static attributes
|
static attributes
|
||||||
(\_ _ ->
|
(\_ _ ->
|
||||||
@ -380,14 +380,14 @@ markdown attributes text =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
static : List (Attribute msg) -> (Context -> flags -> Element msg) -> Tile flags msg flags
|
static : List (Attribute msg) -> (Context -> () -> Element msg) -> Tile () msg flags
|
||||||
static attributes tileView =
|
static attributes tileView =
|
||||||
{ init = \flags -> ( flags, Cmd.none )
|
{ init = \flags -> ( (), Cmd.none )
|
||||||
, update = \_ m -> ( m, Cmd.none )
|
, update = \_ m -> ( m, Cmd.none )
|
||||||
, view =
|
, view =
|
||||||
\pagesize flags ->
|
\pagesize () ->
|
||||||
{ title = Nothing
|
{ title = Nothing
|
||||||
, body = tileView pagesize flags
|
, body = tileView pagesize ()
|
||||||
, position = FullWidthTile
|
, position = FullWidthTile
|
||||||
, attributes = attributes
|
, attributes = attributes
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user