alerts 0.1.0.0 → 0.1.1.0
raw patch · 8 files changed
+79/−36 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Web.Alert.Renderer.Bulma: renderAlertsBulma :: [Alert] -> Text
Files
- README.md +3/−2
- alerts.cabal +5/−2
- src/Web/Alert.hs +1/−1
- src/Web/Alert/Renderer/Bootstrap3.hs +5/−5
- src/Web/Alert/Renderer/Bootstrap4.hs +5/−5
- src/Web/Alert/Renderer/Bulma.hs +40/−0
- src/Web/Alert/Renderer/Common.hs +14/−15
- src/Web/Alert/Renderer/Foundation5.hs +6/−6
README.md view
@@ -6,7 +6,8 @@ alert1 = Alert Success "Yay!" alert2 = Alert Error "Oops!" -html1 = renderAlertsBootstrap3 [alert1, alert2]-html2 = renderAlertsBootstrap4 [alert1, alert2]+html1 = renderAlertsBootstrap3 [alert1, alert2]+html2 = renderAlertsBootstrap4 [alert1, alert2] html3 = renderAlertsFoundation5 Round [alert1, alert2]+html3 = renderAlertsBulma [alert1, alert2] ```
alerts.cabal view
@@ -1,5 +1,5 @@ name: alerts-version: 0.1.0.0+version: 0.1.1.0 synopsis: Alert messages for web applications description: Alert messages for web applications: .@@ -8,6 +8,8 @@ * Bootstrap 4 . * Foundation 5+ .+ * Bulma homepage: https://github.com/alx741/alerts#readme license: BSD3 license-file: LICENSE@@ -25,8 +27,9 @@ , Web.Alert.Renderer.Bootstrap3 , Web.Alert.Renderer.Bootstrap4 , Web.Alert.Renderer.Foundation5+ , Web.Alert.Renderer.Bulma other-modules: Web.Alert.Renderer.Common- ghc-options: -Wall -fwarn-tabs -O2+ ghc-options: -Wall -fwarn-tabs build-depends: base >= 4.7 && < 5 , text >= 0.11 && < 2.0 , blaze-html
src/Web/Alert.hs view
@@ -8,7 +8,7 @@ import Data.Text.Lazy data Alert = Alert- { alertStatus :: AlertStatus+ { alertStatus :: AlertStatus , alertMessage :: Text } deriving (Eq, Show, Read)
src/Web/Alert/Renderer/Bootstrap3.hs view
@@ -12,9 +12,9 @@ ( renderAlertsBootstrap3 ) where -import Data.Text.Lazy-import Text.Blaze.Html-import qualified Text.Blaze.Html5 as H+import Data.Text.Lazy+import Text.Blaze.Html+import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as A import Web.Alert@@ -41,7 +41,7 @@ bootstrap3Clases :: AlertStatus -> AttributeValue bootstrap3Clases Default = "alert-default"-bootstrap3Clases Info = "alert-info"+bootstrap3Clases Info = "alert-info" bootstrap3Clases Success = "alert-success" bootstrap3Clases Warning = "alert-warning"-bootstrap3Clases Error = "alert-danger"+bootstrap3Clases Error = "alert-danger"
src/Web/Alert/Renderer/Bootstrap4.hs view
@@ -12,9 +12,9 @@ ( renderAlertsBootstrap4 ) where -import Data.Text.Lazy-import Text.Blaze.Html-import qualified Text.Blaze.Html5 as H+import Data.Text.Lazy+import Text.Blaze.Html+import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as A import Web.Alert@@ -42,7 +42,7 @@ bootstrap4Clases :: AlertStatus -> AttributeValue bootstrap4Clases Default = "alert-primary"-bootstrap4Clases Info = "alert-info"+bootstrap4Clases Info = "alert-info" bootstrap4Clases Success = "alert-success" bootstrap4Clases Warning = "alert-warning"-bootstrap4Clases Error = "alert-danger"+bootstrap4Clases Error = "alert-danger"
+ src/Web/Alert/Renderer/Bulma.hs view
@@ -0,0 +1,40 @@+{-# LANGUAGE OverloadedStrings #-}++-- | Render 'Alert's using Bulma+--+-- Dependencies (These should be accessible in your app):+--+-- * Bulma's CSS+--+-- * JQuery >= 3.2.1++module Web.Alert.Renderer.Bulma+ ( renderAlertsBulma+ ) where++import Data.Text.Lazy+import Text.Blaze.Html+import qualified Text.Blaze.Html5 as H+import qualified Text.Blaze.Html5.Attributes as A++import Web.Alert+import Web.Alert.Renderer.Common++-- | Render alerts using Bulma notifications+renderAlertsBulma :: [Alert] -> Text+renderAlertsBulma = renderAlerts+ "notification"+ []+ Nothing+ (Just close)+ bulmaClases++close :: Html+close = H.button ! A.class_ "delete" $ ""++bulmaClases :: AlertStatus -> AttributeValue+bulmaClases Default = "is-primary"+bulmaClases Info = "is-info"+bulmaClases Success = "is-success"+bulmaClases Warning = "is-warning"+bulmaClases Error = "is-danger"
src/Web/Alert/Renderer/Common.hs view
@@ -6,25 +6,24 @@ import Data.Maybe -import Data.Text.Lazy hiding (intersperse)-import Data.Monoid-import Data.List (intersperse)-import Data.Foldable (fold)-import Text.Blaze.Html-import Text.Blaze.Html.Renderer.Text-import qualified Text.Blaze.Html5 as H-import qualified Text.Blaze.Html5.Attributes as A+import Data.Foldable (fold)+import Data.List (intersperse)+import Data.Text.Lazy hiding (intersperse)+import Text.Blaze.Html+import Text.Blaze.Html.Renderer.Text+import qualified Text.Blaze.Html5 as H+import qualified Text.Blaze.Html5.Attributes as A import Web.Alert renderAlerts- :: AttributeValue- -> [AttributeValue]- -> Maybe Attribute- -> Maybe Html- -> (AlertStatus -> AttributeValue)- -> [Alert]- -> Text+ :: AttributeValue+ -> [AttributeValue]+ -> Maybe Attribute+ -> Maybe Html+ -> (AlertStatus -> AttributeValue)+ -> [Alert]+ -> Text renderAlerts _ _ _ _ _ [] = mempty renderAlerts baseClass extraClass mAttr mInternal clases msgs = renderHtml $ foldMap makeDivs msgs
src/Web/Alert/Renderer/Foundation5.hs view
@@ -15,9 +15,9 @@ , AlertType(..) ) where -import Data.Text.Lazy-import Text.Blaze.Html-import qualified Text.Blaze.Html5 as H+import Data.Text.Lazy+import Text.Blaze.Html+import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as A import Web.Alert@@ -48,11 +48,11 @@ alertTypeClass :: AlertType -> AttributeValue alertTypeClass Radius = "radius"-alertTypeClass Round = "round"+alertTypeClass Round = "round" foundation5Clases :: AlertStatus -> AttributeValue foundation5Clases Default = "secondary"-foundation5Clases Info = "info"+foundation5Clases Info = "info" foundation5Clases Success = "success" foundation5Clases Warning = "warning"-foundation5Clases Error = "alert"+foundation5Clases Error = "alert"