Causes LESS compilation error when used with Bootstrap 3
When I install bootstrap-switch to my project, I get this syntax error:
SyntaxError: Named argument for .vertical @start-color not found in lib/bootstrap/less/dropdowns.less:70:4
69 color: @dropdown-link-hover-color; 70 #gradient > .vertical(@start-color: @dropdown-link-hover-bg; @end-color: darken(@dropdown-link-hover-bg, 5%)); 71 }
Which 3 Bootstrap version do you have there?
version 3.0.0-rc1
In the last dropdowns.less of 3.0.0-rc1 the lines 69 - 78 should be:
// Hover/Focus state // ----------- .dropdown-menu > li > a { &:hover, &:focus { text-decoration: none; color: @dropdown-link-hover-color; #gradient > .vertical(@start-color: @dropdown-link-hover-bg; @end-color: darken(@dropdown-link-hover-bg, 5%)); } }
But i'm not good with less, so i hope nostalgiaz can better help here
Can you explain to us how you compiled the source?
Just fixed this myself - there's a number of fixes you need to do to get this to compile, associated with variables that have changed and mixins that are no longer there.
This should get you going, I'm dropping this into my custom forms.less file (not touching bootstrap core) - good idea to add comments to the entry to!:
The changes made below are the .border-radius mixin, which is no longer in 3.0x - that just has a standard border-radius entry. Then there's the button border variable, which has changed. Finally, the mixin for buttonBackground is no longer there, but you can use .btn-pseudo-states instead.
.has-switch {
display: inline-block;
cursor: pointer;
border-radius: 5px;
border: 1px solid;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
position: relative;
text-align: left;
overflow: hidden;
line-height: 8px;
.user-select(none);
vertical-align: middle;
min-width: 100px;
&.switch-mini {
min-width: 72px;
}
&.switch-mini i.switch-mini-icons {
height: 1.20em;
line-height: 9px;
vertical-align: text-top;
text-align: center;
transform: scale(0.6);
margin-top: -1px;
margin-bottom: -1px;
}
&.switch-small {
min-width: 80px;
}
&.switch-large {
min-width: 120px;
}
&.deactivate {
.opacity(50);
cursor: default !important;
label, span {
cursor: default !important;
}
}
> div {
display: inline-block;
width: 150%;
position: relative;
top: 0;
&.switch-animate {
.transition(left 0.5s);
}
&.switch-off {
left: -50%;
}
&.switch-on {
left: 0%;
}
}
input[type=radio],
input[type=checkbox] {
//debug
display: none;
//position: absolute;
//margin-left: 60%;
//z-index: 123;
}
span, label {
.box-sizing(border-box);
cursor: pointer;
position: relative;
display: inline-block;
height: 100%;
padding-bottom: 4px;
padding-top: 4px;
font-size: 14px;
line-height: 20px;
&.switch-mini {
padding-bottom: 4px;
padding-top: 4px;
font-size: 10px;
line-height: 9px;
}
&.switch-small {
padding-bottom: 3px;
padding-top: 3px;
font-size: 12px;
line-height: 18px;
}
&.switch-large {
padding-bottom: 9px;
padding-top: 9px;
font-size: 16px;
line-height: normal;
}
}
label {
text-align: center;
margin-top: -1px;
margin-bottom: -1px;
z-index: 100;
width: 34%;
border-left: 1px solid @btn-default-border;
border-right: 1px solid @btn-default-border;
background: red;
i {
color: #000;
text-shadow: 0 1px 0 #fff;
line-height: 18px;
pointer-events: none;
}
}
span {
text-align: center;
z-index: 1;
width: 33%;
&.switch-left {
.border-left-radius(4px);
}
&.switch-right {
.btn-pseudo-states(@btn-default-color; @btn-default-bg; @btn-default-border);
}
&.switch-primary, &.switch-left {
.btn-pseudo-states(@btn-primary-color; @btn-primary-bg; @btn-primary-border);
}
&.switch-info {
.btn-pseudo-states(@btn-info-color; @btn-info-bg; @btn-info-border);
}
&.switch-success {
.btn-pseudo-states(@btn-success-color; @btn-success-bg; @btn-success-border);
}
&.switch-warning {
.btn-pseudo-states(@btn-warning-color; @btn-warning-bg; @btn-warning-border);
}
&.switch-danger {
.btn-pseudo-states(@btn-danger-color; @btn-danger-bg; @btn-danger-border);
}
&.switch-default {
.btn-pseudo-states(@btn-default-color; @btn-default-bg; @btn-default-border);
}
}
}
@mattpi please send us a pull-request!
@nostalgiaz - it's a private repo I'm afraid - and this is a custom less file. If your compiling from less, you can do the same.
Hmm .btn-pseudo-states is not defined in my bootstrap 3.0, instead I have .button-variant
@RushPL - that's because they were renamed a few weeks back: https://github.com/twbs/bootstrap/commit/83293516b6b1785e8f57dc26b9023f26cd7a89a1
I see! Anyway, your style works. One small issue though is that the height does not match bootstrap buttons. I have set line-height: 24px; in line 68. Otherwise great job.
can anyone send us a pull-request? :P
I'm not getting compilation issues with #develop branch, however, including bootstrap less files with bootstrap-switch causes bootstrap styling conflicts and buttons in button groups no longer render correctly. Using plain CSS file instead of LESS solves this issue.
@KFCharron, @RushPL, @alexgorbatchev or others, do you still encounter this problem?
No longer using this project. Thanks for all your help.
On Dec 9, 2013, at 1:15 PM, Emanuele [email protected] wrote:
@KFCharron, @RushPL, @alexgorbatchevare or others, do you still encounter this problem?
— Reply to this email directly or view it on GitHub.
@KFCharron did you perhaps opt for a similar component?
Nope, onto different responsibilities at work
Sent from my iPhone
On Dec 9, 2013, at 1:45 PM, Emanuele [email protected] wrote:
@KFCharron did you perhaps opt for a similar component?
— Reply to this email directly or view it on GitHub.
from version 1.9.0, there are two main .less files to combine with bootstrap 2 or 3, accordingly.