Skip to content

Commit

Permalink
Merge pull request #9778 from RocketChat/alerts
Browse files Browse the repository at this point in the history
[NEW] General alert banner
  • Loading branch information
rodrigok authored Feb 21, 2018
2 parents 013f960 + 735d60f commit e92e59b
Show file tree
Hide file tree
Showing 12 changed files with 13,838 additions and 17 deletions.
13,605 changes: 13,605 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions packages/rocketchat-theme/client/imports/components/alerts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
.rc-alerts {
position: relative;

z-index: 10;

display: flex;

padding: var(--alerts-padding-vertical) var(--alerts-padding);

animation-name: dropdown-show;
animation-duration: 0.3s;

text-align: center;

color: var(--alerts-color);

background: var(--alerts-background);

font-size: var(--alerts-font-size);
align-items: center;
flex-grow: 0;

&--danger {
background: var(--rc-color-error);
}

&--alert {
background: var(--rc-color-alert);
}

&--large > &__content {
flex-direction: column;

text-align: start;
}

&--has-action {
cursor: pointer;
}

&__icon {
cursor: pointer;

color: inherit;

flex-grow: 0;

&--close {
transform: rotate(45deg);
}
}

&__title {
font-weight: bold;
}

&__title,
&__line {
display: block;

overflow: hidden;

white-space: nowrap;
text-overflow: ellipsis;

flex-grow: 0;
}

&__content > &__title + &__line {
margin: 0 var(--alerts-padding-vertical);
}

&--large > &__content > &__title + &__line {
margin: 0;
}

&--large > &__icon {
font-size: 30px;
}

&--large > &__big-icon {
width: 40px;
height: 40px;

font-size: 40px;
}

&--large {
padding: var(--alerts-padding-vertical-large) var(--alerts-padding);
justify-content: start;
}

&__content {
display: flex;
overflow: hidden;

flex-direction: row;

flex: 1;

margin: 0 var(--alerts-padding-vertical);

justify-content: center;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
.main-content {
position: relative;
z-index: 0 !important;

flex: 1 1 100%;

width: 1vw;
Expand All @@ -26,12 +23,3 @@
color: var(--status-invisible);
}
}

@media (width <= 780px) {
.main-content {
position: fixed;

width: 100%;
height: 100%;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.sidebar {

position: relative;

z-index: 2;

display: flex;
Expand Down Expand Up @@ -69,6 +71,10 @@
}

@media (width < 780px) {
.sidebar {
position: absolute;
}

.sidebar:not(.sidebar-light) {
user-select: none;
transform: translate3d(calc(var(--sidebar-width) * -1), 0, 0);
Expand Down
9 changes: 8 additions & 1 deletion packages/rocketchat-theme/client/imports/general/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ html {
body {
position: relative;

display: flex;

flex-direction: column;

overflow: visible;

width: 100%;
Expand Down Expand Up @@ -72,7 +76,8 @@ button {
#rocket-chat {
display: flex;

height: 100%;
flex: 1;

align-items: stretch;

&.animated-hidden {
Expand Down Expand Up @@ -116,12 +121,14 @@ button {
}

.rc-icon {

overflow: hidden;

width: 1.25em;
height: 1em;

vertical-align: -0.15em;
fill: currentColor;

fill: currentColor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2859,7 +2859,6 @@

&::before {
position: absolute;
z-index: 1;
top: -30px;
left: calc(50% - 70px);

Expand All @@ -2880,6 +2879,7 @@
&::after {
position: absolute;
top: -20px;
z-index: -1;
left: 0;

display: block;
Expand Down Expand Up @@ -5492,9 +5492,6 @@ body:not(.is-cordova) {

@media (width <= 780px) {
.rc-old.main-content {
z-index: 1;
left: 0;

transition: right 0.25s cubic-bezier(0.5, 0, 0.1, 1), transform 0.1s linear;
will-change: transform;
}
Expand Down
11 changes: 11 additions & 0 deletions packages/rocketchat-theme/client/imports/general/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,15 @@
--tooltip-text-color: var(--color-white);
--tooltip-text-size: 0.75rem;
--tooltip-radius: var(--border-radius);

/*
* alert
*/
--alerts-padding: var(--sidebar-default-padding);
--alerts-padding-vertical: 10px;
--alerts-padding-vertical-large: 20px;
--alerts-background: #1d73f5;
--alerts-color: var(--color-white);
--alerts-font-size: var(--text-default-size);

}
1 change: 1 addition & 0 deletions packages/rocketchat-theme/client/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
@import 'imports/components/avatar.css';
@import 'imports/components/badge.css';
@import 'imports/components/popover.css';
@import 'imports/components/alerts.css';
@import 'imports/components/popout.css';
@import 'imports/components/modal.css';
@import 'imports/components/tooltip.css';
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-ui-master/client/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>

<body class="global-font-family color-primary-font-color">
<div id='alert-anchor'></div>
</body>

<template name="main">
Expand Down
29 changes: 29 additions & 0 deletions packages/rocketchat-ui/client/views/app/alerts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template name="alerts">
<div class="rc-alerts {{modifiers}} {{customclass}}" data-popover="popover">
{{#if icon}}
<div class="rc-alerts__big-icon rc-alerts__icon {{hasAction}} js-action">
{{> icon icon=icon }}
</div>
{{/if}}
<div class="rc-alerts__content {{hasAction}} js-action">
{{#if template}}
{{> Template.dynamic template=template data=data}}
{{else}}
{{#if title}}
<div class="rc-alerts__title">
{{title}}
</div>
{{/if}}
<div class="rc-alerts__line">
{{text}}
</div>
{{{html}}}
{{/if}}
</div>
{{#if closable}}
<div class="rc-alerts__icon js-close">
{{> icon block="rc-alerts__icon rc-alerts__icon--close" icon='plus'}}
</div>
{{/if}}
</div>
</template>
69 changes: 69 additions & 0 deletions packages/rocketchat-ui/client/views/app/alerts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* globals alerts */
this.alerts = {
renderedAlert: null,
open(config) {
this.close();

config.closable = typeof(config.closable) === typeof(true) ? config.closable : true;

if (config.timer) {
this.timer = setTimeout(() => this.close(), config.timer);
}

this.renderedAlert = Blaze.renderWithData(Template.alerts, config, document.body, document.body.querySelector('#alert-anchor'));
},
close() {
if (this.timer) {
clearTimeout(this.timer);
delete this.timer;
}
if (!this.renderedAlert) {
return false;
}

Blaze.remove(this.renderedAlert);

const activeElement = this.renderedAlert.dataVar.curValue.activeElement;
if (activeElement) {
$(activeElement).removeClass('active');
}
}
};

Template.alerts.helpers({
hasAction() {
return Template.instance().data.action? 'rc-alerts--has-action': '';
},
modifiers() {
return (Template.instance().data.modifiers || []).map(mod => `rc-alerts--${ mod }`).join(' ');
}
});

Template.alerts.onRendered(function() {
if (this.data.onRendered) {
this.data.onRendered();
}
});

Template.alerts.onDestroyed(function() {
if (this.data.onDestroyed) {
this.data.onDestroyed();
}
this.data.onClose && this.data.onClose();
});

Template.alerts.events({
'click .js-action'(e, instance) {
if (!this.action) {
return;
}
this.action.call(this, e, instance.data.data);
},
'click .js-close'() {
alerts.close();
}
});

Template.alerts.helpers({
isSafariIos: /iP(ad|hone|od).+Version\/[\d\.]+.*Safari/i.test(navigator.userAgent)
});
2 changes: 2 additions & 0 deletions packages/rocketchat-ui/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Package.onUse(function(api) {
api.addFiles('client/views/app/pageContainer.html', 'client');
api.addFiles('client/views/app/pageSettingsContainer.html', 'client');
api.addFiles('client/views/app/popout.html', 'client');
api.addFiles('client/views/app/alerts.html', 'client');

api.addFiles('client/views/app/privateHistory.html', 'client');
api.addFiles('client/views/app/room.html', 'client');
Expand Down Expand Up @@ -115,6 +116,7 @@ Package.onUse(function(api) {
api.addFiles('client/views/app/secretURL.js', 'client');
api.addFiles('client/views/app/videoCall/videoButtons.js', 'client');
api.addFiles('client/views/app/videoCall/videoCall.js', 'client');
api.addFiles('client/views/app/alerts.js', 'client');
api.addFiles('client/views/app/popover.js', 'client');
api.addFiles('client/views/app/popout.js', 'client');
api.addFiles('client/views/app/modal.js', 'client');
Expand Down

0 comments on commit e92e59b

Please sign in to comment.