@salesforcedevs/docs-components 1.3.124-old-version-banner-6 → 1.3.124-old-version-banner-8

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.124-old-version-banner-6",
3
+ "version": "1.3.124-old-version-banner-8",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -5,13 +5,13 @@ doc-phase {
5
5
  }
6
6
 
7
7
  /* We need to apply some borders when there are two doc phases */
8
- doc-phase:not(:only-child):first-child::part(container) {
9
- border-top: 1px solid #f9e3b6 !important;
8
+ doc-phase:not(:only-of-type)::part(container) {
9
+ border-top: 1px solid var(--dx-g-yellow-vibrant-90);
10
10
  }
11
11
 
12
12
  doc-phase:nth-child(2)::part(container) {
13
- border-top: 1px solid #f9e3b6 !important;
14
- border-bottom: 1px solid #f9e3b6 !important;
13
+ border-top: 1px solid var(--dx-g-yellow-vibrant-90);
14
+ border-bottom: 1px solid var(--dx-g-yellow-vibrant-90);
15
15
  }
16
16
 
17
17
  /* We don't want second component to sticky as we need to handle different cases like position */
@@ -23,10 +23,11 @@
23
23
  ></doc-phase>
24
24
  <doc-phase
25
25
  slot="version-banner"
26
- if:true={oldVersionInfo}
26
+ if:true={showVersionBanner}
27
27
  doc-phase-info={oldVersionInfo}
28
- dismissible="true"
29
28
  icon-name="warning"
29
+ dismissible="true"
30
+ ondismissphase={handleDismissVersionBanner}
30
31
  ></doc-phase>
31
32
  <div slot="sidebar-header" class="version-picker">
32
33
  <template if:true={isVersionEnabled}>
@@ -26,6 +26,8 @@ import {
26
26
  oldReferenceIdNewReferenceIdMap
27
27
  } from "./constants";
28
28
  import { restoreScroll } from "dx/scrollManager";
29
+ import { DocPhaseInfo } from "typings/custom";
30
+ import { oldVersionDocInfo } from "docUtils/utils";
29
31
 
30
32
  export default class AmfReference extends LightningElement {
31
33
  @api breadcrumbs?: string | null | undefined = null;
@@ -39,6 +41,7 @@ export default class AmfReference extends LightningElement {
39
41
  @api tocOptions?: string;
40
42
  @track navigation = [];
41
43
  @track versions: Array<ReferenceVersion> = [];
44
+ @track showVersionBanner = false;
42
45
 
43
46
  // Update this to update what component gets rendered in the content block
44
47
  @track
@@ -48,13 +51,6 @@ export default class AmfReference extends LightningElement {
48
51
  return !!this._referenceSetConfig?.versions?.length;
49
52
  }
50
53
 
51
- /*TODO: Get the info based on logic*/
52
- @api oldVersionInfo = {
53
- title: "Newer Version Available",
54
- body: `This content describes an older version of this product. <a style="font-weight: bold;" href="https://developer.salesforce.com/">
55
- View Latest</a>`
56
- };
57
-
58
54
  /**
59
55
  * Gives if the currently selected reference is spec based or not
60
56
  */
@@ -109,6 +105,12 @@ export default class AmfReference extends LightningElement {
109
105
  this.versions = this.getVersions();
110
106
  }
111
107
  this.selectedVersion = selectedVersion;
108
+ if (
109
+ this.isSpecBasedReference(this._currentReferenceId) &&
110
+ this.oldVersionInfo
111
+ ) {
112
+ this.showVersionBanner = true;
113
+ }
112
114
  }
113
115
 
114
116
  // This is to check if the url is hash based and redirect if needed
@@ -289,6 +291,17 @@ export default class AmfReference extends LightningElement {
289
291
  return referenceId;
290
292
  }
291
293
 
294
+ private get oldVersionInfo(): DocPhaseInfo | null {
295
+ let info = null;
296
+ if (this.versions.length > 1 && this.selectedVersion) {
297
+ const currentGAVersionRef = this.versions[0];
298
+ if (this.selectedVersion.id !== currentGAVersionRef.id) {
299
+ info = oldVersionDocInfo(currentGAVersionRef.link.href);
300
+ }
301
+ }
302
+ return info;
303
+ }
304
+
292
305
  /**
293
306
  * @returns versions to be shown in the dropdown
294
307
  * For markdown based specs, Adds selected markdown topic url to same references
@@ -1242,6 +1255,9 @@ export default class AmfReference extends LightningElement {
1242
1255
  }
1243
1256
 
1244
1257
  this.versions = this.getVersions();
1258
+ if (this.oldVersionInfo) {
1259
+ this.showVersionBanner = true;
1260
+ }
1245
1261
  this.updateDocPhase();
1246
1262
  this.selectedSidebarValue = window.location.pathname;
1247
1263
  }
@@ -1258,6 +1274,10 @@ export default class AmfReference extends LightningElement {
1258
1274
  );
1259
1275
  }
1260
1276
 
1277
+ handleDismissVersionBanner() {
1278
+ this.showVersionBanner = false;
1279
+ }
1280
+
1261
1281
  private updateNavTitleMetaTag(navTitle = ""): void {
1262
1282
  // this is required to update the nav title meta tag.
1263
1283
  // eslint-disable-next-line @lwc/lwc/no-document-query
@@ -402,3 +402,10 @@ samp,
402
402
  mark {
403
403
  background-color: var(--dx-g-yellow-vibrant-90);
404
404
  }
405
+
406
+ /* offset page jump link due to fixed header */
407
+ [id] {
408
+ scroll-margin-top: calc(
409
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
410
+ );
411
+ }
@@ -40,6 +40,13 @@ dx-toc {
40
40
  display: block;
41
41
  }
42
42
 
43
+ /* offset page jump link due to fixed header */
44
+ ::slotted(doc-heading) {
45
+ scroll-margin-top: calc(
46
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
47
+ );
48
+ }
49
+
43
50
  .content {
44
51
  display: flex;
45
52
  position: relative;
@@ -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";
@@ -204,7 +205,10 @@ export default class ContentLayout extends LightningElement {
204
205
  const docHeaderEl = document.querySelector(
205
206
  ".sticky-doc-header"
206
207
  ) as HTMLElement;
207
- const docPhaseEl = document.querySelector("doc-phase") as HTMLElement;
208
+
209
+ const docPhaseEl = this.template
210
+ .querySelector("[name=doc-phase]")!
211
+ .assignedElements()[0] as HTMLSlotElement;
208
212
 
209
213
  if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
210
214
  console.warn("One or more required elements are missing.");
@@ -237,6 +241,30 @@ export default class ContentLayout extends LightningElement {
237
241
  : globalNavHeight + docHeaderHeight
238
242
  }px`
239
243
  );
244
+
245
+ // Adjust scroll margin for doc headings when doc phase is present
246
+ const docHeadingEls = Array.from(
247
+ document.querySelectorAll("doc-heading")
248
+ );
249
+ docHeadingEls.forEach((docHeadingEl) => {
250
+ docHeadingEl.style.scrollMarginTop = `${
251
+ globalNavHeight +
252
+ docHeaderHeight +
253
+ docPhaseEl.offsetHeight
254
+ }px`;
255
+ });
256
+
257
+ // Adjust right nav bar position when doc phase is present
258
+ const rightNavBarEl =
259
+ this.template.querySelector(".right-nav-bar");
260
+
261
+ if (rightNavBarEl) {
262
+ rightNavBarEl.style.top = `${
263
+ globalNavHeight +
264
+ docHeaderHeight +
265
+ docPhaseEl.offsetHeight
266
+ }px`;
267
+ }
240
268
  }
241
269
  });
242
270
  };
@@ -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,28 +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-max-width);
27
- }
28
-
29
26
  .doc-phase-title-container {
30
27
  display: flex;
31
28
  flex-direction: row;
32
29
  align-items: center;
30
+ width: 100%;
33
31
  }
34
32
 
35
33
  dx-button {
36
34
  margin-left: auto;
37
35
  }
38
36
 
39
- /*
37
+ /*
40
38
  NOTE: Here we are assuming that indicator height won't go beyond 1000px.
41
39
 
42
40
  It's one of the suggested way to achieve the expand/collapse animation
@@ -1,39 +1,37 @@
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={iconName}
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
- if:false={dismissible}
16
- variant="inline"
17
- onclick={onShowHide}
18
- aria-label={hideBodyText}
19
- >
20
- {hideBodyText}
21
- </dx-button>
22
- <dx-icon
23
- if:true={dismissible}
24
- class="dismissible-icon"
25
- onclick={onDismiss}
26
- symbol="close"
27
- size="large"
28
- color="status-icon-color"
29
- ></dx-icon>
30
- </div>
31
- <!--
32
- NOTE: Here we are rendering mark up using lwc:dom & innerHTML
33
- option instead of slots because the html markup will come as a
34
- property to the component from a configuration
35
- -->
36
- <span lwc:dom="manual" class={bodyClassName}></span>
3
+ <div class="doc-phase-title-container">
4
+ <dx-icon
5
+ class="doc-status-icon doc-phase-icon"
6
+ symbol={iconName}
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
+ if:false={dismissible}
15
+ variant="inline"
16
+ onclick={onShowHide}
17
+ aria-label={hideBodyText}
18
+ >
19
+ {hideBodyText}
20
+ </dx-button>
21
+ <dx-icon
22
+ class="dismissible-icon"
23
+ onclick={onDismiss}
24
+ if:true={dismissible}
25
+ symbol="close"
26
+ size="large"
27
+ color="status-icon-color"
28
+ ></dx-icon>
37
29
  </div>
30
+ <!--
31
+ NOTE: Here we are rendering mark up using lwc:dom & innerHTML
32
+ option instead of slots because the html markup will come as a
33
+ property to the component from a configuration
34
+ -->
35
+ <span lwc:dom="manual" class={bodyClassName}></span>
38
36
  </div>
39
37
  </template>
@@ -184,28 +184,7 @@ export default class DocXmlContent extends LightningElementWithState<{
184
184
  ));
185
185
 
186
186
  if (anchorEl) {
187
- const globalNavHeader = document.querySelector(
188
- ".global-nav-container"
189
- ) as HTMLElement;
190
- const docHeader = document.querySelector(
191
- "doc-header"
192
- ) as HTMLElement;
193
- const headerHeight = globalNavHeader.offsetHeight;
194
- const docHeaderHeight = docHeader.offsetHeight;
195
- const rect = anchorEl.getBoundingClientRect();
196
-
197
- // Calculate the scroll position required to bring the element into view
198
- const scrollTop =
199
- window.pageYOffset || document.documentElement.scrollTop;
200
- const scrollX = rect.left + window.pageXOffset;
201
- const scrollY =
202
- rect.top + scrollTop - (headerHeight + docHeaderHeight); // subtract the header height from the top position
203
-
204
- // Scroll to the calculated position
205
- window.scrollTo({
206
- top: scrollY,
207
- left: scrollX
208
- });
187
+ anchorEl.scrollIntoView();
209
188
 
210
189
  this.setState({ internalLinkClicked: false });
211
190
  }