unify bootstrap icon names in a data type

This commit is contained in:
Joey Hess 2012-09-09 15:09:22 -04:00
parent f75ac910c4
commit 690b424cad
2 changed files with 20 additions and 12 deletions

View file

@ -47,12 +47,20 @@ data Alert = Alert
, alertBlockDisplay :: Bool , alertBlockDisplay :: Bool
, alertClosable :: Bool , alertClosable :: Bool
, alertPriority :: AlertPriority , alertPriority :: AlertPriority
, alertIcon :: Maybe String , alertIcon :: Maybe AlertIcon
, alertCombiner :: Maybe AlertCombiner , alertCombiner :: Maybe AlertCombiner
, alertName :: Maybe AlertName , alertName :: Maybe AlertName
, alertButton :: Maybe AlertButton , alertButton :: Maybe AlertButton
} }
data AlertIcon = ActivityIcon | SuccessIcon | ErrorIcon | InfoIcon
bootstrapIcon :: AlertIcon -> String
bootstrapIcon ActivityIcon = "refresh"
bootstrapIcon InfoIcon = "info-sign"
bootstrapIcon SuccessIcon = "ok"
bootstrapIcon ErrorIcon = "exclamation-sign"
{- When clicked, a button always redirects to a URL {- When clicked, a button always redirects to a URL
- It may also run an IO action in the background, which is useful - It may also run an IO action in the background, which is useful
- to make the button close or otherwise change the alert. -} - to make the button close or otherwise change the alert. -}
@ -140,7 +148,7 @@ makeAlertFiller success alert
{ alertClass = if c == Activity then c' else c { alertClass = if c == Activity then c' else c
, alertPriority = Filler , alertPriority = Filler
, alertClosable = True , alertClosable = True
, alertIcon = Just $ if success then "ok" else "exclamation-sign" , alertIcon = Just $ if success then SuccessIcon else ErrorIcon
} }
where where
c = alertClass alert c = alertClass alert
@ -190,7 +198,7 @@ baseActivityAlert = Alert
, alertBlockDisplay = False , alertBlockDisplay = False
, alertClosable = False , alertClosable = False
, alertPriority = Medium , alertPriority = Medium
, alertIcon = Just "refresh" , alertIcon = Just ActivityIcon
, alertCombiner = Nothing , alertCombiner = Nothing
, alertName = Nothing , alertName = Nothing
, alertButton = Nothing , alertButton = Nothing
@ -205,7 +213,7 @@ warningAlert name msg = Alert
, alertBlockDisplay = True , alertBlockDisplay = True
, alertClosable = True , alertClosable = True
, alertPriority = High , alertPriority = High
, alertIcon = Just "exclamation-sign" , alertIcon = Just ErrorIcon
, alertCombiner = Just $ dataCombiner (++) , alertCombiner = Just $ dataCombiner (++)
, alertName = Just $ WarningAlert name , alertName = Just $ WarningAlert name
, alertButton = Nothing , alertButton = Nothing
@ -267,7 +275,7 @@ sanityCheckFixAlert msg = Alert
, alertBlockDisplay = True , alertBlockDisplay = True
, alertPriority = High , alertPriority = High
, alertClosable = True , alertClosable = True
, alertIcon = Just "exclamation-sign" , alertIcon = Just ErrorIcon
, alertName = Just SanityCheckFixAlert , alertName = Just SanityCheckFixAlert
, alertCombiner = Just $ dataCombiner (++) , alertCombiner = Just $ dataCombiner (++)
, alertButton = Nothing , alertButton = Nothing
@ -286,7 +294,7 @@ pairRequestAlert repo msg button = Alert
, alertBlockDisplay = True , alertBlockDisplay = True
, alertPriority = High , alertPriority = High
, alertClosable = True , alertClosable = True
, alertIcon = Just "info-sign" , alertIcon = Just InfoIcon
, alertName = Just $ PairRequestAlert repo , alertName = Just $ PairRequestAlert repo
, alertCombiner = Just $ dataCombiner $ const id , alertCombiner = Just $ dataCombiner $ const id
, alertButton = Just button , alertButton = Just button

View file

@ -4,16 +4,16 @@
$maybe h <- renderAlertHeader alert $maybe h <- renderAlertHeader alert
$if block $if block
<h4 .alert-heading> <h4 .alert-heading>
$maybe name <- alertIcon alert $maybe i <- alertIcon alert
<i .icon-#{name}></i> # <i .icon-#{bootstrapIcon i}></i> #
#{h} #{h}
$else $else
$maybe name <- alertIcon alert $maybe i <- alertIcon alert
<i .icon-#{name}></i> # <i .icon-#{bootstrapIcon i}></i> #
<strong>#{h}</strong> # <strong>#{h}</strong> #
$nothing $nothing
$maybe name <- alertIcon alert $maybe i <- alertIcon alert
<i .icon-#{name}></i> # <i .icon-#{bootstrapIcon i}></i> #
#{renderAlertMessage alert} #{renderAlertMessage alert}
$maybe button <- alertButton alert $maybe button <- alertButton alert
<br> <br>