This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
_mixins.scss
74 lines (60 loc) · 1.92 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* GLOBAL MIXINS
--------------------------------------------- */
/* AUTO SCALING FOR TYPE WITH MIN/MAX SIZES
@param {Number} $responsive - Viewport-based size
@param {Number} $min - Minimum font size (px)
@param {Number} $max - Maximum font size (px) (optional)
@param {Number} $fallback - Fallback for viewport-based units (optional)
@example SCSS - 5vw size, 35px min & 150px max size + 50px fallback:
@include responsive-font(5vw, 35px, 150px, 50px);
*/
@mixin responsive-font($responsive, $min, $max: false, $fallback: false) {
$responsive-unitless: $responsive / ($responsive - $responsive + 1);
$dimension: if(unit($responsive) == "vh", "height", "width");
$min-breakpoint: $min / $responsive-unitless * 100;
@media (max-#{$dimension}: #{$min-breakpoint}) {
font-size: $min;
}
@if $max {
$max-breakpoint: $max / $responsive-unitless * 100;
@media (min-#{$dimension}: #{$max-breakpoint}) {
font-size: $max;
}
}
@if $fallback {
font-size: $fallback;
}
font-size: $responsive;
}
// Reset
@mixin reset {
box-sizing: border-box;
padding: 0;
margin: 0;
}
// Used to prevent text selection on an element
@mixin prevent-user-select {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
/// Used to hide an element visually, but keeping it accessible for
/// accessibility tools.
@mixin visually-hidden {
// Need to make sure we override any existing styles.
position: absolute !important;
top: 0;
clip: rect(1px, 1px, 1px, 1px) !important;
overflow: hidden !important;
height: 1px !important;
width: 1px !important;
padding: 0 !important;
border: 0 !important;
}
/// To be used on flex items. Resolves some common layout issues, such as
/// text truncation not respecting padding or breaking out of container.
/// https://css-tricks.com/flexbox-truncated-text/
@mixin layout-flex-fix {
min-width: 0;
max-width: 100%;
}