-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4253 from bbc/t1601-features-notification
Addition of announcement/notification banner
- Loading branch information
Showing
16 changed files
with
520 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package lib | ||
|
||
import play.api.ConfigLoader | ||
import play.api.libs.json._ | ||
import scala.collection.JavaConverters._ | ||
import scala.util.{Try, Success, Failure} | ||
import java.time.{LocalDate, Period} | ||
|
||
case class Announcement( | ||
announceId: String, | ||
description: String, | ||
endDate: LocalDate, | ||
url: String, | ||
urlText: String, | ||
category: String, | ||
lifespan: String | ||
) | ||
|
||
object Announcement { | ||
|
||
val announceCategory = Set("announcement", "information", "warning", "error", "success") | ||
val announceLifespan = Set("transient", "session", "persistent") | ||
|
||
implicit val writes: Writes[Announcement] = Json.writes[Announcement] | ||
|
||
implicit val configLoader: ConfigLoader[Seq[Announcement]] = { | ||
ConfigLoader(_.getConfigList).map( | ||
_.asScala.map(config => { | ||
|
||
val endDate = if (config.hasPath("endDate")) { | ||
val dte = Try(LocalDate.parse(config.getString("endDate"))) | ||
dte match { | ||
case Success(value) => value | ||
case Failure(_) => LocalDate.now().plus(Period.ofYears(1)) | ||
} | ||
} else { | ||
LocalDate.now().plus(Period.ofYears(1)) | ||
} | ||
|
||
val announceUrl = if (config.hasPath("url")) { | ||
config.getString("url") | ||
} else "" | ||
|
||
val urlText = if (config.hasPath("urlText")) { | ||
config.getString("urlText") | ||
} else "" | ||
|
||
val category = if (announceCategory.contains(config.getString("category"))) { | ||
config.getString("category") | ||
} else "announcement" // the expected category applicationConf announcements | ||
|
||
val lifespan = if (announceLifespan.contains(config.getString("lifespan"))) { | ||
config.getString("lifespan") | ||
} else "persistent" // the expected lifespan for applicationConf announcements | ||
|
||
Announcement(config.getString("announceId"), | ||
config.getString("description"), | ||
endDate, | ||
announceUrl, | ||
urlText, | ||
category, | ||
lifespan | ||
) | ||
})) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
kahuna/public/js/components/gr-notifications-banner/gr-notifications-banner.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
.outer-notifications { | ||
width: 100%; | ||
} | ||
|
||
.notification-container { | ||
width: 100%; | ||
display: flex; | ||
border-bottom: 1px solid black; | ||
} | ||
|
||
.notification-container-last { | ||
width: 100%; | ||
display: flex; | ||
} | ||
|
||
.notification-start { | ||
flex: 0 0 initial; | ||
display: flex; | ||
align-items: center; | ||
margin-top: 6px; | ||
padding: 8px 16px 8px 24px; | ||
justify-content: center; | ||
} | ||
|
||
.notification-start-icon { | ||
text-align: center; | ||
} | ||
|
||
.notification { | ||
flex: 1; | ||
display: flex; | ||
align-items: center; | ||
padding: 8px 0px 8px 0px; | ||
min-height: 28px; | ||
} | ||
|
||
.notification-end { | ||
flex: 0 0 initial; | ||
display: flex; | ||
align-items: center; | ||
padding: 8px 24px 8px 24px; | ||
} | ||
|
||
.notification-url { | ||
color: black; | ||
border-bottom: 1px solid black; | ||
font-weight: 500; | ||
} | ||
|
||
.notification-url:hover { | ||
color: black; | ||
font-weight: 500; | ||
} | ||
|
||
.notification-button { | ||
width: 80px; | ||
padding: 8px 0 0 0; | ||
text-align: center; | ||
} | ||
|
||
.notification-button:hover { | ||
cursor: pointer; | ||
} | ||
|
||
.notification-announcement { | ||
background: #A8CFFF; | ||
color: black; | ||
stroke: #A8CFFF; | ||
} | ||
|
||
.notification-information { | ||
background: #A8CFFF; | ||
color: black; | ||
stroke: #A8CFFF; | ||
} | ||
|
||
.notification-warning { | ||
background: #FEDB8B; | ||
color: black; | ||
stroke: #FEDB8B; | ||
} | ||
|
||
.notification-error { | ||
background: #EEBFBE; | ||
color: black; | ||
stroke: #EEBFBE; | ||
} | ||
|
||
.notification-success { | ||
background: #6FE290; | ||
color: black; | ||
stroke: black; | ||
} |
Oops, something went wrong.