-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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 #9778 from RocketChat/alerts
[NEW] General alert banner
- Loading branch information
Showing
12 changed files
with
13,838 additions
and
17 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
105 changes: 105 additions & 0 deletions
105
packages/rocketchat-theme/client/imports/components/alerts.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,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; | ||
} | ||
} |
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
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
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,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> |
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,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) | ||
}); |
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