Skip to content

Commit

Permalink
fixes some errors in Sass convert task
Browse files Browse the repository at this point in the history
  • Loading branch information
Minwe committed May 25, 2016
1 parent e26361d commit 23093cf
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 11 deletions.
9 changes: 9 additions & 0 deletions tools/tasks/sass/_functions.scss
@@ -0,0 +1,9 @@
// Strip Unit
// Removes the unit (e.g. px, em, rem) from a value, returning the number only.
//
// @param {number} $num - Number to strip unit from.
//
// @return The same number, sans unit.
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
26 changes: 17 additions & 9 deletions tools/tasks/sass/index.js
@@ -1,7 +1,5 @@
'use strict';

/* jshint node: true */

var exec = require('child_process').exec;
var path = require('path');
var format = require('util').format;
Expand All @@ -17,8 +15,8 @@ var paths = {
sassRepo: '../amazeui-sass'
};

gulp.task('sass:clean', function(callback) {
del(sassPath, callback);
gulp.task('sass:clean', function() {
return del(sassPath);
});

gulp.task('sass:copy:less', function() {
Expand All @@ -44,7 +42,7 @@ gulp.task('sass:convert', function() {
paths.scss + '/*.scss',
paths.widget + '/*/src/*.scss'
])
// change less/ dir to scss/ on imports
// change less/ dir to scss/ on imports
.pipe(replace(/\/less\//g, '/scss/'))
// gradient filter
.pipe(replace(/filter:\s*e\(\%\("progid:DXImageTransform\.Microsoft\.gradient\(startColorstr='\%d',\s*endColorstr='\%d',\s*GradientType=(\d)\)",\s*argb\((@.+)*\),\s*argb\((@.*)\)\)\)/g, function(all, $1, $2, $3) {
Expand All @@ -67,6 +65,10 @@ gulp.task('sass:convert', function() {
function(match, $1, $2) {
return format('@include %s(%s);', $1, $2.replace(/;/g, ','));
}))
// button-variant mixin
.pipe(replace('a&:visited {', '$selector: &;\na#{$selector}:visited {'))
// thumbnail.less
.pipe(replace('img&,', '$selector: &;\nimg#{$selector},'))
// button.less
.pipe(replace(/\.(button-\w+)\((.*)\);/g,
function(match, $1, $2) {
Expand All @@ -90,6 +92,11 @@ gulp.task('sass:convert', function() {
.pipe(replace(/\.square\((.*)\);/g, '@include square($1);'))
// .border-*-radius();
.pipe(replace(/\.(border-\w+-radius)\((.*)\)/g, '@include $1($2)'))
// animation.less
.pipe(replace(/\.(variant-animation-delay)\((.*)\);/g,
function(match, $1, $2) {
return format('@include %s(%s);', $1, $2.replace(/;/g, ','));
}))
// comment.less
.pipe(replace(/\.(comment-highlight-variant)\((.*)\);/g,
function(match, $1, $2) {
Expand Down Expand Up @@ -206,10 +213,11 @@ gulp.task('sass:deploy:misc', function() {
});

gulp.task('sass:test', function(callback) {
exec('sass ../amazeui-sass/scss/amazeui.scss', function(err, stdout, stderr) {
// console.log(stdout);
console.log(stderr);
});
exec('node-sass ../amazeui-sass/scss/amazeui.scss',
function(err, stdout, stderr) {
// console.log(stdout);
console.log(stderr);
});
callback();
});

Expand Down
40 changes: 38 additions & 2 deletions tools/tasks/sass/scss/table.scss
Expand Up @@ -147,6 +147,7 @@ th {
/* Bordered version */
.#{$ns}table-bordered {
border: 1px solid $table-border-color;
border-left: none;
// @include hook-table-bordered();

> thead,
Expand All @@ -157,9 +158,10 @@ th {
> td {
border-left: 1px solid $table-border-color;

&:first-child {
// 避免有 rowspan 的时候后面的行没有左边框
/*&:first-child {
border-left: none;
}
}*/
}
}
}
Expand Down Expand Up @@ -245,6 +247,40 @@ th {
}


// Modifiers: compact
// =============================================================================

.#{$ns}table-compact {
> thead,
> tbody,
> tfoot {
> tr {
> th,
> td {
padding: $table-cell-padding-compact;
}
}
}
}


// Modifiers: centered
// =============================================================================

.#{$ns}table-centered {
> thead,
> tbody,
> tfoot {
> tr {
> th,
> td {
text-align: center;
}
}
}
}


// Modifiers: states
// =============================================================================

Expand Down

0 comments on commit 23093cf

Please sign in to comment.