-
Notifications
You must be signed in to change notification settings - Fork 0
/
_index.scss
167 lines (149 loc) · 4.24 KB
/
_index.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
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
@use "sass:string";
/** Show icons only. */
@mixin show(
$url,
$size: null,
$fill-color: null,
$fill-image: null,
$display: inline-block,
$width: $size,
$height: $size
) {
@include box($display, $width, $height);
@include -show-svg($url, $fill-color, $fill-image);
}
/** Displayed with square background. */
@mixin show-square(
$url,
$size: null,
$background-color: null,
$fill-color: null,
$background-image: null,
$fill-image: null,
$border-radius: 25%,
$display: null,
$ratio: 1.4,
$width: $size,
$height: $size,
$svg-size: null,
$svg-width: $svg-size,
$svg-height: $svg-size,
$border-style: null,
$border-width: null,
$border-color: null
) {
@include box($display, $width, $height, border-box);
@include border($border-radius, $border-style, $border-width, $border-color);
@include background($background-color, $background-image);
@if $display == null {
display: inline-flex;
justify-content: center;
align-items: center;
}
position: relative;
&::before {
position: absolute;
$svg-width: calculate-svg-size($svg-width, $width, $ratio);
$svg-height: calculate-svg-size($svg-height, $height, $ratio);
@if $border-width != null {
$svg-width: calc(#{$svg-width} - #{$border-width});
$svg-height: calc(#{$svg-height} - #{$border-width});
}
@include show-with-pseudo($url, null, $fill-color, $fill-image, $display, $svg-width, $svg-height);
}
}
@mixin show-with-pseudo($args...) {
content: "";
pointer-events: none;
@include show($args...);
}
/** Shown with circular background. */
@mixin show-circle($args...) {
@include show-square($args..., $border-radius: 50%);
}
/** Style settings for the box. */
@mixin box($display, $width, $height, $box-sizing: null) {
@if $display != null {
display: $display;
}
@if $width != null {
width: $width;
}
@if $height != null {
height: $height;
}
@if $box-sizing != null {
box-sizing: $box-sizing;
}
}
/** style settings for the background. */
@mixin background($background-color, $background-image) {
@if $background-color != null {
background-color: $background-color;
}
@if $background-image != null {
background-image: $background-image;
}
}
/** style settings related to borders. */
@mixin border($border-radius, $border-style, $border-width, $border-color) {
border-radius: $border-radius;
@if $border-width != null {
border-width: $border-width;
@if $border-style == null {
$border-style: solid;
}
}
@if $border-style != null {
border-style: $border-style;
}
@if $border-color != null {
border-color: $border-color;
}
}
@mixin -show-svg($url, $fill-color: null, $fill-image: null) {
@if $fill-color == null and $fill-image == null {
background-image: resolve-url($url);
background-size: contain;
background-repeat: no-repeat;
background-position: center;
} @else {
@if $fill-color {
background-color: $fill-color;
}
// Assuming background image and linear-gradient are used.
@if $fill-image {
background-image: $fill-image;
}
mask-image: resolve-url($url);
mask-size: contain;
mask-repeat: no-repeat;
mask-position: center;
-webkit-mask-image: resolve-url($url);
-webkit-mask-size: contain;
-webkit-mask-repeat: no-repeat;
-webkit-mask-position: center;
}
}
@function resolve-url($url) {
@if string.index($url, "var(") == 1 {
@return $url;
}
@return url("#{$url}");
}
/**
* Calculate the size of the svg.
*
* If $priority-size is specified, it takes precedence.
* If $priority-size is not specified, the size of the SVG is a fixed percentage of $element-size.
*/
@function calculate-svg-size($priority-size, $element-size, $ratio) {
@if $priority-size == null {
@if $ratio == 1 or $ratio == null {
@return $element-size;
}
@return calc(#{$element-size} / #{$ratio});
} @else {
@return $priority-size;
}
}