Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion overview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@

## Layout components

[![List](../ui/list.reel/screenshot.png)](../ui/list.reel)
[![List](../ui/list.reel/screenshot.png)](../ui/list.reel)
[![Alert](../ui/alert.reel/screenshot.png)](../ui/alert.reel)
[![Confirm](../ui/confirm.reel/screenshot.png)](../ui/confirm.reel)
13 changes: 10 additions & 3 deletions overview/ui/main.reel/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ td:nth-child(2) { background: hsl(0,0%,90%); }
td:nth-child(3) { background: hsl(0,0%,96%); }
td:nth-child(4) { background: hsl(0,0%,24%); }

.layout td:nth-child(3) { background: hsl(0,0%,70%); }
.layout td:nth-child(4) { background: hsl(0,0%,40%); }

.modal td:nth-child(2) {
background: hsla(0,0%,0%,.1);
}
Expand All @@ -100,3 +97,13 @@ td:nth-child(4) { background: hsl(0,0%,24%); }
.layout td:nth-child(4) {
background: hsl(0,0%,40%);
}

.test-alert {
display: inline-block !important;
}

.test-alert .montage-Overlay {
position: relative !important;
display: inline-block !important;
margin: 0px;
}
14 changes: 14 additions & 0 deletions overview/ui/main.reel/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@ <h2>Layout components</h2>
</td>
</tr>

<tr>
<td>Alert</td>
<td><div data-montage-id="alert" class="test-alert"></div></td>
<td data-montage-skin="light"><div data-montage-id="alert-light" class="test-alert"></div></td>
<td data-montage-skin="dark"><div data-montage-id="alert-dark" class="test-alert"></div></td>
</tr>

<tr>
<td>Confirm</td>
<td><div data-montage-id="confirm" class="test-alert"></div></td>
<td data-montage-skin="light"><div data-montage-id="confirm-light" class="test-alert"></div></td>
<td data-montage-skin="dark"><div data-montage-id="confirm-dark" class="test-alert"></div></td>
</tr>


</tbody>
</table>
Expand Down
14 changes: 13 additions & 1 deletion overview/ui/main.reel/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
var Component = require("montage/ui/component").Component;

exports.Main = Component.specialize({});
exports.Main = Component.specialize({

draw: {
value: function() {
// There can normally only be one overlay, absolutely-positioned,
// so we need to manually mangle the dom and style them to appear inline.
var overlays = ["alert", "alert-light", "alert-dark", "confirm", "confirm-light", "confirm-dark"];
overlays.forEach(function(overlayName){
this[overlayName].element.appendChild(this[overlayName]._overlay.element);
}.bind(this));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing .bind(this) you can pass this in as the last argument of forEach

}
}
});
18 changes: 16 additions & 2 deletions overview/ui/main.reel/main.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"owner": {
"properties": {
"element": {"#": "main"}
"element": {"#": "main"},
"alert": {"@": "alert"},
"alert-light": {"@": "alert-light"},
"alert-dark": {"@": "alert-dark"},
"confirm": {"@": "confirm"},
"confirm-light": {"@": "confirm-light"},
"confirm-dark": {"@": "confirm-dark"}
}
},

Expand Down Expand Up @@ -60,5 +66,13 @@
"list-2": { "prototype": "ui/list.reel", "properties": { "element": {"#": "list-2"}, "content": [1, 2, 3] } },
"listItem-2": { "prototype": "ui/list-item.reel", "properties": { "element": {"#": "listItem-2"} } },
"list-3": { "prototype": "ui/list.reel", "properties": { "element": {"#": "list-3"}, "content": [1, 2, 3] } },
"listItem-3": { "prototype": "ui/list-item.reel", "properties": { "element": {"#": "listItem-3"} } }
"listItem-3": { "prototype": "ui/list-item.reel", "properties": { "element": {"#": "listItem-3"} } },

"alert": { "prototype": "ui/alert.reel", "properties": { "element": {"#": "alert"}, "title": "Title", "message": "This is an alert"}},
"alert-light": { "prototype": "ui/alert.reel", "properties": { "element": {"#": "alert-light"}, "title": "Title", "message": "This is an alert"}},
"alert-dark": { "prototype": "ui/alert.reel", "properties": { "element": {"#": "alert-dark"}, "title": "Title", "message": "This is an alert"}},

"confirm": { "prototype": "ui/confirm.reel", "properties": { "element": {"#": "confirm"}, "title": "Title", "message": "This is a confirm"}},
"confirm-light": { "prototype": "ui/confirm.reel", "properties": { "element": {"#": "confirm-light"}, "title": "Title", "message": "This is a confirm"}},
"confirm-dark": { "prototype": "ui/confirm.reel", "properties": { "element": {"#": "confirm-dark"}, "title": "Title", "message": "This is a confirm"}}
}
27 changes: 27 additions & 0 deletions test/alert/alert-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader;

