UNPKG

2.86 kBSCSSView Raw
1// Copyright 2020 Google Inc.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21@use '@material/feature-targeting/feature-targeting';
22///
23/// Emits necessary layout styles to set a transparent border around an element
24/// without interfering with the rest of its component layout. The border is
25/// only visible in high-contrast mode. The target element should be a child of
26/// a relatively positioned top-level element (i.e. a ::before pseudo-element).
27///
28/// @param {number} $border-width - The width of the transparent border.
29/// @param {string} $border-style - The style of the transparent border.
30///
31@mixin transparent-border(
32 $border-width: 1px,
33 $border-style: solid,
34 $query: feature-targeting.all()
35) {
36 $feat-structure: feature-targeting.create-target($query, structure);
37
38 @include feature-targeting.targets($feat-structure) {
39 position: absolute;
40 box-sizing: border-box;
41 width: 100%;
42 height: 100%;
43 top: 0;
44 left: 0;
45 border: $border-width $border-style transparent;
46 border-radius: inherit;
47 content: '';
48 pointer-events: none;
49 }
50}
51
52///
53/// Visually hides text content for accessibility. This text should only be
54/// visible to screen reader users.
55/// See https://a11yproject.com/posts/how-to-hide-content/
56///
57@mixin visually-hidden($query: feature-targeting.all()) {
58 $feat-structure: feature-targeting.create-target($query, structure);
59
60 @include feature-targeting.targets($feat-structure) {
61 clip: rect(1px, 1px, 1px, 1px);
62 height: 1px;
63 overflow: hidden;
64 position: absolute;
65 white-space: nowrap; /* added line */
66 width: 1px;
67 }
68}
69
70///
71/// Selects for high-contrast mode. Currently this only detects high-contrast
72/// mode in IE and Edge.
73///
74@mixin ie-high-contrast-mode {
75 @media screen and (-ms-high-contrast: active) {
76 @content;
77 }
78}