Skip to content

Commit f149ae7

Browse files
jelbournyjbanov
authored andcommitted
feat(material): first ng2 material design components
1 parent ffe1307 commit f149ae7

64 files changed

Lines changed: 4003 additions & 7 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

gulpfile.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
var autoprefixer = require('gulp-autoprefixer');
12
var format = require('gulp-clang-format');
23
var gulp = require('gulp');
34
var gulpPlugins = require('gulp-load-plugins')();
5+
var sass = require('gulp-sass');
46
var shell = require('gulp-shell');
57
var runSequence = require('run-sequence');
68
var madge = require('madge');
@@ -152,7 +154,7 @@ var CONFIG = {
152154
src: ['modules/**/*.css'],
153155
pipes: {}
154156
}
155-
},
157+
}
156158
},
157159
multicopy: {
158160
js: {
@@ -697,3 +699,23 @@ gulp.task('build.js', ['build.js.dev', 'build.js.prod', 'build.js.cjs', 'bundle.
697699
gulp.task('clean', ['build/clean.js', 'build/clean.dart', 'build/clean.docs']);
698700

699701
gulp.task('build', ['build.js', 'build.dart']);
702+
703+
704+
// ------------
705+
// angular material testing rules
706+
gulp.task('build/css.js.dev', function() {
707+
return gulp.src('modules/*/src/**/*.scss')
708+
.pipe(sass())
709+
.pipe(autoprefixer())
710+
.pipe(gulp.dest(CONFIG.dest.js.dev.es5));
711+
});
712+
713+
// TODO: this target is temporary until we find a way to use the SASS transformer
714+
gulp.task('build/css.dart', function() {
715+
return gulp.src('dist/dart/angular2_material/lib/src/**/*.scss')
716+
.pipe(sass())
717+
.pipe(autoprefixer())
718+
.pipe(gulp.dest('dist/dart/angular2_material/lib/src'));
719+
});
720+
721+
gulp.task('build.material', ['build.js.dev', 'build/css.js.dev']);

modules/angular2/src/core/application.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import {Injector, bind, OpaqueToken} from 'angular2/di';
2-
import {Type, isBlank, isPresent, BaseException, assertionsEnabled, print, stringify} from 'angular2/src/facade/lang';
1+
import {Injector, bind, OpaqueToken, Optional} from 'angular2/di';
2+
import {NumberWrapper, Type, isBlank, isPresent, BaseException,
3+
assertionsEnabled, print, stringify} from 'angular2/src/facade/lang';
34
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
45
import {DOM} from 'angular2/src/dom/dom_adapter';
56
import {Compiler, CompilerCache} from './compiler/compiler';

modules/angular2/src/facade/math.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class Math {
1010
return math.pow(x, exponent);
1111
}
1212

13+
static num max(num a, num b) => math.max(a, b);
14+
1315
static num min(num a, num b) => math.min(a, b);
1416

1517
static num floor(num a) => a.floor();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Temporary home of Material Design components for Angular 2.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "angular2_material",
3+
"version": "<%= packageJson.version %>",
4+
"description": "Google material design components for Angular 2",
5+
"homepage": "<%= packageJson.homepage %>",
6+
"bugs": "<%= packageJson.bugs %>",
7+
"contributors": <%= JSON.stringify(packageJson.contributors) %>,
8+
"license": "<%= packageJson.license %>",
9+
"dependencies": {
10+
"angular2": "<%= packageJson.version %>",
11+
"traceur": "<%= packageJson.dependencies.traceur %>",
12+
"rtts_assert": "<%= packageJson.version %>",
13+
"rx": "<%= packageJson.dependencies['rx'] %>",
14+
"zone.js": "<%= packageJson.dependencies['zone.js'] %>"
15+
},
16+
"devDependencies": <%= JSON.stringify(packageJson.devDependencies) %>
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: angular2_material
2+
version: <%= packageJson.version %>
3+
authors:
4+
<%= Object.keys(packageJson.contributors).map(function(name) {
5+
return '- '+name+' <'+packageJson.contributors[name]+'>';
6+
}).join('\n') %>
7+
description: Google material design components for Angular 2
8+
homepage: <%= packageJson.homepage %>
9+
environment:
10+
sdk: '>=1.9.0-dev.8.0'
11+
dependencies:
12+
angular2: '^<%= packageJson.version %>'
13+
browser: '>=0.10.0 <0.11.0'
14+
dependency_overrides:
15+
angular2:
16+
path: ../angular2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<style>@import "angular2_material/src/components/button/button.css";</style>
2+
<span class="md-button-wrapper"><content></content></span>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {Component, View} from 'angular2/angular2';
2+
import {PropertySetter, EventEmitter} from 'angular2/src/core/annotations/di';
3+
import {onChange} from 'angular2/src/core/annotations/annotations';
4+
import {isPresent, StringWrapper} from 'angular2/src/facade/lang';
5+
6+
7+
@Component({selector: '[md-button]:not([href])'})
8+
@View({templateUrl: 'angular2_material/src/components/button/button.html'})
9+
export class MdButton {
10+
// TODO(jelbourn): Ink ripples.
11+
}
12+
13+
14+
@Component({
15+
selector: '[md-button][href]',
16+
properties: {
17+
'disabled': 'disabled'
18+
},
19+
hostListeners: {'click': 'onClick($event)'},
20+
lifecycle: [onChange]
21+
})
22+
@View({
23+
templateUrl: 'angular2_material/src/components/button/button.html'
24+
})
25+
export class MdAnchor {
26+
tabIndexSetter: Function;
27+
28+
/** Whether the component is disabled. */
29+
disabled: boolean;
30+
31+
constructor(@PropertySetter('tabIndex') tabIndexSetter: Function) {
32+
this.tabIndexSetter = tabIndexSetter;
33+
}
34+
35+
onClick(event) {
36+
// A disabled anchor shouldn't navigate anywhere.
37+
if (isPresent(this.disabled) && this.disabled !== false) {
38+
event.preventDefault();
39+
}
40+
}
41+
42+
/** Invoked when a change is detected. */
43+
onChange(_) {
44+
// A disabled anchor should not be in the tab flow.
45+
this.tabIndexSetter(this.disabled ? -1 : 0);
46+
}
47+
}

0 commit comments

Comments
 (0)