Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 8076827

Browse files
committed
feat(theming): add theming
closes #442, thanks @skeemer
1 parent da55b67 commit 8076827

116 files changed

Lines changed: 2353 additions & 1739 deletions

File tree

Some content is hidden

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

docs/app/css/style.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ body {
55
max-height: 100%;
66
}
77

8+
a {
9+
color: #3f51b5;
10+
}
11+
812
md-toolbar.md-medium-tall {
913
height: 88px;
1014
}
@@ -158,13 +162,16 @@ pre > code.highlight {
158162
-moz-flex: 1;
159163
-ms-flex: 1;
160164
flex: 1;
165+
}
166+
167+
.demo-content > div[layout-fill] {
161168
min-height: 448px;
162169
}
163170

164171
md-toolbar.demo-toolbar,
165172
.demo-source-tabs md-tab,
166173
.demo-source-tabs .tabs-header {
167-
background: #00BCD4;
174+
background: #00BCD4 !important;
168175
color: white;
169176
}
170177
md-toolbar.demo-toolbar md-tab-label {

docs/app/partials/home.tmpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div ng-controller="HomeCtrl" layout="vertical">
22
<md-content flex>
33
<p>
4-
<a href="http://www.google.com/design/spec/materal-design/">Material Design</a> is a specification for a unified system of visual, motion, and interaction design that adapts across different devices.
4+
<a href="http://www.google.com/design/spec/material-design/">Material Design</a> is a specification for a unified system of visual, motion, and interaction design that adapts across different devices.
55
</p>
66
<p>
77
The material design project for Angular is a complementary effort to the <a href="http://www.polymer-project.org/">Polymer</a> project's <a href="http://www.polymer-project.org/docs/elements/paper-elements.html">paper elements</a> collection. Our goal is to provide a set of AngularJS-native UI elements that implement the material design system.

docs/config/template/index.template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
component-id="left"
2020
is-locked-open="$media('md')">
2121

22-
<md-toolbar class="md-theme-light md-medium-tall">
22+
<md-toolbar class="md-medium-tall">
2323
<h1 class="md-toolbar-tools" style="padding-top:25px;">
2424
<a href="#/" ng-click="goHome()">Angular<br/>Material Design</a>
2525
</h1>
@@ -50,7 +50,7 @@ <h1 class="md-toolbar-tools" style="padding-top:25px;">
5050
</md-sidenav>
5151

5252
<div layout="vertical" layout-fill tabIndex="-1" role="main">
53-
<md-toolbar class="md-theme-dark md-medium-tall app-toolbar">
53+
<md-toolbar md-theme="indigo" class="md-medium-tall app-toolbar">
5454

5555
<div class="md-toolbar-tools" ng-click="openMenu()">
5656
<button class="menu-icon" hide-md aria-label="Toggle Menu">

docs/gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ module.exports = function(gulp, IS_RELEASE_BUILD) {
118118
gulp.task('docs-css', ['docs-app', 'build'], function() {
119119
return gulp.src([
120120
'dist/angular-material.css',
121+
'dist/themes/*.css',
121122
'docs/app/css/highlightjs-github.css',
122123
'docs/app/css/layout-demo.css',
123-
'docs/app/css/style.css',
124-
'dist/themes/default-theme.css'
124+
'docs/app/css/style.css'
125125
])
126126
.pipe(concat('docs.css'))
127127
.pipe(gulp.dest('dist/docs'));

gulpfile.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var gulp = require('gulp');
99
var karma = require('karma').server;
1010
var pkg = require('./package.json');
1111
var exec = require('child_process').exec;
12+
var mergeStream = require('merge-stream');
1213

1314
var argv = require('minimist')(process.argv.slice(2));
1415

@@ -109,8 +110,8 @@ var config = {
109110
' * v' + pkg.version + '\n' +
110111
' */\n',
111112
jsBaseFiles: ['src/core/core.js', 'src/core/util/*.js'],
112-
themeBaseFiles: ['src/core/style/variables.scss', 'src/core/style/mixins.scss'],
113-
scssBaseFiles: ['src/core/style/variables.scss', 'src/core/style/mixins.scss', 'src/core/style/{structure,layout,table}.scss'],
113+
themeBaseFiles: ['src/core/style/color-palette.scss', 'src/core/style/variables.scss', 'src/core/style/mixins.scss'],
114+
scssBaseFiles: ['src/core/style/color-palette.scss', 'src/core/style/variables.scss', 'src/core/style/mixins.scss', 'src/core/style/{structure,layout,table}.scss'],
114115
paths: 'src/{components,services}/**',
115116
outputDir: 'dist/'
116117
};
@@ -121,7 +122,7 @@ var config = {
121122
* Project wide build related tasks
122123
*/
123124

124-
gulp.task('build', ['build-theme', 'build-scss', 'build-js'], function() {
125+
gulp.task('build', ['build-themes', 'build-scss', 'build-js'], function() {
125126
});
126127

127128
gulp.task('watch', ['build'], function() {
@@ -162,13 +163,27 @@ gulp.task('build-default-theme', function() {
162163
gulp.task('build-theme', ['build-default-theme'], function() {
163164
var theme = argv.theme || argv.t || 'default';
164165
theme = theme.replace(/-theme$/, '');
166+
return buildTheme(theme);
167+
});
168+
169+
gulp.task('build-themes', ['build-default-theme'], function() {
170+
var stream = mergeStream();
171+
var themes = glob('themes/*.scss', { cwd: __dirname });
172+
themes.forEach(function(themeFile) {
173+
var name = themeFile.match(/((\w|-)+)-theme\.scss/)[1];
174+
stream.add(buildTheme(name));
175+
});
176+
return stream;
177+
});
178+
179+
function buildTheme(theme) {
165180
gutil.log("Building theme " + theme + "...");
166-
return gulp.src(['themes/default-theme.scss', 'themes/' + theme + '-theme.scss'])
181+
return gulp.src(['src/core/style/color-palette.scss', 'themes/' + theme + '-theme.scss', 'themes/default-theme.scss'])
167182
.pipe(concat(theme + '-theme.scss'))
168183
.pipe(utils.hoistScssVariables())
169184
.pipe(sass())
170185
.pipe(gulp.dest(config.outputDir + 'themes/'));
171-
});
186+
}
172187

173188
gulp.task('build-scss', function() {
174189
var scssGlob = path.join(config.paths, '*.scss');
@@ -249,7 +264,11 @@ gulp.task('build-demo', function() {
249264
});
250265

251266
function buildModuleStyles(name) {
252-
var baseStyles = glob(config.themeBaseFiles, { cwd: __dirname }).map(function(fileName) {
267+
var files = [];
268+
config.themeBaseFiles.forEach(function(fileGlob) {
269+
files = files.concat(glob(fileGlob, { cwd: __dirname }));
270+
});
271+
var baseStyles = files.map(function(fileName) {
253272
return fs.readFileSync(fileName, 'utf8').toString();
254273
}).join('\n');
255274
return lazypipe()

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"batch": "^0.5.1",
99
"canonical-path": "0.0.2",
1010
"conventional-changelog": "0.0.9",
11+
"dgeni": "^0.4.1",
12+
"dgeni-packages": "^0.10.3",
1113
"esprima": "^1.2.2",
1214
"event-stream": "^3.1.5",
1315
"glob": "~4.0.2",
@@ -21,14 +23,16 @@
2123
"gulp-insert": "^0.4.0",
2224
"gulp-jshint": "^1.5.5",
2325
"gulp-minify-css": "^0.3.4",
26+
"gulp-minify-html": "^0.1.6",
2427
"gulp-ng-html2js": "^0.1.8",
2528
"gulp-rename": "^1.2.0",
2629
"gulp-replace": "^0.3.0",
27-
"gulp-sass": "^0.7.1",
30+
"gulp-sass": "1.2.0",
2831
"gulp-strip-debug": "^0.3.0",
2932
"gulp-uglify": "^0.3.0",
3033
"gulp-uncss": "^0.4.5",
3134
"gulp-util": "^3.0.1",
35+
"gulp-webserver": "^0.8.3",
3236
"jshint-summary": "^0.3.0",
3337
"karma": "^0.12.16",
3438
"karma-chrome-launcher": "^0.1.4",
@@ -39,14 +43,10 @@
3943
"karma-sauce-launcher": "^0.2.10",
4044
"lazypipe": "^0.2.2",
4145
"lodash": "^2.4.1",
46+
"merge-stream": "^0.1.6",
4247
"minimist": "^0.1.0",
43-
"node-sass": "^0.9.5-rc1",
44-
"dgeni": "^0.4.1",
45-
"dgeni-packages": "^0.10.3",
46-
"through2": "^0.6.3",
47-
"gulp-minify-html": "^0.1.6",
4848
"mkdirp": "^0.5.0",
49-
"gulp-webserver": "^0.8.3",
50-
"q": "^1.0.1"
49+
"q": "^1.0.1",
50+
"through2": "^0.6.3"
5151
}
5252
}

scripts/gulp-utils.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,20 @@ exports.hoistScssVariables = function() {
154154
var contents = file.contents.toString().split('\n');
155155
var lastVariableLine = -1;
156156

157+
var openCount = 0;
158+
var closeCount = 0;
159+
var openBlock = false;
160+
157161
for( var currentLine = 0; currentLine < contents.length; ++currentLine) {
158162
var line = contents[currentLine];
159-
if (/^\s*\$/.test(line)) {
160-
if (currentLine != lastVariableLine + 1) {
161-
var variable = contents.splice(currentLine, 1)[0];
162-
contents.splice(++lastVariableLine, 0, variable);
163-
}
163+
164+
if (openBlock || /^\s*\$/.test(line)) {
165+
if (openBlock) debugger;
166+
openCount += (line.match(/\(/g) || []).length;
167+
closeCount += (line.match(/\)/g) || []).length;
168+
openBlock = openCount != closeCount;
169+
var variable = contents.splice(currentLine, 1)[0];
170+
contents.splice(++lastVariableLine, 0, variable);
164171
}
165172
}
166173
file.contents = new Buffer(contents.join('\n'));

src/components/animate/_effects.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
md-tabs-ink-bar {
2-
height: 2px;
3-
background: #ffff85;
4-
position: absolute;
5-
margin-top: -2px;
6-
}
7-
81
// Button ripple: keep same opacity, but expand to 0.75 scale.
92
// Then, fade out and expand to 2.0 scale.
103
@keyframes inkRippleButton {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* @ngdoc module
3+
* @name material.components.backdrop
4+
* @description Backdrop
5+
*/
6+
7+
/**
8+
* @ngdoc directive
9+
* @name mdBackdrop
10+
* @module material.components.backdrop
11+
*
12+
* @restrict E
13+
*
14+
* @description
15+
* `<md-backdrop>` is a backdrop element used by other coponents, such as dialog and bottom sheet.
16+
* Apply class `opaque` to make the backdrop use the theme backdrop color.
17+
*
18+
*/
19+
angular.module('material.components.backdrop', [
20+
'material.services.theming'
21+
])
22+
.directive('mdBackdrop', [
23+
'$mdTheming',
24+
BackdropDirective
25+
]);
26+
27+
function BackdropDirective($mdTheming) {
28+
return $mdTheming;
29+
}

src/components/backdrop/_backdrop.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ md-backdrop {
88
right: 0;
99
bottom: 0;
1010

11-
&.opaque {
12-
background-color: rgba(0,0,0,0.3);
13-
}
14-
1511
transition: all 0.2s ease-out;
1612

1713
&.ng-enter {

0 commit comments

Comments
 (0)