@salesforcedevs/mrkt-components 0.41.0-alpha.8 → 0.41.0-alpha.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/mrkt-components",
3
- "version": "0.41.0-alpha.8",
3
+ "version": "0.41.0-alpha.9",
4
4
  "description": "Marketing Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -35,7 +35,7 @@
35
35
  align-items: center;
36
36
  width: 100%;
37
37
  text-align: center;
38
- z-index: 1;
38
+ z-index: 3;
39
39
  padding: 0 var(--dx-g-page-padding-horizontal);
40
40
  }
41
41
 
@@ -65,7 +65,7 @@ span {
65
65
  display: flex;
66
66
  flex-direction: row;
67
67
  justify-content: space-between;
68
- z-index: 100;
68
+ z-index: 2;
69
69
  }
70
70
 
71
71
  img {
@@ -6,7 +6,8 @@ import { toJson } from "utils/normalizers";
6
6
 
7
7
  export default class SubNavBar extends MatchMediaElement {
8
8
  @api subscribeHref!: string;
9
- @api containerQuery: string = "body";
9
+ @api containerId: string = "body";
10
+ @api showAtId?: string;
10
11
 
11
12
  @api
12
13
  get navItems() {
@@ -33,7 +34,12 @@ export default class SubNavBar extends MatchMediaElement {
33
34
  private sectionsObserver!: IntersectionObserver;
34
35
 
35
36
  private get containerElement(): HTMLElement {
36
- return document.querySelector(this.containerQuery) as HTMLElement;
37
+ return document.getElementById(this.containerId) as HTMLElement;
38
+ }
39
+
40
+ private get showAtElement(): HTMLElement {
41
+ const id = this.showAtId || this.hashIds[0];
42
+ return document.getElementById(id) as HTMLElement;
37
43
  }
38
44
 
39
45
  private get className(): string {
@@ -71,19 +77,18 @@ export default class SubNavBar extends MatchMediaElement {
71
77
  super.connectedCallback();
72
78
  this.observeSectionIntersections();
73
79
  this.onPageScroll();
74
- this.containerElement.addEventListener("scroll", this.onPageScroll);
80
+ this.containerElement?.addEventListener("scroll", this.onPageScroll);
75
81
  }
76
82
 
77
83
  disconnectedCallback(): void {
78
84
  super.disconnectedCallback();
79
85
  this.sectionsObserver.disconnect();
80
- this.containerElement.removeEventListener("scroll", this.onPageScroll);
86
+ this.containerElement?.removeEventListener("scroll", this.onPageScroll);
81
87
  }
82
88
 
83
89
  private onPageScroll = () => {
84
- const firstSection = document.getElementById(this.hashIds[0]);
85
- if (firstSection) {
86
- this.isVisible = firstSection.getBoundingClientRect().y <= 1;
90
+ if (this.showAtElement) {
91
+ this.isVisible = this.showAtElement.getBoundingClientRect().y <= 1;
87
92
  }
88
93
  };
89
94