12 /// Generate a class stack selector form a class list and responsive prefix
13 /// @param {List} $classnames - List of classes for generation
14 /// @param {String} $prefix - Prefix from $queries
15 /// @return {String} Stacked classes with responsive prefixes
17 @function stack-classenames($classnames, $prefix) {
19 @each $classname in $classnames {
20 // Remove dot (.) if there is one
21 $classname: if(string.slice($classname, 1, 1) == '.', string.slice($classname, 2, -1), $classname);
23 // Stack classe with dot, comma and responsive prefix
24 $classstack: if($classstack == '', '.' + $prefix + $classname, $classstack + ', .' + $prefix + $classname);
29 /// Generate responsive classes, duh!
30 /// @param {String | List | Node} $param - List of classes
31 /// @content The declaration block of a css rule. Used when $param is a String or a List
32 /// @returns {String} CSS classes with responsive prefixes
33 /// @example scss - Basic usage: __String__
34 /// @include responsive-classes(dummy-class) {
37 /// @example scss - Several classes with the same declaration block: __List__
38 /// @include responsive-classes((class-1, class-2)) {
41 /// @example scss - When you need to serialize several classes to avoid cascade ordering issues: __Map__
42 /// @include responsive-classes((
46 /// (class-1, class-2): (
51 @mixin responsive-classes($param) {
52 @each $breakpointname, $query in $queries {
53 @include media($query) {
54 $prefix: if($breakpointname == 'default', '', $breakpointname + '\\\:');
55 @if type-of($param) == 'map' {
56 @each $classnames, $properties in $param {
57 #{stack-classenames($classnames, $prefix)} {
58 @each $property, $value in $properties {
59 // Search in the $value string if we need the breakpoint name, e.g. for custom sizing css variables
61 string.index(#{$value}, '[BPN]'),
62 str-replace($value, '[BPN]', if($breakpointname == 'default', '', $breakpointname + '-')),
66 #{$property}: #{$value};
71 #{stack-classenames($param, $prefix)} {