-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating to new Material Design picker spec
- Loading branch information
1 parent
baf84d3
commit 7d383d6
Showing
7 changed files
with
309 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
|
||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"> | ||
|
||
<title>paper-input</title> | ||
|
||
<script src="../../webcomponentsjs/webcomponents.js"></script> | ||
|
||
<link href="../../paper-dialog/paper-dialog.html" rel="import"> | ||
<link href="../../paper-button/paper-button.html" rel="import"> | ||
<link href="../../paper-input/paper-input.html" rel="import"> | ||
|
||
<link href="../paper-color-circle.html" rel="import"> | ||
<link href="../paper-color-picker.html" rel="import"> | ||
<link href="../paper-color-input.html" rel="import"> | ||
|
||
<style shim-shadowdom> | ||
|
||
body { | ||
font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial; | ||
font-size: 14px; | ||
margin: 0; | ||
padding: 24px; | ||
-webkit-tap-highlight-color: rgba(0,0,0,0); | ||
-webkit-touch-callout: none; | ||
} | ||
paper-color-circle{ | ||
width:200px; | ||
height:200px; | ||
} | ||
section{ | ||
padding-bottom:30px; | ||
} | ||
.buttons{ | ||
padding-left:20px; | ||
} | ||
.buttons > div{ | ||
float:left; | ||
} | ||
</style> | ||
|
||
</head> | ||
<body unresolved> | ||
|
||
<section> | ||
<h1>Dialog</h1> | ||
|
||
<br> | ||
|
||
<div class="buttons"> | ||
|
||
<div> | ||
<paper-button raised onclick="this.parentElement.querySelector('paper-color-picker').open()"> | ||
Standard dialog | ||
</paper-button> | ||
|
||
<paper-color-picker no-full-names></paper-color-picker> | ||
</div> | ||
|
||
</div> | ||
|
||
</section> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<link rel="import" href="../polymer/polymer.html"> | ||
<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html"> | ||
<link rel="import" href="../paper-input/paper-input-container.html"> | ||
<link rel="import" href="./paper-color-picker.html"> | ||
|
||
<!-- | ||
@demo demo/index.html | ||
@hero hero.svg | ||
--> | ||
|
||
<dom-module id="paper-color-input"> | ||
<template> | ||
<style> | ||
:host { | ||
} | ||
#colorPreview{ | ||
height: 16px; | ||
width: 16px; | ||
border: 1px solid rgba(0,0,0,.1); | ||
border-radius: 1px; | ||
margin: 2px; | ||
} | ||
#noColor{ | ||
width: 22.6px; | ||
height: 1px; | ||
border-top: 1px solid rgba(0,0,0,.1); | ||
transform-origin: 0px 0px; | ||
transform: translateY(15.5px) rotate(-45deg); | ||
} | ||
</style> | ||
<paper-input-container id="input" always-float-label="{{_isValueDefined(value.*)}}"> | ||
<label>{{label}}</label> | ||
<div class="paper-input-input">{{colorName}} </div> | ||
<div id="colorPreview" suffix style$="{{_computeBackgroundColor(value.*)}}"> | ||
<div id="noColor" hidden="{{_isValueDefined(value.*)}}"></div> | ||
</div> | ||
</paper-input-container> | ||
|
||
<paper-color-picker id="picker" color="{{value}}" color-as-string="{{colorName}}" shape="{{shape}}" type="{{type}}"></paper-color-picker> | ||
|
||
</template> | ||
|
||
<script> | ||
Polymer({ | ||
is: 'paper-color-input', | ||
properties: { | ||
value: { | ||
type: Object, | ||
notify: true | ||
}, | ||
label: { | ||
type: String, | ||
value: 'Color' | ||
}, | ||
colorName: String, | ||
|
||
/** | ||
* *square*, *circle* or *huebox* | ||
* | ||
* @attribute shape | ||
* @type string | ||
* @default 'circle' | ||
*/ | ||
shape: { | ||
type: String, | ||
value: 'circle', | ||
notify: true | ||
}, | ||
|
||
/** | ||
* *hsv* or *hsl* | ||
* | ||
* @attribute type | ||
* @type string | ||
* @default 'hsv' | ||
*/ | ||
type: { | ||
type: String, | ||
value: 'hsv', | ||
notify: true | ||
}, | ||
}, | ||
behaviors: [ | ||
/* Polymer.IronFormElementBehavior */ // disabled till https://github.com/Polymer/polymer/issues/3167 gets fixed | ||
], | ||
listeners: { | ||
'input.tap': 'openColorPicker' | ||
}, | ||
// Element Lifecycle | ||
ready: function() { | ||
if(this._isValueDefined()){ | ||
this.$.picker.set('immediateColor', this.value); | ||
var listenOnce; | ||
this.$.picker.addEventListener('immediate-color-as-string-changed', listenOnce = function(){ | ||
//this.colorName = this.$.picker.immediateColorAsString; | ||
this.$.picker.setColor(); | ||
this.$.picker.removeEventListener('immediate-color-as-string-changed', listenOnce); | ||
}.bind(this)); | ||
} | ||
}, | ||
openColorPicker: function(){ | ||
this.$.picker.open(); | ||
}, | ||
_computeBackgroundColor: function(){ | ||
return 'background: rgb('+this.value.red+', '+this.value.green+','+this.value.blue+')'; | ||
}, | ||
_isValueDefined: function(){ | ||
return this.value.red >= 0 && this.value.green >= 0 && this.value.blue >= 0; | ||
} | ||
}); | ||
</script> | ||
</dom-module> |
Oops, something went wrong.