TestPageLoader.queueTest("alert-test", function(testPage) {

describe("test/alert/alert-spec", function() {
it("should load", function() {
expect(testPage.loaded).toBe(true);
});

describe("Alert", function() {
it("can be created", function() {
expect(testPage.test.templateObjects.alert).toBeDefined();
});

it("can be shown", function() {
var alert = testPage.test.templateObjects.alert;

alert.show();

testPage.waitForComponentDraw(alert._overlay);
runs(function() {
expect(testPage.iframe.contentDocument.body.contains(alert._overlay.element)).toBeTruthy();
});
});
});
});
});
32 changes: 32 additions & 0 deletions test/alert/alert-test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Alert Test</title>
<script type="text/javascript" src="../../node_modules/montage/montage.js" data-package="../../"></script>
<link rel="stylesheet" href="../../ui/text.reel/text.css">
<script type="text/montage-serialization">
{
"test": {
"prototype": "test/alert/alert-test[Test]"
},

"alert": {
"prototype": "ui/alert.reel",
"properties": {
"element": {"#": "alert"},
"title": "A Title",
"message": "A message"
}
}
}
</script>

</head>
<body>
<h1>Alert</h1>

<div data-montage-id="alert"></div>

</body>
</html>
4 changes: 4 additions & 0 deletions test/alert/alert-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var TestController = require("montage-testing/test-controller").TestController;

exports.Test = TestController.specialize({
});
2 changes: 2 additions & 0 deletions test/all.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require("montage-testing").run(require,[
// Please keep in alphabetical order
"test/alert/alert-spec",
"test/button/button-spec",
"test/checkbox/checkbox-spec",
"test/confirm/confirm-spec",
"test/slider/slider-spec",
"test/number-field/number-field-spec",
"test/radio-button/radio-button-spec",
Expand Down
43 changes: 43 additions & 0 deletions test/confirm/confirm-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader;

TestPageLoader.queueTest("confirm-test", function(testPage) {

describe("test/confirm/confirm-spec", function() {
it("should load", function() {
expect(testPage.loaded).toBe(true);
});

describe("Confirm", function() {
it("can be created", function() {
expect(testPage.test.templateObjects.confirm).toBeDefined();
});

it("can be shown", function() {
var confirm = testPage.test.templateObjects.confirm;

confirm.show();

testPage.waitForComponentDraw(confirm._overlay);
runs(function() {
expect(testPage.iframe.contentDocument.body.contains(confirm._overlay.element)).toBeTruthy();
});
});

it("uses the configured ok label", function() {
var confirm = testPage.test.templateObjects.confirm;

confirm.okLabel = "Okay";

expect(confirm._okButton.label).toBe("Okay");
});

it("uses the configured cancel label", function() {
var confirm = testPage.test.templateObjects.confirm;

confirm.cancelLabel = "Nay";

expect(confirm._cancelButton.label).toBe("Nay");
});
});
});
});
33 changes: 33 additions & 0 deletions test/confirm/confirm-test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Confirm Test</title>
<script type="text/javascript" src="../../node_modules/montage/montage.js" data-package="../../"></script>
<script type="text/montage-serialization">
{
"test": {
"prototype": "test/confirm/confirm-test[Test]"
},

"confirm": {
"prototype": "ui/confirm.reel",
"properties": {
"element": {"#": "confirm"},
"title": "A Title",
"message": "A message",
"okLabel": "Okay",
"cancelLabel": "Nay"
}
}
}
</script>

</head>
<body>
<h1>Confirm</h1>

<div data-montage-id="confirm"></div>

</body>
</html>
4 changes: 4 additions & 0 deletions test/confirm/confirm-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var TestController = require("montage-testing/test-controller").TestController;

exports.Test = TestController.specialize({
});
46 changes: 46 additions & 0 deletions ui/alert.reel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Alert

![Alert](screenshot.png)

The alert displays a message to the user, popping up above other content.

## How to use

```json
"alert": {
"prototype": "ui/alert.reel",
"properties": {
"element": {"#": "alert"},
"title": "A Title",
"message": "A message",
"okLabel": "Ok"
}
}
```

```html
<div data-montage-id="alert"></span>
```



## Available properties

* `title` - The text to appear in the title bar.
* `message` - The text to appear in the body.
* `okLabel` - The text to appear in the button to dismiss the alert.



## Customizing with CSS

* `.digit-Alert` - The container element
* `.digit-Alert-header` - The header element
* `.digit-Alert-content` - The main content element
* `.digit-Alert-footer` - The footer element

```css
.digit-Alert-header {
background: red;
}
```
Loading