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,26 @@
{
"name": "paper-fab",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0",
"core-icon": "Polymer/core-icon#^0.5.0",
"core-icons": "Polymer/core-icons#^0.5.0",
"paper-button": "Polymer/paper-button#^0.5.0",
"paper-ripple": "Polymer/paper-ripple#^0.5.0",
"paper-shadow": "Polymer/paper-shadow#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1.1.4"
},
"version": "0.5.1",
"homepage": "https://github.com/Polymer/paper-fab",
"_release": "0.5.1",
"_resolution": {
"type": "version",
"tag": "0.5.1",
"commit": "4416c627459f147458c3b276b6a6be1db52a973d"
},
"_source": "git://github.com/Polymer/paper-fab.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/paper-fab"
}

View File

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

View File

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

View File

@@ -0,0 +1,87 @@
<!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>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>paper-fab</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link href="../font-roboto/roboto.html" rel="import">
<link href="../core-icons/core-icons.html" rel="import">
<link href="paper-fab.html" rel="import">
<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-fab {
color: #fff;
margin-right:2em;
}
paper-fab.blue {
background: #5677fc;
}
paper-fab.green {
background: #259b24;
}
paper-fab.yellow {
background: #ffeb3b;
}
</style>
</head>
<body unresolved>
<section>
<div>Regular</div>
<paper-fab icon="arrow-forward" title="arrow-forward"></paper-fab>
<paper-fab icon="create" class="blue" title="create"></paper-fab>
</section>
<section>
<div>Mini</div>
<paper-fab mini icon="done" class="green" title="done"></paper-fab>
<paper-fab mini icon="reply" class="yellow" title="reply"></paper-fab>
</section>
</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,36 @@
<!--
@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-fab" label="Floating Action Button" group="Paper">
<template>
<paper-fab icon="av:play-arrow"></paper-fab>
</template>
<template id="imports">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="paper-fab.html">
</template>
</x-meta>
<x-meta id="paper-fab-right-aligned" label="Floating Action Button Panel" group="Paper">
<template>
<div layout horizontal>
<paper-fab icon="check"></paper-fab>
</div>
</template>
<template id="imports">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="paper-fab.html">
</template>
</x-meta>

View File

@@ -0,0 +1,180 @@
<!--
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
-->
<!--
@group Paper Elements
Material Design: <a href="http://www.google.com/design/spec/components/buttons.html">Button</a>
`paper-fab` is a floating action button. It contains an image placed in the center and
comes in two sizes: regular size and a smaller size by applying the attribute `mini`. When
the user touches the button, a ripple effect emanates from the center of the button.
You may import `core-icons` to use with this element, or provide an URL to a custom icon.
See `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-fab icon="add"></paper-fab>
<paper-fab mini icon="favorite"></paper-fab>
<paper-fab src="star.png"></paper-fab>
Styling
-------
Style the button with CSS as you would a normal DOM element. If you are using the icons
provided by `core-icons`, the icon will inherit the foreground color of the button.
/* make a blue "cloud" button */
<paper-fab icon="cloud" style="color: blue;"></paper-fab>
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-fab src="star.png" aria-label="star"></paper-fab>
@element paper-fab
@extends paper-button-base
@status unstable
-->
<link href="../polymer/polymer.html" rel="import">
<link href="../core-icon/core-icon.html" rel="import">
<link href="../paper-button/paper-button-base.html" rel="import">
<link href="../paper-ripple/paper-ripple.html" rel="import">
<link href="../paper-shadow/paper-shadow.html" rel="import">
<polymer-element name="paper-fab" extends="paper-button-base" attributes="src icon mini" role="button">
<template>
<style>
:host {
display: inline-block;
position: relative;
outline: none;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
z-index: 0;
box-sizing: border-box;
width: 56px;
height: 56px;
background: #d23f31;
color: #fff;
border-radius: 50%;
padding: 16px;
}
:host([mini]) {
width: 40px;
height: 40px;
padding: 8px;
}
:host([disabled]) {
color: #c9c9c9;
pointer-events: none;
cursor: auto;
}
#ripple {
pointer-events: none;
z-index: -1;
}
#shadow {
border-radius: inherit;
pointer-events: none;
}
#icon {
display: block;
pointer-events: none;
}
</style>
<template if="{{raised}}">
<paper-shadow id="shadow" fit animated></paper-shadow>
</template>
<!-- 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: '',
/**
* Set this to true to style this is a "mini" FAB.
*
* @attribute mini
* @type boolean
* @default false
*/
mini: false,
raised: true,
recenteringTouch: false,
fill: true
},
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,66 @@
<!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-fab 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-fab.html" rel="import">
</head>
<body>
<paper-fab id="fab1" icon="add"></paper-fab>
<paper-fab id="fab2" icon="add" disabled></paper-fab>
<paper-fab id="fab3" icon="add" aria-label="custom"></paper-fab>
<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'));
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,45 @@
<!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-fab 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-fab.html" rel="import">
</head>
<body>
<div style="line-height:30px;">
<paper-fab id="fab1" icon="add"></paper-fab>
</div>
<script>
var f1 = document.getElementById('fab1');
function centerOf(element) {
var rect = element.getBoundingClientRect();
return {left: rect.left + rect.width / 2, top: rect.top + rect.height / 2};
}
test('renders correctly independent of line height', function() {
assert.deepEqual(centerOf(f1.$.icon), centerOf(f1));
});
</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-fab tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
'basic.html',
'a11y.html'
]);
</script>
</body>
</html>