0

Is there an intelligent way to use the function result of map.get as an arglist without first saving the list to a variable?

@use "sass:map";

@mixin make-button-size($font-size, $padding-vertical, $padding-horizontal) {
    // make-button-size implementation
}

$sizes: (
    md: (10px, 11px, 12px),
)

$params: map.get($sizes, md);
@include make-button-size($params...);

I tried the following, but this leads to a syntax error:

@include make-button-size((map.get($sizes, md))...);
MrMartiniMo
  • 149
  • 8

1 Answers1

1

It is based on https://www.sassmeister.com/ .

Even if I type the following, the error does not appear.

@mixin make-button-size($font-size, $padding-vertical, $padding-horizontal) {
    a: $font-size;
    b: $padding-vertical;
    c: $padding-horizontal;
}

$sizes: (
    md: (10px, 11px, 12px),
);
$params: map-get($sizes, md);

p {
  sizes: $params;
  @include make-button-size(map-get($sizes, md)...);
}

Compiled:

p {
  sizes: 10px, 11px, 12px;
  a: 10px;
  b: 11px;
  c: 12px;
}

$sizes: (...) doesn't have a semicolon, so make sure it's not.

M.S Youn
  • 36
  • 5
  • You're right! It seems to be a problem of PhpStorm that the SCSS code cannot be parsed, so the FileWatcher is not triggered. Thanks for your answer. – MrMartiniMo Aug 03 '20 at 12:40