Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move notification banner back to top and add banner type capabilities #359

Merged
merged 23 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8f9327d
feat: add top aligned banner that does not block anything
karrui Sep 22, 2020
12dcff2
style: update styling of app to allow for sticky banner/navbar
karrui Sep 22, 2020
55a4d61
feat: remove scroll-to-id directive and use $anchorScroll
karrui Sep 22, 2020
4174f64
style: update MyInfo field tab styling
karrui Sep 22, 2020
e136237
style: update form builder styling for mobile
karrui Sep 22, 2020
3445f70
feat: add function to process banner message encoding to display
karrui Sep 22, 2020
ebcc466
style: add banner styling for the various types of banners
karrui Sep 22, 2020
e158c57
style: update styling for signin view to accommodate banner
karrui Sep 22, 2020
e07c734
style: correct link styling for banner
karrui Sep 22, 2020
d9434e1
chore: add documentation and example to banner env vars
karrui Sep 22, 2020
4cc90f2
Merge branch 'develop' into feat/banner-changes
karrui Sep 22, 2020
dbb3be0
style: update avatar styling to center on iOS
karrui Sep 22, 2020
7a264bc
Merge branch 'develop' into feat/banner-changes
karrui Sep 24, 2020
aef4155
fix: typo in banner component comment
karrui Sep 24, 2020
43136d8
style: add vendor prefixes to avatar-dropdown.css
karrui Sep 28, 2020
3e5cc54
style: remove section.content styling add add .page-container class
karrui Sep 28, 2020
7ecaa99
feat: add page-container class to all route htmls
karrui Sep 28, 2020
5b68d27
feat: add back overlay to trigger
karrui Sep 28, 2020
5552c9f
feat: add id to banner component
karrui Sep 28, 2020
514c2bf
feat: add dynamic padding to form header when banner is shown
karrui Sep 28, 2020
9ab0829
feat: make retrieval of banner type more forgiving
karrui Sep 28, 2020
50f2db3
style: fix wrong paddings on myinfo disabled overlay in add fields
karrui Sep 29, 2020
e1d9a1a
style: update add myinfo field padding to be back to original style
karrui Sep 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/DEPLOYMENT_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,45 @@ The following env variables are set in Travis:

#### Banners

These environment variables allow us to set notification banners in the
application without a full redeployment of the application. Note the hierarchy
of the banner content.

In addition, you can change the color of the banner by adding a type encoding in
the environment variable string. The default banner type will be `info` if no encoding is
provided.

The possible banner type prefixes are: `info:`, `warn:`, and `error:`. Other
prefixes will not work and the invalid prefixes will be shown in the banner
text.

Examples:

```
SITE_BANNER_CONTENT=info:This is an info banner. You can also add links in the text like https://example.com. There is also a dismiss button to the right of the text.
```

