File: input.scss

package info (click to toggle)
node-node-sass 9.0.0%2Bgit20240131.6081731%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 75,520 kB
  • sloc: javascript: 7,313; cpp: 1,495; perl: 428; makefile: 11
file content (260 lines) | stat: -rw-r--r-- 6,793 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----

@function remove-modifiers($selector) {
    // convert selector to a string
    $selector: inspect(nth($selector, 1));
  
    $modifier: '';
  
    // Find out where the first modifier starts
    $modifier-index: str-index($selector, '"--');
  
    @if $modifier-index {
      // Strip the first part of the selector up until the first modifier
      $modifier: str-slice($selector, $modifier-index);
      // Find out where the modifier ends
      $modifier-end: str-index($modifier, '"]');
      // Isolate the modifier
      $modifier: str-slice($modifier, 0, $modifier-end);
      // Remove the modifier from the selector
      $selector: str-replace($selector, $modifier, '');
      // Remove junk characters
      $selector: str-replace($selector, '[class*=]', '');
      // Recurse the function to eliminate any remainig modifiers
      $selector: remove-modifiers($selector);
    }
  
    @return $selector;
  }
  
  @function remove-duplicates($list, $recursive: false) {
    $result: ();
    
    @each $item in $list {
      @if not index($result, $item) {
        @if length($item) > 1 and $recursive {
          $result: append($result, remove-duplicates($item, $recursive));
        }
        @else {
          $result: append($result, $item);
        }
      }
    }
    
    @return $result;
  }
  
  @function str-replace($string, $search, $replace) { 
    $index: str-index($string, $search);
  
    @if $index {
      @return str-slice($string, 1, $index - 1) + $replace + str-replace(
        str-slice($string, $index + str-length($search)), $search, $replace
      );
    }
  
    @return $string;
  }
  
  @function module-tree($selector) {
    $parent-module: $module;
  
    // Remove any modifers
    $selectors: remove-modifiers($selector);
  
    // Remove any junk characters
    $selectors: str-replace($selectors, '.', '');
    $selectors: str-replace($selectors, '[class*="--', '');
    $selectors: str-replace($selectors, '[class*="', '');
    $selectors: str-replace($selectors, '--"]', '');
    $selectors: str-replace($selectors, '"]', '');
  
    // Spoof our modules into a list
    $selectors: str-replace($selectors, ' ', ', ');
    $selectors: selector-parse($selectors);
  
    @return $selectors;
  }
  
  @function list-remove($list, $value, $recursive: false) { 
      $result: ();
  
      @for $i from 1 through length($list) {
          @if type-of(nth($list, $i)) == list and $recursive {
              $result: append($result, list-remove(nth($list, $i), $value, $recursive), comma);
          } @else if nth($list, $i) != $value {
              $result: append($result, nth($list, $i), comma);
          }
      }
  
      @return $result;
   }
   
  @function this($options...) {
    $value: map-get($config, $options...);
    $debug: true;
  
    $this: &;
  
    @if length($this) > 0 {
      @if str-index(inspect(nth($this, 1)), '%') == 1 {
        $debug: false;
      }
    }
  
    @if $debug and not $value and $value != false {
        @warn '#{$options} not found in #{$module} config';
    }
  
    @return $value;
  }
  
  @function config($map-old, $map-new) {
      // Merge default and custom options
      $map-merged: map-merge($map-old, $map-new);
    
      // Store config in global variable
      $config: $map-merged !global;
  
      // Return merged map
      @return $map-merged;
  }
  
  @mixin module($module: $module) {
    $nested: &;
  
    @if not $nested {
      $module: $module !global;
    }
    
    $selectors: ();
  
    @each $item in $module {
      $selectors: join($selectors, '.#{$module}', comma);
      $selectors: join($selectors, '[class*="#{$module}--"]', comma);
    }
      
    #{$selectors} {
      @content;
    }
  }
  
  @mixin component($components: null, $glue: '__') {
      $selectors: '[class*="#{$module}#{$glue}"]';
      $this: &;
      $tree: module-tree($this);
      $namespace: nth($tree, length($tree));
  
      @if $components {
        $selectors: ();
  
        @each $component in $components {
          $selectors: join(
            $selectors, 
            '.#{$namespace}#{$glue}#{$component}, [class*="#{$namespace}#{$glue}#{$component}-"]', 
            comma
          );
        }
      }
  
      $parents: ();
  
      @each $selector in & {
        // spoof the selector into a list
        $selector: str-replace(inspect($selector), ' ', ', ');
        $selector: selector-parse($selector);
  
        // if the last item isn't a modifier, remove it
        @if not str-index(inspect(nth($selector, length($selector))), '[class*="--') {
          $selector: list-remove($selector, nth($selector, length($selector)));
        }
  
        // convert the selector back into a string
        @if length($selector) == 1 {
          $selector: nth($selector, 1);
        }
        $selector: str-replace(inspect($selector), ', ', ' ');
  
        // Re-build the parent selector
        $parents: append($parents, $selector, comma);
      }
  
      // remove duplicate selectors
      $parents: remove-duplicates($parents);
  
      @if length($parents) == 1 {
        $parents: nth($parents, 1);
      }
  
      @if ($parents == '()') {
        @at-root #{$selectors} {
          @content;
        }
      } @else {
        @at-root #{$parents} {
          #{$selectors} {
              @content;
          }
        }
      }
  
  }
  
  @mixin modifier($modifier) {
    $selectors: &;
  
    @if str-index(inspect(&), '.#{$module}') {
      $selectors: ();
  
      @for $i from 1 through length(&) {
        @if $i % 2 == 0 {
          $selectors: append($selectors, nth(&, $i), comma);
        }
      }
    }
  
    @at-root #{$selectors} {
      $modifier-selectors: ();
      
      @each $item in $modifier {
        $modifier-selectors: join(
          $modifier-selectors, '&[class*="--#{$modifier}"]', comma
        );
      }
  
      #{$modifier-selectors} {
        @content;
      }
    }
  }
  
  @mixin button($custom:()) {
    $buttons: config((
      'group-spacing': 1em
    ), $custom);
  
    @include module('button') {
      @include component('group') {
        content: 'fizzbuzz';
        @include module {
          margin-left: this('group-spacing');
          &:first-child {
            margin-left: 0;
          }
        }
      }
    }
  }
  
  @include button();
  
  @include module('modal') {
    @include modifier('animate') {
      @include modifier('zoom') {
        content: "fizzbuzz"
      }
    }
  }