From 690b424cad86f6ebd4e5f9755f0f2751aafb4cdd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Sep 2012 15:09:22 -0400 Subject: unify bootstrap icon names in a data type --- Assistant/Alert.hs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'Assistant') diff --git a/Assistant/Alert.hs b/Assistant/Alert.hs index f67de2402..f9cf4b3a8 100644 --- a/Assistant/Alert.hs +++ b/Assistant/Alert.hs @@ -47,12 +47,20 @@ data Alert = Alert , alertBlockDisplay :: Bool , alertClosable :: Bool , alertPriority :: AlertPriority - , alertIcon :: Maybe String + , alertIcon :: Maybe AlertIcon , alertCombiner :: Maybe AlertCombiner , alertName :: Maybe AlertName , 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 - It may also run an IO action in the background, which is useful - 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 , alertPriority = Filler , alertClosable = True - , alertIcon = Just $ if success then "ok" else "exclamation-sign" + , alertIcon = Just $ if success then SuccessIcon else ErrorIcon } where c = alertClass alert @@ -190,7 +198,7 @@ baseActivityAlert = Alert , alertBlockDisplay = False , alertClosable = False , alertPriority = Medium - , alertIcon = Just "refresh" + , alertIcon = Just ActivityIcon , alertCombiner = Nothing , alertName = Nothing , alertButton = Nothing @@ -205,7 +213,7 @@ warningAlert name msg = Alert , alertBlockDisplay = True , alertClosable = True , alertPriority = High - , alertIcon = Just "exclamation-sign" + , alertIcon = Just ErrorIcon , alertCombiner = Just $ dataCombiner (++) , alertName = Just $ WarningAlert name , alertButton = Nothing @@ -267,7 +275,7 @@ sanityCheckFixAlert msg = Alert , alertBlockDisplay = True , alertPriority = High , alertClosable = True - , alertIcon = Just "exclamation-sign" + , alertIcon = Just ErrorIcon , alertName = Just SanityCheckFixAlert , alertCombiner = Just $ dataCombiner (++) , alertButton = Nothing @@ -286,7 +294,7 @@ pairRequestAlert repo msg button = Alert , alertBlockDisplay = True , alertPriority = High , alertClosable = True - , alertIcon = Just "info-sign" + , alertIcon = Just InfoIcon , alertName = Just $ PairRequestAlert repo , alertCombiner = Just $ dataCombiner $ const id , alertButton = Just button -- cgit v1.2.3