Skip to content

Commit 13cc161

Browse files
authored
Merge pull request #24 from leekelleher/dev/alerts-notifications
Adds alerts and notifications examples
2 parents 134fc89 + de968bb commit 13cc161

File tree

5 files changed

+147
-0
lines changed

5 files changed

+147
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
(function () {
2+
'use strict';
3+
4+
function alertsController($scope, exampleResource, notificationsService) {
5+
6+
var vm = this;
7+
8+
function init() {
9+
10+
vm.loading = true;
11+
12+
vm.linkAway = exampleResource.linkAway;
13+
14+
vm.alerts = [
15+
{ type: "form", class: "alert alert-form", headline: "Form", message: "A message, displaying on a white background with a dark border.", style: "info" },
16+
{ type: "info", class: "alert alert-info", headline: "Info", message: "An informational message, displaying on a blue background.", style: "action" },
17+
{ type: "success", class: "alert alert-success", headline: "Success", message: "A success message, displaying on a green background.", style: "success" },
18+
{ type: "warning", class: "alert alert-warning", headline: "Warning", message: "A warning message, displaying on an orange background.", style: "warning" },
19+
{ type: "error", class: "alert alert-error", headline: "Error", message: "An error message, displaying on a red background.", style: "danger" },
20+
{ type: "", class: "well", headline: "Well", message: "An informational message, displaying inset on a gray background.", style: "info" }
21+
];
22+
23+
vm.snippetNotification = `// To display a success notification.
24+
notificationsService.success("Document Published", "hooraaaay for you!");
25+
26+
// To display an error notification.
27+
notificationsService.error("Document Failed", "booooh");
28+
29+
// To display a custom notification, with sticky.
30+
notificationsService.add({ headline: 'Custom notification', message: 'My custom notification message', type: 'info', sticky: true });`;
31+
32+
vm.showNotification = showNotification;
33+
vm.snippetAlert = snippetAlert;
34+
};
35+
36+
function showNotification(item) {
37+
notificationsService.add({
38+
headline: item.headline,
39+
message: item.message,
40+
type: item.type
41+
});
42+
};
43+
44+
function snippetAlert(item) {
45+
return `<div class="${item.class}" role="alert">
46+
<h4>${item.headline}</h4>
47+
<span>${item.message}</span>
48+
</div>`;
49+
};
50+
51+
init();
52+
};
53+
54+
angular.module('umbraco').controller('alertsController', alertsController);
55+
})();
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<div class="editor-panels-container" ng-controller="alertsController as vm">
2+
3+
<umb-box>
4+
<umb-box-header title-key="alerts_alertsTitle"></umb-box-header>
5+
<umb-box-content>
6+
<p>The alerts and notifications can provide contextual feedback messages for typical user actions.</p>
7+
<p>The difference between alerts and notifications is that, an <strong>alert</strong> is a set of visual styles to display a feedback message, whereas a <strong>notification</strong> is a temporary feedback message that is displayed at the bottom of the screen.</p>
8+
</umb-box-content>
9+
</umb-box>
10+
11+
<umb-box>
12+
<umb-box-header title="Notifications">
13+
<umb-button action="vm.linkAway('https://our.umbraco.com/apidocs/v8/ui/#/api/umbraco.directives.directive:umbNotifications');"
14+
label="umb-notifications"
15+
type="button"
16+
icon="icon-book"
17+
button-style="info">
18+
</umb-button>
19+
</umb-box-header>
20+
<umb-box-content>
21+
22+
<p>A notification is a contextual feedback message that appears at the bottom of the screen.</p>
23+
24+
<h5>Initialization</h5>
25+
<p>The initialization of the <code>umb-notifications</code> directive is done at page level, typically you will not need to this, as it is already added to the main CMS backoffice pages.</p>
26+
<p>But if you do need to add the directive, this is the code snippet:</p>
27+
<umb-code-snippet language="'html'">&lt;umb-notifications&gt;&lt;/umb-notifications&gt;</umb-code-snippet>
28+
29+
<h5>Examples</h5>
30+
<p>The styling and types of the notifications are the same as the alerts (below). Use the buttons below to trigger the different types.</p>
31+
32+
<div class="mb3">
33+
<umb-button ng-repeat="item in vm.alerts"
34+
ng-if="item.type != ''"
35+
action="vm.showNotification(item)"
36+
label="{{item.headline}}"
37+
type="button"
38+
button-style="{{item.style}}">
39+
</umb-button>
40+
</div>
41+
42+
<p>The default timeout for a notification message before it disappears is 10 seconds.</p>
43+
44+
<h5>Code</h5>
45+
<p>To use notifications in your own code, you will need to inject the <a href="https://our.umbraco.com/apidocs/v8/ui/#/api/umbraco.services.notificationsService" target="_blank"><code>notificationsService</code></a> into your AngularJS code.</p>
46+
<umb-code-snippet language="'javascript'">{{vm.snippetNotification}}</umb-code-snippet>
47+
48+
</umb-box-content>
49+
</umb-box>
50+
51+
<umb-box>
52+
<umb-box-header title="Alerts"></umb-box-header>
53+
<umb-box-content>
54+
55+
<p>An alert is a set of visual styles (e.g. CSS classes), that can be used to display feedback messages.</p>
56+
57+
<div class="flex" ng-repeat="item in vm.alerts">
58+
59+
<div class="mt3 umb-editor--small">
60+
<div ng-class="item.class" role="alert">
61+
<h4 ng-bind="item.headline"></h4>
62+
<span ng-bind="item.message"></span>
63+
</div>
64+
</div>
65+
66+
<div class="ml3 umb-editor--medium">
67+
<umb-code-snippet language="'html'">{{vm.snippetAlert(item)}}</umb-code-snippet>
68+
</div>
69+
70+
</div>
71+
72+
</umb-box-content>
73+
</umb-box>
74+
75+
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<language alias="en" intName="English (UK)" localName="English (UK)" lcid="" culture="en-GB">
3+
<area alias="alerts">
4+
<key alias="alertsTitle">Alerts and notifications</key>
5+
</area>
6+
</language>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"javascript": [
3+
"~/App_Plugins/uiexamples/alerts/alerts.controller.js"
4+
]
5+
}

src/Our.Umbraco.UiExamples/App_Plugins/uiexamples/uiexamples.section.controller.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
'alias': 'editorPanels',
5959
'icon': 'icon-screensharing',
6060
'view': Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + '/uiexamples/editorPanels/panels.html',
61+
},
62+
{
63+
'name': 'Alerts',
64+
'alias': 'alerts',
65+
'icon': 'icon-alert',
66+
'view': Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + '/uiexamples/alerts/alerts.html',
6167
}
6268
]
6369
}

0 commit comments

Comments
 (0)