MODULE-TYPO

- Sass set-up
- md-list
- md-theming (install)
This commit is contained in:
iRouge
2015-01-16 07:52:29 -05:00
parent ec1b4b9b0c
commit f1d2b8cb75
312 changed files with 26839 additions and 1309 deletions

View File

@@ -0,0 +1,12 @@
<div ng-controller="AppCtrl" layout="column" layout-margin style="padding:25px;">
<md-progress-linear md-mode="indeterminate"></md-progress-linear>
<md-progress-linear class="md-warn" md-mode="buffer" value="{{determinateValue}}" md-buffer-value="{{determinateValue2}}">
</md-progress-linear>
<md-progress-linear class="md-accent" md-mode="{{mode}}" value="{{determinateValue}}"></md-progress-linear>
<md-progress-linear md-theme="custom" md-mode="determinate" ng-value="determinateValue" ></md-progress-linear>
</div>

View File

@@ -0,0 +1,21 @@
angular.module('progressLinearDemo1', ['ngMaterial'])
.config(function($mdThemingProvider) {
})
.controller('AppCtrl', ['$scope', '$interval', function($scope, $interval) {
$scope.mode = 'query';
$scope.determinateValue = 30;
$scope.determinateValue2 = 30;
$interval(function() {
$scope.determinateValue += 1;
$scope.determinateValue2 += 1.5;
if ($scope.determinateValue > 100) {
$scope.determinateValue = 30;
$scope.determinateValue2 = 30;
}
}, 100, 0, true);
$interval(function() {
$scope.mode = ($scope.mode == 'query' ? 'determinate' : 'query');
}, 7200, 0, true);
}]);

View File

@@ -0,0 +1,12 @@
body {
padding: 20px;
}
h4 {
margin: 10px 0;
}
md-progress-linear {
padding-top:10px;
margin-bottom:20px;
}

View File

@@ -0,0 +1,44 @@
md-progress-linear.md-THEME_NAME-theme {
.md-container {
background-color: '{{primary-100}}';
}
.md-bar {
background-color: '{{primary-color}}';
}
&.md-warn .md-container {
background-color: '{{warn-100}}';
}
&.md-warn .md-bar {
background-color: '{{warn-color}}';
}
&.md-accent .md-container {
background-color: '{{accent-100}}';
}
&.md-accent .md-bar {
background-color: '{{accent-color}}';
}
&[md-mode=buffer] {
&.md-warn {
.md-bar1 {
background-color: '{{warn-100}}';
}
.md-dashed:before {
background: radial-gradient('{{warn-100}}' 0%, '{{warn-100}}' 16%, transparent 42%);
}
}
&.md-accent {
.md-bar1 {
background-color: '{{accent-100}}';
}
.md-dashed:before {
background: radial-gradient('{{accent-100}}' 0%, '{{accent-100}}' 16%, transparent 42%);
}
}
}
}

View File

