Skip to content

Commit d9d38dd

Browse files
authored
Adding less for bootstrap v3 (#5)
* Adding less for bootstrap v3
1 parent f322ef8 commit d9d38dd

File tree

11 files changed

+198
-307
lines changed

11 files changed

+198
-307
lines changed

Gruntfile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = function(grunt) {
22
const projectMap = require('./grunt/project-map.js');
33
const sassConfig = require('./grunt/sass');
4+
const lessConfig = require('./grunt/less');
45
const eslintConfig = require('./grunt/eslint');
56
const copyConfig = require('./grunt/copy');
67
const uglifyConfig = require('./grunt/uglify');
@@ -20,6 +21,7 @@ module.exports = function(grunt) {
2021
filename : 'bootstrap-tooltip-custom-class'
2122
},
2223
sass: sassConfig,
24+
less: lessConfig,
2325
eslint: eslintConfig,
2426
copy: copyConfig,
2527
uglify: uglifyConfig,
@@ -28,6 +30,7 @@ module.exports = function(grunt) {
2830
});
2931

3032
grunt.loadNpmTasks('grunt-sass');
33+
grunt.loadNpmTasks('grunt-contrib-less');
3134
grunt.loadNpmTasks('grunt-contrib-copy');
3235
grunt.loadNpmTasks('grunt-contrib-uglify');
3336
grunt.loadNpmTasks('grunt-contrib-clean');

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,18 @@ Include `bootstrap-tooltip-custom-class.css` in your project or use the `.scss`
3232
Use the mixin `tooltip-custom` to create styles for your custom tooltip:
3333
````sass
3434
.tooltip-custom {
35-
@include tooltip-custom(#f2653c);
35+
@include tooltip-custom(#f2653c, #fff);
36+
}
37+
````
38+
39+
#### Less (only for Bootstrap v3):
40+
```less
41+
@import "bootstrap-tooltip-custom-class.less";
42+
```
43+
Use the mixin `tooltip-custom`:
44+
````less
45+
.tooltip-custom {
46+
.tooltip-custom(#f2653c, #fff);
3647
}
3748
````
3849

bootstrap-v3/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import "variables.less";
2+
@import "mixin.less";
3+
@import "tooltips.less";

bootstrap-v3/src/less/main.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import "../../node_modules/bootstrap/less/variables.less";
2+
@import "bootstrap-tooltip-custom-class.less";

bootstrap-v3/src/less/mixin.less

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//== Tooltip Custom Mixin
2+
//
3+
//##
4+
5+
.tooltip-custom(@bg-color, @color) {
6+
7+
.tooltip-inner {
8+
background-color: @bg-color;
9+
color: @color;
10+
}
11+
12+
&.top .tooltip-arrow {
13+
border-top-color: @bg-color;
14+
}
15+
16+
&.right .tooltip-arrow {
17+
border-right-color: @bg-color;
18+
}
19+
20+
&.left .tooltip-arrow {
21+
border-left-color: @bg-color;
22+
}
23+
24+
&.bottom .tooltip-arrow {
25+
border-bottom-color: @bg-color;
26+
}
27+
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//== Styles for predefined Tooltip Custom Classes
2+
//
3+
//##
4+
5+
.tooltip-primary {
6+
.tooltip-custom(@tooltip-primary-bg, @tooltip-color);
7+
}
8+
9+
.tooltip-success {
10+
.tooltip-custom(@tooltip-success-bg, @tooltip-color);
11+
}
12+
13+
.tooltip-info {
14+
.tooltip-custom(@tooltip-info-bg, @tooltip-color);
15+
}
16+
17+
.tooltip-warning {
18+
.tooltip-custom(@tooltip-warning-bg, @tooltip-color);
19+
}
20+
21+
.tooltip-danger {
22+
.tooltip-custom(@tooltip-danger-bg, @tooltip-color);
23+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//== Define Bootstrap variables for Tooltips
2+
//
3+
//##
4+
5+
//
6+
// Tooltip primary background color
7+
@tooltip-primary-bg: @brand-primary;
8+
// Tooltip success background color
9+
@tooltip-success-bg: @brand-success;
10+
// Tooltip info background color
11+
@tooltip-info-bg: @brand-info;
12+
// Tooltip warning background color
13+
@tooltip-warning-bg: @brand-warning;
14+
// Tooltip danger background color
15+
@tooltip-danger-bg: @brand-danger;

grunt/less.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
let config = {
2+
v3: {
3+
files: {
4+
'bootstrap-v3/dist/css/<%= meta.filename %>.less.css': 'bootstrap-v3/src/less/main.less'
5+
}
6+
}
7+
};
8+
9+
module.exports = config;

0 commit comments

Comments
 (0)