packages feed

lucid-alpine 0.1.0.5 → 0.1.0.6

raw patch · 4 files changed

+65/−32 lines, 4 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Lucid.Alpine: alpineSrc :: Text
+ Lucid.Alpine: alpineSrcWithSemVer :: (Int, Int, Int) -> Text
+ Lucid.Alpine: showT :: Show a => a -> Text
+ Lucid.Alpine: useAlpine :: Monad m => HtmlT m ()
+ Lucid.Alpine: useAlpineVersion :: Monad m => (Int, Int, Int) -> HtmlT m ()

Files

ChangeLog.md view
@@ -19,3 +19,7 @@ ## 0.1.0.5  Depend on `lucid-2.11.0`++## 0.1.0.6++Add helpers for importing Alpine.js script
LICENSE view
@@ -1,4 +1,4 @@-Copyright Author name here (c) 2021+Copyright 2022 Monadic Systems LLC  All rights reserved. @@ -13,7 +13,7 @@       disclaimer in the documentation and/or other materials provided       with the distribution. -    * Neither the name of Author name here nor the names of other+    * Neither the name of Monadic Systems LLC here nor the names of other       contributors may be used to endorse or promote products derived       from this software without specific prior written permission. 
lucid-alpine.cabal view
@@ -1,16 +1,16 @@ cabal-version:      1.12 name:               lucid-alpine-version:            0.1.0.5+version:            0.1.0.6 license:            BSD3 license-file:       LICENSE-copyright:          (c) 2021 Wavi Labs LLC-maintainer:         rashad@wavilabs.com-author:             Wavi Labs LLC-homepage:           https://github.com/WaviLabs/lucid-alpine#readme-bug-reports:        https://github.com/WaviLabs/lucid-alpine/issues+copyright:          2022 Monadic Systems LLC+maintainer:         tech@monadic.systems+author:             Monadic Systems LLC+homepage:           https://github.com/MonadicSystems/lucid-alpine#readme+bug-reports:        https://github.com/MonadicSystems/lucid-alpine/issues synopsis:           Use Alpine.js in your lucid templates description:-    Please see the README on GitHub at <https://github.com/WaviLabs/lucid-alpine#readme>+    Please see the README on GitHub at <https://github.com/MonadicSystems/lucid-alpine#readme>  category:           Web, HTML build-type:         Simple@@ -20,7 +20,7 @@  source-repository head     type:     git-    location: https://github.com/WaviLabs/lucid-alpine+    location: https://github.com/MonadicSystems/lucid-alpine  library     exposed-modules:  Lucid.Alpine
src/Lucid/Alpine.hs view
@@ -1,9 +1,9 @@ {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE LambdaCase #-}  module Lucid.Alpine where -import Data.Text+import Data.Text (Text, intercalate, pack)+import Lucid (Html, HtmlT, defer_, script_, src_) import Lucid.Base (Attribute, makeAttribute)  -- | x-data@@ -19,10 +19,11 @@  -- | x-bind -- Dynamically set HTML attributes on an element-xBind_-  :: Text -- ^ Attribute name-  -> Text-  -> Attribute+xBind_ ::+  -- | Attribute name+  Text ->+  Text ->+  Attribute xBind_ attr = makeAttribute ("x-bind:" <> attr)  {-@@ -33,10 +34,11 @@  -- | x-on -- Listen for browser events on an element-xOn_-  :: Text -- ^ Event name-  -> Text-  -> Attribute+xOn_ ::+  -- | Event name+  Text ->+  Text ->+  Attribute xOn_ event = makeAttribute ("x-on:" <> event)  {-@@ -71,18 +73,19 @@  -- | x-model -- Synchronize a piece of data with an input element-xModel_-  :: [Text] -- ^ List of x-model modifiers-  -> Text-  -> Attribute+xModel_ ::+  -- | List of x-model modifiers+  [Text] ->+  Text ->+  Attribute xModel_ mods = case mods of   [] -> makeAttribute "x-model"-  _  -> makeAttribute ("x-model." <> intercalate "." mods)+  _ -> makeAttribute ("x-model." <> intercalate "." mods)  {- <div x-data="{ search: '' }">   <input type="text" x-model="search">- +   Searching for: <span x-text="search"></span> </div> -}@@ -100,11 +103,13 @@  -- | x-transition -- Transition an element in and out using CSS transitions-xTransition_-  :: Maybe Text -- ^ Transition directive-  -> [Text]     -- ^ List of x-transition modifiers-  -> Text-  -> Attribute+xTransition_ ::+  -- | Transition directive+  Maybe Text ->+  -- | List of x-transition modifiers+  [Text] ->+  Text ->+  Attribute xTransition_ Nothing [] _ = makeAttribute "x-transition" mempty -- No directive or modifiers xTransition_ (Just dir) [] attrVal = makeAttribute ("x-transition:" <> dir) attrVal -- Directive with custom transition classes xTransition_ Nothing mods _ = makeAttribute ("x-transition." <> intercalate "." mods) mempty -- No directive, but with modifiers@@ -166,7 +171,7 @@  {- <input type="text" x-ref="content">- + <button x-on:click="navigator.clipboard.writeText($refs.content.value)">   Copy </button>@@ -193,3 +198,27 @@   ... </div> -}++-- | Use this value in your @head_@ tag to use Alpine.js in your lucid templates+useAlpine :: Monad m => HtmlT m ()+useAlpine = script_ [defer_ "", src_ alpineSrc] ("" :: Html ())++-- | Choose the version of Alpine.js to use using a 3-tuple representing semantic versioning+useAlpineVersion :: Monad m => (Int, Int, Int) -> HtmlT m ()+useAlpineVersion semVer = script_ [defer_ "", src_ $ alpineSrcWithSemVer semVer] ("" :: Html ())++alpineSrc :: Text+alpineSrc = "https://unpkg.com/alpinejs"++alpineSrcWithSemVer :: (Int, Int, Int) -> Text+alpineSrcWithSemVer (major, minor, patch) =+  alpineSrc+    <> "@"+    <> showT major+    <> "."+    <> showT minor+    <> "."+    <> showT patch++showT :: Show a => a -> Text+showT = pack . show