@@ -0,0 +1,121 @@
(function() {
'use strict';
/**
* @ngdoc module
* @name material.components.progressLinear
* @description Linear Progress module!
*/
angular.module('material.components.progressLinear', [
'material.core'
])
.directive('mdProgressLinear', MdProgressLinearDirective);
/**
* @ngdoc directive
* @name mdProgressLinear
* @module material.components.progressLinear
* @restrict E
*
* @description
* The linear progress directive is used to make loading content in your app as delightful and painless as possible by minimizing the amount of visual change a user sees before they can view and interact with content. Each operation should only be represented by one activity indicator—for example, one refresh operation should not display both a refresh bar and an activity circle.
*
* For operations where the percentage of the operation completed can be determined, use a determinate indicator. They give users a quick sense of how long an operation will take.
*
* For operations where the user is asked to wait a moment while something finishes up, and its not necessary to expose what's happening behind the scenes and how long it will take, use an indeterminate indicator.
*
* @param {string} md-mode Select from one of four modes: determinate, indeterminate, buffer or query.
* @param {number=} value In determinate and buffer modes, this number represents the percentage of the primary progress bar. Default: 0
* @param {number=} md-buffer-value In the buffer mode, this number represents the precentage of the secondary progress bar. Default: 0
*
* @usage
* <hljs lang="html">
* <md-progress-linear md-mode="determinate" value="..."></md-progress-linear>
*
* <md-progress-linear md-mode="determinate" ng-value="..."></md-progress-linear>
*
* <md-progress-linear md-mode="indeterminate"></md-progress-linear>
*
* <md-progress-linear md-mode="buffer" value="..." md-buffer-value="..."></md-progress-linear>
*
* <md-progress-linear md-mode="query"></md-progress-linear>
* </hljs>
*/
function MdProgressLinearDirective($$rAF, $mdConstant, $mdTheming) {
return {
restrict: 'E',
template: '<div class="md-container">' +
'<div class="md-dashed"></div>' +
'<div class="md-bar md-bar1"></div>' +
'<div class="md-bar md-bar2"></div>' +
'</div>',
compile: compile
};
function compile(tElement, tAttrs, transclude) {
tElement.attr('aria-valuemin', 0);
tElement.attr('aria-valuemax', 100);
tElement.attr('role', 'progressbar');
return postLink;
}
function postLink(scope, element, attr) {
$mdTheming(element);
var bar1Style = element[0].querySelector('.md-bar1').style,
bar2Style = element[0].querySelector('.md-bar2').style,
container = angular.element(element[0].querySelector('.md-container'));
attr.$observe('value', function(value) {
if (attr.mdMode == 'query') {
return;
}
var clamped = clamp(value);
element.attr('aria-valuenow', clamped);
bar2Style[$mdConstant.CSS.TRANSFORM] = transforms[clamped];
});
attr.$observe('mdBufferValue', function(value) {
bar1Style[$mdConstant.CSS.TRANSFORM] = transforms[clamp(value)];
});
$$rAF(function() {
container.addClass('md-ready');
});
}
function clamp(value) {
if (value > 100) {
return 100;
}
if (value < 0) {
return 0;
}
return Math.ceil(value || 0);
}
}
// **********************************************************
// Private Methods
// **********************************************************
var transforms = (function() {
var values = new Array(101);
for(var i = 0; i < 101; i++){
values[i] = makeTransform(i);
}
return values;
function makeTransform(value){
var scale = value/100;
var translateX = (value-100)/2;
return 'translateX(' + translateX.toString() + '%) scale(' + scale.toString() + ', 1)';
}
})();
})();

View File

@@ -0,0 +1,201 @@
$progress-linear-bar-height:5px !default;
md-progress-linear {
display: block;
width: 100%;
height: $progress-linear-bar-height;
.md-container {
overflow: hidden;
position: relative;
height: $progress-linear-bar-height;
top: $progress-linear-bar-height;
transform: translate(0, 5px) scale(1, 0);
transition: all .3s linear;
}
.md-container.md-ready {
transform: translate(0, 0) scale(1, 1);
}
.md-bar {
height: $progress-linear-bar-height;
position: absolute;
width: 100%;
}
.md-bar1, .md-bar2 {
transition: all 0.2s linear;
}
&[md-mode=determinate] {
.md-bar1 {
display: none;
}
}
&[md-mode=indeterminate] {
.md-bar1 {
animation: indeterminate1 4s infinite linear;
}
.md-bar2 {
animation: indeterminate2 4s infinite linear;
}
}
&[md-mode=buffer] {
.md-container {
background-color: transparent !important;
}
.md-dashed:before {
content: "";
display: block;
height: $progress-linear-bar-height;
width: 100%;
margin-top: 0px;
position: absolute;
background-color: transparent;
background-size: 10px 10px !important;
background-position: 0px -23px;
animation: buffer 3s infinite linear;
}
}
&[md-mode=query] {
.md-bar2 {
animation: query .8s infinite cubic-bezier(0.390, 0.575, 0.565, 1.000);
}
}
}
@keyframes indeterminate1 {
0% {
transform: translateX(-25%) scale(.5, 1);
}
10% {
transform: translateX(25%) scale(.5, 1);
}
19.99% {
transform: translateX(50%) scale(0, 1);
}
20% {
transform: translateX(-37.5%) scale(.25, 1);
}
30% {
transform: translateX(37.5%) scale(.25, 1);
}
34.99% {
transform: translateX(50%) scale(0, 1);
}
36.99% {
transform: translateX(50%) scale(0, 1);
}
37% {
transform: translateX(-37.5%) scale(.25, 1);
}
47% {
transform: translateX(20%) scale(.25, 1);
}
52% {
transform: translateX(35%) scale(.05, 1);
}
55% {
transform: translateX(35%) scale(.1, 1);
}
58% {
transform: translateX(50%) scale(.1, 1);
}
61.99% {
transform: translateX(50%) scale(0, 1);
}
69.99% {
transform: translateX(50%) scale(0, 1);
}
70% {
transform: translateX(-37.5%) scale(.25, 1);
}
80% {
transform: translateX(20%) scale(.25, 1);
}
85% {
transform: translateX(35%) scale(.05, 1);
}
88% {
transform: translateX(35%) scale(.1, 1);
}
91% {
transform: translateX(50%) scale(.1, 1);
}
92.99% {
transform: translateX(50%) scale(0, 1);
}
93% {
transform: translateX(-50%) scale(0, 1);
}
100% {
transform: translateX(-25%) scale(.5, 1);
}
}
@keyframes indeterminate2 {
0% {
transform: translateX(-50%) scale(0, 1);
}
25.99%{
transform: translateX(-50%) scale(0, 1);
}
28% {
transform: translateX(-37.5%) scale(.25, 1);
}
38% {
transform: translateX(37.5%) scale(.25, 1);
}
42.99% {
transform: translateX(50%) scale(0, 1);
}
46.99% {
transform: translateX(50%) scale(0, 1);
}
49.99% {
transform: translateX(50%) scale(0, 1);
}
50% {
transform: translateX(-50%) scale(0, 1);
}
60% {
transform: translateX(-25%) scale(.5, 1);
}
70% {
transform: translateX(25%) scale(.5, 1);
}
79.99% {
transform: translateX(50%) scale(0, 1);
}
}
@keyframes query {
0% {
opacity: 1;
transform: translateX(35%) scale(.3, 1);
}
100% {
opacity: 0;
transform: translateX(-50%) scale(0, 1);
}
}
@keyframes buffer {
0% {
opacity: 1;
background-position: 0px -23px;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
background-position: -200px -23px;
}
}

