V
V
Vladislav2021-03-18 10:01:44
Sass
Vladislav, 2021-03-18 10:01:44

How to compile stilys function to sass?

$font-size-base = 12px
$line-height-base = 16px
text-margin($top, $right, $bottom, $left, $font-size = $font-size-base, $line-height = $line-height-base)
  if $top != 0
    $top = $top - ($line-height - $font-size) / 2

  if $bottom != 0
    $bottom = $bottom - ($line-height - $font-size) / 2

  margin $top $right $bottom $left

this function is written on the stylus, please write who worked with sass and the stylus, how does this function look in the sass syntax, which is without brackets

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-03-18
@SlavaMaxwell

Here the difference is only in the assignment. In stylus, the "equal" sign, in sass - "colon"

$font-size-base: 12px
$line-height-base: 16px
text-margin($top, $right, $bottom, $left, $font-size: $font-size-base, $line-height: $line-height-base)
  if $top != 0
    $top: $top - ($line-height - $font-size) / 2

  if $bottom != 0
    $bottom: $bottom - ($line-height - $font-size) / 2

  margin: $top $right $bottom $left

Oh yes. The mixin function is also defined somehow . I don't remember.
In normal sass it would be like this:
@mixin text-margin($top, $right, $bottom, $left, $font-size: $font-size-base, $line-height: $line-height-base) {

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question