Added Polymer

This commit is contained in:
Thaum
2014-11-26 10:18:35 +00:00
parent 5eea4714b2
commit 3408ba9e8d
1210 changed files with 394645 additions and 47 deletions

View File

@@ -0,0 +1,25 @@
{
"name": "paper-icon-button",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0",
"paper-button": "Polymer/paper-button#^0.5.0",
"core-icon": "Polymer/core-icon#^0.5.0",
"core-icons": "Polymer/core-icons#^0.5.0",
"paper-ripple": "Polymer/paper-ripple#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1.1.4"
},
"version": "0.5.1",
"homepage": "https://github.com/Polymer/paper-icon-button",
"_release": "0.5.1",
"_resolution": {
"type": "version",
"tag": "0.5.1",
"commit": "d09ae2f1de7bf2ebb0239cf4fe08265824d83a2e"
},
"_source": "git://github.com/Polymer/paper-icon-button.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/paper-icon-button"
}

View File

@@ -0,0 +1,4 @@
paper-icon-button
=================
See the [component page](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-icon-button) for more information.

View File

@@ -0,0 +1,15 @@
{
"name": "paper-icon-button",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0",
"paper-button": "Polymer/paper-button#^0.5.0",
"core-icon": "Polymer/core-icon#^0.5.0",
"core-icons": "Polymer/core-icons#^0.5.0",
"paper-ripple": "Polymer/paper-ripple#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1.1.4"
},
"version": "0.5.1"
}

View File

@@ -0,0 +1,146 @@
<!doctype html>
<!--
Copyright 2013 The Polymer Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<html>
<head>
<title>paper-icon-button</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="paper-icon-button.html">
<style shim-shadowdom>
body {
font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial;
font-size: 14px;
margin: 0;
padding: 24px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-touch-callout: none;
}
section {
padding: 20px 0;
}
section > div {
padding: 14px;
font-size: 16px;
}
paper-icon-button {
vertical-align: middle;
}
paper-icon-button.hover:hover {
background: #eee;
border-radius: 50%;
}
paper-icon-button.red {
color: #fe774d;
}
paper-icon-button.blueRipple::shadow #ripple {
color: #4285f4;
}
/* core-selector paper-icon-button:not([active])::shadow core-icon {
color: #c9c9c9;
}
*/
paper-icon-button.custom {
color: #a9edff;
}
</style>
</head>
<body unresolved onclick="clickAction(event);">
<column>
<section>
<div>Icon buttons</div>
<paper-icon-button icon="menu" title="menu"></paper-icon-button>
<paper-icon-button icon="arrow-back" title="arrow-back"></paper-icon-button>
<paper-icon-button icon="arrow-forward" title="arrow-forward"></paper-icon-button>
<paper-icon-button disabled icon="clear" title="clear"></paper-icon-button>
</section>
<br>
<section>
<div>Styled</div>
<paper-icon-button icon="favorite" title="favorite"></paper-icon-button>
<paper-icon-button class="hover" icon="favorite" title="favorite"></paper-icon-button>
<paper-icon-button class="red" icon="favorite" title="favorite"></paper-icon-button>
<paper-icon-button class="red blueRipple" icon="favorite" title="favorite"></paper-icon-button>
</section>
<section>
<div>Link</div>
<a href="https://www.polymer-project.org" target="_blank">
<paper-icon-button icon="polymer" title="polymer"></paper-icon-button>
</a>
</section>
<!-- <section>
<span>focused</span>
<paper-icon-button focused icon="social:cake"></paper-icon-button>
<paper-icon-button focused icon="social:plus-one"></paper-icon-button>
</section>
-->
<!-- <section>
<span>segmented</span>
<core-selector selected="1">
<paper-icon-button fill isToggle icon="maps:directionswalk"></paper-icon-button>
<paper-icon-button fill isToggle icon="maps:directions-bike"></paper-icon-button>
<paper-icon-button fill isToggle icon="maps:directions-transit"></paper-icon-button>
<paper-icon-button fill isToggle icon="maps:directions-car"></paper-icon-button>
</core-selector>
</section>
-->
<section>
<div>Custom icon src</div>
<paper-icon-button class="custom" src="https://assets-cdn.github.com/images/modules/logos_page/Octocat.png" aria-label="octocat" title="octocat"></paper-icon-button>
</section>
</column>
<script>
function clickAction(e) {
var t = e.target;
if (t.localName === 'paper-icon-button') {
if (t.hasAttribute('disabled')) {
console.error('should not be able to click disabled button', t);
} else {
console.log('click', t);
}
}
}
</script>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page></core-component-page>
</body>
</html>

View File

@@ -0,0 +1,21 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<x-meta id="paper-icon-button" label="Icon Button" group="Paper">
<template>
<paper-icon-button icon="menu"></paper-icon-button>
</template>
<template id="imports">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="paper-icon-button.html">
</template>
</x-meta>

View File

