N
N
NerVik2016-02-24 16:12:01
Sass
NerVik, 2016-02-24 16:12:01

How to rewrite such code from SASS to LESS?

Save how to rewrite this piece of code from SASS to LESS:

$red: (
  "lighten-5":  #FFEBEE,
  "lighten-4":  #FFCDD2,
  "base":       #F44336
);

$pink: (
  "lighten-5":  #fce4ec,
  "lighten-4":  #f8bbd0,
  "base":       #e91e63
);

$colors: (
  "red": $red,
  "pink": $pink,

@each $color_name, $color in $colors {
  @each $color_type, $color_value in $color {
    @if $color_type == "base" {
      .#{$color_name} {
        background-color: $color_value !important;
      }
      .#{$color_name}-text {
        color: $color_value !important;
      }
    }
    @else {
      .#{$color_name}.#{$color_type} {
        background-color: $color_value !important;
      }
      .#{$color_name}-text.text-#{$color_type} {
        color: $color_value !important;
      }
    }
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-02-24
@sim3x

start with the bare minimum
lesscss.org/features/#features-overview-feature-fu...
sass-lang.com/documentation/Sass/Script/Functions.html
Try to avoid using this feature - it looks weird
Then read these guides
https ://csspre.com/convert/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question