mirror of
https://github.com/byteverse/colonnade.git
synced 2026-04-19 14:44:16 +02:00
make yesod-colonnade compatible with profunctor argument order, still missing Cornice support
This commit is contained in:
parent
dccacf0d75
commit
6b007f8a7e
@ -33,7 +33,7 @@ import Text.Blaze (Attribute,toValue)
|
|||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
import qualified Text.Blaze.Html5.Attributes as HA
|
import qualified Text.Blaze.Html5.Attributes as HA
|
||||||
import qualified Text.Blaze.Html5 as H
|
import qualified Text.Blaze.Html5 as H
|
||||||
import qualified Colonnade.Encode as Encode
|
import qualified Colonnade.Encode as E
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
import qualified Data.Text.Lazy as LText
|
import qualified Data.Text.Lazy as LText
|
||||||
import qualified Data.Text.Lazy.Builder as TBuilder
|
import qualified Data.Text.Lazy.Builder as TBuilder
|
||||||
@ -87,13 +87,13 @@ encodeListItems ::
|
|||||||
-- ^ Wrapper for items, often @ul@
|
-- ^ Wrapper for items, often @ul@
|
||||||
-> (WidgetT site IO () -> WidgetT site IO () -> WidgetT site IO ())
|
-> (WidgetT site IO () -> WidgetT site IO () -> WidgetT site IO ())
|
||||||
-- ^ Combines header with data
|
-- ^ Combines header with data
|
||||||
-> Colonnade Headed (Cell site) a
|
-> Colonnade Headed a (Cell site)
|
||||||
-- ^ How to encode data as a row
|
-- ^ How to encode data as a row
|
||||||
-> a
|
-> a
|
||||||
-- ^ The value to display
|
-- ^ The value to display
|
||||||
-> WidgetT site IO ()
|
-> WidgetT site IO ()
|
||||||
encodeListItems ulWrap combine enc =
|
encodeListItems ulWrap combine enc =
|
||||||
ulWrap . Encode.bothMonadic_ enc
|
ulWrap . E.bothMonadic_ enc
|
||||||
(\(Cell ha hc) (Cell ba bc) ->
|
(\(Cell ha hc) (Cell ba bc) ->
|
||||||
li_ (ha <> ba) (combine hc bc)
|
li_ (ha <> ba) (combine hc bc)
|
||||||
)
|
)
|
||||||
@ -104,13 +104,13 @@ encodeListItems ulWrap combine enc =
|
|||||||
encodeDefinitionTable ::
|
encodeDefinitionTable ::
|
||||||
Attribute
|
Attribute
|
||||||
-- ^ Attributes of @table@ element.
|
-- ^ Attributes of @table@ element.
|
||||||
-> Colonnade Headed (Cell site) a
|
-> Colonnade Headed a (Cell site)
|
||||||
-- ^ How to encode data as a row
|
-- ^ How to encode data as a row
|
||||||
-> a
|
-> a
|
||||||
-- ^ The value to display
|
-- ^ The value to display
|
||||||
-> WidgetT site IO ()
|
-> WidgetT site IO ()
|
||||||
encodeDefinitionTable attrs enc a = table_ attrs $ tbody_ mempty $
|
encodeDefinitionTable attrs enc a = table_ attrs $ tbody_ mempty $
|
||||||
Encode.bothMonadic_ enc
|
E.bothMonadic_ enc
|
||||||
(\theKey theValue -> tr_ mempty $ do
|
(\theKey theValue -> tr_ mempty $ do
|
||||||
widgetFromCell td_ theKey
|
widgetFromCell td_ theKey
|
||||||
widgetFromCell td_ theValue
|
widgetFromCell td_ theValue
|
||||||
@ -122,7 +122,7 @@ encodeDefinitionTable attrs enc a = table_ attrs $ tbody_ mempty $
|
|||||||
-- > encodeHeadedCellTable (HA.class_ "table table-striped") ...
|
-- > encodeHeadedCellTable (HA.class_ "table table-striped") ...
|
||||||
encodeHeadedCellTable :: Foldable f
|
encodeHeadedCellTable :: Foldable f
|
||||||
=> Attribute -- ^ Attributes of @table@ element
|
=> Attribute -- ^ Attributes of @table@ element
|
||||||
-> Colonnade Headed (Cell site) a -- ^ How to encode data as a row
|
-> Colonnade Headed a (Cell site) -- ^ How to encode data as a row
|
||||||
-> f a -- ^ Rows of data
|
-> f a -- ^ Rows of data
|
||||||
-> WidgetT site IO ()
|
-> WidgetT site IO ()
|
||||||
encodeHeadedCellTable = encodeTable
|
encodeHeadedCellTable = encodeTable
|
||||||
@ -130,7 +130,7 @@ encodeHeadedCellTable = encodeTable
|
|||||||
|
|
||||||
encodeHeadlessCellTable :: Foldable f
|
encodeHeadlessCellTable :: Foldable f
|
||||||
=> Attribute -- ^ Attributes of @table@ element
|
=> Attribute -- ^ Attributes of @table@ element
|
||||||
-> Colonnade Headless (Cell site) a -- ^ How to encode data as columns
|
-> Colonnade Headless a (Cell site) -- ^ How to encode data as columns
|
||||||
-> f a -- ^ Rows of data
|
-> f a -- ^ Rows of data
|
||||||
-> WidgetT site IO ()
|
-> WidgetT site IO ()
|
||||||
encodeHeadlessCellTable = encodeTable
|
encodeHeadlessCellTable = encodeTable
|
||||||
@ -138,7 +138,7 @@ encodeHeadlessCellTable = encodeTable
|
|||||||
|
|
||||||
encodeHeadedWidgetTable :: Foldable f
|
encodeHeadedWidgetTable :: Foldable f
|
||||||
=> Attribute -- ^ Attributes of @table@ element
|
=> Attribute -- ^ Attributes of @table@ element
|
||||||
-> Colonnade Headed (WidgetT site IO ()) a -- ^ How to encode data as columns
|
-> Colonnade Headed a (WidgetT site IO ()) -- ^ How to encode data as columns
|
||||||
-> f a -- ^ Rows of data
|
-> f a -- ^ Rows of data
|
||||||
-> WidgetT site IO ()
|
-> WidgetT site IO ()
|
||||||
encodeHeadedWidgetTable = encodeTable
|
encodeHeadedWidgetTable = encodeTable
|
||||||
@ -146,7 +146,7 @@ encodeHeadedWidgetTable = encodeTable
|
|||||||
|
|
||||||
encodeHeadlessWidgetTable :: Foldable f
|
encodeHeadlessWidgetTable :: Foldable f
|
||||||
=> Attribute -- ^ Attributes of @\<table\>@ element
|
=> Attribute -- ^ Attributes of @\<table\>@ element
|
||||||
-> Colonnade Headless (WidgetT site IO ()) a -- ^ How to encode data as columns
|
-> Colonnade Headless a (WidgetT site IO ()) -- ^ How to encode data as columns
|
||||||
-> f a -- ^ Rows of data
|
-> f a -- ^ Rows of data
|
||||||
-> WidgetT site IO ()
|
-> WidgetT site IO ()
|
||||||
encodeHeadlessWidgetTable = encodeTable
|
encodeHeadlessWidgetTable = encodeTable
|
||||||
@ -162,17 +162,17 @@ encodeTable ::
|
|||||||
-> (a -> Attribute) -- ^ Attributes of each @\<tr\>@ element
|
-> (a -> Attribute) -- ^ Attributes of each @\<tr\>@ element
|
||||||
-> ((Attribute -> WidgetT site IO () -> WidgetT site IO ()) -> c -> WidgetT site IO ()) -- ^ Wrap content and convert to 'Html'
|
-> ((Attribute -> WidgetT site IO () -> WidgetT site IO ()) -> c -> WidgetT site IO ()) -- ^ Wrap content and convert to 'Html'
|
||||||
-> Attribute -- ^ Attributes of @\<table\>@ element
|
-> Attribute -- ^ Attributes of @\<table\>@ element
|
||||||
-> Colonnade h c a -- ^ How to encode data as a row
|
-> Colonnade h a c -- ^ How to encode data as a row
|
||||||
-> f a -- ^ Collection of data
|
-> f a -- ^ Collection of data
|
||||||
-> WidgetT site IO ()
|
-> WidgetT site IO ()
|
||||||
encodeTable mtheadAttrs tbodyAttrs trAttrs wrapContent tableAttrs colonnade xs =
|
encodeTable mtheadAttrs tbodyAttrs trAttrs wrapContent tableAttrs colonnade xs =
|
||||||
table_ tableAttrs $ do
|
table_ tableAttrs $ do
|
||||||
for_ mtheadAttrs $ \theadAttrs -> do
|
for_ mtheadAttrs $ \theadAttrs -> do
|
||||||
thead_ theadAttrs $ do
|
thead_ theadAttrs $ do
|
||||||
Encode.headerMonadicGeneral_ colonnade (wrapContent th_)
|
E.headerMonadicGeneral_ colonnade (wrapContent th_)
|
||||||
tbody_ tbodyAttrs $ do
|
tbody_ tbodyAttrs $ do
|
||||||
forM_ xs $ \x -> do
|
forM_ xs $ \x -> do
|
||||||
tr_ (trAttrs x) (Encode.rowMonadic_ colonnade (wrapContent td_) x)
|
tr_ (trAttrs x) (E.rowMonadic_ colonnade (wrapContent td_) x)
|
||||||
|
|
||||||
widgetFromCell ::
|
widgetFromCell ::
|
||||||
(Attribute -> WidgetT site IO () -> WidgetT site IO ())
|
(Attribute -> WidgetT site IO () -> WidgetT site IO ())
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-colonnade
|
name: yesod-colonnade
|
||||||
version: 0.4
|
version: 1.1.0
|
||||||
synopsis: Helper functions for using yesod with colonnade
|
synopsis: Helper functions for using yesod with colonnade
|
||||||
description: Yesod and colonnade
|
description: Yesod and colonnade
|
||||||
homepage: https://github.com/andrewthad/colonnade#readme
|
homepage: https://github.com/andrewthad/colonnade#readme
|
||||||
@ -18,7 +18,7 @@ library
|
|||||||
Yesod.Colonnade
|
Yesod.Colonnade
|
||||||
build-depends:
|
build-depends:
|
||||||
base >= 4.7 && < 5
|
base >= 4.7 && < 5
|
||||||
, colonnade >= 1.0 && < 1.1
|
, colonnade >= 1.1 && < 1.2
|
||||||
, yesod-core >= 1.4 && < 1.5
|
, yesod-core >= 1.4 && < 1.5
|
||||||
, text >= 1.0 && < 1.3
|
, text >= 1.0 && < 1.3
|
||||||
, blaze-markup >= 0.7 && < 0.9
|
, blaze-markup >= 0.7 && < 0.9
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user