-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement gulp to create dist version
- Loading branch information
Loic Kartono
committed
Jan 30, 2015
1 parent
dc73759
commit ab427cd
Showing
6 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.lk-color-chooser { | ||
list-style-type: none; | ||
padding-left: 0; | ||
} | ||
|
||
.lk-color-chooser__color { | ||
display: inline-block; | ||
width : 30px; | ||
height: 30px; | ||
border-radius: 50%; | ||
margin-right: 5px; | ||
cursor: pointer; | ||
opacity: 0.5; | ||
filter: alpha(opacity=50); | ||
} | ||
|
||
.lk-color-chooser__color:hover, .lk-color-chooser__color.selected { | ||
opacity: 1; | ||
filter: alpha(opacity=100); | ||
} | ||
|
||
.lk-color-chooser__color:last-child { | ||
margin-right: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* angular-color-chooser | ||
* | ||
* Allow you to pick a color from a custom palette | ||
* | ||
* (c) 2015 Loic Kartono | ||
* License: MIT | ||
*/ | ||
|
||
'use strict'; | ||
|
||
(function () { | ||
|
||
angular.module('lk-color-chooser', []) | ||
|
||
.provider('lkColorSettings', function () { | ||
this.colors = []; | ||
|
||
/** | ||
* @ngdoc function | ||
* @name lkColorSettings.$get | ||
* @module lk-color-chooser | ||
* @kind function | ||
* | ||
* @description Provider factory $get method. | ||
* @returns {object} Hash of attributes. | ||
*/ | ||
this.$get = function () { | ||
return { | ||
colors: this.colors | ||
} | ||
}; | ||
|
||
/** | ||
* @ngdoc function | ||
* @name lkColorSettings.configure | ||
* @module lk-color-chooser | ||
* @kind function | ||
* | ||
* @description Set the options. | ||
* @param {object} Hash of options. | ||
* @returns {void} Modify class attributes value. | ||
*/ | ||
this.configure = function (config) { | ||
var key; | ||
for (key in config) { | ||
this[key] = config[key]; | ||
} | ||
}; | ||
}) | ||
|
||
.directive('lkColorChooser', ['lkColorSettings', '$timeout', function (lkColorSettings, $timeout) { | ||
return { | ||
restrict: 'EA', | ||
template: '<ul class="lk-color-chooser"><lk-color ng-repeat="color in colors track by $index" color="color" ng-class="{\'selected\': selected == color}"></lk-color></ul>', | ||
replace: true, | ||
scope: { | ||
colors: '=?', | ||
selected: '=' | ||
}, | ||
controller: ['$scope', '$timeout', function lkColorChooserCtrl ($scope, $timeout) { | ||
this.setSelectedColor = function (color) { | ||
$timeout(function() { | ||
$scope.selected = color; | ||
}); | ||
} | ||
}], | ||
link: function (scope, element, attrs) { | ||
if (!scope.colors) { | ||
scope.colors = lkColorSettings.colors; | ||
} | ||
} | ||
} | ||
}]) | ||
|
||
.directive('lkColor', function () { | ||
return { | ||
restrict: 'EA', | ||
require: '^lkColorChooser', | ||
template: '<li class="lk-color-chooser__color" style="background-color: {{ color }}"> </li>', | ||
replace: true, | ||
scope: { | ||
color: '=' | ||
}, | ||
link: function (scope, element, attrs, lkColorChooserCtrl) { | ||
element.on('click', function () { | ||
lkColorChooserCtrl.setSelectedColor(scope.color); | ||
}) | ||
} | ||
} | ||
}); | ||
|
||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var gulp = require('gulp'); | ||
var uglify = require('gulp-uglify'); | ||
var rename = require('gulp-rename'); | ||
var minifyCSS = require('gulp-minify-css'); | ||
|
||
// Copy non-uglify version to "dist" | ||
gulp.task('copy', function() { | ||
return gulp.src(['src/*.js', 'src/*.css']).pipe(gulp.dest('dist')); | ||
}); | ||
|
||
// Create an uglify version to "dist" | ||
gulp.task('uglify', function() { | ||
return gulp.src('src/*.js').pipe(uglify()) | ||
.pipe(rename('color-chooser.min.js')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
|
||
// Minify css | ||
gulp.task('cssmin', function() { | ||
return gulp.src('src/*.css').pipe(minifyCSS()) | ||
.pipe(rename('color-chooser.min.css')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
|
||
gulp.task('watch', function() { | ||
gulp.watch('src/*.js', ['copy', 'uglify', 'cssmin']) | ||
}); | ||
|
||
gulp.task('default', function() { | ||
gulp.start('watch'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters