2015-06-18 21:23:55 -07:00
|
|
|
<!--
|
|
|
|
@license
|
|
|
|
Copyright (c) 2015 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
|
|
|
|
-->
|
|
|
|
|
|
|
|
<link rel="import" href="../polymer/polymer.html">
|
|
|
|
<link rel="import" href="../iron-flex-layout/classes/iron-flex-layout.html">
|
2015-12-14 08:43:03 -07:00
|
|
|
<link rel="import" href="../iron-icon/iron-icon.html">
|
|
|
|
<link rel="import" href="../paper-behaviors/paper-button-behavior.html">
|
2015-06-18 21:23:55 -07:00
|
|
|
<link rel="import" href="../paper-material/paper-material.html">
|
|
|
|
<link rel="import" href="../paper-ripple/paper-ripple.html">
|
2015-12-14 08:43:03 -07:00
|
|
|
<link rel="import" href="../paper-styles/color.html">
|
|
|
|
<link rel="import" href="../paper-styles/default-theme.html">
|
2015-06-18 21:23:55 -07:00
|
|
|
|
|
|
|
<!--
|
2015-10-07 18:49:40 -07:00
|
|
|
Material design: [Floating Action Button](https://www.google.com/design/spec/components/buttons-floating-action-button.html)
|
2015-06-18 21:23:55 -07:00
|
|
|
|
|
|
|
`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 `iron-icons` to use with this element, or provide a URL to a custom icon.
|
|
|
|
See `iron-iconset` for more information about how to use a custom icon set.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
<link href="path/to/iron-icons/iron-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
|
|
|
|
|
|
|
|
The following custom properties and mixins are available for styling:
|
|
|
|
|
|
|
|
Custom property | Description | Default
|
|
|
|
----------------|-------------|----------
|
|
|
|
`--paper-fab-background` | The background color of the button | `--accent-color`
|
|
|
|
`--paper-fab-keyboard-focus-background` | The background color of the button when focused | `--paper-pink-900`
|
|
|
|
`--paper-fab-disabled-background` | The background color of the button when it's disabled | `--paper-grey-300`
|
|
|
|
`--paper-fab-disabled-text` | The text color of the button when it's disabled | `--paper-grey-500`
|
|
|
|
`--paper-fab` | Mixin applied to the button | `{}`
|
|
|
|
`--paper-fab-mini` | Mixin applied to a mini button | `{}`
|
|
|
|
`--paper-fab-disabled` | Mixin applied to a disabled button | `{}`
|
2015-10-07 18:49:40 -07:00
|
|
|
`--paper-fab-iron-icon` | Mixin applied to the iron-icon within the button | `{}`
|
2015-06-18 21:23:55 -07:00
|
|
|
|
|
|
|
@group Paper Elements
|
|
|
|
@demo demo/index.html
|
|
|
|
|
|
|
|
-->
|
|
|
|
|
|
|
|
<dom-module id="paper-fab">
|
2015-10-07 18:49:40 -07:00
|
|
|
<template strip-whitespace>
|
|
|
|
<style include="paper-material">
|
|
|
|
:host {
|
|
|
|
display: inline-block;
|
|
|
|
position: relative;
|
|
|
|
outline: none;
|
|
|
|
-moz-user-select: none;
|
|
|
|
-ms-user-select: none;
|
|
|
|
-webkit-user-select: none;
|
|
|
|
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
|
|
|
user-select: none;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
min-width: 0;
|
|
|
|
width: 56px;
|
|
|
|
height: 56px;
|
|
|
|
background: var(--paper-fab-background, --accent-color);
|
|
|
|
color: var(--text-primary-color);
|
|
|
|
border-radius: 50%;
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
z-index: 0;
|
|
|
|
|
|
|
|
@apply(--layout-vertical);
|
|
|
|
@apply(--layout-center-center);
|
|
|
|
@apply(--paper-fab);
|
|
|
|
}
|
2015-06-18 21:23:55 -07:00
|
|
|
|
2015-10-07 18:49:40 -07:00
|
|
|
:host([mini]) {
|
|
|
|
width: 40px;
|
|
|
|
height: 40px;
|
|
|
|
padding: 8px;
|
2015-06-18 21:23:55 -07:00
|
|
|
|
2015-10-07 18:49:40 -07:00
|
|
|
@apply(--paper-fab-mini);
|
|
|
|
}
|
2015-06-18 21:23:55 -07:00
|
|
|
|
2015-10-07 18:49:40 -07:00
|
|
|
:host([disabled]) {
|
|
|
|
color: var(--paper-fab-disabled-text, --paper-grey-500);
|
|
|
|
background: var(--paper-fab-disabled-background, --paper-grey-300);
|
|
|
|
@apply(--paper-fab-disabled);
|
|
|
|
}
|
2015-06-18 21:23:55 -07:00
|
|
|
|
2015-10-07 18:49:40 -07:00
|
|
|
iron-icon {
|
|
|
|
@apply(--paper-fab-iron-icon);
|
|
|
|
}
|
2015-06-18 21:23:55 -07:00
|
|
|
|
2015-10-07 18:49:40 -07:00
|
|
|
:host(.keyboard-focus) {
|
|
|
|
background: var(--paper-fab-keyboard-focus-background, --paper-pink-900);
|
|
|
|
}
|
|
|
|
</style>
|
2015-12-14 08:43:03 -07:00
|
|
|
|
2015-10-07 18:49:40 -07:00
|
|
|
<iron-icon id="icon" src="[[src]]" icon="[[icon]]"></iron-icon>
|
2015-06-18 21:23:55 -07:00
|
|
|
</template>
|
|
|
|
</dom-module>
|
2015-12-14 08:43:03 -07:00
|
|
|
|
2015-06-18 21:23:55 -07:00
|
|
|
<script>
|
|
|
|
Polymer({
|
|
|
|
is: 'paper-fab',
|
|
|
|
|
|
|
|
behaviors: [
|
|
|
|
Polymer.PaperButtonBehavior
|
|
|
|
],
|
|
|
|
|
|
|
|
properties: {
|
|
|
|
/**
|
|
|
|
* 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: {
|
|
|
|
type: String,
|
|
|
|
value: ''
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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: {
|
|
|
|
type: String,
|
|
|
|
value: ''
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set this to true to style this is a "mini" FAB.
|
|
|
|
*
|
|
|
|
* @attribute mini
|
|
|
|
* @type boolean
|
|
|
|
* @default false
|
|
|
|
*/
|
|
|
|
mini: {
|
|
|
|
type: Boolean,
|
2015-09-03 21:33:31 -07:00
|
|
|
value: false,
|
|
|
|
reflectToAttribute: true
|
2015-06-18 21:23:55 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|