Skip to content

Commit ab427cd

Browse files
author
Loic Kartono
committed
Implement gulp to create dist version
1 parent dc73759 commit ab427cd

File tree

6 files changed

+152
-1
lines changed

6 files changed

+152
-1
lines changed

dist/color-chooser.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.lk-color-chooser {
2+
list-style-type: none;
3+
padding-left: 0;
4+
}
5+
6+
.lk-color-chooser__color {
7+
display: inline-block;
8+
width : 30px;
9+
height: 30px;
10+
border-radius: 50%;
11+
margin-right: 5px;
12+
cursor: pointer;
13+
opacity: 0.5;
14+
filter: alpha(opacity=50);
15+
}
16+
17+
.lk-color-chooser__color:hover, .lk-color-chooser__color.selected {
18+
opacity: 1;
19+
filter: alpha(opacity=100);
20+
}
21+
22+
.lk-color-chooser__color:last-child {
23+
margin-right: 0;
24+
}

dist/color-chooser.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* angular-color-chooser
3+
*
4+
* Allow you to pick a color from a custom palette
5+
*
6+
* (c) 2015 Loic Kartono
7+
* License: MIT
8+
*/
9+
10+
'use strict';
11+
12+
(function () {
13+
14+
angular.module('lk-color-chooser', [])
15+
16+
.provider('lkColorSettings', function () {
17+
this.colors = [];
18+
19+
/**
20+
* @ngdoc function
21+
* @name lkColorSettings.$get
22+
* @module lk-color-chooser
23+
* @kind function
24+
*
25+
* @description Provider factory $get method.
26+
* @returns {object} Hash of attributes.
27+
*/
28+
this.$get = function () {
29+
return {
30+
colors: this.colors
31+
}
32+
};
33+
34+
/**
35+
* @ngdoc function
36+
* @name lkColorSettings.configure
37+
* @module lk-color-chooser
38+
* @kind function
39+
*
40+
* @description Set the options.
41+
* @param {object} Hash of options.
42+
* @returns {void} Modify class attributes value.
43+
*/
44+
this.configure = function (config) {
45+
var key;
46+
for (key in config) {
47+
this[key] = config[key];
48+
}
49+
};
50+
})
51+
52+
.directive('lkColorChooser', ['lkColorSettings', '$timeout', function (lkColorSettings, $timeout) {
53+
return {
54+
restrict: 'EA',
55+
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>',
56+
replace: true,
57+
scope: {
58+
colors: '=?',
59+
selected: '='
60+
},
61+
controller: ['$scope', '$timeout', function lkColorChooserCtrl ($scope, $timeout) {
62+
this.setSelectedColor = function (color) {
63+
$timeout(function() {
64+
$scope.selected = color;
65+
});
66+
}
67+
}],
68+
link: function (scope, element, attrs) {
69+
if (!scope.colors) {
70+
scope.colors = lkColorSettings.colors;
71+
}
72+
}
73+
}
74+
}])
75+
76+
.directive('lkColor', function () {
77+
return {
78+
restrict: 'EA',
79+
require: '^lkColorChooser',
80+
template: '<li class="lk-color-chooser__color" style="background-color: {{ color }}">&nbsp;</li>',
81+
replace: true,
82+
scope: {
83+
color: '='
84+
},
85+
link: function (scope, element, attrs, lkColorChooserCtrl) {
86+
element.on('click', function () {
87+
lkColorChooserCtrl.setSelectedColor(scope.color);
88+
})
89+
}
90+
}
91+
});
92+
93+
})();

dist/color-chooser.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/color-chooser.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var gulp = require('gulp');
2+
var uglify = require('gulp-uglify');
3+
var rename = require('gulp-rename');
4+
var minifyCSS = require('gulp-minify-css');
5+
6+
// Copy non-uglify version to "dist"
7+
gulp.task('copy', function() {
8+
return gulp.src(['src/*.js', 'src/*.css']).pipe(gulp.dest('dist'));
9+
});
10+
11+
// Create an uglify version to "dist"
12+
gulp.task('uglify', function() {
13+
return gulp.src('src/*.js').pipe(uglify())
14+
.pipe(rename('color-chooser.min.js'))
15+
.pipe(gulp.dest('dist'));
16+
});
17+
18+
// Minify css
19+
gulp.task('cssmin', function() {
20+
return gulp.src('src/*.css').pipe(minifyCSS())
21+
.pipe(rename('color-chooser.min.css'))
22+
.pipe(gulp.dest('dist'));
23+
});
24+
25+
gulp.task('watch', function() {
26+
gulp.watch('src/*.js', ['copy', 'uglify', 'cssmin'])
27+
});
28+
29+
gulp.task('default', function() {
30+
gulp.start('watch');
31+
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"jasmine-core": "^2.1.3",
1111
"karma": "^0.12.31",
1212
"karma-jasmine": "^0.3.5",
13-
"karma-phantomjs-launcher": "^0.1.4"
13+
"karma-phantomjs-launcher": "^0.1.4",
14+
"gulp-minify-css": "^0.4.3"
1415
}
1516
}

0 commit comments

Comments
 (0)