-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_sections.scss
80 lines (69 loc) · 2.8 KB
/
_sections.scss
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
@import '~sass-fluid';
@import 'map-get-deep';
@import 'index-to-key';
@mixin sections($sectionSpacings, $blockClass: 'section', $sectionBackgroundColors: ('white', 'purple', 'yellow'), $backgroundClass: 'bg--') {
@if $sectionSpacings == null or $sectionSpacings == '' {
$sectionSpacings: (
small: (
min: 10px,
max: 20px
),
medium: (
min: 20px,
max: 30px
),
large: (
min: 30px,
max: 40px
)
);
}
$firstSize: index-to-key($sectionSpacings, 1);
// use this block for resetting top padding
%nospacingtop {
padding-top: 0;
}
.#{$blockClass} {
// default styling for small block
@include fluid(padding, map-get-deep($sectionSpacings, $firstSize, min) 0, map-get-deep($sectionSpacings, $firstSize, max) 0);
// loop the other sizes for the default styling
@each $index, $spacing in $sectionSpacings {
@if $index != $firstSize {
&.#{$blockClass}--spacing-#{$index} {
@include fluid(padding, map-get($spacing, min) 0, map-get($spacing, max) 0);
}
}
}
// reset padding-top's for each available color
@each $color in $sectionBackgroundColors {
@each $index, $spacing in $sectionSpacings {
$lower: true;
@each $index2, $spacing2 in $sectionSpacings {
$spacingClass2: '';
$spacingClass: '';
$bgclass: '.#{$backgroundClass}#{$color}';
@if $index == $index2 or $lower == false {
$lower: false;
}
// render the first size as default value
@if $index != $firstSize {
$spacingClass: '.#{$blockClass}--spacing-#{$index}';
}
@if $index2 != $firstSize {
$spacingClass2: '.#{$blockClass}--spacing-#{$index2}';
}
&#{$spacingClass}#{$bgclass} + .#{$blockClass}#{$spacingClass2}#{$bgclass},
&#{$spacingClass}#{$bgclass} + [skip-section] + .#{$blockClass}#{$spacingClass2}#{$bgclass} {
@if $index == $index2 or $lower == true {
@extend %nospacingtop;
// padding-top: 0;
}
@else {
@include fluid(padding-top, map-get($spacing2, min) - map-get($spacing, min), map-get($spacing2, max) - map-get($spacing, max));
}
}
}
}
}
}
}