Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from PolymerElements/implement-for-1.0
Browse files Browse the repository at this point in the history
Implement iron-dropdown for Polymer 1.0
  • Loading branch information
cdata committed Jul 17, 2015
2 parents 325f951 + 63b7f38 commit b276e27
Show file tree
Hide file tree
Showing 12 changed files with 953 additions and 53 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
iron-dropdown
=============

An element that implements a simple drop-down menu widget with a trigger and content.
22 changes: 12 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iron-dropdown",
"version": "0.9.0",
"version": "1.0.0",
"description": "",
"authors": [
"The Polymer Authors"
Expand All @@ -19,18 +19,20 @@
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/iron-dropdown",
"dependencies": {
"polymer": "polymer/polymer#^0.9.0",
"iron-overlay-behavior": "polymerelements/iron-overlay-behavior#^0.9.0"
"polymer": "polymer/polymer#^1.0.0",
"iron-overlay-behavior": "polymerelements/iron-overlay-behavior#^1.0.0",
"iron-resizable-behavior": "polymerelements/iron-resizable-behavior#^1.0.0",
"neon-animation": "polymerelements/neon-animation#^1.0.0",
"iron-a11y-keys-behavior": "polymerelements/iron-a11y-keys-behavior#^1.0.0",
"iron-image": "polymerelements/iron-image#^1.0.0"
},
"devDependencies": {
"iron-component-page": "polymerelements/iron-component-page#^0.9.0",
"test-fixture": "polymerelements/test-fixture#^0.9.0",
"iron-icon": "polymerelements/iron-icon#^0.9.0",
"iron-icons": "polymerelements/iron-icons#^0.9.0",
"iron-test-helpers": "polymerelements/iron-test-helpers#^0.9.0",
"paper-styles": "polymerelements/paper-styles#^0.9.0",
"iron-component-page": "polymerelements/iron-component-page#^1.0.0",
"test-fixture": "polymerelements/test-fixture#^1.0.0",
"iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0",
"paper-styles": "polymerelements/paper-styles#^1.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0",
"web-component-tester": "*",
"paper-menu": "polymerelements/paper-menu#^0.9.0"
"iron-image": "polymerelements/iron-image#^1.0.0"
}
}
36 changes: 36 additions & 0 deletions demo/grow-height-animation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
@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="../../neon-animation/neon-animation-behavior.html">

<script>
Polymer({
is: 'expand-animation',

behaviors: [
Polymer.NeonAnimationBehavior
],

configure: function(config) {
var node = config.node;

var height = node.getBoundingClientRect().height;

this._effect = new KeyframeEffect(node, [{
height: (height / 2) + 'px'
}, {
height: height + 'px'
}], this.timingFromConfig(config));

return this._effect;
}
});
</script>
153 changes: 144 additions & 9 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html>
<!--
@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
Expand All @@ -13,16 +14,150 @@
<title>iron-dropdown</title>

<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-dropdown.html">
<link rel="import" href="../../paper-menu/paper-menu.html">
<link rel="import" href="../../iron-image/iron-image.html">
<link rel="import" href="../../paper-styles/demo-pages.html">
<link rel="import" href="x-select.html">
<style>

ul {
display: block;
position: relative;
background-color: #fff;
box-shadow: 0px 2px 6px #ccc;
margin: 0.25em 0;
padding: 0.25em;
border-radius: 3px;
}

[vertical-align="top"] ul {
margin-top: 0;
}

[vertical-align="bottom"] ul {
margin-bottom: 0;
}

li {
display: block;
position: relative;
margin: 0;
padding: 0;
}

a {
display: block;
position: relative;
padding: 1em;
text-decoration: none;
}

li:not(:last-of-type) {
border-bottom: 1px solid #eee;
}

a:hover {
text-decoration: underline;
}

button {
border: 1px solid #ccc;
background-color: #eee;
padding: 1em;
border-radius: 3px;
cursor: pointer;
}

button:focus {
outline: none;
border-color: blue;
}

