UNPKG

3.77 kBSCSSView Raw
1@mixin str-truncated($max-width: 82%) {
2 display: inline-block;
3 overflow: hidden;
4 text-overflow: ellipsis;
5 vertical-align: top;
6 white-space: nowrap;
7 max-width: $max-width;
8}
9
10@mixin gl-fluid-font-size($min, $max) {
11 @include gl-responsive-property('font-size', $min, $max);
12}
13
14@mixin gl-fluid-line-height($min, $max) {
15 @include gl-responsive-property('line-height', $min, $max);
16}
17
18/**
19* Declares a property with a fluid value that decreases or
20* rises depending on the viewport’s size. The property type
21* should be numeric.
22*
23* Values are expected in rem units.
24* Fluid range: between 48rem (768px) – 75rem (1200px).
25*
26* @param $property Property name, i.e. line-height, font-size, width, height, etc.
27* @param $min Property value lower bound.
28* @param $max Property value upper bound.
29*/
30@mixin gl-responsive-property($property, $min, $max) {
31 #{$property}: clamp-between($min, $max);
32}
33
34/**
35* Helper function for :focus
36*
37* @param $size is deprecated and should not be used anymore
38*/
39@mixin gl-focus(
40 $size: null,
41 $color: false,
42 $important: false,
43 $inset: false,
44 $focus-ring: $focus-ring,
45 $outline: false,
46 $outline-offset: $outline-offset
47) {
48 @if $inset == true {
49 @if $color {
50 box-shadow: inset 0 0 0 $outline-width $blue-400,
51 inset 0 0 0 #{$outline-width + $outline-offset} $white,
52 inset 0 0 0 #{$outline-width + $outline-offset + 1px} $color,
53 $focus-ring-inset if-important($important);
54 outline: none if-important($important);
55 } @else if $outline == true {
56 outline: $focus-ring-outline if-important($important);
57 outline-offset: $outline-offset;
58 } @else {
59 box-shadow: inset 0 0 0 $outline-width $blue-400, $focus-ring-inset if-important($important);
60 outline: none if-important($important);
61 }
62 } @else if $color {
63 box-shadow: inset 0 0 0 $gl-border-size-1 $color, $focus-ring if-important($important);
64 outline: none if-important($important);
65 } @else if $outline == true {
66 outline: $focus-ring-outline if-important($important);
67 outline-offset: $outline-offset;
68 } @else {
69 box-shadow: $focus-ring if-important($important);
70 outline: none if-important($important);
71 }
72}
73
74@mixin gl-bg-gradient-blur($direction, $color) {
75 background-image: linear-gradient(to $direction, $transparent-rgba, $color 33%);
76}
77
78/**
79* Helper function for @media of at least the minimum
80* breakpoint width.
81*
82* @param $name Breakpoint name, such as `sm` or `md`.
83*/
84@mixin gl-media-breakpoint-up($name) {
85 $min: map-get($breakpoints, $name);
86 @if $min == null {
87 @error "#{$name} is not a valid breakpoint for this @media query.";
88 }
89 @if $min != 0 {
90 @media (min-width: $min) {
91 @content;
92 }
93 } @else {
94 @content;
95 }
96}
97
98/**
99* Helper function for @media of at most the maximum
100* breakpoint width.
101*
102* Note: Before using, consider using a mobile-first
103* approach, and define @media for larger breakpoints
104* using `gl-media-breakpoint-up` while using this rule as
105* the starting point instead.
106*
107* @param $name Breakpoint, such as `sm` or `md`. `xs` is not valid
108*/
109@mixin gl-media-breakpoint-down($name) {
110 $max: map-get($breakpoints, $name);
111 @if ($max == null or $max == 0) {
112 @error "#{$name} is not a valid breakpoint for this @media query.";
113 }
114 // The maximum value is reduced by 0.02px to work around the limitations of
115 // `min-` and `max-` prefixes and with fractional viewport sizes.
116 // See: https://www.w3.org/TR/mediaqueries-4/#mq-min-max
117 // Use 0.02px rather than 0.01px to work around a current rounding bug in Safari.
118 // See https://bugs.webkit.org/show_bug.cgi?id=178261
119 $breakpoint-max-range-precision: 0.02px;
120
121 @media (max-width: $max - $breakpoint-max-range-precision) {
122 @content;
123 }
124}