-
Notifications
You must be signed in to change notification settings - Fork 25
/
breadcrumbs.js
74 lines (67 loc) · 1.71 KB
/
breadcrumbs.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
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
import './breadcrumb.js';
import { css, html, LitElement } from 'lit';
import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
/**
* Help users understand where they are within the application, and provide useful clues about how the space is organized. They also provide a convenient navigation mechanism.
* @slot - Breadcrumb items
*/
class Breadcrumbs extends LocalizeCoreElement(RtlMixin(LitElement)) {
static get properties() {
return {
/**
* Renders in compact mode, displaying only the last item
* @type {boolean}
*/
compact: { type: Boolean, reflect: true }
};
}
static get styles() {
return css`
:host {
display: block;
font-size: 0.7rem;
line-height: 1.05rem;
overflow: hidden;
position: relative;
white-space: nowrap;
}
:host([hidden]) {
display: none;
}
:host::after {
background: linear-gradient(to right, rgba(255, 255, 255, 0), rgb(251, 252, 252));
bottom: 0;
content: "";
pointer-events: none;
position: absolute;
right: 0;
top: 0;
width: 10px;
}
:host([dir="rtl"])::after {
background: linear-gradient(to left, rgba(255, 255, 255, 0), rgb(251, 252, 252));
left: 0;
right: auto;
}
:host([compact]) ::slotted(d2l-breadcrumb:not(:last-of-type)),
:host([compact]) ::slotted(d2l-breadcrumb-current-page) {
display: none;
}
`;
}
constructor() {
super();
this.compact = false;
}
render() {
return html`
<nav aria-label="${this.localize('components.breadcrumbs.breadcrumb')}">
<div role="list">
<slot></slot>
</div>
</nav>
`;
}
}
customElements.define('d2l-breadcrumbs', Breadcrumbs);