This repository has been archived by the owner on Dec 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmixins.scss
51 lines (47 loc) · 1.48 KB
/
mixins.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
// Should apply to all variants sharing the same parent name
// Specificity should be 0010
// output: `.parent-name`
@mixin parent($parent-name) {
[class^="#{$parent-name}\~"]:not([class*="\:"]),
.#{$parent-name} {
@content;
}
}
// should inherit styles from non-variable parent of same name
// specificy should be 0010
// output: `.parent-name~variant-name`
@mixin parent-variant($parent-name, $variant-name) {
[class*="#{$parent-name}\~#{$variant-name}"]:not([class*="\:"]),
.#{$parent-name}\~#{$variant-name} {
@content;
}
}
// variants of this child should inherit styles from here
// specificity should be 0010
// output: `.parent:child`, `.parent~variant:child`
@mixin child($parent-name, $child-name, $has-parent-variant: 'false', $parent-variant:null) {
@if $has-parent-variant == 'false' {
[class^="#{$parent-name}\:#{$child-name}\~"],
.#{$parent-name}\:#{$child-name} {
@content;
}
}
@if $has-parent-variant == 'true' {
[class^="#{parent-name}\~#{$parent-variant}\:#{$child-name}\~"],
.#{$parent-name}\~#{$parent-variant}\:#{$child-name} {
@content;
}
}
}
@mixin child-variant($parent-name, $child-name, $variant-name, $has-parent-variant: 'false', $parent-variant:null) {
@if $has-parent-variant == 'false' {
.#{$parent-name}\:#{$child-name}\~#{$variant-name} {
@content;
}
}
@if $has-parent-variant == 'true' {
.#{$parent-name}\~#{$parent-variant}\:#{$child-name}\~#{$variant-name} {
@content;
}
}
}