From 989d01687d8c125900c3351d1a96161e56cd5ff0 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Mon, 16 Jan 2017 20:28:57 -0500 Subject: Reformat Ur files This should be a behaviour-preserving change. --- main.ur | 102 +++++++++++----------- material/material.ur | 229 ++++++++++++++++++++++++-------------------------- material/material.urs | 14 +-- 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 = - (* TODO(bbaren): Write a meta-description tag. *) - Next actions - - (* TODO(bbaren): Support homescreen tiles for Chrome on Android, Safari on - iOS, and Windows 8. *) - - - , - Body = -
visible - | _ => hidden) - }> - {Material.AppBar.make "New action"} -
-
visible - | _ => hidden) - }> - {Material.AppBar.make "Next actions"} - {Material.List.SingleLine.make - - } - {floatingActionButton} -
-
- }) + actionItems <- bind renderNextActions source; + mode <- source NextActions; + floatingActionButton <- Material.FloatingActionButton.make + "add" + (fn _ => set mode NewNextAction); + let + val head = + (* TODO(bbaren): Write a meta-description tag. *) + Next actions + + (* TODO(bbaren): Support homescreen tiles for Chrome on Android, + Safari on iOS, and Windows 8. *) + + + + + val body = +
visible + | _ => hidden)}> + {Material.AppBar.make "New action"} +
+
visible + | _ => hidden)}> + {Material.AppBar.make "Next actions"} + {Material.List.SingleLine.make + } + {floatingActionButton} +
+
+ 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 = {[s]} fun inNewStackingContext x =
{x}
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 = - - - | Some xy => - - - ) - } - /> + 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 = + + | Some xy => + + + + )} /> - 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 = - + @@ -82,93 +81,87 @@ fun page p = structure AppBar = struct - style bar - style title - - fun make t = -
-

{[t]}

-
-
+ style bar + style title + + fun make t = +
+

{[t]}

+
+
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 -
- {ink.Placeholder} - - ink.Trigger {X = click.ClientX, Y = click.ClientY}; - c <- get s; - let - val c' = not c - in - set s c'; - onChange c' - end - } - > - -
-
) + 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 +
+ {ink.Placeholder} + + ink.Trigger {X = click.ClientX, + Y = click.ClientY}; + c <- get s; + let + val c' = not c + in + set s c'; + onChange c' + end}> +
+
) 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 -
- - {ink.Placeholder} -
-
-end - -structure List = struct - structure SingleLine = struct + style container style element - style icon - style list - fun make es =
    {es}
+ (* 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 +
+ + {ink.Placeholder} +
+
+end - fun item i = -
  • - {i.Icon} - {i.Content} -
  • -
    - end +structure List = struct + structure SingleLine = struct + style element + style icon + style list + + fun make es =
      {es}
    + + fun item i = +
  • + {i.Icon} + {i.Content} +
  • +
    + 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 -- cgit v1.2.3