![Info banner
example](https://user-images.githubusercontent.com/22133008/93852946-8a867780-fce5-11ea-929f-a0ce1c6796b9.png)

```
SITE_BANNER_CONTENT=warn:This is a warning banner. You can also add links in the text like https://example.com
```

![Warning banner example](https://user-images.githubusercontent.com/22133008/93852559-cec54800-fce4-11ea-9376-9b2802e8ac62.png)

```
SITE_BANNER_CONTENT=error:This is an error banner. You can also add links in the text like https://example.com
```

![Error banner example](https://user-images.githubusercontent.com/22133008/93852689-1055f300-fce5-11ea-956d-d5966cbe86d8.png)

```
SITE_BANNER_CONTENT=hello:This is an invalid banner type, and the full text will be shown. The default banner type of `info` will used.
```

![Invalid banner default example](https://user-images.githubusercontent.com/22133008/93853306-392ab800-fce6-11ea-9891-f752bdad236e.png)

| Variable | Description |
| :----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SITE_BANNER_CONTENT` | If set, displays a banner message on both private routes that `ADMIN_BANNER_CONTENT` covers **and** public form routes that `IS_GENERAL_MAINTENANCE` covers. Overrides all other banner environment variables |
Expand Down
1 change: 1 addition & 0 deletions src/public/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@import './modules/core/css/admin-form-header.css';
@import './modules/core/css/sg-govt-banner.css';
@import './modules/core/css/landing.css';
@import './modules/core/css/banner.css';
@import './modules/core/css/how-it-works.css';
@import './modules/forms/admin/css/pop-up-modal.css';
@import './modules/forms/admin/css/edit-form.css';
Expand Down
1 change: 0 additions & 1 deletion src/public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ require('./modules/forms/admin/directives/configure-form.client.directive.js')
require('./modules/forms/admin/directives/configure-mobile.client.directive.js')
require('./modules/forms/admin/directives/verify-secret-key.client.directive.js')
require('./modules/forms/admin/directives/daterangepicker.client.directive.js')
require('./modules/forms/admin/directives/scroll-to-id.client.directive.js')
require('./modules/forms/admin/directives/edit-captcha.client.directive.js')
require('./modules/forms/admin/controllers/create-form-template-modal.client.controller.js')
require('./modules/forms/admin/controllers/collaborator-modal.client.controller.js')
Expand Down
13 changes: 10 additions & 3 deletions src/public/modules/core/componentViews/banner.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<div class="banner-container" ng-if="!vm.bannerHidden">
<div
class="banner-container banner-container-{{vm.bannerType}}"
ng-if="!vm.bannerHidden"
>
<div>
<span ng-bind-html="vm.message"></span>
<span ng-bind-html="vm.bannerMessage"></span>
</div>
<div id="dismiss" ng-click="vm.dismissBanner()">
<div
ng-if="vm.bannerType === vm.BANNER_TYPES.info"
id="dismiss"
ng-click="vm.dismissBanner()"
>
<i class="bx bx-x bx-md"></i>
</div>
</div>
24 changes: 24 additions & 0 deletions src/public/modules/core/components/banner.client.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ angular.module('core').component('bannerComponent', {
function bannerController() {
const vm = this

vm.BANNER_TYPES = {
info: 'info',
warn: 'warn',
error: 'error',
}

vm.$onInit = () => {
if (!vm.message) {
vm.bannerHidden = true
} else {
processBannerMessage()
vm.bannerHidden = false
}
}
Expand All @@ -26,4 +33,21 @@ function bannerController() {
vm.bannerHidden = true
})
}

const processBannerMessage = () => {
mantariksh marked this conversation as resolved.
Show resolved Hide resolved
// Retrieve banenr type from message, but it is possible that no types
karrui marked this conversation as resolved.
Show resolved Hide resolved
// exist.
const vmMessage = vm.message || ''
const type = vmMessage.split(':').shift().toLowerCase()
karrui marked this conversation as resolved.
Show resolved Hide resolved
const retrievedType = vm.BANNER_TYPES[type]

vm.bannerType = retrievedType || vm.BANNER_TYPES.info

// If there is a type retrieved from message, remove the type encoding in
// the message.
// The + 1 is to also remove the semicolon from the encoding
vm.bannerMessage = retrievedType
? vmMessage.substring(retrievedType.length + 1).trim()
karrui marked this conversation as resolved.
Show resolved Hide resolved
: vmMessage
mantariksh marked this conversation as resolved.
Show resolved Hide resolved
}
}
33 changes: 33 additions & 0 deletions src/public/modules/core/css/admin-form-header.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
/*
* Prefixed by https://autoprefixer.github.io
karrui marked this conversation as resolved.
Show resolved Hide resolved
* PostCSS: v7.0.29,
* Autoprefixer: v9.7.6
* Browsers: last 4 version
*/

/* Form header */

#admin-form .vcenter {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}

#admin-form #form-header {
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
-webkit-box-flex: 0;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
}

#admin-form #form-header #header-myforms {
Expand All @@ -26,8 +42,14 @@

#admin-form #form-header .right-spacer {
margin-right: 15px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
}

Expand All @@ -48,6 +70,7 @@

#admin-form #form-header #header-myforms a:hover {
color: #2f60ce;
-webkit-text-decoration-line: none;
text-decoration-line: none;
}

Expand All @@ -61,6 +84,7 @@
margin-bottom: 0;
white-space: nowrap;
overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
}

Expand Down Expand Up @@ -205,6 +229,8 @@
width: 700px;
top: 125px;
left: 50%;
-webkit-transform: translate(-50%);
-ms-transform: translate(-50%);
transform: translate(-50%);
}

Expand Down Expand Up @@ -379,6 +405,7 @@
margin-bottom: 10px;
white-space: nowrap;
overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
}

Expand All @@ -396,9 +423,15 @@
cursor: pointer;
height: 20px;
width: 20px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
font-size: 30px;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
color: #979797;
margin-left: 20px;
Expand Down
91 changes: 91 additions & 0 deletions src/public/modules/core/css/banner.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Prefixed by https://autoprefixer.github.io
* PostCSS: v7.0.29,
* Autoprefixer: v9.7.6
* Browsers: last 4 version
*/

/* BANNER COMPONENT */

banner-component {
-webkit-box-flex: 0;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
}

.banner-container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
padding: 12px 20px;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
line-height: 20px;
font-weight: normal;
overflow: hidden;
font-size: 16px;
z-index: 10;
width: 100%;
position: relative;
}

.banner-container-info {
/* Additional padding as opposed to the rest to accomodate dismiss button */
padding: 12px 50px 12px 20px;
background-color: #1e3e84;
color: #f0f4f6;
}

.banner-container-info a {
color: #f0f4f6;
}

.banner-container a {
text-decoration: underline;
cursor: pointer;
font-weight: normal;
}

.banner-container-warn {
background-color: #ffe47a;
color: #323232;
}

.banner-container-warn a {
color: #323232;
}

.banner-container-error {
background-color: #a94442;
color: #fff;
}

.banner-container-error a {
color: #fff;
}

.banner-container div {
display: inline-block;
}

.banner-container #dismiss {
position: absolute;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
right: 0;
top: 0;
height: 100%;
width: 50px;
cursor: pointer;
}
Loading