bootstrap-sass 3.2.0.4 → 3.3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bootstrap-sass might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.gitignore +2 -1
- data/.travis.yml +8 -2
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +29 -6
- data/Rakefile +3 -4
- data/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +1 -1
- data/assets/javascripts/bootstrap.js +329 -176
- data/assets/javascripts/bootstrap/affix.js +43 -23
- data/assets/javascripts/bootstrap/alert.js +6 -4
- data/assets/javascripts/bootstrap/button.js +16 -10
- data/assets/javascripts/bootstrap/carousel.js +26 -10
- data/assets/javascripts/bootstrap/collapse.js +69 -28
- data/assets/javascripts/bootstrap/dropdown.js +20 -10
- data/assets/javascripts/bootstrap/modal.js +22 -21
- data/assets/javascripts/bootstrap/popover.js +13 -7
- data/assets/javascripts/bootstrap/scrollspy.js +12 -7
- data/assets/javascripts/bootstrap/tab.js +41 -16
- data/assets/javascripts/bootstrap/tooltip.js +60 -39
- data/assets/javascripts/bootstrap/transition.js +1 -1
- data/assets/stylesheets/bootstrap/_button-groups.scss +18 -11
- data/assets/stylesheets/bootstrap/_buttons.scss +8 -5
- data/assets/stylesheets/bootstrap/_carousel.scss +25 -1
- data/assets/stylesheets/bootstrap/_code.scss +1 -0
- data/assets/stylesheets/bootstrap/_component-animations.scss +5 -2
- data/assets/stylesheets/bootstrap/_dropdowns.scss +4 -6
- data/assets/stylesheets/bootstrap/_forms.scss +51 -28
- data/assets/stylesheets/bootstrap/_glyphicons.scss +2 -5
- data/assets/stylesheets/bootstrap/_grid.scss +4 -4
- data/assets/stylesheets/bootstrap/_jumbotron.scss +4 -4
- data/assets/stylesheets/bootstrap/_list-group.scss +1 -0
- data/assets/stylesheets/bootstrap/_media.scss +27 -36
- data/assets/stylesheets/bootstrap/_modals.scss +3 -4
- data/assets/stylesheets/bootstrap/_navbar.scss +35 -33
- data/assets/stylesheets/bootstrap/_navs.scss +5 -3
- data/assets/stylesheets/bootstrap/_normalize.scss +5 -3
- data/assets/stylesheets/bootstrap/_pager.scss +2 -3
- data/assets/stylesheets/bootstrap/_pagination.scss +1 -1
- data/assets/stylesheets/bootstrap/_panels.scss +22 -4
- data/assets/stylesheets/bootstrap/_popovers.scss +5 -4
- data/assets/stylesheets/bootstrap/_print.scss +102 -96
- data/assets/stylesheets/bootstrap/_progress-bars.scss +2 -20
- data/assets/stylesheets/bootstrap/_responsive-embed.scss +2 -1
- data/assets/stylesheets/bootstrap/_scaffolding.scss +3 -3
- data/assets/stylesheets/bootstrap/_tables.scss +11 -10
- data/assets/stylesheets/bootstrap/_theme.scss +16 -14
- data/assets/stylesheets/bootstrap/_thumbnails.scss +2 -2
- data/assets/stylesheets/bootstrap/_type.scss +10 -16
- data/assets/stylesheets/bootstrap/_utilities.scss +3 -4
- data/assets/stylesheets/bootstrap/_variables.scss +29 -19
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +5 -1
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +2 -2
- data/assets/stylesheets/bootstrap/mixins/_hide-text.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_image.scss +0 -1
- data/assets/stylesheets/bootstrap/mixins/_labels.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_progress-bar.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_vendor-prefixes.scss +6 -3
- data/lib/bootstrap-sass.rb +2 -5
- data/lib/bootstrap-sass/engine.rb +1 -1
- data/lib/bootstrap-sass/version.rb +2 -2
- data/package.json +3 -3
- data/tasks/converter/less_conversion.rb +60 -28
- data/tasks/converter/network.rb +12 -6
- data/templates/project/_bootstrap-variables.sass +866 -0
- data/templates/project/manifest.rb +5 -11
- data/test/node_sass_compile_test.sh +8 -0
- metadata +7 -28
- data/templates/project/_bootstrap-variables.sass.erb +0 -4
- data/test/dummy_rails/bin/bundle +0 -3
- data/test/dummy_rails/bin/rails +0 -4
- data/test/dummy_rails/bin/rake +0 -4
- data/test/dummy_rails/db/test.sqlite3 +0 -0
- data/test/dummy_rails/lib/assets/.keep +0 -0
- data/test/dummy_rails/public/404.html +0 -58
- data/test/dummy_rails/public/422.html +0 -58
- data/test/dummy_rails/public/500.html +0 -57
- data/test/dummy_rails/public/favicon.ico +0 -0
- data/test/node_sass_test.rb +0 -16
- data/test/support/integration_test.rb +0 -22
@@ -12,11 +12,11 @@
|
|
12
12
|
background-color: $thumbnail-bg;
|
13
13
|
border: 1px solid $thumbnail-border;
|
14
14
|
border-radius: $thumbnail-border-radius;
|
15
|
-
@include transition(
|
15
|
+
@include transition(border .2s ease-in-out);
|
16
16
|
|
17
17
|
> img,
|
18
18
|
a > img {
|
19
|
-
@include img-responsive
|
19
|
+
@include img-responsive;
|
20
20
|
margin-left: auto;
|
21
21
|
margin-right: auto;
|
22
22
|
}
|
@@ -80,11 +80,6 @@ small,
|
|
80
80
|
font-size: floor((100% * $font-size-small / $font-size-base));
|
81
81
|
}
|
82
82
|
|
83
|
-
// Undo browser default styling
|
84
|
-
cite {
|
85
|
-
font-style: normal;
|
86
|
-
}
|
87
|
-
|
88
83
|
mark,
|
89
84
|
.mark {
|
90
85
|
background-color: $state-warning-bg;
|
@@ -163,15 +158,20 @@ ol {
|
|
163
158
|
|
164
159
|
// List options
|
165
160
|
|
166
|
-
//
|
167
|
-
|
161
|
+
// [converter] extracted from `.list-unstyled` for libsass compatibility
|
162
|
+
@mixin list-unstyled {
|
168
163
|
padding-left: 0;
|
169
164
|
list-style: none;
|
170
165
|
}
|
166
|
+
// [converter] extracted as `@mixin list-unstyled` for libsass compatibility
|
167
|
+
.list-unstyled {
|
168
|
+
@include list-unstyled;
|
169
|
+
}
|
170
|
+
|
171
171
|
|
172
172
|
// Inline turns list items into inline-block
|
173
173
|
.list-inline {
|
174
|
-
@
|
174
|
+
@include list-unstyled;
|
175
175
|
margin-left: -5px;
|
176
176
|
|
177
177
|
> li {
|
@@ -204,7 +204,7 @@ dd {
|
|
204
204
|
|
205
205
|
.dl-horizontal {
|
206
206
|
dd {
|
207
|
-
@include clearfix
|
207
|
+
@include clearfix; // Clear the floated `dt` if an empty `dd` is present
|
208
208
|
}
|
209
209
|
|
210
210
|
@media (min-width: $grid-float-breakpoint) {
|
@@ -213,7 +213,7 @@ dd {
|
|
213
213
|
width: ($dl-horizontal-offset - 20);
|
214
214
|
clear: left;
|
215
215
|
text-align: right;
|
216
|
-
@include text-overflow
|
216
|
+
@include text-overflow;
|
217
217
|
}
|
218
218
|
dd {
|
219
219
|
margin-left: $dl-horizontal-offset;
|
@@ -290,12 +290,6 @@ blockquote.pull-right {
|
|
290
290
|
}
|
291
291
|
}
|
292
292
|
|
293
|
-
// Quotes
|
294
|
-
blockquote:before,
|
295
|
-
blockquote:after {
|
296
|
-
content: "";
|
297
|
-
}
|
298
|
-
|
299
293
|
// Addresses
|
300
294
|
address {
|
301
295
|
margin-bottom: $line-height-computed;
|
@@ -7,10 +7,10 @@
|
|
7
7
|
// -------------------------
|
8
8
|
|
9
9
|
.clearfix {
|
10
|
-
@include clearfix
|
10
|
+
@include clearfix;
|
11
11
|
}
|
12
12
|
.center-block {
|
13
|
-
@include center-block
|
13
|
+
@include center-block;
|
14
14
|
}
|
15
15
|
.pull-right {
|
16
16
|
float: right !important;
|
@@ -34,7 +34,7 @@
|
|
34
34
|
visibility: hidden;
|
35
35
|
}
|
36
36
|
.text-hide {
|
37
|
-
@include text-hide
|
37
|
+
@include text-hide;
|
38
38
|
}
|
39
39
|
|
40
40
|
|
@@ -53,5 +53,4 @@
|
|
53
53
|
|
54
54
|
.affix {
|
55
55
|
position: fixed;
|
56
|
-
@include translate3d(0, 0, 0);
|
57
56
|
}
|
@@ -12,11 +12,12 @@ $bootstrap-sass-asset-helper: (twbs-font-path("") != unquote('twbs-font-path("")
|
|
12
12
|
//
|
13
13
|
//## Gray and brand colors for use across Bootstrap.
|
14
14
|
|
15
|
-
$gray-
|
16
|
-
$gray-
|
17
|
-
$gray:
|
18
|
-
$gray
|
19
|
-
$gray-
|
15
|
+
$gray-base: #000 !default;
|
16
|
+
$gray-darker: lighten($gray-base, 13.5%) !default; // #222
|
17
|
+
$gray-dark: lighten($gray-base, 20%) !default; // #333
|
18
|
+
$gray: lighten($gray-base, 33.5%) !default; // #555
|
19
|
+
$gray-light: lighten($gray-base, 46.7%) !default; // #777
|
20
|
+
$gray-lighter: lighten($gray-base, 93.5%) !default; // #eee
|
20
21
|
|
21
22
|
$brand-primary: #428bca !default;
|
22
23
|
$brand-success: #5cb85c !default;
|
@@ -38,6 +39,8 @@ $text-color: $gray-dark !default;
|
|
38
39
|
$link-color: $brand-primary !default;
|
39
40
|
//** Link hover color set via `darken()` function.
|
40
41
|
$link-hover-color: darken($link-color, 15%) !default;
|
42
|
+
//** Link hover decoration.
|
43
|
+
$link-hover-decoration: underline !default;
|
41
44
|
|
42
45
|
|
43
46
|
//== Typography
|
@@ -189,13 +192,20 @@ $input-bg-disabled: $gray-lighter !default;
|
|
189
192
|
$input-color: $gray !default;
|
190
193
|
//** `<input>` border color
|
191
194
|
$input-border: #ccc !default;
|
192
|
-
|
195
|
+
|
196
|
+
// TODO: Rename `$input-border-radius` to `$input-border-radius-base` in v4
|
197
|
+
//** Default `.form-control` border radius
|
193
198
|
$input-border-radius: $border-radius-base !default;
|
199
|
+
//** Large `.form-control` border radius
|
200
|
+
$input-border-radius-large: $border-radius-large !default;
|
201
|
+
//** Small `.form-control` border radius
|
202
|
+
$input-border-radius-small: $border-radius-small !default;
|
203
|
+
|
194
204
|
//** Border color for inputs on focus
|
195
205
|
$input-border-focus: #66afe9 !default;
|
196
206
|
|
197
207
|
//** Placeholder text color
|
198
|
-
$input-color-placeholder:
|
208
|
+
$input-color-placeholder: #999 !default;
|
199
209
|
|
200
210
|
//** Default `.form-control` height
|
201
211
|
$input-height-base: ($line-height-computed + ($padding-base-vertical * 2) + 2) !default;
|
@@ -212,6 +222,9 @@ $input-group-addon-bg: $gray-lighter !default;
|
|
212
222
|
//** Border color for textual input addons
|
213
223
|
$input-group-addon-border-color: $input-border !default;
|
214
224
|
|
225
|
+
//** Disabled cursor for form controls and buttons.
|
226
|
+
$cursor-disabled: not-allowed !default;
|
227
|
+
|
215
228
|
|
216
229
|
//== Dropdowns
|
217
230
|
//
|
@@ -260,8 +273,7 @@ $zindex-dropdown: 1000 !default;
|
|
260
273
|
$zindex-popover: 1060 !default;
|
261
274
|
$zindex-tooltip: 1070 !default;
|
262
275
|
$zindex-navbar-fixed: 1030 !default;
|
263
|
-
$zindex-modal
|
264
|
-
$zindex-modal: 1050 !default;
|
276
|
+
$zindex-modal: 1040 !default;
|
265
277
|
|
266
278
|
|
267
279
|
//== Media queries breakpoints
|
@@ -323,17 +335,17 @@ $grid-float-breakpoint-max: ($grid-float-breakpoint - 1) !default;
|
|
323
335
|
//## Define the maximum width of `.container` for different screen sizes.
|
324
336
|
|
325
337
|
// Small screen / tablet
|
326
|
-
$container-tablet: (
|
338
|
+
$container-tablet: (720px + $grid-gutter-width) !default;
|
327
339
|
//** For `$screen-sm-min` and up.
|
328
340
|
$container-sm: $container-tablet !default;
|
329
341
|
|
330
342
|
// Medium screen / desktop
|
331
|
-
$container-desktop: (
|
343
|
+
$container-desktop: (940px + $grid-gutter-width) !default;
|
332
344
|
//** For `$screen-md-min` and up.
|
333
345
|
$container-md: $container-desktop !default;
|
334
346
|
|
335
347
|
// Large screen / wide desktop
|
336
|
-
$container-large-desktop: (
|
348
|
+
$container-large-desktop: (1140px + $grid-gutter-width) !default;
|
337
349
|
//** For `$screen-lg-min` and up.
|
338
350
|
$container-lg: $container-large-desktop !default;
|
339
351
|
|
@@ -376,12 +388,12 @@ $navbar-default-toggle-border-color: #ddd !default;
|
|
376
388
|
|
377
389
|
// Inverted navbar
|
378
390
|
// Reset inverted navbar basics
|
379
|
-
$navbar-inverse-color: $gray-light !default;
|
391
|
+
$navbar-inverse-color: lighten($gray-light, 15%) !default;
|
380
392
|
$navbar-inverse-bg: #222 !default;
|
381
393
|
$navbar-inverse-border: darken($navbar-inverse-bg, 10%) !default;
|
382
394
|
|
383
395
|
// Inverted navbar links
|
384
|
-
$navbar-inverse-link-color: $gray-light !default;
|
396
|
+
$navbar-inverse-link-color: lighten($gray-light, 15%) !default;
|
385
397
|
$navbar-inverse-link-hover-color: #fff !default;
|
386
398
|
$navbar-inverse-link-hover-bg: transparent !default;
|
387
399
|
$navbar-inverse-link-active-color: $navbar-inverse-link-hover-color !default;
|
@@ -411,8 +423,6 @@ $nav-link-hover-bg: $gray-lighter !default;
|
|
411
423
|
$nav-disabled-link-color: $gray-light !default;
|
412
424
|
$nav-disabled-link-hover-color: $gray-light !default;
|
413
425
|
|
414
|
-
$nav-open-link-hover-color: #fff !default;
|
415
|
-
|
416
426
|
//== Tabs
|
417
427
|
$nav-tabs-border-color: #ddd !default;
|
418
428
|
|
@@ -537,7 +547,7 @@ $popover-title-bg: darken($popover-bg, 3%) !default;
|
|
537
547
|
//** Popover arrow width
|
538
548
|
$popover-arrow-width: 10px !default;
|
539
549
|
//** Popover arrow color
|
540
|
-
$popover-arrow-color:
|
550
|
+
$popover-arrow-color: $popover-bg !default;
|
541
551
|
|
542
552
|
//** Popover outer arrow width
|
543
553
|
$popover-arrow-outer-width: ($popover-arrow-width + 1) !default;
|
@@ -636,6 +646,8 @@ $alert-danger-border: $state-danger-border !default;
|
|
636
646
|
$progress-bg: #f5f5f5 !default;
|
637
647
|
//** Progress bar text color
|
638
648
|
$progress-bar-color: #fff !default;
|
649
|
+
//** Variable for setting rounded corners on progress bar.
|
650
|
+
$progress-border-radius: $border-radius-base !default;
|
639
651
|
|
640
652
|
//** Default progress bar color
|
641
653
|
$progress-bar-bg: $brand-primary !default;
|
@@ -850,5 +862,3 @@ $page-header-border-color: $gray-lighter !default;
|
|
850
862
|
$dl-horizontal-offset: $component-offset-horizontal !default;
|
851
863
|
//** Horizontal line color.
|
852
864
|
$hr-border: $gray-lighter !default;
|
853
|
-
|
854
|
-
|
@@ -10,7 +10,11 @@
|
|
10
10
|
.radio,
|
11
11
|
.checkbox,
|
12
12
|
.radio-inline,
|
13
|
-
.checkbox-inline
|
13
|
+
.checkbox-inline,
|
14
|
+
&.radio label,
|
15
|
+
&.checkbox label,
|
16
|
+
&.radio-inline label,
|
17
|
+
&.checkbox-inline label {
|
14
18
|
color: $text-color;
|
15
19
|
}
|
16
20
|
// Set the border and box shadow on specific inputs to match
|
@@ -8,14 +8,14 @@
|
|
8
8
|
margin-left: auto;
|
9
9
|
padding-left: ($gutter / 2);
|
10
10
|
padding-right: ($gutter / 2);
|
11
|
-
@include clearfix
|
11
|
+
@include clearfix;
|
12
12
|
}
|
13
13
|
|
14
14
|
// Creates a wrapper for a series of columns
|
15
15
|
@mixin make-row($gutter: $grid-gutter-width) {
|
16
16
|
margin-left: ($gutter / -2);
|
17
17
|
margin-right: ($gutter / -2);
|
18
|
-
@include clearfix
|
18
|
+
@include clearfix;
|
19
19
|
}
|
20
20
|
|
21
21
|
// Generate the extra small columns
|
@@ -8,7 +8,6 @@
|
|
8
8
|
// Keep images from scaling beyond the width of their parents.
|
9
9
|
@mixin img-responsive($display: block) {
|
10
10
|
display: $display;
|
11
|
-
width: 100% \9; // Force IE10 and below to size SVG images correctly
|
12
11
|
max-width: 100%; // Part 1: Set a maximum relative to the parent
|
13
12
|
height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching
|
14
13
|
}
|
@@ -99,9 +99,12 @@
|
|
99
99
|
|
100
100
|
// Placeholder text
|
101
101
|
@mixin placeholder($color: $input-color-placeholder) {
|
102
|
-
|
103
|
-
|
104
|
-
|
102
|
+
// Firefox
|
103
|
+
&::-moz-placeholder {
|
104
|
+
color: $color;
|
105
|
+
opacity: 1; // See https://github.com/twbs/bootstrap/pull/11526
|
106
|
+
}
|
107
|
+
&:-ms-input-placeholder { color: $color; } // Internet Explorer 10+
|
105
108
|
&::-webkit-input-placeholder { color: $color; } // Safari and Chrome
|
106
109
|
}
|
107
110
|
|
data/lib/bootstrap-sass.rb
CHANGED
@@ -3,11 +3,7 @@ module Bootstrap
|
|
3
3
|
# Inspired by Kaminari
|
4
4
|
def load!
|
5
5
|
register_compass_extension if compass?
|
6
|
-
|
7
|
-
if rails?
|
8
|
-
register_rails_engine
|
9
|
-
end
|
10
|
-
|
6
|
+
register_rails_engine if rails?
|
11
7
|
configure_sass
|
12
8
|
end
|
13
9
|
|
@@ -59,6 +55,7 @@ module Bootstrap
|
|
59
55
|
def register_compass_extension
|
60
56
|
::Compass::Frameworks.register(
|
61
57
|
'bootstrap',
|
58
|
+
:version => Bootstrap::VERSION,
|
62
59
|
:path => gem_path,
|
63
60
|
:stylesheets_directory => stylesheets_path,
|
64
61
|
:templates_directory => File.join(gem_path, 'templates')
|
@@ -3,7 +3,7 @@ module Bootstrap
|
|
3
3
|
class Engine < ::Rails::Engine
|
4
4
|
initializer 'bootstrap-sass.assets.precompile' do |app|
|
5
5
|
%w(stylesheets javascripts fonts images).each do |sub|
|
6
|
-
app.config.assets.paths << root.join('assets', sub)
|
6
|
+
app.config.assets.paths << root.join('assets', sub).to_s
|
7
7
|
end
|
8
8
|
app.config.assets.precompile << %r(bootstrap/glyphicons-halflings-regular\.(?:eot|svg|ttf|woff)$)
|
9
9
|
end
|
data/package.json
CHANGED
@@ -22,7 +22,7 @@ class Converter
|
|
22
22
|
# match any brace that opens or closes a properties body
|
23
23
|
BRACE_RE = /#{RULE_OPEN_BRACE_RE}|#{RULE_CLOSE_BRACE_RE}/m
|
24
24
|
BRACE_RE_REVERSE = /#{RULE_OPEN_BRACE_RE_REVERSE}|#{RULE_CLOSE_BRACE_RE_REVERSE}/m
|
25
|
-
# valid
|
25
|
+
# valid characters in mixin definitions
|
26
26
|
SCSS_MIXIN_DEF_ARGS_RE = /[\w\-,\s$:#%()]*/
|
27
27
|
LESS_MIXIN_DEF_ARGS_RE = /[\w\-,;.\s@:#%()]*/
|
28
28
|
|
@@ -31,27 +31,34 @@ class Converter
|
|
31
31
|
|
32
32
|
# These mixins will get vararg definitions in SCSS (not supported by LESS):
|
33
33
|
VARARG_MIXINS = %w(
|
34
|
-
|
35
|
-
|
34
|
+
scale transition transition-duration transition-property transition-transform box-shadow
|
35
|
+
)
|
36
|
+
|
37
|
+
# A list of classes that will be extracted into mixins
|
38
|
+
# Only the top-level selectors of form .CLASS { ... } are extracted. CLASS must not be used in any other rule definition.
|
39
|
+
# This is a work-around for libsass @extend issues
|
40
|
+
CLASSES_TO_MIXINS = %w(
|
41
|
+
list-unstyled form-inline
|
42
|
+
)
|
36
43
|
|
37
44
|
# Convert a snippet of bootstrap LESS to Scss
|
38
45
|
def convert_less(less)
|
39
|
-
load_shared
|
40
46
|
less = convert_to_scss(less)
|
41
47
|
less = yield(less) if block_given?
|
42
48
|
less
|
43
49
|
end
|
44
50
|
|
45
|
-
def
|
51
|
+
def shared_mixins
|
46
52
|
@shared_mixins ||= begin
|
47
53
|
log_status ' Reading shared mixins from mixins.less'
|
48
|
-
read_mixins
|
54
|
+
CLASSES_TO_MIXINS + read_mixins(read_files('less', bootstrap_less_files.grep(/mixins\//)).values.join("\n"),
|
55
|
+
nested: NESTED_MIXINS)
|
49
56
|
end
|
50
57
|
end
|
51
58
|
|
52
59
|
def process_stylesheet_assets
|
53
60
|
log_status 'Processing stylesheets...'
|
54
|
-
files
|
61
|
+
files = read_files('less', bootstrap_less_files)
|
55
62
|
save_to = @save_to[:scss]
|
56
63
|
|
57
64
|
log_status ' Converting LESS files to Scss:'
|
@@ -94,7 +101,7 @@ class Converter
|
|
94
101
|
// NB: in Sass 3.3 there is a native function: function-exists(twbs-font-path)
|
95
102
|
$bootstrap-sass-asset-helper: #{sass_fn_exists('twbs-font-path')} !default;
|
96
103
|
SCSS
|
97
|
-
file = replace_all file, %r{(\$icon-font-path): \s*"(.*)" (!default);},
|
104
|
+
file = replace_all file, %r{(\$icon-font-path): \s*"(.*)" (!default);}, "\n" + unindent(<<-SCSS, 14)
|
98
105
|
// [converter] Asset helpers such as Sprockets and Node.js Mincer do not resolve relative paths
|
99
106
|
\\1: if($bootstrap-sass-asset-helper, "bootstrap/", "\\2bootstrap/") \\3;
|
100
107
|
SCSS
|
@@ -114,7 +121,6 @@ class Converter
|
|
114
121
|
when 'thumbnails.less', 'labels.less', 'badges.less'
|
115
122
|
file = extract_nested_rule file, 'a&'
|
116
123
|
when 'glyphicons.less'
|
117
|
-
file = bootstrap_font_files.map { |p| %Q(//= depend_on "bootstrap/#{File.basename(p)}") } * "\n" + "\n" + file
|
118
124
|
file = replace_rules(file, '@font-face') { |rule|
|
119
125
|
rule = replace_all rule, /(\$icon-font(?:-\w+)+)/, '#{\1}'
|
120
126
|
replace_asset_url rule, :font
|
@@ -136,6 +142,11 @@ class Converter
|
|
136
142
|
main_to = File.expand_path("#{save_to}/../_bootstrap.scss")
|
137
143
|
save_file main_to, File.read(main_from).gsub(/ "/, ' "bootstrap/')
|
138
144
|
File.delete(main_from)
|
145
|
+
|
146
|
+
# generate variables template
|
147
|
+
save_file 'templates/project/_bootstrap-variables.sass',
|
148
|
+
"// Override Bootstrap variables here (defaults from bootstrap-sass v<%= Bootstrap::VERSION %>):\n\n" +
|
149
|
+
File.read("#{save_to}/_variables.scss").gsub(/^(?=\$)/, '// ').gsub(/ !default;/, '')
|
139
150
|
end
|
140
151
|
|
141
152
|
def bootstrap_less_files
|
@@ -147,10 +158,11 @@ class Converter
|
|
147
158
|
# apply general less to scss conversion
|
148
159
|
def convert_to_scss(file)
|
149
160
|
# get local mixin names before converting the definitions
|
150
|
-
mixins =
|
161
|
+
mixins = shared_mixins + read_mixins(file)
|
151
162
|
file = replace_vars(file)
|
152
163
|
file = replace_mixin_definitions(file)
|
153
164
|
file = replace_mixins(file, mixins)
|
165
|
+
file = extract_mixins_from_selectors(file, CLASSES_TO_MIXINS.inject({}) { |h, cl| h.update(".#{cl}" => cl) })
|
154
166
|
file = replace_spin(file)
|
155
167
|
file = replace_fadein(file)
|
156
168
|
file = replace_image_urls(file)
|
@@ -371,7 +383,7 @@ SASS
|
|
371
383
|
sel = parent_sel + sel[1..-1]
|
372
384
|
end
|
373
385
|
# unwrap, and replace @include
|
374
|
-
unindent unwrap_rule_block(rule).gsub(/(@include [\w-]+)\(([\$\w\-,\s]*)\)
|
386
|
+
unindent unwrap_rule_block(rule).gsub(/(@include [\w-]+)\(?([\$\w\-,\s]*)\)?/) {
|
375
387
|
args = $2
|
376
388
|
"#{cmt}#{$1}('#{sel.gsub(/\s+/, ' ')}'#{', ' if args && !args.empty?}#{args})"
|
377
389
|
}
|
@@ -388,6 +400,25 @@ SASS
|
|
388
400
|
end
|
389
401
|
end
|
390
402
|
|
403
|
+
# .btn { ... } -> @mixin btn { ... }; .btn { @include btn }
|
404
|
+
def extract_mixins_from_selectors(file, selectors_to_mixins)
|
405
|
+
selectors_to_mixins.each do |selector, mixin|
|
406
|
+
file = replace_rules file, Regexp.escape(selector), prefix: false do |selector_css|
|
407
|
+
log_transform "#{selector} { ... } -> @mixin #{mixin} { ... }; #{selector} { @include #{mixin} } ", from: 'extract_mixins_from_selectors'
|
408
|
+
<<-SCSS
|
409
|
+
// [converter] extracted from `#{selector}` for libsass compatibility
|
410
|
+
@mixin #{mixin} {#{unwrap_rule_block(selector_css)}
|
411
|
+
}
|
412
|
+
// [converter] extracted as `@mixin #{mixin}` for libsass compatibility
|
413
|
+
#{selector} {
|
414
|
+
@include #{mixin};
|
415
|
+
}
|
416
|
+
SCSS
|
417
|
+
end
|
418
|
+
end
|
419
|
+
file
|
420
|
+
end
|
421
|
+
|
391
422
|
# @include and @extend from LESS:
|
392
423
|
# .mixin() -> @include mixin()
|
393
424
|
# #scope > .mixin() -> @include scope-mixin()
|
@@ -396,14 +427,11 @@ SASS
|
|
396
427
|
mixin_pattern = /(\s+)(([#|\.][\w-]+\s*>\s*)*)\.([\w-]+\(.*\))(?!\s\{)/
|
397
428
|
|
398
429
|
less = less.gsub(mixin_pattern) do |match|
|
399
|
-
matches
|
400
|
-
scope
|
401
|
-
if scope != ''
|
402
|
-
scope = scope.scan(/[\w-]+/).join('-') + '-'
|
403
|
-
end
|
430
|
+
matches = match.scan(mixin_pattern).flatten
|
431
|
+
scope = matches[1] && matches[1] != '' ? matches[1].scan(/[\w-]+/).join('-') + '-' : ''
|
404
432
|
mixin_name = match.scan(/\.([\w-]+)\(.*\)\s?\{?/).first
|
405
433
|
if mixin_name && mixin_names.include?("#{scope}#{mixin_name.first}")
|
406
|
-
"#{matches.first}@include #{scope}#{matches.last
|
434
|
+
"#{matches.first}@include #{scope}#{matches.last.gsub(/;\s*\$/, ', $').sub(/;\)$/, ')').sub(/\(\)$/, '')}"
|
407
435
|
else
|
408
436
|
"#{matches.first}@extend .#{scope}#{matches.last.gsub(/\(\)/, '')}"
|
409
437
|
end
|
@@ -414,7 +442,7 @@ SASS
|
|
414
442
|
selector =~ /\.([\w-]+)/
|
415
443
|
mixin = $1
|
416
444
|
if mixin && mixin_names.include?(mixin)
|
417
|
-
"@include #{mixin}
|
445
|
+
"@include #{mixin}"
|
418
446
|
else
|
419
447
|
"@extend #{selector}"
|
420
448
|
end
|
@@ -548,16 +576,20 @@ SASS
|
|
548
576
|
# option :comments -- include immediately preceding comments in rule_block
|
549
577
|
#
|
550
578
|
# replace_rules(".a{ \n .b{} }", '.b') { |rule, pos| ">#{rule}<" } #=> ".a{ \n >.b{}< }"
|
551
|
-
def replace_rules(less,
|
552
|
-
options
|
553
|
-
less
|
554
|
-
s
|
555
|
-
rule_re
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
579
|
+
def replace_rules(less, selector = SELECTOR_RE, options = {}, &block)
|
580
|
+
options = {prefix: true, comments: true}.merge(options || {})
|
581
|
+
less = less.dup
|
582
|
+
s = CharStringScanner.new(less)
|
583
|
+
rule_re = if options[:prefix]
|
584
|
+
/(?:#{selector}[#{SELECTOR_CHAR})=(\s]*?#{RULE_OPEN_BRACE_RE})/
|
585
|
+
else
|
586
|
+
/#{selector}[\s]*#{RULE_OPEN_BRACE_RE}/
|
587
|
+
end
|
588
|
+
rule_start_re = if options[:comments]
|
589
|
+
/(?:#{COMMENT_RE}*)^#{rule_re}/
|
590
|
+
else
|
591
|
+
/^#{rule_re}/
|
592
|
+
end
|
561
593
|
|
562
594
|
positions = []
|
563
595
|
while (rule_start = s.scan_next(rule_start_re))
|