summaryrefslogtreecommitdiff
path: root/main.ur
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <benjamin@barenblat.name>2016-11-05 17:39:41 -0400
committerGravatar Benjamin Barenblat <benjamin@barenblat.name>2016-11-05 17:39:41 -0400
commit43dca1d076bdea10473f61dd53ddcd7e43fa5b55 (patch)
tree3cca7a8859786110c064d75da0c71970aa3f4864 /main.ur
parent9e4a75fe23afd82dd4556c73be654366f47bad00 (diff)
Begin writing a custom Material Design library
Stop using Material Design Lite, as its execution model doesn’t play well with Ur/Web’s functional-reactive page generation. Start building a Material Design library more closely tailored to uGTD and Ur/Web.
Diffstat (limited to 'main.ur')
-rw-r--r--main.ur93
1 files changed, 11 insertions, 82 deletions
diff --git a/main.ur b/main.ur
index b9b5699..3131f14 100644
--- a/main.ur
+++ b/main.ur
@@ -1,5 +1,4 @@
-(* Copyright 2015 Google Inc.
-Copyright 2016 Benjamin Barenblat
+(* Copyright 2016 Benjamin Barenblat
Licensed under the Apache License, Version 2.0 (the “License”); you may not use
this file except in compliance with the License. You may obtain a copy of the
@@ -12,8 +11,6 @@ under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License. *)
-open Mdl.Classes
-
table nextAction : {
Id : int,
Nam : string,
@@ -22,32 +19,11 @@ table nextAction : {
sequence nextActionId
-(* Forces JavaScript to be enabled on the given page, so as to pull in external
-scripts specified in the .urp file. *)
-val forceJavaScript = <xml><script code={return ()} /></xml>
-
fun markNextActionStatus id done =
dml (UPDATE nextAction SET Done = {[done]} WHERE Id = {[id]})
-fun renderNextAction action =
- c <- fresh;
- done <- source action.Done;
- return <xml>
- <li class="mdl-list__item">
- <span class="mdl-list__item-primary-content">
- <span class="mdl-list__item-icon">
- <label class="mdl-checkbox" for={c}>
- <ccheckbox id={c} source={done} class="mdl-checkbox__input"
- onchange={
- b <- get done;
- rpc (markNextActionStatus action.Id b)
- } />
- </label>
- </span>
- {[action.Nam]}
- </span>
- </li>
- </xml>
+fun renderNextAction action : transaction xbody =
+ return <xml></xml>
val renderNextActions =
queryX1' (SELECT * FROM nextAction WHERE nextAction.Done = FALSE) renderNextAction
@@ -66,57 +42,24 @@ datatype mode = NextActions | NewNextAction
val main =
actionItems <- bind renderNextActions source;
mode <- source NextActions;
- newNextActionDescription <- Mdl.Textbox.make "Description";
- return <xml>
- <head>
+ return (Material.page {
+ Head = <xml>
(* TODO(bbaren): Write a meta-description tag. *)
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Next actions</title>
- (* Disable tap highlight on IE. *)
- <meta name="msapplication-tap-highlight" content="no" />
-
(* TODO(bbaren): Support homescreen tiles for Chrome on Android, Safari on
iOS, and Windows 8. *)
- (* Color the status bar on mobile devices. *)
- <meta name="theme-color" content="#9c27b0" />
-
- (* Material Design Lite *)
- <link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.purple-orange.min.css" />
- <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
- {forceJavaScript}
-
<link rel="stylesheet" href="/ugtd.css" />
- </head>
- <body>
+ </xml>,
+ Body = <xml>
<div dynClass={
currentMode <- signal mode;
return (case currentMode of
NewNextAction => visible
| _ => hidden)
}>
- <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
- <header class="mdl-layout__header">
- <button class="mdl-layout__drawer-button" onclick={fn _ => set mode NextActions}>
- <i class="material-icons">close</i>
- </button>
- <div class="mdl-layout__header-row">
- <span class="mdl-layout-title">New action</span>
- <div class="mdl-layout-spacer" />
- <button class="mdl-button mdl-js-button" value="Save" onclick={fn _ =>
- name <- get newNextActionDescription.Source;
- bind (rpc (newNextAction name)) (set actionItems);
- sleep 0;
- set mode NextActions;
- set newNextActionDescription.Source ""
- } />
- </div>
- </header>
- <div class="mdl-layout__content">
- {newNextActionDescription.Xml}
- </div>
- </div>
+ {Material.AppBar.make "New action"}
</div>
<div dynClass={
currentMode <- signal mode;
@@ -124,21 +67,7 @@ val main =
NextActions => visible
| _ => hidden)
}>
- <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
- <div class="mdl-layout__header mdl-layout__header--waterfall mdl-layout__header--waterfall-hide-top">
- <div class="mdl-layout__header-row">
- <span class="mdl-layout-title">Next actions</span>
- </div>
- </div>
- <div class="mdl-layout__content">
- <ul class="mdl-list">
- <dyn signal={signal actionItems} />
- </ul>
- <button class="mdl-button mdl-js-button mdl-button--fab mdl-button--colored" onclick={fn _ => set mode NewNextAction}>
- <i class="material-icons">add</i>
- </button>
- </div>
- </div>
+ {Material.AppBar.make "Next actions"}
</div>
- </body>
- </xml>
+ </xml>
+ })