Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 1 | /* Prefix */ |
| 2 | |
| 3 | $box-sizing-prefix: webkit moz spec; |
| 4 | $border-radius-prefix: webkit spec; |
| 5 | $box-shadow-radius-prefix: webkit moz spec; |
| 6 | $text-shadow-radius-prefix: spec; |
| 7 | $text-shadow-prefix: spec; |
| 8 | $box-shadow-prefix: all; |
| 9 | $linear-gradient-prefix: all; |
| 10 | $transition-prefix: webkit moz o spec; |
| 11 | $flex-prefix: webkit spec; |
| 12 | $browserPrefixes: webkit moz o ms; |
| 13 | |
| 14 | @mixin prefix($property, $value, $prefixeslist: 'all') { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 15 | @if $prefixeslist == all { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 16 | -webkit-#{$property}: $value; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 17 | -moz-#{$property}: $value; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 18 | -ms-#{$property}: $value; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 19 | -o-#{$property}: $value; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 20 | #{$property}: $value; |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 21 | } @else { |
| 22 | @each $prefix in $prefixeslist { |
| 23 | @if $prefix == webkit { |
| 24 | -webkit-#{$property}: $value; |
| 25 | } @else if $prefix == moz { |
| 26 | -moz-#{$property}: $value; |
| 27 | } @else if $prefix == ms { |
| 28 | -ms-#{$property}: $value; |
| 29 | } @else if $prefix == o { |
| 30 | -o-#{$property}: $value; |
| 31 | } @else if $prefix == spec { |
| 32 | #{$property}: $value; |
| 33 | } @else { |
| 34 | @warn "No such prefix: #{$prefix}"; |
| 35 | } |
| 36 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 37 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | /* Value Prefix*/ |
| 41 | @mixin value-suffix-with-range($property, $valuesuffix, $from, $to, $prefixeslist) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 42 | @if $prefixeslist == all { |
| 43 | #{property}: -webkit-#{$valuesuffix}($from, $to); |
| 44 | #{property}: -moz-#{$valuesuffix}($from, $to); |
| 45 | #{property}: -o-#{$valuesuffix}($from, $to); |
| 46 | #{property}: -ms-#{$valuesuffix}($from, $to); |
| 47 | } @else { |
| 48 | @each $prefix in $prefixeslist { |
| 49 | @if $prefix == webkit { |
| 50 | #{property}: -webkit-#{$valuesuffix}($from, $to); |
| 51 | } @else if $prefix == moz { |
| 52 | #{property}: -moz-#{$valuesuffix}($from, $to); |
| 53 | } @else if $prefix == ms { |
| 54 | #{property}: -ms-#{$valuesuffix}($from, $to); |
| 55 | } @else if $prefix == o { |
| 56 | #{property}: -o-#{$valuesuffix}($from, $to); |
| 57 | } @else { |
| 58 | @warn "No such prefix: #{$prefix}"; |
| 59 | } |
| 60 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 61 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | /* Box sizing */ |
| 65 | @mixin box-sizing($value: border-box) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 66 | @include prefix(box-sizing, $value, $box-sizing-prefix); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | /* Borders & Shadows */ |
| 70 | @mixin box-shadow($value) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 71 | @include prefix(box-shadow, $value, $box-shadow-radius-prefix); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | @mixin text-shadow($value) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 75 | @include prefix(text-shadow, $value, $text-shadow-radius-prefix); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | @mixin border-radius($value, $positions: all) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 79 | @if ($positions == all) { |
| 80 | @include prefix(border-radius, $value, $border-radius-prefix); |
| 81 | } @else { |
| 82 | @each $position in $positions { |
| 83 | @include prefix(border-#{$position}-radius, $value, $border-radius-prefix); |
| 84 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 85 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | @mixin transition($value) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 89 | @include prefix(transition, $value, $transition-prefix); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | /* Opacity */ |
| 93 | @mixin opacity($alpha) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 94 | $ie-opacity: round($alpha * 100); |
| 95 | opacity: $alpha; |
| 96 | filter: unquote('alpha(opacity = #{$ie-opacity})'); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | /* Ellipsis */ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 100 | @mixin ellipsis($width: 100%, $display: inline-block, $max-width: none) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 101 | overflow: hidden; |
| 102 | text-overflow: ellipsis; |
| 103 | width: $width; |
| 104 | white-space: nowrap; |
| 105 | display: $display; |
| 106 | max-width: $max-width; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 107 | } |
| 108 | |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 109 | @mixin multiline-ellipsis($lineHeight: 1.3em, $lineCount: 2, $bgColor: $white) { |
| 110 | overflow: hidden; |
| 111 | position: relative; |
| 112 | line-height: $lineHeight; |
| 113 | max-height: $lineHeight * $lineCount; |
| 114 | text-align: justify; |
| 115 | word-break: break-all; |
| 116 | // margin-right: -1em; |
| 117 | padding-right: 1em; |
| 118 | &:before { |
| 119 | content: '...'; |
| 120 | position: absolute; |
| 121 | right: 3px; |
| 122 | bottom: 0; |
| 123 | } |
| 124 | &:after { |
| 125 | content: ''; |
| 126 | position: absolute; |
| 127 | right: 0; |
| 128 | width: 1em; |
| 129 | height: 1em; |
| 130 | margin-top: 0.2em; |
| 131 | background: $bgColor; |
| 132 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | @mixin gradient($from, $to) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 136 | /* fallback/image non-cover color */ |
| 137 | background-color: $from; |
| 138 | background-image: -webkit-gradient( |
| 139 | linear, |
| 140 | 0% 0%, |
| 141 | 0% 100%, |
| 142 | from($from), |
| 143 | to($to) |
| 144 | ); |
| 145 | @include value-suffix-with-range(background-color, linear-gradient, $from, $to, $linear-gradient-prefix); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | /* Vertical placement of multuple lines of text */ |
| 149 | @mixin vertical-text($height) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 150 | position: absolute; |
| 151 | top: 50%; |
| 152 | margin-top: -$height/2; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 153 | } |
| 154 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 155 | @mixin text-vertical-align($align: middle) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 156 | display: table; |
| 157 | width: 100%; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 158 | |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 159 | & > * { |
| 160 | vertical-align: $align; |
| 161 | display: table-cell; |
| 162 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | @mixin center-element($width) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 166 | width: $width; |
| 167 | margin-left: auto; |
| 168 | margin-right: auto; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | @mixin center-content($width) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 172 | & > * { |
| 173 | @include center-element($width); |
| 174 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | /* transform-rotate */ |
| 178 | // @mixin |
| 179 | // Defines a 2D rotation, the angle is specified in the parameter |
| 180 | // @param |
| 181 | // $deg - angle in degrees |
| 182 | @mixin transform-rotate($deg) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 183 | transform: rotate($deg + deg); /* IE10 and Mozilla */ |
| 184 | -ms-transform: rotate($deg + deg); /* IE 9 */ |
| 185 | -webkit-transform: rotate($deg + deg); /* Safari and Chrome */ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | /* transform-translate */ |
| 189 | // @mixin |
| 190 | // Defines a 2D rotation, the angle is specified in the parameter |
| 191 | // @param |
| 192 | // $deg - angle in degrees |
| 193 | @mixin transform-translate($x, $y) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 194 | transform: translate($x, $y); /* IE10 and Mozilla */ |
| 195 | -ms-transform: translate($x, $y); /* IE 9 */ |
| 196 | -webkit-transform: translate($x, $y); /* Safari and Chrome */ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | /* transform-scale */ |
| 200 | // @mixin |
| 201 | // Defines a 2D scale transformation, changing the elements width and height |
| 202 | // @param |
| 203 | // $width - width |
| 204 | // @param |
| 205 | // $height - height |
| 206 | @mixin transform-scale($width, $height) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 207 | transform: scale($width, $height); /* IE10 and Mozilla */ |
| 208 | -ms-transform: scale($width, $height); /* IE 9 */ |
| 209 | -webkit-transform: scale($width, $height); /* Safari and Chrome */ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | @mixin scrollable() { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 213 | ::-webkit-scrollbar { |
| 214 | width: 8px; |
| 215 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 216 | } |
| 217 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 218 | @mixin create-circle($size, $bgcolor) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 219 | border-radius: 50%; |
| 220 | width: $size; |
| 221 | height: $size; |
| 222 | background: $bgcolor; |
| 223 | border: 3px solid $bgcolor; |
| 224 | display: flex; |
| 225 | align-items: center; |
| 226 | justify-content: center; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | /**/ |
| 230 | @mixin keyframe-animation($animationType, $properties, $fromValue, $toValue) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 231 | @keyframes #{$animationType} { |
| 232 | from { |
| 233 | $startIndex: 1; |
| 234 | @each $property in $properties { |
| 235 | #{$property}: nth($fromValue, $startIndex); |
| 236 | $startIndex: $startIndex + 1; |
| 237 | } |
| 238 | } |
| 239 | to { |
| 240 | $startIndex: 1; |
| 241 | @each $property in $properties { |
| 242 | #{$property}: nth($toValue, $startIndex); |
| 243 | $startIndex: $startIndex + 1; |
| 244 | } |
| 245 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 246 | } |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 247 | @-moz-keyframes #{$animationType} { |
| 248 | /* Firefox */ |
| 249 | from { |
| 250 | $startIndex: 1; |
| 251 | @each $property in $properties { |
| 252 | #{$property}: nth($fromValue, $startIndex); |
| 253 | $startIndex: $startIndex + 1; |
| 254 | } |
| 255 | } |
| 256 | to { |
| 257 | $startIndex: 1; |
| 258 | @each $property in $properties { |
| 259 | #{$property}: nth($toValue, $startIndex); |
| 260 | $startIndex: $startIndex + 1; |
| 261 | } |
| 262 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 263 | } |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 264 | @-webkit-keyframes #{$animationType} { |
| 265 | /* Safari and Chrome */ |
| 266 | from { |
| 267 | $startIndex: 1; |
| 268 | @each $property in $properties { |
| 269 | #{$property}: nth($fromValue, $startIndex); |
| 270 | $startIndex: $startIndex + 1; |
| 271 | } |
| 272 | } |
| 273 | to { |
| 274 | $startIndex: 1; |
| 275 | @each $property in $properties { |
| 276 | #{$property}: nth($toValue, $startIndex); |
| 277 | $startIndex: $startIndex + 1; |
| 278 | } |
| 279 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 280 | } |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 281 | @-o-keyframes #{$animationType} { |
| 282 | /* Opera */ |
| 283 | from { |
| 284 | $startIndex: 1; |
| 285 | @each $property in $properties { |
| 286 | #{$property}: nth($fromValue, $startIndex); |
| 287 | $startIndex: $startIndex + 1; |
| 288 | } |
| 289 | } |
| 290 | to { |
| 291 | $startIndex: 1; |
| 292 | @each $property in $properties { |
| 293 | #{$property}: nth($toValue, $startIndex); |
| 294 | $startIndex: $startIndex + 1; |
| 295 | } |
| 296 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 297 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 298 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 299 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 300 | /**/ |
| 301 | @mixin border-shadow($xShadow: 0.545px, $yShadow: 0.839px, $blur: 4px, $spread: 0, $color: $light-gray, $opacity: 0.2) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 302 | @include box-shadow($xShadow $yShadow $blur $spread rgba($color, $opacity)); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 303 | } |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 304 | |
| 305 | /* percent-plus-value */ |
| 306 | // @mixin |
| 307 | // Calculate length property (e.g. width, margin) by adding a value (e.g. in pixels) |
| 308 | // to a percentage of container height/width |
| 309 | @mixin percent-plus-value($property, $value, $percent: 100%) { |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 310 | $string: 'calc(' + $percent + ' + ' + $value + ')'; |
| 311 | #{$property}: unquote($string); |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 312 | } |