From 810b5d82584005f38c01eaa95900632bcefb4f99 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Sun, 31 Jul 2022 09:37:06 -0400 Subject: [PATCH] WIP on htmx addition (#36) - Remove custom tags/attrs now provided by Giraffe View Engine --- src/PrayerTracker.UI/Church.fs | 2 +- src/PrayerTracker.UI/CommonFunctions.fs | 34 +- src/PrayerTracker.UI/Home.fs | 358 +++++++++---------- src/PrayerTracker.UI/Layout.fs | 243 +++++++------ src/PrayerTracker.UI/PrayerTracker.UI.fsproj | 1 + 5 files changed, 328 insertions(+), 310 deletions(-) diff --git a/src/PrayerTracker.UI/Church.fs b/src/PrayerTracker.UI/Church.fs index 50fb4d1..9ebe2ea 100644 --- a/src/PrayerTracker.UI/Church.fs +++ b/src/PrayerTracker.UI/Church.fs @@ -6,7 +6,7 @@ open PrayerTracker.ViewModels /// View for the church edit page let edit (m : EditChurch) ctx vi = - let pageTitle = match m.IsNew with true -> "Add a New Church" | false -> "Edit Church" + let pageTitle = if m.IsNew then "Add a New Church" else "Edit Church" let s = I18N.localizer.Force () [ form [ _action "/church/save"; _method "post"; _class "pt-center-columns" ] [ style [ _scoped ] [ diff --git a/src/PrayerTracker.UI/CommonFunctions.fs b/src/PrayerTracker.UI/CommonFunctions.fs index 17692f6..03a07ca 100644 --- a/src/PrayerTracker.UI/CommonFunctions.fs +++ b/src/PrayerTracker.UI/CommonFunctions.fs @@ -27,7 +27,7 @@ let space = rawText " " let icon name = i [ _class "material-icons" ] [ rawText name ] /// Generate a Material Design icon, specifying the point size (must be defined in CSS) -let iconSized size name = i [ _class $"material-icons md-{size}" ] [ rawText name ] +let iconSized size name = i [ _class $"material-icons md-%i{size}" ] [ rawText name ] /// Generate a CSRF prevention token let csrfToken (ctx : HttpContext) = @@ -80,13 +80,11 @@ let namedColorList name selected attrs (s : IStringLocalizer) = /// Generate an input[type=radio] that is selected if its value is the current value let radio name domId value current = - input - [ _type "radio" - _name name - _id domId - _value value - if value = current then _checked - ] + input [ _type "radio" + _name name + _id domId + _value value + if value = current then _checked ] /// Generate a select list with the current value selected let selectList name selected attrs items = @@ -100,7 +98,7 @@ let selectList name selected attrs items = |> select (List.concat [ [ _name name; _id name ]; attrs ]) /// Generate the text for a default entry at the top of a select list -let selectDefault text = $"— {text} —" +let selectDefault text = $"— %s{text} —" /// Generate a standard submit button with icon and text let submit attrs ico text = button (_type "submit" :: attrs) [ icon ico; rawText "  "; locStr text ] @@ -108,29 +106,13 @@ let submit attrs ico text = button (_type "submit" :: attrs) [ icon ico; rawText open System +// TODO: this is where to implement issue #1 /// Format a GUID with no dashes (used for URLs and forms) let flatGuid (x : Guid) = x.ToString "N" /// An empty GUID string (used for "add" actions) let emptyGuid = flatGuid Guid.Empty - -/// blockquote tag -let blockquote = tag "blockquote" - -/// role attribute -let _role = attr "role" -/// aria-* attribute -let _aria typ = attr $"aria-{typ}" -/// onclick attribute -let _onclick = attr "onclick" -/// onsubmit attribute -let _onsubmit = attr "onsubmit" - -/// scoped flag (used for