Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
therewasaguy committed Sep 23, 2015
0 parents commit 49d1a72
Show file tree
Hide file tree
Showing 14 changed files with 344 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "../"
}
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]

# Change these settings to your own preference
indent_style = space
indent_size = 2

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
.sass-cache
.tmp
28 changes: 28 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"jquery": true,
"globals": {
"wrap": true,
"unwrap": true,
"Polymer": true,
"Platform": true
}
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# lens-ui-dialog

Implementation of [iron overlay behavior](https://elements.polymer-project.org/elements/iron-overlay-behavior?active=Polymer.IronOverlayBehavior) for use in Lenses.

See the [component page](http://therewasaguy.github.io/lens-ui-dialog) for more information.
13 changes: 13 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "lens-ui-dialog",
"version": "0.0.1",
"keywords": "lenses, polymer, web-components",
"main": "lens-ui-dialog.html",
"dependencies": {
"iron-component-page": "PolymerElements/iron-component-page",
"iron-overlay-behavior": "PolymerElements/iron-overlay-behavior"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester"
}
}
94 changes: 94 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>lens-ui-dialog Demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../lens-ui-dialog.html">

<style>
</style>
</head>

<body onclick="clickHandler(event);" unresolved>

<button data-dialog="plain">plain</button>

<lens-ui-dialog id="plain">
This is a plain dialog
</lens-ui-dialog>

<button data-dialog="delete">with backdrop</button>

<lens-ui-dialog id="delete" with-backdrop>
<p>Hello world!</p>
<button data-cancel="delete">cancel</button>
<button data-cancel="delete" autofocus>autofocus</button>
</lens-ui-dialog>

<button data-dialog="noescape">no cancel</button>
<lens-ui-dialog id="noescape" no-cancel-on-esc-key no-cancel-on-outside-click>
<div id="test-parent">
<button data-dialog-close="noescape">accept</button>
<button data-dialog-cancel="noescape">cancel</button>
</div>
</lens-ui-dialog>

<script>

function clickHandler(e) {
checkForDialog(e);
checkForClose(e);
checkForCancel(e);
}

function checkForDialog(e) {
if (!e.target.hasAttribute('data-dialog')) {
return;
}

var id = e.target.getAttribute('data-dialog');
var dialog = document.getElementById(id);
if (dialog) {
dialog.open();
}
}

function checkForClose(e) {
if (!e.target.hasAttribute('data-dialog-close')) {
return;
} else {
var id = e.target.getAttribute('data-dialog-close');
var dialog = document.getElementById(id);
if (dialog) {
dialog.close();
}
}
}

function checkForCancel(e) {
if (!e.target.hasAttribute('data-dialog-cancel')) {
return;
} else {
var id = e.target.getAttribute('data-dialog-cancel');
var dialog = document.getElementById(id);
if (dialog) {
dialog.cancel();
}
}
}

window.onload = function() {

document.addEventListener('iron-overlay-closed', function(e) {
var target = e.target;
var canceled = e.detail.canceled;
console.log('canceled: ' + canceled);
});
}

</script>

</body>
</html>

14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-component-page/iron-component-page.html">
</head>

<body>
<iron-component-page></iron-component-page>
</body>
</html>
6 changes: 6 additions & 0 deletions lens-ui-dialog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:host {
display: inline-block;
color: black;
width: 300px;
height: 300px;
}
45 changes: 45 additions & 0 deletions lens-ui-dialog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-overlay-behavior/iron-overlay-behavior.html">

<!--
Dialog that extends the Polymer Iron Overlay Behavior
##### Example
<lens-ui-dialog></lens-ui-dialog>
@element lens-ui-dialog
@status alpha
@homepage http://therewasguy.github.io/lens-ui-dialog
-->

<dom-module id="lens-ui-dialog">

<style>
:host {
background: white;
color:black;
padding: 24px;
box-shadow: rgba(0, 0, 0, 0.24) -2.3408942051048403px 5.524510324047423px 12.090680100755666px 0px, rgba(0, 0, 0, 0.12) 0px 0px 12px 0px;
}
</style>

<template>
<content></content>
</template>
</dom-module>

<script>

(function() {

Polymer({
is: 'lens-ui-dialog',

behaviors: [
Polymer.IronOverlayBehavior
]

});

})();

</script>
15 changes: 15 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Thelma Test Runner</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites(['lens-ui-dialog-basic.html']);
</script>
</body>
</html>
84 changes: 84 additions & 0 deletions test/lens-ui-dialog-basic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>lens-ui-dialog</title>

<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>

<!-- Step 1: import the element to test -->
<link rel="import" href="../lens-ui-dialog.html">

</head>
<body>

<lens-ui-dialog id="fixture"></lens-ui-dialog>

<script>
var should = chai.should();
var myEl = document.getElementById("fixture");

// the event listener callback will be added / removed in every async test
var callback = function() {};

// some input data
var input = new Object([{"label":"Marshawn Lynch, RB"},{"label":"Dez Bryant, WR"},{"label":"Jamaal Charles, RB"}]);

suite("<lens-ui-dialog>", function() {

test("component can be created as an object", function(done) {
should.exist(myEl);
done();
});

test("accepts input", function(done) {

// set the event listener callback
myEl.removeEventListener("th-output-ready", callback);
callback = function(e) {
myEl.input.should.equal(input);
};
myEl.addEventListener("th-output-ready", callback);

// change input
myEl.input = input;

// fire th-output-ready event
asyncPlatformFlush(function() {
done();
});
});

// repeat as needed
test("change an argument, fire outputReady, output new result", function(done) {

// myEl.removeEventListener("th-output-ready", callback);
// callback = function(e) {
// // // check that the argument has been changed
// // myEl.splitCol.should.equal(splitCol);

// // // check that the output has been changed
// // var player = myEl.output[0].split1;
// // var pos = myEl.output[0].split2;
// // player.should.equal("Marshawn Lynch");
// // pos.should.equal("RB");
// };
// myEl.addEventListener("th-output-ready", callback);

// // change an argument
// myEl.splitCol = splitCol;

// fire th-output-ready event
asyncPlatformFlush(function() {
done();
});
});

});

</script>

</body>
</html>
11 changes: 11 additions & 0 deletions wct.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Custom Web Component Test configuration options

module.exports = {
verbose: true,
plugins: {
// specify which browser to test (optional, defaults to all browsers)
// local: {
// browsers: ['firefox', 'canary']
// }
},
};

0 comments on commit 49d1a72

Please sign in to comment.