bootstrap-switch icon indicating copy to clipboard operation
bootstrap-switch copied to clipboard

Causes LESS compilation error when used with Bootstrap 3

Open ghost opened this issue 13 years ago • 17 comments

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 }

ghost avatar Aug 06 '13 19:08 ghost

Which 3 Bootstrap version do you have there?

BdMdesigN avatar Aug 06 '13 19:08 BdMdesigN

version 3.0.0-rc1

ghost avatar Aug 06 '13 19:08 ghost

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

BdMdesigN avatar Aug 06 '13 20:08 BdMdesigN

Can you explain to us how you compiled the source?

nostalgiaz avatar Aug 10 '13 20:08 nostalgiaz

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 avatar Aug 13 '13 10:08 mattpi

@mattpi please send us a pull-request!

nostalgiaz avatar Aug 21 '13 15:08 nostalgiaz

@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.

mattpi avatar Aug 21 '13 15:08 mattpi

Hmm .btn-pseudo-states is not defined in my bootstrap 3.0, instead I have .button-variant

Rush avatar Sep 10 '13 19:09 Rush

@RushPL - that's because they were renamed a few weeks back: https://github.com/twbs/bootstrap/commit/83293516b6b1785e8f57dc26b9023f26cd7a89a1

mattpi avatar Sep 11 '13 08:09 mattpi

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.

Rush avatar Sep 11 '13 08:09 Rush

can anyone send us a pull-request? :P

nostalgiaz avatar Sep 30 '13 07:09 nostalgiaz

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.

alexgorbatchev avatar Oct 23 '13 03:10 alexgorbatchev

@KFCharron, @RushPL, @alexgorbatchev or others, do you still encounter this problem?

LostCrew avatar Dec 09 '13 18:12 LostCrew

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.

ghost avatar Dec 09 '13 18:12 ghost

@KFCharron did you perhaps opt for a similar component?

LostCrew avatar Dec 09 '13 18:12 LostCrew

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.

ghost avatar Dec 09 '13 18:12 ghost

from version 1.9.0, there are two main .less files to combine with bootstrap 2 or 3, accordingly.

LostCrew avatar Dec 12 '13 21:12 LostCrew