From c2e13cf4df1fc8a6e0d919b5171a7eaf002fd381 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 27 Aug 2019 09:34:04 +0200 Subject: [PATCH] feat: optional ribbon --- config/settings.yml | 1 + src/Foundation.hs | 2 ++ src/Settings.hs | 3 +++ start.sh | 1 + templates/default-layout.hamlet | 4 ++++ templates/default-layout.lucius | 24 ++++++++++++++++++++++++ 6 files changed, 35 insertions(+) diff --git a/config/settings.yml b/config/settings.yml index 9d787ed7f..ca2520708 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -122,3 +122,4 @@ user-defaults: warning-days: 1209600 instance-id: "_env:INSTANCE_ID:instance" +ribbon: "_env:RIBBON:" diff --git a/src/Foundation.hs b/src/Foundation.hs index 5077ef4a5..1852150ac 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -1664,6 +1664,8 @@ siteLayout' headingOverride widget = do hasPageActions = hasPrimaryPageActions || hasSecondaryPageActions hasSecondaryPageActions = any (is _PageActionSecondary) $ toListOf (traverse . _1 . _menuItemType) menuTypes hasPrimaryPageActions = any (is _PageActionPrime) $ toListOf (traverse . _1 . _menuItemType) menuTypes + contentRibbon :: Maybe Widget + contentRibbon = fmap toWidget appRibbon MsgRenderer mr <- getMsgRenderer let diff --git a/src/Settings.hs b/src/Settings.hs index 7bec37cb8..7e99cae3a 100644 --- a/src/Settings.hs +++ b/src/Settings.hs @@ -138,6 +138,7 @@ data AppSettings = AppSettings , appAuthPWHash :: PWHashConf , appInitialInstanceID :: Maybe (Either FilePath UUID) + , appRibbon :: Maybe Text } deriving (Show) data LogSettings = LogSettings @@ -419,6 +420,8 @@ instance FromJSON AppSettings where _ -> return () return val' + appRibbon <- assertM (not . Text.null) . fmap Text.strip <$> o.:? "ribbon" + return AppSettings {..} makeClassy_ ''AppSettings diff --git a/start.sh b/start.sh index a9ef7cb8d..ffe083bea 100755 --- a/start.sh +++ b/start.sh @@ -10,6 +10,7 @@ export LOG_ALL=${LOG_ALL:-false} export LOGLEVEL=${LOGLEVEL:-info} export DUMMY_LOGIN=${DUMMY_LOGIN:-true} export ALLOW_DEPRECATED=${ALLOW_DEPRECATED:-true} +export RIBBON=${RIBBON:-Localhost} move-back() { mv -v .stack-work .stack-work-run diff --git a/templates/default-layout.hamlet b/templates/default-layout.hamlet index 21ac81042..cdcffaad5 100644 --- a/templates/default-layout.hamlet +++ b/templates/default-layout.hamlet @@ -5,6 +5,10 @@ $if not isModal ^{navbar} + $maybe ribbon <- contentRibbon +
+ ^{ribbon} +
diff --git a/templates/default-layout.lucius b/templates/default-layout.lucius index b3b493fd5..99dd61366 100644 --- a/templates/default-layout.lucius +++ b/templates/default-layout.lucius @@ -694,3 +694,27 @@ section { .form--inline { display: inline-block; } + + +.ribbon { + position: fixed; + top: calc(40px + var(--header-height)); + right: -63px; + transform: rotate(45deg); + width: 250px; + background: var(--color-error); + text-align: center; + color: var(--color-lightwhite); + font-weight: 600; + font-size: 1.25rem; + line-height: 2em; + box-shadow: 0 0 3px rgba(0, 0, 0, 0.4); + z-index: 19; + pointer-events: none; +} + +@media (max-height: 500px) { + .ribbon { + top: calc(25px + var(--header-height-collapsed)); + } +}