@salesforcedevs/docs-components 1.3.127 → 1.3.130-alpha.1

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/docs-components",
3
- "version": "1.3.127",
3
+ "version": "1.3.130-alpha.1",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -24,5 +24,5 @@
24
24
  "@types/lodash.orderby": "^4.6.7",
25
25
  "@types/lodash.uniqby": "^4.7.7"
26
26
  },
27
- "gitHead": "74db03edcd4920e328787e4174126ba6ee39a1dc"
27
+ "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
28
28
  }
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @lwc/lwc/no-document-query */
1
2
  import { LightningElement, api, track } from "lwc";
2
3
  import { closest } from "kagekiri";
3
4
  import { toJson } from "dxUtils/normalizers";
@@ -91,9 +92,6 @@ export default class ContentLayout extends LightningElement {
91
92
 
92
93
  private searchSyncer = new SearchSyncer({
93
94
  callbacks: {
94
- onUrlChange: (nextSearchString: string): void => {
95
- this.updateHighlightsAndSearch(nextSearchString);
96
- },
97
95
  onSearchChange: (nextSearchString: string): void => {
98
96
  this.dispatchHighlightChange(
99
97
  new URLSearchParams(nextSearchString).get("q") || ""
@@ -204,7 +202,10 @@ export default class ContentLayout extends LightningElement {
204
202
  const docHeaderEl = document.querySelector(
205
203
  ".sticky-doc-header"
206
204
  ) as HTMLElement;
207
- const docPhaseEl = document.querySelector("doc-phase") as HTMLElement;
205
+
206
+ const docPhaseEl = this.template
207
+ .querySelector("[name=doc-phase]")!
208
+ .assignedElements()[0] as HTMLSlotElement;
208
209
 
209
210
  if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
210
211
  console.warn("One or more required elements are missing.");
@@ -237,6 +238,30 @@ export default class ContentLayout extends LightningElement {
237
238
  : globalNavHeight + docHeaderHeight
238
239
  }px`
239
240
  );
241
+
242
+ // Adjust scroll margin for doc headings when doc phase is present
243
+ const docHeadingEls = Array.from(
244
+ document.querySelectorAll("doc-heading")
245
+ );
246
+ docHeadingEls.forEach((docHeadingEl) => {
247
+ docHeadingEl.style.scrollMarginTop = `${
248
+ globalNavHeight +
249
+ docHeaderHeight +
250
+ docPhaseEl.offsetHeight
251
+ }px`;
252
+ });
253
+
254
+ // Adjust right nav bar position when doc phase is present
255
+ const rightNavBarEl =
256
+ this.template.querySelector(".right-nav-bar");
257
+
258
+ if (rightNavBarEl) {
259
+ rightNavBarEl.style.top = `${
260
+ globalNavHeight +
261
+ docHeaderHeight +
262
+ docPhaseEl.offsetHeight
263
+ }px`;
264
+ }
240
265
  }
241
266
  });
242
267
  };
@@ -252,15 +277,25 @@ export default class ContentLayout extends LightningElement {
252
277
  return;
253
278
  }
254
279
  this.disconnectObserver();
255
- this.observer = new IntersectionObserver((entries) => {
256
- entries.forEach(
257
- (entry) =>
258
- (this.anchoredElements[
259
- entry.target.getAttribute("id")
260
- ].intersect = entry.isIntersecting)
261
- );
262
- this.calculateActualSection();
263
- });
280
+
281
+ const globalNavOffset = `-${getComputedStyle(
282
+ document.documentElement
283
+ ).getPropertyValue("--dx-g-doc-header-main-nav-height")}`;
284
+
285
+ this.observer = new IntersectionObserver(
286
+ (entries) => {
287
+ entries.forEach(
288
+ (entry) =>
289
+ (this.anchoredElements[
290
+ entry.target.getAttribute("id")
291
+ ].intersect = entry.isIntersecting)
292
+ );
293
+ this.calculateActualSection();
294
+ },
295
+ {
296
+ rootMargin: globalNavOffset.trim()
297
+ }
298
+ );
264
299
 
265
300
  // Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
266
301
  const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
@@ -279,10 +314,6 @@ export default class ContentLayout extends LightningElement {
279
314
  }
280
315
  };
281
316
 
282
- onSidebarClick() {
283
- this.resetScrollThreshold();
284
- }
285
-
286
317
  onSlotChange(event: Event): void {
287
318
  const slotElements = (
288
319
  event.target as HTMLSlotElement
@@ -338,15 +369,52 @@ export default class ContentLayout extends LightningElement {
338
369
  let { hash } = window.location;
339
370
  if (hash) {
340
371
  hash = hash.substr(1);
372
+
373
+ const docHeaderEl = document.querySelector(
374
+ ".sticky-doc-header"
375
+ ) as HTMLElement;
376
+ const globalNavEl = document.querySelector(
377
+ "hgf-c360nav"
378
+ ) as HTMLElement;
379
+ const contextNavEl = document.querySelector(
380
+ "hgf-c360contextnav"
381
+ ) as HTMLElement;
382
+
383
+ const headerHeight =
384
+ docHeaderEl.offsetHeight +
385
+ globalNavEl.offsetHeight +
386
+ contextNavEl.offsetHeight;
387
+
388
+ const docPhaseEl = this.template
389
+ .querySelector("[name=doc-phase]")!
390
+ .assignedElements()[0] as HTMLSlotElement;
391
+
392
+ const offset = docPhaseEl
393
+ ? headerHeight + docPhaseEl.offsetHeight
394
+ : headerHeight;
395
+
341
396
  for (const headingElement of headingElements) {
342
397
  if (headingElement.getAttribute("id") === hash) {
343
- headingElement.scrollIntoView({ behavior: "auto" });
398
+ this.scrollIntoViewWithOffset(headingElement, offset);
344
399
  break;
345
400
  }
346
401
  }
347
402
  }
348
403
  }
349
404
 
405
+ private scrollIntoViewWithOffset(
406
+ headingElement: HTMLElement,
407
+ offset: number
408
+ ) {
409
+ window.scrollTo({
410
+ behavior: "auto",
411
+ top:
412
+ headingElement.getBoundingClientRect().top -
413
+ document.body.getBoundingClientRect().top -
414
+ offset
415
+ });
416
+ }
417
+
350
418
  private calculateActualSection(): void {
351
419
  const currentScrollPosition = document.documentElement.scrollTop;
352
420
  const id = Object.keys(this.anchoredElements).find(
@@ -2,7 +2,6 @@
2
2
  <div class="container">
3
3
  <doc-phase
4
4
  if:true={docPhaseInfo}
5
- max-width-size="large"
6
5
  doc-phase-info={docPhaseInfo}
7
6
  ></doc-phase>
8
7
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  :host {
6
6
  --doc-c-phase-top: 0;
7
+ --doc-c-phase-container-align-items: flex-start;
7
8
 
8
9
  position: sticky;
9
10
  top: var(--doc-c-phase-top);
@@ -15,32 +16,25 @@
15
16
  .doc-phase-container {
16
17
  display: flex;
17
18
  flex-direction: column;
18
- align-items: center;
19
+ align-items: var(--doc-c-phase-container-align-items);
19
20
  padding-left: var(--dx-g-global-header-padding-horizontal);
20
21
  padding-right: var(--dx-g-global-header-padding-horizontal);
21
22
  width: 100%;
22
23
  border: none;
23
24
  }
24
25
 
25
- .max-width-container {
26
- max-width: var(--dx-g-doc-content-body-max-width);
27
- }
28
-
29
- .doc-phase-max-width-large .max-width-container {
30
- max-width: var(--dx-g-doc-content-max-width);
31
- }
32
-
33
26
  .doc-phase-title-container {
34
27
  display: flex;
35
28
  flex-direction: row;
36
29
  align-items: center;
30
+ width: 100%;
37
31
  }
38
32
 
39
33
  dx-button {
40
34
  margin-left: auto;
41
35
  }
42
36
 
43
- /*
37
+ /*
44
38
  NOTE: Here we are assuming that indicator height won't go beyond 1000px.
45
39
 
46
40
  It's one of the suggested way to achieve the expand/collapse animation
@@ -1,30 +1,28 @@
1
1
  <template>
2
2
  <div class={className} part="container">
3
- <div class="max-width-container">
4
- <div class="doc-phase-title-container">
5
- <dx-icon
6
- class="doc-status-icon doc-phase-icon"
7
- symbol="recipe"
8
- size="large"
9
- color="status-icon-color"
10
- ></dx-icon>
11
- <p class="doc-status-title doc-phase-title dx-text-body-3">
12
- {docPhaseTitle}
13
- </p>
14
- <dx-button
15
- variant="inline"
16
- onclick={onButtonClick}
17
- aria-label={hideBodyText}
18
- >
19
- {hideBodyText}
20
- </dx-button>
21
- </div>
22
- <!--
3
+ <div class="doc-phase-title-container">
4
+ <dx-icon
5
+ class="doc-status-icon doc-phase-icon"
6
+ symbol="recipe"
7
+ size="large"
8
+ color="status-icon-color"
9
+ ></dx-icon>
10
+ <p class="doc-status-title doc-phase-title dx-text-body-3">
11
+ {docPhaseTitle}
12
+ </p>
13
+ <dx-button
14
+ variant="inline"
15
+ onclick={onButtonClick}
16
+ aria-label={hideBodyText}
17
+ >
18
+ {hideBodyText}
19
+ </dx-button>
20
+ </div>
21
+ <!--
23
22
  NOTE: Here we are rendering mark up using lwc:dom & innerHTML
24
23
  option instead of slots because the html markup will come as a
25
24
  property to the component from a configuration
26
25
  -->
27
- <span lwc:dom="manual" class={bodyClassName}></span>
28
- </div>
26
+ <span lwc:dom="manual" class={bodyClassName}></span>
29
27
  </div>
30
28
  </template>
@@ -9,9 +9,6 @@ export default class Phase extends LightningElement {
9
9
 
10
10
  isBodyHidden = false;
11
11
 
12
- @api
13
- maxWidthSize: "small" | "large" = "small";
14
-
15
12
  get docPhaseTitle() {
16
13
  return this.docPhaseInfo?.title;
17
14
  }
@@ -33,8 +30,7 @@ export default class Phase extends LightningElement {
33
30
  return cx(
34
31
  "doc-status-base",
35
32
  "doc-status-container",
36
- "doc-phase-container",
37
- `doc-phase-max-width-${this.maxWidthSize}`
33
+ "doc-phase-container"
38
34
  );
39
35
  }
40
36
 
package/LICENSE DELETED
@@ -1,12 +0,0 @@
1
- Copyright (c) 2020, Salesforce.com, Inc.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
8
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
-
10
- * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.