From eeaa05d2a2a7ab69634bda8bf0cdc94eca2bc77b Mon Sep 17 00:00:00 2001 From: Andrew Martin Date: Thu, 28 Sep 2017 17:05:49 -0400 Subject: [PATCH] hide inactive rows --- reflex-dom-colonnade/src/Reflex/Dom/Colonnade.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/reflex-dom-colonnade/src/Reflex/Dom/Colonnade.hs b/reflex-dom-colonnade/src/Reflex/Dom/Colonnade.hs index 09f8c6b..362fe71 100644 --- a/reflex-dom-colonnade/src/Reflex/Dom/Colonnade.hs +++ b/reflex-dom-colonnade/src/Reflex/Dom/Colonnade.hs @@ -731,7 +731,7 @@ tableBodyExpandable colCount renderExpansion bodyAttrs trAttrs col collection a0 let attrs = trAttrs a expanded <- elDynAttr "tr" attrs (rowSizableReified (return False) (zipDynWith (||)) col a) visibleVal <- gateDynamic expanded a0 a - elDynAttr "tr" attrs $ do + elDynAttr "tr" (zipDynWith insertVisibilityAttr expanded attrs) $ do -- TODO: possibly provide a way to customize these attributes let expansionTdAttrs = pure M.empty elDynAttr "td" (zipDynWith insertSizeAttr colCount expansionTdAttrs) (renderExpansion visibleVal) @@ -783,6 +783,11 @@ rowSizable (E.Colonnade v) a = V.foldM (\m oc -> do return (mappend m e) ) mempty v +insertVisibilityAttr :: Bool -> Map Text Text -> Map Text Text +insertVisibilityAttr b m = case b of + False -> M.insertWith T.append "style" "display:none;" m + True -> m + insertSizeAttr :: Int -> Map Text Text -> Map Text Text insertSizeAttr i m | i < 1 = M.insertWith T.append "style" "display:none;" m