-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathoffscreen.js
40 lines (37 loc) · 1.05 KB
/
offscreen.js
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
import { css, html, LitElement } from 'lit';
import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
/**
* A private helper declarations that should not be used by general consumers
*/
export const _offscreenStyleDeclarations = css`
direction: var(--d2l-document-direction, ${document.dir === 'rtl' ? css`rtl` : css`ltr`}); /* stylelint-disable-line @stylistic/string-quotes */
height: 1px;
inset-inline-start: -10000px;
overflow: hidden;
position: absolute !important;
white-space: nowrap;
width: 1px;
${document.dir === 'rtl' ? css`right` : css`left`}: -10000px;
`;
export const offscreenStyles = css`
.d2l-offscreen {
${_offscreenStyleDeclarations}
}
`;
/**
* A component for positioning content offscreen to only be visible to screen readers.
* @slot - Default content placed inside of the component
*/
class Offscreen extends RtlMixin(LitElement) {
static get styles() {
return css`
:host {
${_offscreenStyleDeclarations}
}
`;
}
render() {
return html`<slot></slot>`;
}
}
customElements.define('d2l-offscreen', Offscreen);