update shared components

This commit is contained in:
Luke Pulverenti 2016-03-09 12:40:22 -05:00
parent fb269362ff
commit 71811cb9e3
221 changed files with 32936 additions and 101 deletions

View file

@ -0,0 +1,34 @@
/**
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@import "../variables";
.mdl-animation--default {
transition-timing-function: $animation-curve-default;
}
.mdl-animation--fast-out-slow-in {
transition-timing-function: $animation-curve-fast-out-slow-in;
}
.mdl-animation--linear-out-slow-in {
transition-timing-function: $animation-curve-linear-out-slow-in;
}
.mdl-animation--fast-out-linear-in {
transition-timing-function: $animation-curve-fast-out-linear-in;
}

View file

@ -0,0 +1,95 @@
/**
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.demo-animation {
height: 200px;
width: 300px;
padding: 0;
background: none;
}
.demo-animation__container {
position: relative;
overflow: hidden;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
text-align: center;
background-color: #ddd;
}
.demo-animation__container-foreground {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: 100;
}
.demo-animation__container-background {
line-height: 200px;
z-index: -100;
}
/* Outside the view, on the left.
We leave the view when moving to this state, so we use fast-out-linear-in. */
.demo-animation--position-0 {
left: -102px;
}
/* Left side.
We enter the view when moving to this state, so we use linear-out-slow-in. */
.demo-animation--position-1 {
left: 20px;
}
/* Right side.
We're always visible when moving to this state, so we use default. */
.demo-animation--position-2 {
left: 180px;
}
/* Outside the view, on the right.
We leave the view when moving to this state, so we use fast-out-linear-in. */
.demo-animation--position-3 {
left: 302px;
}
/* Right side.
We enter the view when moving to this state, so we use linear-out-slow-in. */
.demo-animation--position-4 {
left: 180px;
}
/* Left side.
We're always visible when moving to this state, so we use default. */
.demo-animation--position-5 {
left: 20px;
}
.demo-animation__movable {
background-color: red;
border-radius: 2px;
display: block;
height: 100px;
width: 100px;
position: absolute;
top: 50px;
transition-property: left;
transition-duration: 0.2s;
}

View file

@ -0,0 +1,7 @@
<div class="demo-preview-block demo-animation demo-js-animation">
<div class="demo-animation__container">
<div class="demo-animation__container-background">Click me to animate</div>
<div class="demo-animation__container-foreground"></div>
<div class="demo-animation__movable demo-animation--position-0 mdl-shadow--2dp"></div>
</div>
</div>

View file

@ -0,0 +1,112 @@
/**
* @license
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Class constructor for Animation MDL component.
* Implements MDL component design pattern defined at:
* https://github.com/jasonmayes/mdl-component-design-pattern
* @param {HTMLElement} element The element that will be upgraded.
*/
function DemoAnimation(element) {
'use strict';
this.element_ = element;
this.position_ = this.Constant_.STARTING_POSITION;
this.movable_ = this.element_.querySelector('.' + this.CssClasses_.MOVABLE);
// Initialize instance.
this.init();
}
/**
* Store strings for class names defined by this component that are used in
* JavaScript. This allows us to simply change it in one place should we
* decide to modify at a later date.
* @enum {string}
* @private
*/
DemoAnimation.prototype.CssClasses_ = {
MOVABLE: 'demo-animation__movable',
POSITION_PREFIX: 'demo-animation--position-',
FAST_OUT_SLOW_IN: 'mdl-animation--fast-out-slow-in',
LINEAR_OUT_SLOW_IN: 'mdl-animation--linear-out-slow-in',
FAST_OUT_LINEAR_IN: 'mdl-animation--fast-out-linear-in'
};
/**
* Store constants in one place so they can be updated easily.
* @enum {string | number}
* @private
*/
DemoAnimation.prototype.Constant_ = {
STARTING_POSITION: 0,
// Which animation to use for which state. Check demo.css for an explanation.
ANIMATIONS: [
DemoAnimation.prototype.CssClasses_.FAST_OUT_LINEAR_IN,
DemoAnimation.prototype.CssClasses_.LINEAR_OUT_SLOW_IN,
DemoAnimation.prototype.CssClasses_.FAST_OUT_SLOW_IN,
DemoAnimation.prototype.CssClasses_.FAST_OUT_LINEAR_IN,
DemoAnimation.prototype.CssClasses_.LINEAR_OUT_SLOW_IN,
DemoAnimation.prototype.CssClasses_.FAST_OUT_SLOW_IN
]
};
/**
* Handle click of element.
* @param {Event} event The event that fired.
* @private
*/
DemoAnimation.prototype.handleClick_ = function(event) {
'use strict';
this.movable_.classList.remove(this.CssClasses_.POSITION_PREFIX +
this.position_);
this.movable_.classList.remove(this.Constant_.ANIMATIONS[this.position_]);
this.position_++;
if (this.position_ > 5) {
this.position_ = 0;
}
this.movable_.classList.add(this.Constant_.ANIMATIONS[this.position_]);
this.movable_.classList.add(this.CssClasses_.POSITION_PREFIX +
this.position_);
};
/**
* Initialize element.
*/
DemoAnimation.prototype.init = function() {
'use strict';
if (this.element_) {
if (!this.movable_) {
console.error('Was expecting to find an element with class name ' +
this.CssClasses_.MOVABLE + ' inside of: ', this.element_);
return;
}
this.element_.addEventListener('click', this.handleClick_.bind(this));
}
};
// The component registers itself. It can assume componentHandler is available
// in the global scope.
componentHandler.register({
constructor: DemoAnimation,
classAsString: 'DemoAnimation',
cssClass: 'demo-js-animation'
});