Skip to content

Commit

Permalink
2.0 preview (#66)
Browse files Browse the repository at this point in the history
* port to 2.0

* use demo-snippet, bump to 2.0.0

* remove iron-flex-layout devDependency (not used in the demo)

* point to custom-elements-v1

* keep enableTransition to have minimally breaking change

* will animate if attached and if desired size changed

* use new custom-style syntax

* update repos links

* update deps

* remove <content>

* add variants. make horizontal collapse content scrollable in demo

* fix safari10 tests (needs prefixed transition-duration)

* test native SD also for basic.html

* update deps and resolutions

* Depend on test-fixture v2

* auto-generated: update repo for v2

* remove test-fixture since it gets imported by wct

* fix safari9

* fix IE11 tests

* update deps

* Point to Polymer 2.0 RC 1

* use wct 5

* no test-fixture

* ignore variants artifacts

* use shadow-elevation mixin

* incorporate feedback

* Update travis config

* [skip ci] update readme

* Update travis config (#75)
  • Loading branch information
valdrinkoshi authored May 12, 2017
1 parent a6a6628 commit 920a2a5
Show file tree
Hide file tree
Showing 13 changed files with 220 additions and 140 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
bower_components
bower_components*
bower-*.json
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
language: node_js
sudo: required
before_script:
- npm install -g bower polylint web-component-tester
- bower install
- polylint
- npm install -g polymer-cli
- polymer install --variants
env:
global:
- secure: >-
UKNKHUjbp8O3UiVmnCmmprLR573ZXak9znhIvy0Uvxpkga7DFvfKvYRFCXQI/eV2I9YOI1FgVjlPfH8Id1NOWdMLdNjAI7G5p4FWisgu36kfat853HDYemoxx0C9nqPwakPGCJ9duL1w0dwje2sEHndk1cdwkU3TMsgkawdOJbU=
- secure: >-
cWudj1yh2mzialubEqhSHBG/CPLtI9ZeUPaI1+N3hiPzvuxqGaEbkpzEmlZrdAfuy9axCQStg88dgKRSv+TdMbcDKpzQqfClxTf9baKgrSgzVoMReY0kjHumCJz1tIVIz74ggp/gdQVFyS9CiA82pHTnxDl/drwPIHa2S8ST02U=
node_js: '6'
node_js: stable
addons:
firefox: latest
apt:
Expand All @@ -19,6 +18,8 @@ addons:
packages:
- google-chrome-stable
script:
- xvfb-run wct
- 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s ''default''; fi'
- xvfb-run polymer test
- >-
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then polymer test -s 'default';
fi
dist: trusty
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@

<!---
This README is automatically generated from the comments in these files:
iron-collapse.html
Edit those files, and our readme bot will duplicate them over here!
Edit this file, and the bot will squash your changes :)
The bot does some handling of markdown. Please file a bug if it does the wrong
thing! https://github.com/PolymerLabs/tedium/issues
-->

[![Build status](https://travis-ci.org/PolymerElements/iron-collapse.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-collapse)

_[Demo and API docs](https://elements.polymer-project.org/elements/iron-collapse)_


##&lt;iron-collapse&gt;
## &lt;iron-collapse&gt;

`iron-collapse` creates a collapsible block of content. By default, the content
will be collapsed. Use `opened` or `toggle()` to show/hide the content.
Expand Down
32 changes: 23 additions & 9 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iron-collapse",
"version": "1.3.0",
"version": "2.0.0",
"description": "Provides a collapsable container",
"authors": [
"The Polymer Authors"
Expand All @@ -19,16 +19,30 @@
"homepage": "https://github.com/PolymerElements/iron-collapse",
"ignore": [],
"dependencies": {
"iron-resizable-behavior": "PolymerElements/iron-resizable-behavior#^1.0.0",
"polymer": "Polymer/polymer#^1.5.0"
"iron-resizable-behavior": "PolymerElements/iron-resizable-behavior#2.0-preview",
"polymer": "Polymer/polymer#^2.0.0-rc.1"
},
"devDependencies": {
"web-component-tester": "^4.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-flex-layout": "polymerelements/iron-flex-layout#^1.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
"iron-component-page": "PolymerElements/iron-component-page#2.0-preview",
"paper-styles": "PolymerElements/paper-styles#2.0-preview",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#2.0-preview",
"web-component-tester": "Polymer/web-component-tester#^6.0.0-prerelease.6",
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0-rc.1"
},
"variants": {
"1.x": {
"dependencies": {
"iron-resizable-behavior": "PolymerElements/iron-resizable-behavior#^1.0.0",
"polymer": "Polymer/polymer#^1.0.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
"web-component-tester": "^5.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
}
}
},
"main": "iron-collapse.html"
}
168 changes: 86 additions & 82 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,95 +10,99 @@
-->

<html>
<head>

<title>iron-collapse demo</title>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-collapse.html">
<link rel="import" href="../../paper-styles/shadow.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">

<style is="custom-style">
.heading {
padding: 10px 15px;
margin-top: 20px;
background-color: #f3f3f3;
border: 1px solid #dedede;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
font-size: 18px;
cursor: pointer;
-webkit-tap-highlight-color: rgba(0,0,0,0);
width: 100%;
text-align: left;
}

.content {
padding: 15px;
border: 1px solid #dedede;
border-top: none;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
@apply(--shadow-elevation-2dp);
}

#collapse3 {
max-height: 250px;
}

</style>
<head>

</head>
<body unresolved>
<template is="dom-bind">
<title>iron-collapse demo</title>

<button class="heading" aria-expanded$="[[isExpanded(opened1)]]" aria-controls="collapse1" onclick="toggle('#collapse1')">Collapse #1</button>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<iron-collapse id="collapse1" tabindex="0" opened="{{opened1}}">
<div class="content">
<div>Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea, id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus. Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea, id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus.</div>
</div>
</iron-collapse>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>

<button class="heading" aria-expanded$="[[isExpanded(opened2)]]" aria-controls="collapse2" onclick="toggle('#collapse2')">Collapse #2</button>
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
<link rel="import" href="simple-expand-collapse.html">

<iron-collapse id="collapse2" tabindex="0" opened="{{opened2}}">
<div class="content">
<div>Pro saepe pertinax ei, ad pri animal labores suscipiantur. Modus commodo minimum eum te, vero utinam assueverit per eu, zril oportere suscipiantur pri te. Partem percipitur deterruisset ad sea, at eam suas luptatum dissentiunt. No error alienum pro, erant senserit ex mei, pri semper alterum no. Ut habemus menandri vulputate mea. Feugiat verterem ut sed. Dolores maiestatis id per. Pro saepe pertinax ei, ad pri animal labores suscipiantur. Modus commodo minimum eum te, vero utinam assueverit per eu, zril oportere suscipiantur pri te. Partem percipitur deterruisset ad sea, at eam suas luptatum dissentiunt. No error alienum pro, erant senserit ex mei, pri semper alterum no. Ut habemus menandri vulputate mea. Feugiat verterem ut sed. Dolores maiestatis id per.</div>
<custom-style><style is="custom-style" include="demo-pages-shared-styles">

<button class="heading" aria-expanded$="[[isExpanded(opened3)]]" aria-controls="collapse3" onclick="toggle('#collapse3')">Collapse #3 (horizontal)</button>

<iron-collapse id="collapse3" tabindex="0" opened="{{opened3}}" horizontal>
<div class="content">
<div>Iisque perfecto dissentiet cum et, sit ut quot mandamus, ut vim tibique splendide instructior. Id nam odio natum malorum, tibique copiosae expetenda mel ea. Mea melius malorum ut. Ut nec tollit vocent timeam. Facer nonumy numquam id his, munere salutatus consequuntur eum et, eum cotidieque definitionem signiferumque id. Ei oblique graecis patrioque vis, et probatus dignissim inciderint vel. Sed id paulo erroribus, autem semper accusamus in mel. Iisque perfecto dissentiet cum et, sit ut quot mandamus, ut vim tibique splendide instructior. Id nam odio natum malorum, tibique copiosae expetenda mel ea. Mea melius malorum ut. Ut nec tollit vocent timeam. Facer nonumy numquam id his, munere salutatus consequuntur eum et, eum cotidieque definitionem signiferumque id. Ei oblique graecis patrioque vis, et probatus dignissim inciderint vel. Sed id paulo erroribus, autem semper accusamus in mel.</div>
</div>
</iron-collapse>

<button class="heading" aria-expanded$="[[isExpanded(opened4)]]" aria-controls="collapse4" onclick="toggle('#collapse4')">Collapse #4 (no animation)</button>

<iron-collapse id="collapse4" tabindex="0" opened="{{opened4}}" no-animation>
<div class="content">
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
demo-snippet {
--demo-snippet-code: {
max-height: 250px;
}
}

simple-expand-collapse {
margin: 10px;
}

.content {
padding: 15px;
}
</style></custom-style>

</head>

<body unresolved class="centered">

<h4>Basic</h4>
<demo-snippet>
<template>
<simple-expand-collapse>
<div class="content">
Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea, id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum
eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus. Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea,
id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique
neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus.
</div>
</simple-expand-collapse>
</template>
</demo-snippet>

<h4>Nested, horizontal expand</h4>
<demo-snippet>
<template>
<style>
simple-expand-collapse[horizontal] .content {
max-height: 250px;
overflow: auto;
}
</style>

<simple-expand-collapse>
<div class="content">
<div>
Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea, id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum
eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus. Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea,
id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique
neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus.
</div>
</iron-collapse>
</div>
</iron-collapse>
</template>

<script>

function toggle(selector) {
document.querySelector(selector).toggle();
}

document.querySelector('template[is=dom-bind]').isExpanded = function(opened) {
return String(opened);
};
<simple-expand-collapse horizontal>
<div class="content">
Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea, id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum
eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus. Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere
ea, id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum eu tempor populo, graece sententiae constituam vim ex. Cu torquatos
reprimique neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus.
</div>
</simple-expand-collapse>
</div>
</simple-expand-collapse>
</template>
</demo-snippet>

<h4>No animation</h4>
<demo-snippet>
<template>
<simple-expand-collapse no-animation>
<div class="content">
Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea, id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum
eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus. Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea,
id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique
neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus.
</div>
</simple-expand-collapse>
</template>
</demo-snippet>
</body>

</script>
</body>
</html>
85 changes: 85 additions & 0 deletions demo/simple-expand-collapse.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!--
@license
Copyright (c) 2016 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-collapse.html">
<link rel="import" href="../../paper-styles/shadow.html">

<dom-module id="simple-expand-collapse">

<template>

<style>

:host {
display: block;
}

#trigger {
padding: 10px 15px;
background-color: #f3f3f3;
border: 1px solid #dedede;
border-radius: 5px;
font-size: 18px;
cursor: pointer;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
text-align: left;
}

:host([opened]) #trigger {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}

iron-collapse {
border: 1px solid #dedede;
border-top: none;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
@apply --shadow-elevation-2dp;
}
</style>
<button id="trigger" on-click="toggle" aria-expanded$="[[opened]]" aria-controls="collapse">[[_getText(opened)]]</button>
<iron-collapse id="collapse" opened="{{opened}}" horizontal="[[horizontal]]" no-animation="[[noAnimation]]" tabindex="0">
<slot></slot>
</iron-collapse>

</template>

</dom-module>

<script>
Polymer({

is: 'simple-expand-collapse',

properties: {

horizontal: {
type: Boolean
},
opened: {
type: Boolean,
reflectToAttribute: true
},
noAnimation: {
type: Boolean
},
},

toggle: function() {
this.$.collapse.toggle();
},

_getText: function(opened) {
return opened ? 'Collapse' : 'Expand';
}

});
</script>
4 changes: 3 additions & 1 deletion iron-collapse.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
:host {
display: block;
transition-duration: var(--iron-collapse-transition-duration, 300ms);
/* Safari 10 needs this property prefixed to correctly apply the custom property */
-webkit-transition-duration: var(--iron-collapse-transition-duration, 300ms);
overflow: visible;
}

Expand All @@ -78,7 +80,7 @@
}
</style>

<content></content>
<slot></slot>

</template>

Expand Down
Loading

0 comments on commit 920a2a5

Please sign in to comment.