@@ -0,0 +1,154 @@
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<!--
@group Paper Elements
Material Design: <a href="http://www.google.com/design/spec/components/buttons.html">Buttons</a>
`paper-icon-button` is a button with an image placed at the center. When the user touches
the button, a ripple effect emanates from the center of the button.
`paper-icon-button` includes a default icon set. Use `icon` to specify which icon
from the icon set to use.
<paper-icon-button icon="menu"></paper-icon-button>
See [`core-iconset`](#core-iconset) for more information about
how to use a custom icon set.
Example:
<link href="path/to/core-icons/core-icons.html" rel="import">
<paper-icon-button icon="favorite"></paper-icon-button>
<paper-icon-button src="star.png"></paper-icon-button>
Styling
-------
Style the button with CSS as you would a normal DOM element. If you are using the icons
provided by `core-icons`, they will inherit the foreground color of the button.
/* make a red "favorite" button */
<paper-icon-button icon="favorite" style="color: red;"></paper-icon-button>
By default, the ripple is the same color as the foreground at 25% opacity. You may
customize the color using this selector:
/* make #my-button use a blue ripple instead of foreground color */
#my-button::shadow #ripple {
color: blue;
}
The opacity of the ripple is not customizable via CSS.
Accessibility
-------------
The button is accessible by default if you use the `icon` property. By default, the
`aria-label` attribute will be set to the `icon` property. If you use a custom icon,
you should ensure that the `aria-label` attribute is set.
<paper-icon-button src="star.png" aria-label="star"></paper-icon-button>
@element paper-icon-button
@extends paper-button-base
@homepage github.io
-->
<link href="../polymer/polymer.html" rel="import">
<link href="../core-icon/core-icon.html" rel="import">
<link href="../core-icons/core-icons.html" rel="import">
<link href="../paper-button/paper-button-base.html" rel="import">
<link href="../paper-ripple/paper-ripple.html" rel="import">
<polymer-element name="paper-icon-button" extends="paper-button-base" attributes="src icon" role="button">
<template>
<style>
:host {
display: inline-block;
position: relative;
padding: 8px;
outline: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: pointer;
z-index: 0;
}
:host([disabled]) {
color: #c9c9c9;
pointer-events: none;
cursor: auto;
}
#ripple {
pointer-events: none;
z-index: -1;
}
#icon {
display: block;
pointer-events: none;
}
</style>
<!-- to position to ripple behind the icon -->
<core-icon relative id="icon" src="{{src}}" icon="{{icon}}"></core-icon>
</template>
<script>
Polymer({
publish: {
/**
* The URL of an image for the icon. If the src property is specified,
* the icon property should not be.
*
* @attribute src
* @type string
* @default ''
*/
src: '',
/**
* Specifies the icon name or index in the set of icons available in
* the icon's icon set. If the icon property is specified,
* the src property should not be.
*
* @attribute icon
* @type string
* @default ''
*/
icon: '',
recenteringTouch: true,
fill: false
},
iconChanged: function(oldIcon) {
var label = this.getAttribute('aria-label');
if (!label || label === oldIcon) {
this.setAttribute('aria-label', this.icon);
}
}
});
</script>
</polymer-element>

View File

@@ -0,0 +1,68 @@
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>paper-icon-button a11y tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link href="../../core-icons/core-icons.html" rel="import">
<link href="../paper-icon-button.html" rel="import">
</head>
<body>
<paper-icon-button id="fab1" icon="add"></paper-icon-button>
<paper-icon-button id="fab2" icon="add" disabled></paper-icon-button>
<paper-icon-button id="fab3" icon="add" aria-label="custom"></paper-icon-button>
<script>
var f1 = document.getElementById('fab1');
var f2 = document.getElementById('fab2');
var f3 = document.getElementById('fab3');
test('aria role is a button', function() {
assert.strictEqual(f1.getAttribute('role'), 'button');
});
test('aria-disabled is set', function(done) {
assert.ok(f2.hasAttribute('aria-disabled'));
flush(function() {
f2.removeAttribute('disabled');
flush(function() {
assert.ok(!f2.hasAttribute('aria-disabled'));
done();
});
});
});
test('aria-label is set', function() {
assert.strictEqual(f1.getAttribute('aria-label'), 'add');
});
test('user-defined aria-label is preserved', function(done) {
assert.strictEqual(f3.getAttribute('aria-label'), 'custom');
f3.icon = 'arrow-forward';
flush(function() {
assert.strictEqual(f3.getAttribute('aria-label'), 'custom');
done();
});
});
</script>
</body>
</html>

View File

@@ -0,0 +1,50 @@
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>paper-icon-button basic tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link href="../../core-icons/core-icons.html" rel="import">
<link href="../paper-icon-button.html" rel="import">
</head>
<body>
<div style="font-size:40px;">
Toolbar
<paper-icon-button id="button1" icon="add"></paper-icon-button>
</div>
<script>
var b1 = document.getElementById('button1');
function centerOf(element) {
var rect = element.getBoundingClientRect();
return {left: rect.left + rect.width / 2, top: rect.top + rect.height / 2};
}
function approxEqual(p1, p2) {
return Math.round(p1.left) == Math.round(p2.left) && Math.round(p1.top) == Math.round(p2.top);
}
test('renders correctly independent of font size', function() {
assert.ok(approxEqual(centerOf(b1.$.icon), centerOf(b1)));
});
</script>
</body>
</html>

View File

@@ -0,0 +1,25 @@
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>paper-icon-button tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
'basic.html',
'a11y.html'
]);
</script>
</body>
</html>