From 72ea18ba5e50412a35e5c141c81c2d3bdc107ebf Mon Sep 17 00:00:00 2001 From: Andrew Martin Date: Sun, 17 Sep 2017 13:03:02 -0400 Subject: [PATCH] add helper function to prevent looping --- .../src/Reflex/Dom/Colonnade.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/reflex-dom-colonnade/src/Reflex/Dom/Colonnade.hs b/reflex-dom-colonnade/src/Reflex/Dom/Colonnade.hs index c79fa4f..67b39b9 100644 --- a/reflex-dom-colonnade/src/Reflex/Dom/Colonnade.hs +++ b/reflex-dom-colonnade/src/Reflex/Dom/Colonnade.hs @@ -20,6 +20,7 @@ module Reflex.Dom.Colonnade , static , capped , cappedResizable + , cappedResizableTableless , cappedTraversing , dynamic , dynamicCapped @@ -263,6 +264,23 @@ cappedResizable tableAttrs headAttrs bodyAttrs beneathBody trAttrs fascia cornic c <- beneathBody return (h `mappend` b, c, E.size annCornice) +-- | Same as 'cappedResizable' but without the @\@ wrapping it. +-- Also, it does not take extra content to go beneath the @\@. +cappedResizableTableless :: + (DomBuilder t m, PostBuild t m, MonadHold t m, Foldable f, Monoid e) + => Map Text Text -- ^ @\@ tag attributes + -> Map Text Text -- ^ @\@ tag attributes + -> (a -> Map Text Text) -- ^ @\@ tag attributes + -> Fascia p (Map Text Text) -- ^ Attributes for @\@ elements in the @\@ + -> Cornice (Resizable t Headed) p a (Cell t m e) -- ^ Data encoding strategy + -> f a -- ^ Collection of data + -> m (e, Dynamic t Int) +cappedResizableTableless headAttrs bodyAttrs trAttrs fascia cornice collection = do + let annCornice = dynamicAnnotate cornice + h <- encodeCorniceResizableHead headAttrs fascia annCornice + b <- bodyResizable bodyAttrs trAttrs (E.discard cornice) collection + return (h `mappend` b, E.size annCornice) + dynamicAnnotate :: Reflex t => Cornice (Resizable t Headed) p a c -> E.AnnotatedCornice (Dynamic t Int) p a c