@salesforcedevs/dx-components 0.43.2-alpha2 → 0.43.3-tree-selected-scroll-2
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 +1 -1
- package/src/modules/base-elements/sidebarBase/sidebarBase.ts +25 -0
- package/src/modules/dx/cardBlogPost/cardBlogPost.css +1 -1
- package/src/modules/dx/cardContent/cardContent.css +1 -1
- package/src/modules/dx/cardTrailheadModule/cardTrailheadModule.css +1 -1
- package/src/modules/dx/cardVideoPreview/cardVideoPreview.css +1 -1
- package/src/modules/dx/cardVideoPreview/cardVideoPreview.html +0 -1
- package/src/modules/dx/cardVideoPreview/cardVideoPreview.ts +1 -1
- package/src/modules/dx/section/section.css +1 -1
- package/src/modules/dx/section/section.ts +9 -9
- package/src/modules/dx/sidebar/sidebar.html +1 -0
- package/src/modules/dx/sidebar/sidebar.ts +3 -2
- package/src/modules/dx/sidebarOld/sidebarOld.html +2 -1
- package/src/modules/dx/sidebarOld/sidebarOld.ts +3 -2
- package/src/modules/dx/treeItem/treeItem.ts +20 -0
- package/src/modules/dx/vimeoPlayer/vimeoPlayer.html +1 -1
- package/src/modules/helpers/card/card.css +16 -21
- package/src/modules/utils/browser/browser.ts +19 -0
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LightningElement } from "lwc";
|
|
2
|
+
|
|
3
|
+
const HEIGHT_OF_SIDEBAR_ITEM = 32;
|
|
4
|
+
|
|
5
|
+
export class SidebarBase extends LightningElement {
|
|
6
|
+
/*Scroll to selected tree item */
|
|
7
|
+
private onSelectedItemRendered(event: CustomEvent) {
|
|
8
|
+
event.preventDefault();
|
|
9
|
+
const selectedTreeItem = event.detail.element;
|
|
10
|
+
if (selectedTreeItem) {
|
|
11
|
+
const sidebarContent = this.template.querySelector(
|
|
12
|
+
".sidebar-content-tree"
|
|
13
|
+
);
|
|
14
|
+
if (sidebarContent) {
|
|
15
|
+
sidebarContent.scrollTo({
|
|
16
|
+
top:
|
|
17
|
+
selectedTreeItem.offsetTop +
|
|
18
|
+
HEIGHT_OF_SIDEBAR_ITEM + // add height of sidebar item
|
|
19
|
+
HEIGHT_OF_SIDEBAR_ITEM * 2, // add height of 2 more items so that user can see at least two more items after selected item
|
|
20
|
+
behavior: "smooth"
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -2,7 +2,7 @@ import { LightningElement, api } from "lwc";
|
|
|
2
2
|
|
|
3
3
|
export default class CardVideoPreview extends LightningElement {
|
|
4
4
|
@api body?: string | null = null;
|
|
5
|
-
@api datetime
|
|
5
|
+
@api datetime!: string;
|
|
6
6
|
@api featured?: boolean = false;
|
|
7
7
|
@api href!: string;
|
|
8
8
|
@api imgAlt?: string;
|
|
@@ -3,16 +3,16 @@ import cx from "classnames";
|
|
|
3
3
|
import { toDxColor } from "utils/css";
|
|
4
4
|
|
|
5
5
|
export default class Section extends LightningElement {
|
|
6
|
-
@api backgroundColor
|
|
7
|
-
@api dark
|
|
6
|
+
@api backgroundColor?: string | null = "transparent";
|
|
7
|
+
@api dark?: boolean = false;
|
|
8
8
|
@api headingLevel: "1" | "2" | "3" | "4" | "5" = "3";
|
|
9
|
-
@api label?: string;
|
|
10
|
-
@api subtitle?: string;
|
|
11
|
-
@api textAlign
|
|
12
|
-
@api title?: string;
|
|
13
|
-
@api topGraphic
|
|
14
|
-
@api graphicOverlap
|
|
15
|
-
@api bottomGraphic
|
|
9
|
+
@api label?: string | null = null;
|
|
10
|
+
@api subtitle?: string | null = null;
|
|
11
|
+
@api textAlign?: "center" | "left" = "left";
|
|
12
|
+
@api title?: string | null = null;
|
|
13
|
+
@api topGraphic?: boolean = false;
|
|
14
|
+
@api graphicOverlap?: boolean = false;
|
|
15
|
+
@api bottomGraphic?: boolean = false;
|
|
16
16
|
|
|
17
17
|
private get style(): string {
|
|
18
18
|
return `--dx-c-section-background-color: ${toDxColor(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cx from "classnames";
|
|
2
2
|
import { track as trackAnalytics } from "dx/instrumentation";
|
|
3
|
-
import {
|
|
3
|
+
import { api, track } from "lwc";
|
|
4
4
|
import {
|
|
5
5
|
TreeNode,
|
|
6
6
|
SidebarGtmAction,
|
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
import { getSidebarSearchParams } from "utils/coveo";
|
|
10
10
|
import { toJson } from "utils/normalizers";
|
|
11
11
|
import SidebarSearch from "dx/sidebarSearch";
|
|
12
|
+
import { SidebarBase } from "base-elements/sidebarBase";
|
|
12
13
|
|
|
13
14
|
const MOBILE_SIZE_MATCH = "768px";
|
|
14
15
|
const TOGGLE_BUTTON_LABEL = "Toggle Sidebar";
|
|
15
16
|
|
|
16
|
-
export default class Sidebar extends
|
|
17
|
+
export default class Sidebar extends SidebarBase {
|
|
17
18
|
@api coveoOrganizationId!: string;
|
|
18
19
|
@api coveoPublicAccessToken!: string;
|
|
19
20
|
@api coveoSearchHub!: string;
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
></dx-input>
|
|
50
50
|
</div>
|
|
51
51
|
</div>
|
|
52
|
-
<div class="sidebar-content" if:true={anyResultMatch}>
|
|
52
|
+
<div class="sidebar-content sidebar-content-tree" if:true={anyResultMatch}>
|
|
53
53
|
<dx-tree
|
|
54
54
|
for:each={filteredTrees}
|
|
55
55
|
for:item="tree"
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
tree-root={tree.tree}
|
|
58
58
|
onselect={onSelect}
|
|
59
59
|
value={value}
|
|
60
|
+
onselecteditemrendered={onSelectedItemRendered}
|
|
60
61
|
></dx-tree>
|
|
61
62
|
</div>
|
|
62
63
|
<dx-empty-state
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import cx from "classnames";
|
|
2
2
|
import { track } from "dx/instrumentation";
|
|
3
|
-
import {
|
|
3
|
+
import { api } from "lwc";
|
|
4
4
|
|
|
5
5
|
import { TreeNode, SidebarGtmAction } from "typings/custom";
|
|
6
6
|
import { toJson } from "utils/normalizers";
|
|
7
|
+
import { SidebarBase } from "base-elements/sidebarBase";
|
|
7
8
|
|
|
8
9
|
const WAIT_TIME = 500;
|
|
9
10
|
const MOBILE_SIZE_MATCH = "768px";
|
|
10
11
|
const TOGGLE_BUTTON_LABEL = "Toggle Sidebar";
|
|
11
12
|
|
|
12
|
-
export default class Sidebar extends
|
|
13
|
+
export default class Sidebar extends SidebarBase {
|
|
13
14
|
@api header: string = "";
|
|
14
15
|
|
|
15
16
|
@api
|
|
@@ -2,6 +2,7 @@ import { LightningElement, api } from "lwc";
|
|
|
2
2
|
import { InternalTreeNode } from "typings/custom";
|
|
3
3
|
import { track } from "dx/instrumentation";
|
|
4
4
|
import { SidebarGtmAction } from "typings/custom";
|
|
5
|
+
import { isInViewport } from "utils/browser";
|
|
5
6
|
|
|
6
7
|
const DEFAULT_TARGET = "_self";
|
|
7
8
|
|
|
@@ -61,6 +62,25 @@ export default class TreeItem extends LightningElement {
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
renderedCallback(): void {
|
|
66
|
+
this.sendEventToParentIfSelected();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private sendEventToParentIfSelected(): void {
|
|
70
|
+
/**
|
|
71
|
+
* This is to send selected element reference to parent if it's not visible in the viewport
|
|
72
|
+
* Parent component will use the elements offsetTop scrollTo that element's position
|
|
73
|
+
*/
|
|
74
|
+
if (this.isSelected) {
|
|
75
|
+
const element = this.template.querySelector("dx-tree-tile");
|
|
76
|
+
if (element && !isInViewport(element)) {
|
|
77
|
+
this.fireEvent("selecteditemrendered", {
|
|
78
|
+
element
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
64
84
|
private onIconClick(event: CustomEvent): void {
|
|
65
85
|
const isSelectAction = false;
|
|
66
86
|
this.doExpand(isSelectAction);
|
|
@@ -184,6 +184,18 @@ a.dx-card-base:hover dx-card-title {
|
|
|
184
184
|
|
|
185
185
|
/* Desktop Only */
|
|
186
186
|
@media screen and (min-width: 1024px) {
|
|
187
|
+
.dx-card-base_layout-horizontal .dx-card-base_borderless-image_link {
|
|
188
|
+
align-self: flex-start;
|
|
189
|
+
flex-shrink: 0;
|
|
190
|
+
width: 0;
|
|
191
|
+
height: unset;
|
|
192
|
+
margin-right: var(--dx-g-card-img-spacing);
|
|
193
|
+
margin-bottom: unset;
|
|
194
|
+
padding-top: unset;
|
|
195
|
+
padding-right: 45%;
|
|
196
|
+
padding-bottom: 22.5%;
|
|
197
|
+
}
|
|
198
|
+
|
|
187
199
|
.dx-card-base_featured dx-card-title {
|
|
188
200
|
--dx-c-card-title-letter-spacing: -0.6px;
|
|
189
201
|
--dx-c-card-title-font-size: 32px;
|
|
@@ -204,21 +216,6 @@ a.dx-card-base:hover dx-card-title {
|
|
|
204
216
|
}
|
|
205
217
|
}
|
|
206
218
|
|
|
207
|
-
/* Tablet + Desktop Only */
|
|
208
|
-
@media screen and (min-width: 764px) {
|
|
209
|
-
.dx-card-base_layout-horizontal .dx-card-base_borderless-image_link {
|
|
210
|
-
align-self: flex-start;
|
|
211
|
-
flex-shrink: 0;
|
|
212
|
-
width: 0;
|
|
213
|
-
height: unset;
|
|
214
|
-
margin-right: var(--dx-g-card-img-spacing);
|
|
215
|
-
margin-bottom: unset;
|
|
216
|
-
padding-top: unset;
|
|
217
|
-
padding-right: 45%;
|
|
218
|
-
padding-bottom: 22.5%;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
219
|
/* Tablet */
|
|
223
220
|
@media screen and (max-width: 1024px) {
|
|
224
221
|
:host {
|
|
@@ -226,6 +223,10 @@ a.dx-card-base:hover dx-card-title {
|
|
|
226
223
|
--dx-g-card-img-spacing: 16px;
|
|
227
224
|
}
|
|
228
225
|
|
|
226
|
+
.dx-card-base_borderless-image {
|
|
227
|
+
min-height: unset;
|
|
228
|
+
}
|
|
229
|
+
|
|
229
230
|
/* text resp */
|
|
230
231
|
.dx-text-body-2,
|
|
231
232
|
.dx-text-body-3 {
|
|
@@ -255,9 +256,3 @@ a.dx-card-base:hover dx-card-title {
|
|
|
255
256
|
font-size: var(--dx-g-text-sm);
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
|
-
|
|
259
|
-
@media screen and (max-width: 764px) {
|
|
260
|
-
.dx-card-base_borderless-image {
|
|
261
|
-
min-height: unset;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns whether given element is in browser viewport or not
|
|
3
|
+
*/
|
|
4
|
+
function isInViewport(element: HTMLElement): boolean {
|
|
5
|
+
if (element) {
|
|
6
|
+
const rect = element.getBoundingClientRect();
|
|
7
|
+
return (
|
|
8
|
+
rect.top >= 0 &&
|
|
9
|
+
rect.left >= 0 &&
|
|
10
|
+
rect.bottom <=
|
|
11
|
+
(window.innerHeight || document.documentElement.clientHeight) &&
|
|
12
|
+
rect.right <=
|
|
13
|
+
(window.innerWidth || document.documentElement.clientWidth)
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { isInViewport };
|