-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
_element.scss
200 lines (182 loc) · 5.36 KB
/
_element.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
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
@use 'sass:list';
@use 'sass:meta';
@use '../functions';
/// Adds two lines between an element.
/// There is an example https://css-tricks.com/line-on-sides-headers/
/// @param {Number} $space-between-lines [1.5rem]
/// @param {Color} $line-color [#000]
/// @param {Number} $line-width [2px]
/// @group Element
/// @author Felix Scholze
/// @since v1.0.0
@mixin line-on-sides(
$space-between-lines: 1.5rem,
$line-color: #000,
$line-width: 2px
) {
@if meta.type-of($line-color) != color {
@error '❌ ===> #{$line-color} is not a color.';
}
@if meta.type-of($space-between-lines) != number {
@error '❌ ===> #{$space-between-lines} is not a number.';
}
@if meta.type-of($line-width) != number {
@error '❌ ===> #{$line-width} is not a number.';
}
display: flex;
align-items: center;
@content;
&::before,
&::after {
content: '';
position: static;
display: block;
flex-grow: 1;
width: auto;
border-bottom: $line-width solid $line-color;
}
&::before {
margin-right: $space-between-lines;
}
&::after {
margin-left: $space-between-lines;
}
}
/// Adds an overlay
/// @param {String} $overlay-type
/// @param {String} $overlay-size
/// @param {String} $parent-element
/// @param {String} $overlay-element
/// @param {Color} $overlay-bg-color
/// @param {String} $valide-type [(hover,static)]
/// @param {String} $valide-size [(full, free)]
/// @content Add additional styles
/// @group Element
/// @author Felix Scholze
/// @since v1.0.0
@mixin overlay(
$overlay-type,
$overlay-size,
$parent-element,
$overlay-element,
$overlay-bg-color
) {
// Types of overlay
$valide-type: (hover, static);
// Sizes available for the overlay
$valide-size: (full, free);
@if not list.index($valide-size, $overlay-size) {
@error '❌ ===> #{$overlay-size} is not a valide option for overlay-size. Please use: #{$valide-size}';
}
@if not list.index($valide-type, $overlay-type) {
@error '❌ ===> #{$overlay-type} is not a valide option for overlay-type. Please use: #{$valide-type}';
}
@if $overlay-type == hover {
.#{$overlay-element} {
opacity: 0;
transition: 0.5s ease;
}
}
.#{$parent-element} {
position: relative;
@if $overlay-type == hover {
&:hover,
&:focus-visible {
.#{$overlay-element} {
opacity: 1;
}
}
}
}
.#{$overlay-element} {
@if $overlay-size == full {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
background: $overlay-bg-color;
transform: translate(-50%, -50%);
@content;
}
@if $overlay-size == free {
position: absolute;
background: $overlay-bg-color;
@content;
}
}
}
/// Custom bullets for lists with different image types (as file or inline svg)
///
/// @param {List} $path-and-color-name [''] Path to image file, color name
/// @param {String} $data-type ['file'] Choose between image file or svg inline data
/// @param {Number} $bullet-size [1rem] Defines the bullet size and distance to the text
/// @param {Number} $spacing-multiplicator [1.5] Defines the spacing between bullet and text ($bullet-size * $spacing-multiplicator)
/// @param {String} $list [ul] Class of the unordered list
/// @param {String} $list-item [li] Class of the list item
/// @todo build a version for icon fonts
/// @group Element
/// @author Felix Scholze
/// @since v1.0.0
///
/// @example
/// Image as file
/// $icons: '#{$path-to-img}/icons/ok-sign-b.svg'blue,
/// '#{$path-to-img}/icons/ok-sign.svg'white;
/// @include list-style-image($icons, 'file', 1.2rem, 1.7, '.icon-list');
///
/// Image as inline svg
/// $list-icon-color-primary: $primary;
/// $list-icon-primary: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='30'><path d='M1631.23 1749.44l-6.26-7.15 2.76-2.87 3.67 4.3 10.3-9.01 2.79 2.79zM1634 1726a15 15 0 1015 15 14.993 14.993 0 00-15-15' transform='translate(-1619 -1726)' fill='#{$list-icon-color-primary}' fill-rule='evenodd'/></svg>");
/// $list-icons: $list-icon-primary blue, $list-icon-primary white;
/// @include list-style-image($list-icons, 'data', 1.2rem, 1.7, '.icon-list');
///
@mixin list-style-image(
$path-and-color-name: '',
$data-type: 'file',
$bullet-size: 1rem,
$spacing-multiplier: 1.5,
$list: ul,
$list-item: li
) {
// Validate variables
$valide-type: (file, data);
@if not list.index($valide-type, $data-type) {
@error '❌ ===> #{$data-type} is not a valide option for data-type. Please use: #{$valide-type}';
}
@if type-checking.is-number($spacing-multiplier) == false {
@error '❌ ===> #{$spacing-multiplier} is not a number.';
}
@each $path, $color-mod in $path-and-color-name {
#{$list + '--' + $color-mod} {
#{$list-item} {
&::before {
@if $data-type == 'file' {
background-image: url('#{$path}');
}
@if $data-type == 'data' {
background-image: functions.escape-svg($path);
}
}
}
}
}
#{$list} {
padding-left: 0;
list-style: none;
#{$list-item} {
position: relative;
padding-left: $bullet-size * $spacing-multiplier;
&::before {
content: '';
position: absolute;
top: 4px;
left: 0;
width: $bullet-size;
height: $bullet-size;
background-position: center;
background-size: contain;
}
}
}
}