summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <benjamin@barenblat.name>2017-01-16 20:28:57 -0500
committerGravatar Benjamin Barenblat <benjamin@barenblat.name>2017-01-16 20:28:57 -0500
commit989d01687d8c125900c3351d1a96161e56cd5ff0 (patch)
tree41d0fca98c5e905ff1010465b47942cfc32d0560
parentf5ef470c3484f1b37d7334dc24a3c500b149da12 (diff)
Reformat Ur filesmaterial
This should be a behaviour-preserving change.
-rw-r--r--main.ur102
-rw-r--r--material/material.ur229
-rw-r--r--material/material.urs14
3 files changed, 167 insertions, 178 deletions
diff --git a/main.ur b/main.ur
index 42c3dab..54ccb14 100644
--- a/main.ur
+++ b/main.ur
@@ -11,32 +11,29 @@ 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. *)
-table nextAction : {
- Id : int,
- Nam : string,
- Done : bool,
-} PRIMARY KEY Id
+table nextAction : { Id : int, Nam : string, Done : bool } PRIMARY KEY Id
sequence nextActionId
fun markNextActionStatus id done =
- dml (UPDATE nextAction SET Done = {[done]} WHERE Id = {[id]})
+ dml (UPDATE nextAction SET Done = {[done]} WHERE Id = {[id]})
fun renderNextAction action : transaction xbody =
- c <- Material.Checkbox.make action.Done
- (fn b => rpc (markNextActionStatus action.Id b));
- return (Material.List.SingleLine.item {
- Icon = c,
- Content = cdata action.Nam
- })
+ c <- Material.Checkbox.make
+ action.Done
+ (fn b => rpc (markNextActionStatus action.Id b));
+ return (Material.List.SingleLine.item {Icon = c,
+ Content = cdata action.Nam})
val renderNextActions =
- queryX1' (SELECT * FROM nextAction WHERE nextAction.Done = FALSE) renderNextAction
+ queryX1' (SELECT * FROM nextAction WHERE nextAction.Done = FALSE)
+ renderNextAction
fun newNextAction name =
- id <- nextval nextActionId;
- dml (INSERT INTO nextAction (Id, Nam, Done) VALUES ({[4 + id]}, {[name]}, FALSE));
- renderNextActions
+ id <- nextval nextActionId;
+ dml (INSERT INTO nextAction (Id, Nam, Done)
+ VALUES ({[4 + id]}, {[name]}, FALSE));
+ renderNextActions
style hidden
@@ -45,40 +42,39 @@ style visible
datatype mode = NextActions | NewNextAction
val main =
- actionItems <- bind renderNextActions source;
- mode <- source NextActions;
- floatingActionButton <-
- Material.FloatingActionButton.make "add" (fn _ => set mode NewNextAction);
- return (Material.page {
- Head = <xml>
- (* TODO(bbaren): Write a meta-description tag. *)
- <title>Next actions</title>
-
- (* TODO(bbaren): Support homescreen tiles for Chrome on Android, Safari on
- iOS, and Windows 8. *)
-
- <link rel="stylesheet" href="/ugtd.css" />
- </xml>,
- Body = <xml>
- <div dynClass={
- currentMode <- signal mode;
- return (case currentMode of
- NewNextAction => visible
- | _ => hidden)
- }>
- {Material.AppBar.make "New action"}
- </div>
- <div dynClass={
- currentMode <- signal mode;
- return (case currentMode of
- NextActions => visible
- | _ => hidden)
- }>
- {Material.AppBar.make "Next actions"}
- {Material.List.SingleLine.make <xml>
- <dyn signal={signal actionItems} />
- </xml>}
- {floatingActionButton}
- </div>
- </xml>
- })
+ actionItems <- bind renderNextActions source;
+ mode <- source NextActions;
+ floatingActionButton <- Material.FloatingActionButton.make
+ "add"
+ (fn _ => set mode NewNextAction);
+ let
+ val head = <xml>
+ (* TODO(bbaren): Write a meta-description tag. *)
+ <title>Next actions</title>
+
+ (* TODO(bbaren): Support homescreen tiles for Chrome on Android,
+ Safari on iOS, and Windows 8. *)
+
+ <link rel="stylesheet" href="/ugtd.css" />
+ </xml>
+
+ val body = <xml>
+ <div dynClass={currentMode <- signal mode;
+ return (case currentMode of
+ NewNextAction => visible
+ | _ => hidden)}>
+ {Material.AppBar.make "New action"}
+ </div>
+ <div dynClass={currentMode <- signal mode;
+ return (case currentMode of
+ NextActions => visible
+ | _ => hidden)}>
+ {Material.AppBar.make "Next actions"}
+ {Material.List.SingleLine.make
+ <xml><dyn signal={signal actionItems} /></xml>}
+ {floatingActionButton}
+ </div>
+ </xml>
+ in
+ return (Material.page {Head = head, Body = body})
+ end
diff --git a/material/material.ur b/material/material.ur
index c28e449..fc4ab58 100644
--- a/material/material.ur
+++ b/material/material.ur
@@ -20,52 +20,51 @@ fun icon s = <xml><i class={materialIcon}>{[s]}</i></xml>
fun inNewStackingContext x = <xml><div class={stackingContext}>{x}</div></xml>
structure Ripple : sig
- val make : int (* radius *)
- -> transaction {Placeholder : xbody,
- Trigger : {X : int, Y : int} -> transaction unit}
+ val make : int (* radius *)
+ -> transaction { Placeholder : xbody,
+ Trigger : { X : int, Y : int }
+ -> transaction unit }
end = struct
- style ink
-
- fun inkStyle radius xy =
- let
- fun p a b = value (property a) (atom (show b ^ "px"))
- val diameter = 2 * radius
- in
- oneProperty
- (oneProperty
- (oneProperty
- (oneProperty noStyle
- (p "width" diameter))
- (p "height" diameter))
- (p "left" (xy.X - radius)))
- (p "top" (xy.Y - radius))
- end
-
- fun inkAnimation radius s =
- <xml>
- <dyn
- signal={
- v <- signal s;
- return (case v of
- None => <xml></xml>
- | Some xy => <xml>
- <span class={ink} style={inkStyle radius xy}>
- </span>
- </xml>)
- }
- />
+ style ink
+
+ fun inkStyle radius xy =
+ let
+ fun p a b = value (property a) (atom (show b ^ "px"))
+ val diameter = 2 * radius
+ in
+ oneProperty
+ (oneProperty
+ (oneProperty
+ (oneProperty noStyle
+ (p "width" diameter))
+ (p "height" diameter))
+ (p "left" (xy.X - radius)))
+ (p "top" (xy.Y - radius))
+ end
+
+ fun inkAnimation radius s = <xml>
+ <dyn signal={v <- signal s;
+ return (case v of
+ None => <xml></xml>
+ | Some xy =>
+ <xml>
+ <span class={ink}
+ style={inkStyle radius xy}>
+ </span>
+ </xml>)} />
</xml>
- fun make radius =
- center <- source None;
- return {Placeholder = inkAnimation radius center,
- Trigger = fn xy => set center (Some xy)}
+ fun make radius =
+ center <- source None;
+ return {Placeholder = inkAnimation radius center,
+ Trigger = fn xy => set center (Some xy)}
end
(* TODO(bbaren): Support attributes in the arguments. *)
fun page p = <xml>
<head>
- <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
+ <link rel="stylesheet"
+ href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="stylesheet" href="/material.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -82,93 +81,87 @@ fun page p = <xml>
</xml>
structure AppBar = struct
- style bar
- style title
-
- fun make t = <xml>
- <header class={bar}>
- <h1 class={title}>{[t]}</h1>
- </header>
- </xml>
+ style bar
+ style title
+
+ fun make t = <xml>
+ <header class={bar}>
+ <h1 class={title}>{[t]}</h1>
+ </header>
+ </xml>
end
structure Checkbox = struct
- style checkbox
- style checked
- style container
-
- (* Pixel dimensions of the checkbox. If you update these, you must also
- update the CSS file. *)
- val width = 24
- val height = 24
-
- val make c onChange =
- s <- source c;
- ink <- Ripple.make (width / 2);
- return (inNewStackingContext <xml>
- <div class={container}>
- {ink.Placeholder}
- <span
- dynClass={
- c <- signal s;
- return (classes checkbox (if c then checked else null))
- }
- onclick={fn click =>
- ink.Trigger {X = click.ClientX, Y = click.ClientY};
- c <- get s;
- let
- val c' = not c
- in
- set s c';
- onChange c'
- end
- }
- >
- </span>
- </div>
- </xml>)
+ style checkbox
+ style checked
+ style container
+
+ (* Pixel dimensions of the checkbox. If you update these, you must also
+ update the CSS file. *)
+ val width = 24
+ val height = 24
+
+ val make c onChange =
+ s <- source c;
+ ink <- Ripple.make (width / 2);
+ return (inNewStackingContext <xml>
+ <div class={container}>
+ {ink.Placeholder}
+ <span dynClass={c <- signal s;
+ return (classes checkbox
+ (if c then checked else null))}
+ onclick={fn click =>
+ ink.Trigger {X = click.ClientX,
+ Y = click.ClientY};
+ c <- get s;
+ let
+ val c' = not c
+ in
+ set s c';
+ onChange c'
+ end}></span>
+ </div>
+ </xml>)
end
structure FloatingActionButton = struct
- style container
- style element
-
- (* Pixel dimensions of the button. If you update these, you must also
- update the CSS file. *)
- val width = 56
- val height = 56
-
- fun make s clickHandler =
- ink <- Ripple.make (width / 2);
- return <xml>
- <div class={container}>
- <button
- class={element}
- onclick={fn click =>
- ink.Trigger {X = click.ClientX, Y = click.ClientY};
- clickHandler click
- }
- >
- {icon s}
- </button>
- {ink.Placeholder}
- </div>
- </xml>
-end
-
-structure List = struct
- structure SingleLine = struct
+ style container
style element
- style icon
- style list
- fun make es = <xml><ul class={list}>{es}</ul></xml>
+ (* Pixel dimensions of the button. If you update these, you must also
+ update the CSS file. *)
+ val width = 56
+ val height = 56
+
+ fun make s clickHandler =
+ ink <- Ripple.make (width / 2);
+ return <xml>
+ <div class={container}>
+ <button class={element}
+ onclick={fn click =>
+ ink.Trigger {X = click.ClientX,
+ Y = click.ClientY};
+ clickHandler click}>
+ {icon s}
+ </button>
+ {ink.Placeholder}
+ </div>
+ </xml>
+end
- fun item i = <xml>
- <li class={element}>
- <span class={icon}>{i.Icon}</span>
- {i.Content}
- </li>
- </xml>
- end
+structure List = struct
+ structure SingleLine = struct
+ style element
+ style icon
+ style list
+
+ fun make es = <xml><ul class={list}>{es}</ul></xml>
+
+ fun item i = <xml>
+ <li class={element}>
+ <span class={icon}>{i.Icon}</span>
+ {i.Content}
+ </li>
+ </xml>
+ end
end
diff --git a/material/material.urs b/material/material.urs
index d244ec0..dd5b7e1 100644
--- a/material/material.urs
+++ b/material/material.urs
@@ -14,21 +14,21 @@ specific language governing permissions and limitations under the License. *)
val page : {Head : xhead, Body : xbody} -> page
structure AppBar : sig
- val make : string (* app title *) -> xbody
+ val make : string (* app title *) -> xbody
end
structure Checkbox : sig
- val make : bool -> (bool -> transaction unit) -> transaction xbody
+ val make : bool -> (bool -> transaction unit) -> transaction xbody
end
structure FloatingActionButton : sig
- val make : string -> (mouseEvent -> transaction unit) -> transaction xbody
+ val make : string -> (mouseEvent -> transaction unit) -> transaction xbody
end
structure List : sig
- structure SingleLine : sig
- val make : xbody -> xbody
+ structure SingleLine : sig
+ val make : xbody -> xbody
- val item : {Icon : xbody, Content : xbody} -> xbody
- end
+ val item : {Icon : xbody, Content : xbody} -> xbody
+ end
end