Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
refactor(theming): switch angular-material.css to include default-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
rschmukler committed Oct 31, 2014
1 parent ea73c23 commit ddd977d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 41 deletions.
12 changes: 8 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ gulp.task('server', function() {

gulp.task('build-default-theme', function() {
return gulp.src(config.themeBaseFiles.concat(path.join(config.paths, '*-theme.scss')))
.pipe(concat('default-theme.scss'))
.pipe(concat('_default-theme.scss'))
.pipe(utils.hoistScssVariables())
.pipe(gulp.dest('themes/'));
});
Expand All @@ -168,7 +168,7 @@ gulp.task('build-theme', ['build-default-theme'], function() {

gulp.task('build-themes', ['build-default-theme'], function() {
var stream = mergeStream();
var themes = glob('themes/*.scss', { cwd: __dirname });
var themes = glob('themes/**.scss', { cwd: __dirname }).filter(function(themeName) { return themeName.split('/')[1].charAt(0) != '_'; });
themes.forEach(function(themeFile) {
var name = themeFile.match(/((\w|-)+)-theme\.scss/)[1];
stream.add(buildTheme(name));
Expand All @@ -178,20 +178,24 @@ gulp.task('build-themes', ['build-default-theme'], function() {

function buildTheme(theme) {
gutil.log("Building theme " + theme + "...");
return gulp.src(['src/core/style/color-palette.scss', 'themes/' + theme + '-theme.scss', 'themes/default-theme.scss'])
return gulp.src(['src/core/style/color-palette.scss', 'themes/' + theme + '-theme.scss', 'themes/_default-theme.scss'])
.pipe(concat(theme + '-theme.scss'))
.pipe(utils.hoistScssVariables())
.pipe(sass())
.pipe(gulp.dest(config.outputDir + 'themes/'));
}

gulp.task('build-scss', function() {
gulp.task('build-scss', ['build-default-theme'], function() {
var defaultThemeContents = fs.readFileSync('themes/_default-theme.scss');


var scssGlob = path.join(config.paths, '*.scss');
gutil.log("Building css files...");
return gulp.src(config.scssBaseFiles.concat(scssGlob))
.pipe(filterNonCodeFiles())
.pipe(filter(['**', '!**/*-theme.scss'])) // remove once ported
.pipe(concat('angular-material.scss'))
.pipe(insert.append(defaultThemeContents))
.pipe(sass())
.pipe(autoprefix())
.pipe(insert.prepend(config.banner))
Expand Down
37 changes: 0 additions & 37 deletions src/main.scss

This file was deleted.

File renamed without changes.

1 comment on commit ddd977d

@ThomasBurleson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By changing the name to _default-theme.scss you can then easily filter it.
Then you just use fs.readFileSync to load the content and insert in the angular-material.css

  • This is very elegant, subtle, and nice.

Please sign in to comment.