From e85a461f772d23d8af66adbab838db5e86d2b632 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 19 May 2021 18:51:08 -0400 Subject: [PATCH] Add twindShim to dynamically determine shim Also update tailwind cdn --- src/Ema/Helper/Tailwind.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Ema/Helper/Tailwind.hs b/src/Ema/Helper/Tailwind.hs index 2809fc0..1f20017 100644 --- a/src/Ema/Helper/Tailwind.hs +++ b/src/Ema/Helper/Tailwind.hs @@ -9,6 +9,7 @@ module Ema.Helper.Tailwind layoutWith, -- * Tailwind shims + twindShim, twindShimCdn, twindShimOfficial, twindShimUnofficial, @@ -25,7 +26,11 @@ import qualified Text.Blaze.Html5.Attributes as A -- | A simple and off-the-shelf layout using Tailwind CSS layout :: Ema.CLI.Action -> H.Html -> H.Html -> LByteString layout action = - layoutWith "en" "UTF-8" $ case action of + layoutWith "en" "UTF-8" $ twindShim action + +twindShim :: Ema.CLI.Action -> H.Html +twindShim action = + case action of Ema.CLI.Generate _ -> twindShimUnofficial _ -> @@ -35,14 +40,14 @@ layout action = -- | Like @layout@, but pick your own language, encoding and tailwind shim. layoutWith :: H.AttributeValue -> H.AttributeValue -> H.Html -> H.Html -> H.Html -> LByteString -layoutWith lang encoding twindShim appHead appBody = RU.renderHtml $ do +layoutWith lang encoding tshim appHead appBody = RU.renderHtml $ do H.docType H.html ! A.lang lang $ do H.head $ do H.meta ! A.charset encoding -- This makes the site mobile friendly by default. H.meta ! A.name "viewport" ! A.content "width=device-width, initial-scale=1" - twindShim + tshim appHead -- The "overflow-y-scroll" makes the scrollbar visible always, so as to -- avoid janky shifts when switching to routes with suddenly scrollable content. @@ -54,7 +59,7 @@ twindShimCdn :: H.Html twindShimCdn = H.unsafeByteString . encodeUtf8 $ [text| - + |] -- | This shim may not work with hot reload.