View File

@@ -0,0 +1,68 @@
describe('mdProgressLinear', function() {
beforeEach(module('material.components.progressLinear'));
it('should set transform based on value', inject(function($compile, $rootScope, $mdConstant) {
var element = $compile('<div>' +
'<md-progress-linear value="{{progress}}">' +
'</md-progress-linear>' +
'</div>')($rootScope);
$rootScope.$apply(function() {
$rootScope.progress = 50;
});
var progress = element.find('md-progress-linear'),
bar2 = angular.element(progress[0].querySelectorAll('.md-bar2'))[0];
expect(bar2.style[$mdConstant.CSS.TRANSFORM]).toEqual('translateX(-25%) scale(0.5, 1)');
}));
it('should update aria-valuenow', inject(function($compile, $rootScope) {
var element = $compile('<div>' +
'<md-progress-linear value="{{progress}}">' +
'</md-progress-linear>' +
'</div>')($rootScope);
$rootScope.$apply(function() {
$rootScope.progress = 50;
});
var progress = element.find('md-progress-linear');
expect(progress.eq(0).attr('aria-valuenow')).toEqual('50');
}));
it('should set transform based on buffer value', inject(function($compile, $rootScope, $mdConstant) {
var element = $compile('<div>' +
'<md-progress-linear value="{{progress}}" md-buffer-value="{{progress2}}">' +
'</md-progress-linear>' +
'</div>')($rootScope);
$rootScope.$apply(function() {
$rootScope.progress = 50;
$rootScope.progress2 = 75;
});
var progress = element.find('md-progress-linear'),
bar1 = angular.element(progress[0].querySelectorAll('.md-bar1'))[0];
expect(bar1.style[$mdConstant.CSS.TRANSFORM]).toEqual('translateX(-12.5%) scale(0.75, 1)');
}));
it('should not set transform in query mode', inject(function($compile, $rootScope, $mdConstant) {
var element = $compile('<div>' +
'<md-progress-linear md-mode="query" value="{{progress}}">' +
'</md-progress-linear>' +
'</div>')($rootScope);
$rootScope.$apply(function() {
$rootScope.progress = 80;
});
var progress = element.find('md-progress-linear'),
bar2 = angular.element(progress[0].querySelectorAll('.md-bar2'))[0];
expect(bar2.style[$mdConstant.CSS.TRANSFORM]).toBeFalsy();
}));
});