iron-image {
padding: 1em;
background-color: #fff;
box-shadow: 0px 2px 6px #ccc;
border-radius: 3px;
}
</style>
</head>
<body>
<iron-dropdown>
<button dropdown-trigger>Tap</button>
<paper-menu tabindex="0" dropdown-content>
<a href="javascript:console.log('lorem')">Lorem</a>
<a href="javascript:console.log('ipsum')">Ipsum</a>
</paper-menu>
</iron-dropdown>
<template is="dom-bind" id="Demo">
<div class="horizontal-section flex layout horizontal">
<x-select>
<button class="dropdown-trigger">Basic</button>
<ul class="dropdown-content">
<template is="dom-repeat" items="[[letters]]">
<li><a href="javascript:void(0)">[[item]]</a></li>
</template>
</ul>
</x-select>
<x-select>
<button class="dropdown-trigger">Overflowing</button>
<ul class="dropdown-content" tabindex="0">
<template is="dom-repeat" items="[[dinosaurs]]">
<li><a href="javascript:void(0)">[[item]]</a></li>
</template>
</ul>
</x-select>
<x-select vertical-align="bottom">
<button class="dropdown-trigger">Bottom-left Aligned</button>
<ul class="dropdown-content">
<template is="dom-repeat" items="[[letters]]">
<li><a href="javascript:void(0)">[[item]]</a></li>
</template>
</ul>
</x-select>
<x-select horizontal-align="right" vertical-align="top">
<button class="dropdown-trigger">Top-right Aligned</button>
<ul class="dropdown-content">
<template is="dom-repeat" items="[[dinosaurs]]">
<li><a href="javascript:void(0)">[[item]]</a></li>
</template>
</ul>
</x-select>
<x-select horizontal-align="left" vertical-align="top">
<button class="dropdown-trigger">Alternate Content</button>
<iron-image class="dropdown-content" src="../../iron-image/demo/polymer.svg"></iron-image>
</x-select>
</div>
</template>

<script>
Demo.letters = [
'alpha',
'beta',
'gamma',
'delta',
'epsilon'
];
Demo.dinosaurs = [
'allosaurus',
'brontosaurus',
'carcharodontosaurus',
'diplodocus',
'ekrixinatosaurus',
'fukuiraptor',
'gallimimus',
'hadrosaurus',
'iguanodon',
'jainosaurus',
'kritosaurus',
'liaoceratops',
'megalosaurus',
'nemegtosaurus',
'ornithomimus',
'protoceratops',
'quetecsaurus',
'rajasaurus',
'stegosaurus',
'triceratops',
'utahraptor',
'vulcanodon',
'wannanosaurus',
'xenoceratops',
'yandusaurus',
'zephyrosaurus'
];
</script>
</body>
</html>
80 changes: 80 additions & 0 deletions demo/x-select.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!--
@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="../iron-dropdown.html">
<link rel="import" href="../../neon-animation/neon-animations.html">
<link rel="import" href="grow-height-animation.html">

<dom-module id="x-select">
<style>
:host {
display: inline-block;
margin: 1em;
}
</style>
<template>
<div on-tap="open">
<content select=".dropdown-trigger"></content>
</div>
<iron-dropdown id="dropdown"
vertical-align="[[verticalAlign]]"
horizontal-align="[[horizontalAlign]]"
disabled="[[disabled]]"
open-animation-config="[[openAnimationConfig]]"
close-animation-config="[[closeAnimationConfig]]">
<content select=".dropdown-content"></content>
</iron-dropdown>
</template>
<script>
Polymer({
is: 'x-select',

properties: {
verticalAlign: String,
horizontalAlign: String,
disabled: Boolean,
openAnimationConfig: {
type: Array,
value: function() {
return [{
name: 'fade-in-animation',
timing: {
delay: 150,
duration: 50
}
}, {
name: 'expand-animation',
timing: {
delay: 150,
duration: 200
}
}];
}
},

closeAnimationConfig: {
type: Array,
value: function() {
return [{
name: 'fade-out-animation',
timing: {
duration: 200
}
}];
}
}
},

open: function() {
this.$.dropdown.open();
}
});
</script>
</dom-module>
24 changes: 24 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!doctype html>
<!--
@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
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>

<title>iron-dropdown</title>
<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>
21 changes: 0 additions & 21 deletions iron-dropdown-overlay.html

This file was deleted.

Loading

0 comments on commit b276e27

Please sign in to comment.