@brightspace-ui/labs 2.7.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +21 -1
- package/src/components/card-overlay/README.md +12 -0
- package/src/components/card-overlay/card-overlay.js +79 -0
- package/src/components/navigation/README.md +192 -0
- package/src/components/navigation/navigation-band.js +134 -0
- package/src/components/navigation/navigation-button-icon.js +120 -0
- package/src/components/navigation/navigation-dropdown-button-custom.js +35 -0
- package/src/components/navigation/navigation-dropdown-button-icon.js +86 -0
- package/src/components/navigation/navigation-immersive.js +265 -0
- package/src/components/navigation/navigation-iterator.js +97 -0
- package/src/components/navigation/navigation-link-back.js +39 -0
- package/src/components/navigation/navigation-link-icon.js +127 -0
- package/src/components/navigation/navigation-link-image.js +73 -0
- package/src/components/navigation/navigation-link.js +62 -0
- package/src/components/navigation/navigation-main-footer.js +27 -0
- package/src/components/navigation/navigation-main-header.js +67 -0
- package/src/components/navigation/navigation-notification-icon.js +54 -0
- package/src/components/navigation/navigation-separator.js +30 -0
- package/src/components/navigation/navigation-shared-styles.js +32 -0
- package/src/components/navigation/navigation-skip-main.js +31 -0
- package/src/components/navigation/navigation-skip.js +59 -0
- package/src/components/navigation/navigation-styles.js +107 -0
- package/src/components/navigation/navigation.js +60 -0
- package/src/lang/ar.js +4 -0
- package/src/lang/cy.js +4 -0
- package/src/lang/da.js +4 -0
- package/src/lang/de.js +4 -0
- package/src/lang/en-gb.js +4 -0
- package/src/lang/en.js +4 -0
- package/src/lang/es-es.js +4 -0
- package/src/lang/es.js +4 -0
- package/src/lang/fr-fr.js +4 -0
- package/src/lang/fr-on.js +4 -0
- package/src/lang/fr.js +4 -0
- package/src/lang/haw.js +4 -0
- package/src/lang/hi.js +4 -0
- package/src/lang/ja.js +4 -0
- package/src/lang/ko.js +4 -0
- package/src/lang/nl.js +4 -0
- package/src/lang/pt.js +4 -0
- package/src/lang/sv.js +4 -0
- package/src/lang/tr.js +4 -0
- package/src/lang/zh-cn.js +4 -0
- package/src/lang/zh-tw.js +4 -0
package/package.json
CHANGED
|
@@ -7,9 +7,29 @@
|
|
|
7
7
|
"./components/accessibility-disability-simulator.js": "./src/components/accessibility-disability-simulator/accessibility-disability-simulator.js",
|
|
8
8
|
"./components/attribute-picker.js": "./src/components/attribute-picker/attribute-picker.js",
|
|
9
9
|
"./components/checkbox-drawer.js": "./src/components/checkbox-drawer/checkbox-drawer.js",
|
|
10
|
+
"./components/card-overlay.js": "./src/components/card-overlay/card-overlay.js",
|
|
10
11
|
"./components/community-button.js": "./src/components/community/community-button.js",
|
|
11
12
|
"./components/community-link.js": "./src/components/community/community-link.js",
|
|
12
13
|
"./components/community-url-factory.js": "./src/components/community/community-url-factory.js",
|
|
14
|
+
"./components/navigation/navigation-band.js": "./src/components/navigation/navigation-band.js",
|
|
15
|
+
"./components/navigation/navigation-button-icon.js": "./src/components/navigation/navigation-button-icon.js",
|
|
16
|
+
"./components/navigation/navigation-dropdown-button-custom.js": "./src/components/navigation/navigation-dropdown-button-custom.js",
|
|
17
|
+
"./components/navigation/navigation-dropdown-button-icon.js": "./src/components/navigation/navigation-dropdown-button-icon.js",
|
|
18
|
+
"./components/navigation/navigation-immersive.js": "./src/components/navigation/navigation-immersive.js",
|
|
19
|
+
"./components/navigation/navigation-iterator.js": "./src/components/navigation/navigation-iterator.js",
|
|
20
|
+
"./components/navigation/navigation-link-back.js": "./src/components/navigation/navigation-link-back.js",
|
|
21
|
+
"./components/navigation/navigation-link-icon.js": "./src/components/navigation/navigation-link-icon.js",
|
|
22
|
+
"./components/navigation/navigation-link-image.js": "./src/components/navigation/navigation-link-image.js",
|
|
23
|
+
"./components/navigation/navigation-link.js": "./src/components/navigation/navigation-link.js",
|
|
24
|
+
"./components/navigation/navigation-main-footer.js": "./src/components/navigation/navigation-main-footer.js",
|
|
25
|
+
"./components/navigation/navigation-main-header.js": "./src/components/navigation/navigation-main-header.js",
|
|
26
|
+
"./components/navigation/navigation-notification-icon.js": "./src/components/navigation/navigation-notification-icon.js",
|
|
27
|
+
"./components/navigation/navigation-separator.js": "./src/components/navigation/navigation-separator.js",
|
|
28
|
+
"./components/navigation/navigation-shared-styles.js": "./src/components/navigation/navigation-shared-styles.js",
|
|
29
|
+
"./components/navigation/navigation-skip-main.js": "./src/components/navigation/navigation-skip-main.js",
|
|
30
|
+
"./components/navigation/navigation-skip.js": "./src/components/navigation/navigation-skip.js",
|
|
31
|
+
"./components/navigation/navigation-styles.js": "./src/components/navigation/navigation-styles.js",
|
|
32
|
+
"./components/navigation/navigation.js": "./src/components/navigation/navigation.js",
|
|
13
33
|
"./components/opt-in-flyout.js": "./src/components/opt-in-flyout/opt-in-flyout.js",
|
|
14
34
|
"./components/opt-out-flyout.js": "./src/components/opt-in-flyout/opt-out-flyout.js",
|
|
15
35
|
"./components/opt-out-reason.js": "./src/components/opt-in-flyout/opt-out-reason.js",
|
|
@@ -56,5 +76,5 @@
|
|
|
56
76
|
"@brightspace-ui/core": "^3",
|
|
57
77
|
"lit": "^3"
|
|
58
78
|
},
|
|
59
|
-
"version": "2.
|
|
79
|
+
"version": "2.9.0"
|
|
60
80
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Card Overlay
|
|
2
|
+
|
|
3
|
+
A placeholder when an actual card component is loading
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<script type="module">
|
|
9
|
+
import '@brightspace-ui/labs/components/card-overlay.js';
|
|
10
|
+
</script>
|
|
11
|
+
<d2l-labs-card-overlay>My element</d2l-labs-card-overlay>
|
|
12
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
2
|
+
import { bodyStandardStyles } from '@brightspace-ui/core/components/typography/styles.js';
|
|
3
|
+
import { SkeletonMixin } from '@brightspace-ui/core/components/skeleton/skeleton-mixin.js';
|
|
4
|
+
|
|
5
|
+
class CardOverlay extends SkeletonMixin(LitElement) {
|
|
6
|
+
|
|
7
|
+
static get styles() {
|
|
8
|
+
return [super.styles, bodyStandardStyles, css`
|
|
9
|
+
:host {
|
|
10
|
+
display: block;
|
|
11
|
+
left: 0;
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: 0;
|
|
14
|
+
}
|
|
15
|
+
:host([skeleton]) {
|
|
16
|
+
height: 100%;
|
|
17
|
+
width: 100%;
|
|
18
|
+
}
|
|
19
|
+
:host([hidden]) {
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
22
|
+
.d2l-insights-card-overlay-container {
|
|
23
|
+
background-color: white;
|
|
24
|
+
border-radius: 15px;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
height: calc(100% - 20px);
|
|
28
|
+
justify-content: center;
|
|
29
|
+
padding-left: 7px;
|
|
30
|
+
padding-top: 20px;
|
|
31
|
+
width: calc(100% - 28px);
|
|
32
|
+
}
|
|
33
|
+
.d2l-insights-card-overlay-title {
|
|
34
|
+
margin-left: 15px;
|
|
35
|
+
margin-right: 15px;
|
|
36
|
+
margin-top: 10px;
|
|
37
|
+
width: 100%;
|
|
38
|
+
}
|
|
39
|
+
.d2l-insights-card-overlay-body {
|
|
40
|
+
align-items: center;
|
|
41
|
+
display: flex;
|
|
42
|
+
height: 100%;
|
|
43
|
+
margin-bottom: 25px;
|
|
44
|
+
}
|
|
45
|
+
.d2l-insights-card-overlay-body > div {
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
height: 70px;
|
|
48
|
+
margin: 0 15px;
|
|
49
|
+
width: 70px;
|
|
50
|
+
}
|
|
51
|
+
.d2l-insights-card-overlay-message {
|
|
52
|
+
display: inline-block;
|
|
53
|
+
font-size: 14px;
|
|
54
|
+
line-height: 1rem;
|
|
55
|
+
margin: 10px;
|
|
56
|
+
margin-left: 5px;
|
|
57
|
+
margin-right: 0;
|
|
58
|
+
vertical-align: middle;
|
|
59
|
+
}
|
|
60
|
+
`];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
render() {
|
|
64
|
+
if (!this.skeleton) {
|
|
65
|
+
return nothing;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return html`
|
|
69
|
+
<div class="d2l-insights-card-overlay-container" aria-hidden="true">
|
|
70
|
+
<div class="d2l-insights-card-overlay-title d2l-skeletize d2l-skeletize-45 d2l-body-standard">A title. Do not localize.</div>
|
|
71
|
+
<div class="d2l-insights-card-overlay-body">
|
|
72
|
+
<div class="d2l-skeletize"></div>
|
|
73
|
+
<span class="d2l-insights-card-overlay-message d2l-body-standard d2l-skeletize-paragraph-3">A text that triggers CSS styling. Do not localize.</span>
|
|
74
|
+
</div>
|
|
75
|
+
</div>`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
customElements.define('d2l-labs-card-overlay', CardOverlay);
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
## Usage: Primary Components
|
|
2
|
+
|
|
3
|
+
> These are the components that should be used in the **VAST MAJORITY** of use cases
|
|
4
|
+
|
|
5
|
+
### d2l-labs-navigation
|
|
6
|
+
|
|
7
|
+
Add the `d2l-labs-navigation` component, and provide sub elements `d2l-labs-navigation-main-header` & `d2l-labs-navigation-main-footer` (along with their respective slot contents).
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<script type="module">
|
|
11
|
+
import '@brightspace-ui/labs/navigation/navigation.js';
|
|
12
|
+
import '@brightspace-ui/labs/navigation/navigation-main-header.js';
|
|
13
|
+
import '@brightspace-ui/labs/navigation/navigation-main-footer.js';
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<d2l-labs-navigation>
|
|
17
|
+
<d2l-labs-navigation-main-header>
|
|
18
|
+
<div slot="left" class="d2l-labs-navigation-header-left">This should be on the left. As the width changes it shrinks as needed.</div>
|
|
19
|
+
|
|
20
|
+
<div slot="right" class="d2l-labs-navigation-header-right">This should be on the right. It doesn't shrink.</div>
|
|
21
|
+
</d2l-labs-navigation-main-header>
|
|
22
|
+
<d2l-labs-navigation-main-footer>
|
|
23
|
+
<div slot="main" class="d2l-labs-navigation-s-main-wrapper">Stuff goes in here (small border above and below)</div>
|
|
24
|
+
</d2l-labs-navigation-main-footer>
|
|
25
|
+
</d2l-labs-navigation>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
***Relevant CSS class name:***
|
|
29
|
+
* `--d2l-labs-navigation-shadow-drop-border-display`: The default value is `block`, but this property can be used to hide the shadow by setting it to `none`.
|
|
30
|
+
|
|
31
|
+
### d2l-labs-navigation-immersive
|
|
32
|
+
|
|
33
|
+
Add the `d2l-labs-navigation-immersive` component, providing values for the `backLinkHref` & `backLinkText`. Additionally, you may override any of the 3 slots (`left`, `middle`, `right`).
|
|
34
|
+
Please note that overridding the `left` slot will prevent the Back link from displaying. This should only be done in very specialized cases.
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<script type="module">
|
|
38
|
+
import '@brightspace-ui/labs/navigation/navigation-immersive.js';
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<d2l-labs-navigation-immersive back-link-href="https://www.d2l.com" back-link-text="Back to D2L">
|
|
42
|
+
<div class="d2l-typography d2l-body-standard" slot="middle">
|
|
43
|
+
<p>Economics 101</p>
|
|
44
|
+
</div>
|
|
45
|
+
<div slot="right">
|
|
46
|
+
...
|
|
47
|
+
</div>
|
|
48
|
+
</d2l-labs-navigation-immersive>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Optionally:
|
|
52
|
+
|
|
53
|
+
- The max-width can be configured to match the max-width used by the LE by setting `widthType` to `normal`
|
|
54
|
+
- Overflow can be enabled to facilitate components like dropdowns by including the `allow-overflow` boolean attribute
|
|
55
|
+
- A shorter version of the back text can be provided by setting the `back-link-text-short` attribute
|
|
56
|
+
|
|
57
|
+
## Secondary Components
|
|
58
|
+
|
|
59
|
+
> These are the components that make up the Primary Components. There might be an edge case or two where it makes sense to use one of these in isolation,
|
|
60
|
+
> but **PLEASE STRONGLY CONSIDER** using a Primary Component instead.
|
|
61
|
+
|
|
62
|
+
### d2l-labs-navigation-band
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<script type="module">
|
|
66
|
+
import '@brightspace-ui/labs/navigation/navigation-band.js';
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<d2l-labs-navigation-band></d2l-labs-navigation-band>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The `d2l-labs-navigation-band` also includes a `slot` with a custom scrollbar and fading effects, but this has only been designed for the `d2l-organization-consortium-tabs` and should not be used for anything else right now.
|
|
73
|
+
|
|
74
|
+
***Relevant CSS class name:***
|
|
75
|
+
* `--d2l-branding-primary-color`: Used to customize the colour of the top navigation band.
|
|
76
|
+
* `--d2l-labs-navigation-band-slot-height`: When using the slot, this is needed to setup the proper scrollbar and fading effects.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### d2l-labs-navigation-main-header
|
|
81
|
+
|
|
82
|
+
Add the `d2l-labs-navigation-main-header` component, and provide elements for the `left` and `right` slots.
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<script type="module">
|
|
86
|
+
import '@brightspace-ui/labs/navigation/navigation-main-header.js';
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<d2l-labs-navigation-main-header>
|
|
90
|
+
<div slot="left"></div>
|
|
91
|
+
<div slot="right"></div>
|
|
92
|
+
</d2l-labs-navigation-main-header>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
***Slots:***
|
|
96
|
+
|
|
97
|
+
* `left` (required): Secondary content (that will shrink with page size) oriented on the left side of the centre gutter (whitespace)
|
|
98
|
+
* `right` (required): Primary content (that will not shrink with page size) oriented on the right side of the centre gutter (whitespace)
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### d2l-labs-navigation-main-footer
|
|
103
|
+
|
|
104
|
+
Add the `d2l-labs-navigation-main-footer` component, and provide elements for the `main` slot.
|
|
105
|
+
|
|
106
|
+
```html
|
|
107
|
+
<script type="module">
|
|
108
|
+
import '@brightspace-ui/labs/navigation/navigation-main-footer.js';
|
|
109
|
+
</script>
|
|
110
|
+
|
|
111
|
+
<d2l-labs-navigation-main-footer>
|
|
112
|
+
<div slot="main"></div>
|
|
113
|
+
</d2l-labs-navigation-main-footer>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
***Slots:***
|
|
117
|
+
|
|
118
|
+
* `main` (required): Primary content of the footer. The footer will change in size to accommodate its contents
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### d2l-labs-navigation-link
|
|
123
|
+
|
|
124
|
+
(Placeholder for now)
|
|
125
|
+
|
|
126
|
+
***Relevant CSS class name:***
|
|
127
|
+
* `--d2l-labs-navigation-primary-color`: Used to customize the hover colour of the highlight links and buttons
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### d2l-labs-navigation-button-icon
|
|
132
|
+
|
|
133
|
+
`<d2l-labs-navigation-button-icon>` provides a button with an icon and optional text.
|
|
134
|
+
|
|
135
|
+
### Properties
|
|
136
|
+
|
|
137
|
+
| Property | Type | Description |
|
|
138
|
+
|--|--|--|
|
|
139
|
+
| `disabled` | Boolean | Disables the button |
|
|
140
|
+
| `text` | String, required | Text for the button |
|
|
141
|
+
| `icon` | String | Preset icon key (e.g. `tier1:gear`) |
|
|
142
|
+
| `no-highlight-border` | Boolean | Visually hides the highlight border when hovered/focused |
|
|
143
|
+
| `text-hidden` | Boolean | Visually hides the text |
|
|
144
|
+
| `tooltip-position` | String | Position of the tooltip ( top\|bottom\|left\|right ); default is bottom |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### d2l-labs-navigation-link-icon
|
|
149
|
+
|
|
150
|
+
Similar to `<d2l-labs-navigation-button-icon>`, a link that comes with an icon and optional text.
|
|
151
|
+
|
|
152
|
+
### Properties
|
|
153
|
+
|
|
154
|
+
| Property | Type | Description |
|
|
155
|
+
|--|--|--|
|
|
156
|
+
| `href` | String, required | URL or URL fragment of the link |
|
|
157
|
+
| `text` | String, required | Text for the button |
|
|
158
|
+
| `icon` | String | Preset icon key (e.g. `tier1:gear`) |
|
|
159
|
+
| `text-hidden` | Boolean | Visually hides the text |
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### d2l-labs-navigation-iterator
|
|
164
|
+
|
|
165
|
+
```html
|
|
166
|
+
<script type="module">
|
|
167
|
+
import '@brightspace-ui/labs/navigation/navigation-iterator.js';
|
|
168
|
+
</script>
|
|
169
|
+
|
|
170
|
+
<d2l-labs-navigation-iterator></d2l-labs-navigation-iterator>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
There is only one slot, and the default button text can be hidden with `hide-text`.
|
|
174
|
+
|
|
175
|
+
```html
|
|
176
|
+
<d2l-labs-navigation-iterator hide-text>
|
|
177
|
+
<span>User 1 of 17</span>
|
|
178
|
+
</d2l-labs-navigation-iterator>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The iterator button labels can be customized with `previous-text` and `next-text`.
|
|
182
|
+
|
|
183
|
+
```html
|
|
184
|
+
<d2l-labs-navigation-iterator previous-text="Back" next-text="Forward"></d2l-labs-navigation-iterator>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The iterator buttons can be hidden completely with `no-next` or `no-previous`.
|
|
188
|
+
|
|
189
|
+
```html
|
|
190
|
+
<d2l-labs-navigation-iterator no-next></d2l-labs-navigation-iterator>
|
|
191
|
+
<d2l-labs-navigation-iterator no-previous></d2l-labs-navigation-iterator>
|
|
192
|
+
```
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import '@brightspace-ui/core/components/colors/colors.js';
|
|
2
|
+
import { centererStyles, guttersStyles } from './navigation-styles.js';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
|
|
5
|
+
function useCustomScroll() {
|
|
6
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
7
|
+
return (userAgent.indexOf('win') > -1 && userAgent.indexOf('mobile') === -1);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class NavigationBand extends LitElement {
|
|
11
|
+
|
|
12
|
+
static get styles() {
|
|
13
|
+
return [centererStyles, guttersStyles, css`
|
|
14
|
+
:host {
|
|
15
|
+
background: linear-gradient(180deg, var(--d2l-branding-primary-color, var(--d2l-color-celestine)) var(--d2l-labs-navigation-band-slot-height, 1.5rem), #ffffff 0%);
|
|
16
|
+
display: block;
|
|
17
|
+
min-height: 4px;
|
|
18
|
+
position: relative; /* Needed for Firefox */
|
|
19
|
+
}
|
|
20
|
+
:host([hidden]) {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.d2l-labs-navigation-scroll {
|
|
25
|
+
overflow-x: auto;
|
|
26
|
+
overflow-y: hidden;
|
|
27
|
+
scroll-behavior: smooth;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.d2l-labs-navigation-scroll[data-custom-scroll] {
|
|
31
|
+
/* Firefox Styles */
|
|
32
|
+
scrollbar-color: var(--d2l-color-galena) var(--d2l-color-sylvite);
|
|
33
|
+
scrollbar-width: thin;
|
|
34
|
+
}
|
|
35
|
+
/* Webkit Styles */
|
|
36
|
+
.d2l-labs-navigation-scroll[data-custom-scroll]::-webkit-scrollbar {
|
|
37
|
+
background-color: var(--d2l-color-sylvite);
|
|
38
|
+
border-radius: 8px;
|
|
39
|
+
height: 9px;
|
|
40
|
+
}
|
|
41
|
+
.d2l-labs-navigation-scroll[data-custom-scroll]::-webkit-scrollbar-thumb {
|
|
42
|
+
background-color: var(--d2l-color-galena);
|
|
43
|
+
border-bottom: 1px solid var(--d2l-color-sylvite);
|
|
44
|
+
border-radius: 8px;
|
|
45
|
+
border-top: 1px solid var(--d2l-color-sylvite);
|
|
46
|
+
}
|
|
47
|
+
/* Faded edges styles */
|
|
48
|
+
.d2l-labs-navigation-scroll-before,
|
|
49
|
+
.d2l-labs-navigation-scroll-after {
|
|
50
|
+
height: 100%;
|
|
51
|
+
max-height: var(--d2l-labs-navigation-band-slot-height, 1.5rem);
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
position: absolute;
|
|
54
|
+
top: 0;
|
|
55
|
+
width: 2.439%; /* should match gutter width */
|
|
56
|
+
z-index: 2;
|
|
57
|
+
}
|
|
58
|
+
.d2l-labs-navigation-scroll-before {
|
|
59
|
+
background: linear-gradient(to right, var(--d2l-branding-primary-color, var(--d2l-color-celestine)), transparent);
|
|
60
|
+
left: 0;
|
|
61
|
+
}
|
|
62
|
+
.d2l-labs-navigation-scroll-after {
|
|
63
|
+
background: linear-gradient(to left, var(--d2l-branding-primary-color, var(--d2l-color-celestine)), transparent);
|
|
64
|
+
right: 0;
|
|
65
|
+
}
|
|
66
|
+
/* Styles to ensure the right padding is respected when scrolling */
|
|
67
|
+
.d2l-labs-navigation-centerer {
|
|
68
|
+
line-height: 0;
|
|
69
|
+
position: relative;
|
|
70
|
+
}
|
|
71
|
+
.d2l-labs-navigation-gutters {
|
|
72
|
+
display: inline-block;
|
|
73
|
+
position: unset;
|
|
74
|
+
vertical-align: top;
|
|
75
|
+
}
|
|
76
|
+
@media (max-width: 615px) {
|
|
77
|
+
.d2l-labs-navigation-scroll-before,
|
|
78
|
+
.d2l-labs-navigation-scroll-after {
|
|
79
|
+
width: 15px;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
@media (min-width: 1230px) {
|
|
83
|
+
.d2l-labs-navigation-scroll-before,
|
|
84
|
+
.d2l-labs-navigation-scroll-after {
|
|
85
|
+
width: 30px;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
constructor() {
|
|
92
|
+
super();
|
|
93
|
+
this._customScroll = useCustomScroll();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
connectedCallback() {
|
|
97
|
+
super.connectedCallback();
|
|
98
|
+
this.addEventListener('d2l-labs-navigation-band-slot-scroll-request', this._handleScrollRequest);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
disconnectedCallback() {
|
|
102
|
+
super.disconnectedCallback();
|
|
103
|
+
this.removeEventListener('d2l-labs-navigation-band-slot-scroll-request', this._handleScrollRequest);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
render() {
|
|
107
|
+
return html`
|
|
108
|
+
<div class="d2l-labs-navigation-centerer">
|
|
109
|
+
<div class="d2l-labs-navigation-scroll" ?data-custom-scroll="${this._customScroll}">
|
|
110
|
+
<div class="d2l-labs-navigation-scroll-before"></div>
|
|
111
|
+
<div class="d2l-labs-navigation-scroll-after"></div>
|
|
112
|
+
<div class="d2l-labs-navigation-gutters">
|
|
113
|
+
<slot></slot>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
_handleScrollRequest(e) {
|
|
121
|
+
e.stopPropagation();
|
|
122
|
+
const dir = document.documentElement.getAttribute('dir') || 'ltr';
|
|
123
|
+
if (dir.toLowerCase() === 'rtl') {
|
|
124
|
+
return; // We turn off this feature in RTL due to browser inconsistencies
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const scroll = this.shadowRoot.querySelector('.d2l-labs-navigation-scroll');
|
|
128
|
+
requestAnimationFrame(() => {
|
|
129
|
+
scroll.scrollLeft = e.detail.pointToCenter - 0.5 * scroll.offsetWidth;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
customElements.define('d2l-labs-navigation-band', NavigationBand);
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import '@brightspace-ui/core/components/colors/colors.js';
|
|
2
|
+
import '@brightspace-ui/core/components/icons/icon.js';
|
|
3
|
+
import '@brightspace-ui/core/components/tooltip/tooltip.js';
|
|
4
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
5
|
+
import { highlightBorderStyles, highlightButtonStyles } from './navigation-styles.js';
|
|
6
|
+
import { FocusMixin } from '@brightspace-ui/core/mixins/focus-mixin.js';
|
|
7
|
+
import { getUniqueId } from '@brightspace-ui/core/helpers/uniqueId.js';
|
|
8
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Navigation button with an icon and text.
|
|
12
|
+
*/
|
|
13
|
+
class NavigationButtonIcon extends FocusMixin(LitElement) {
|
|
14
|
+
|
|
15
|
+
static get properties() {
|
|
16
|
+
return {
|
|
17
|
+
/**
|
|
18
|
+
* Disables the button
|
|
19
|
+
* @type {boolean}
|
|
20
|
+
*/
|
|
21
|
+
disabled: { reflect: true, type: Boolean },
|
|
22
|
+
/**
|
|
23
|
+
* REQUIRED: Preset icon key (e.g. "tier1:gear")
|
|
24
|
+
* @type {string}
|
|
25
|
+
*/
|
|
26
|
+
icon: { type: String },
|
|
27
|
+
/**
|
|
28
|
+
* Position of the icon.
|
|
29
|
+
* @type {'start'|'end'}
|
|
30
|
+
*/
|
|
31
|
+
iconPosition: { attribute: 'icon-position', type: String },
|
|
32
|
+
/**
|
|
33
|
+
* Visually hides the highlight border when hovered/focused
|
|
34
|
+
* @type {boolean}
|
|
35
|
+
*/
|
|
36
|
+
noHighlightBorder: { attribute: 'no-highlight-border', type: Boolean },
|
|
37
|
+
/**
|
|
38
|
+
* REQUIRED: Text for the button
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
text: { type: String },
|
|
42
|
+
/**
|
|
43
|
+
* Visually hides the text but still accessible
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
*/
|
|
46
|
+
textHidden: { attribute: 'text-hidden', type: Boolean },
|
|
47
|
+
/**
|
|
48
|
+
* Offset of the tooltip
|
|
49
|
+
* @type {Number}
|
|
50
|
+
*/
|
|
51
|
+
tooltipOffset: { attribute: 'tooltip-offset', type: Number },
|
|
52
|
+
/**
|
|
53
|
+
* Position of the tooltip
|
|
54
|
+
* @type {'top'|'bottom'|'left'|'right'}
|
|
55
|
+
*/
|
|
56
|
+
tooltipPosition: { attribute: 'tooltip-position', type: String }
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static get styles() {
|
|
61
|
+
return [highlightBorderStyles, highlightButtonStyles, css`
|
|
62
|
+
:host {
|
|
63
|
+
display: inline-block;
|
|
64
|
+
height: 100%;
|
|
65
|
+
}
|
|
66
|
+
:host([hidden]) {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
`];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
constructor() {
|
|
73
|
+
super();
|
|
74
|
+
this.disabled = false;
|
|
75
|
+
this.iconPosition = 'start';
|
|
76
|
+
this.noHighlightBorder = false;
|
|
77
|
+
this.textHidden = false;
|
|
78
|
+
this._buttonId = getUniqueId();
|
|
79
|
+
this.tooltipPosition = 'bottom';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static get focusElementSelector() {
|
|
83
|
+
return 'button';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
render() {
|
|
87
|
+
const { ariaLabel, id, text, tooltip } = this._getRenderSettings();
|
|
88
|
+
const highlightBorder = (!this.disabled && !this.noHighlightBorder) ? html`<span class="d2l-labs-navigation-highlight-border"></span>` : nothing;
|
|
89
|
+
const icon = html`<d2l-icon icon="${this.icon}"></d2l-icon>`;
|
|
90
|
+
return html`
|
|
91
|
+
<button id="${ifDefined(id)}" ?disabled="${this.disabled}" aria-label="${ifDefined(ariaLabel)}" type="button">
|
|
92
|
+
${highlightBorder}
|
|
93
|
+
${this.iconPosition === 'start' ? icon : nothing}
|
|
94
|
+
${text}
|
|
95
|
+
${this.iconPosition === 'end' ? icon : nothing}
|
|
96
|
+
</button>
|
|
97
|
+
${tooltip}
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_getRenderSettings() {
|
|
102
|
+
if (this.textHidden) {
|
|
103
|
+
return {
|
|
104
|
+
ariaLabel: this.text,
|
|
105
|
+
id: this._buttonId,
|
|
106
|
+
text: nothing,
|
|
107
|
+
tooltip: html`<d2l-tooltip close-on-click for="${this._buttonId}" for-type="label" position="${this.tooltipPosition}" offset="${ifDefined(this.tooltipOffset)}" class="vdiff-target">${this.text}</d2l-tooltip>`
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
ariaLabel: undefined,
|
|
112
|
+
id: undefined,
|
|
113
|
+
text: this.text,
|
|
114
|
+
tooltip: nothing
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
customElements.define('d2l-labs-navigation-button-icon', NavigationButtonIcon);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { css, html, LitElement } from 'lit';
|
|
2
|
+
import { highlightBorderStyles, highlightButtonStyles } from './navigation-styles.js';
|
|
3
|
+
import { DropdownOpenerMixin } from '@brightspace-ui/core/components/dropdown/dropdown-opener-mixin.js';
|
|
4
|
+
|
|
5
|
+
class NavigationDropdownButtonCustom extends DropdownOpenerMixin(LitElement) {
|
|
6
|
+
|
|
7
|
+
static get styles() {
|
|
8
|
+
return [highlightBorderStyles, highlightButtonStyles, css`
|
|
9
|
+
:host {
|
|
10
|
+
display: inline-block;
|
|
11
|
+
height: 100%;
|
|
12
|
+
position: relative;
|
|
13
|
+
}
|
|
14
|
+
:host([hidden]) {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
`];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
render() {
|
|
21
|
+
return html`
|
|
22
|
+
<button type="button">
|
|
23
|
+
<span class="d2l-labs-navigation-highlight-border"></span>
|
|
24
|
+
<slot name="opener"></slot>
|
|
25
|
+
</button>
|
|
26
|
+
<slot></slot>
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getOpenerElement() {
|
|
31
|
+
return this.shadowRoot?.querySelector('button');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
customElements.define('d2l-labs-navigation-dropdown-button-custom', NavigationDropdownButtonCustom);
|