mirror of
https://github.com/byteverse/colonnade.git
synced 2026-09-08 04:43:50 +02:00
sized table
This commit is contained in:
parent
1e02817557
commit
2894964d94
@ -119,6 +119,15 @@ encodeCellTable ::
|
|||||||
encodeCellTable = encodeTable
|
encodeCellTable = encodeTable
|
||||||
(E.headednessPure ([],[])) mempty (const mempty) htmlFromCell
|
(E.headednessPure ([],[])) mempty (const mempty) htmlFromCell
|
||||||
|
|
||||||
|
encodeCellTableSized ::
|
||||||
|
(E.Headedness h, Foldable f, Monoid d)
|
||||||
|
=> [Attribute] -- ^ Attributes of @\<table\>@ element
|
||||||
|
-> Colonnade (E.Sized Int h) a (Cell d) -- ^ How to encode data as columns
|
||||||
|
-> f a -- ^ Collection of data
|
||||||
|
-> Html ()
|
||||||
|
encodeCellTableSized = encodeTableSized
|
||||||
|
(E.headednessPure ([],[])) mempty (const mempty) htmlFromCell
|
||||||
|
|
||||||
-- | Encode a table. This handles a very general case and
|
-- | Encode a table. This handles a very general case and
|
||||||
-- is seldom needed by users. One of the arguments provided is
|
-- is seldom needed by users. One of the arguments provided is
|
||||||
-- used to add attributes to the generated @\<tr\>@ elements.
|
-- used to add attributes to the generated @\<tr\>@ elements.
|
||||||
@ -163,12 +172,12 @@ encodeBody trAttrs wrapContent tbodyAttrs colonnade xs = do
|
|||||||
|
|
||||||
encodeBodySized ::
|
encodeBodySized ::
|
||||||
(Foldable f, Monoid d)
|
(Foldable f, Monoid d)
|
||||||
=> [Attribute]
|
=> (a -> [Attribute])
|
||||||
-> (a -> [Attribute])
|
-> [Attribute]
|
||||||
-> Colonnade (E.Sized Int h) a (Cell d)
|
-> Colonnade (E.Sized Int h) a (Cell d)
|
||||||
-> f a
|
-> f a
|
||||||
-> Html ()
|
-> Html ()
|
||||||
encodeBodySized bodyAttrs trAttrs colonnade collection = tbody_ bodyAttrs $ do
|
encodeBodySized trAttrs tbodyAttrs colonnade collection = tbody_ tbodyAttrs $ do
|
||||||
flip foldMap collection $ \a -> tr_ (trAttrs a) $ do
|
flip foldMap collection $ \a -> tr_ (trAttrs a) $ do
|
||||||
E.rowMonoidalHeader
|
E.rowMonoidalHeader
|
||||||
colonnade
|
colonnade
|
||||||
@ -177,6 +186,30 @@ encodeBodySized bodyAttrs trAttrs colonnade collection = tbody_ bodyAttrs $ do
|
|||||||
)
|
)
|
||||||
a
|
a
|
||||||
|
|
||||||
|
encodeTableSized :: forall f h a d c.
|
||||||
|
(Foldable f, E.Headedness h, Monoid d)
|
||||||
|
=> h ([Attribute],[Attribute]) -- ^ Attributes of @\<thead\>@ and its @\<tr\>@
|
||||||
|
-> [Attribute] -- ^ Attributes of @\<tbody\>@ element
|
||||||
|
-> (a -> [Attribute]) -- ^ Attributes of each @\<tr\>@ element
|
||||||
|
-> (([Attribute] -> Html d -> Html d) -> (Cell d) -> Html d) -- ^ Wrap content and convert to 'Html'
|
||||||
|
-> [Attribute] -- ^ Attributes of @\<table\>@ element
|
||||||
|
-> Colonnade (E.Sized Int h) a (Cell d) -- ^ How to encode data as a row
|
||||||
|
-> f a -- ^ Collection of data
|
||||||
|
-> Html ()
|
||||||
|
encodeTableSized mtheadAttrs tbodyAttrs trAttrs wrapContent tableAttrs colonnade xs =
|
||||||
|
table_ tableAttrs $ do
|
||||||
|
d1 <- case E.headednessExtractForall of
|
||||||
|
Nothing -> return mempty
|
||||||
|
Just extractForall -> do
|
||||||
|
let (theadAttrs,theadTrAttrs) = extract mtheadAttrs
|
||||||
|
thead_ theadAttrs $ tr_ theadTrAttrs $ do
|
||||||
|
foldlMapM' (wrapContent th_ . extract . (\(E.Sized _ h) -> h) . E.oneColonnadeHead) (E.getColonnade colonnade)
|
||||||
|
where
|
||||||
|
extract :: forall y. h y -> y
|
||||||
|
extract = E.runExtractForall extractForall
|
||||||
|
encodeBodySized trAttrs tbodyAttrs colonnade xs
|
||||||
|
pure ()
|
||||||
|
|
||||||
setColspanOrHide :: Int -> [Attribute] -> [Attribute]
|
setColspanOrHide :: Int -> [Attribute] -> [Attribute]
|
||||||
setColspanOrHide i attrs
|
setColspanOrHide i attrs
|
||||||
| i < 1 = style_ "display:none;" : attrs
|
| i < 1 = style_ "display:none;" : attrs
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user