A
A
Alexander Karpov2017-04-20 10:42:53
Sass
Alexander Karpov, 2017-04-20 10:42:53

Is it possible to use pointers in SASS?

Code example:

$sizes-rules:(
  480:  (logo:16,menu:12,animals:16,titles:30,text:14),
  720:  (logo:18,menu:12,animals:22,titles:36,text:16),
  1000: (logo:25,menu:15,animals:30,titles:46,text:16),
  1260: (logo:32,menu:17,animals:35,titles:46,text:16)
);
@each $level,$list in $sizes-rules{
  /*#{$level} #{nth($list,1)}*/
}

conclusion
/*480 logo 16*/
/*720 logo 18*/
/*1000 logo 25*/
/*1260 logo 32*/

Question such:
How to me to use pointers (keys)?
For example, so that the call looks something like this
$list->logo
and the output is
16
I would be glad to help. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karpov, 2017-04-20
@Inkognitoss

Oh, yes, of course you can .. I looked in the wrong place right away:
Example

$sizes-rules:(

  /*keys(logo:**,menu:**,animals:**,titles:**,text:**)*/
  480:  (logo:16,menu:12,animals:16,titles:30,text:14),
  720:  (logo:18,menu:12,animals:22,titles:36,text:16),
  1000: (logo:25,menu:15,animals:30,titles:46,text:16),
  1260: (logo:32,menu:17,animals:35,titles:46,text:16)
);


@each $level,$list in $sizes-rules{
  /*#{$level} #{map-get($list, logo)}*/
}

source
sass-lang.com/documentation/Sass/Script/Functions....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question