@salesforcedevs/docs-components 1.28.7-alpha.1 → 1.28.7-alpha.10

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.28.7-alpha.1",
3
+ "version": "1.28.7-alpha.10",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -25,5 +25,5 @@
25
25
  "@types/lodash.orderby": "4.6.9",
26
26
  "@types/lodash.uniqby": "4.7.9"
27
27
  },
28
- "gitHead": "3782e0f52d705901c7307ba5751d1c3297f7ca25"
28
+ "gitHead": "6418874a60d7d6e4404e13517f2aa5c2746b1f39"
29
29
  }
@@ -1 +1,8 @@
1
1
  @import "docHelpers/contentLayoutStyle";
2
+
3
+ /* Reserve sidebar space during load so layout doesn't shift when dx-sidebar or dx-sidebar-old renders. */
4
+ .sidebar-placeholder {
5
+ flex-shrink: 0;
6
+ width: var(--dx-c-sidebar-width, 337px);
7
+ min-height: var(--dx-c-sidebar-height);
8
+ }
@@ -1,32 +1,40 @@
1
1
  <template>
2
2
  <div class="content">
3
- <dx-sidebar-old
4
- lwc:if={useOldSidebar}
5
- class="is-sticky left-nav-bar"
6
- trees={sidebarContent}
7
- value={sidebarValue}
8
- header={sidebarHeader}
9
- ontogglesidebar={onToggleSidebar}
10
- languages={languages}
11
- language={language}
12
- bail-href={bailHref}
13
- bail-label={bailLabel}
14
- dev-center={devCenter}
15
- brand={brand}
16
- empty-state-message={emptyStateMessage}
17
- >
18
- <slot name="sidebar-header" slot="version-picker"></slot>
19
- </dx-sidebar-old>
20
- <dx-sidebar
21
- lwc:else
22
- class="is-sticky left-nav-bar"
23
- trees={sidebarContent}
24
- value={sidebarValue}
25
- header={sidebarHeader}
26
- ontogglesidebar={onToggleSidebar}
27
- >
28
- <slot name="sidebar-header" slot="version-picker"></slot>
29
- </dx-sidebar>
3
+ <template lwc:if={showDataCloudSidebar}>
4
+ <dx-sidebar
5
+ class="is-sticky left-nav-bar"
6
+ trees={sidebarContent}
7
+ value={sidebarValue}
8
+ header={sidebarHeader}
9
+ ontogglesidebar={onToggleSidebar}
10
+ >
11
+ <slot name="sidebar-header" slot="version-picker"></slot>
12
+ </dx-sidebar>
13
+ </template>
14
+ <template lwc:if={showOldSidebar}>
15
+ <dx-sidebar-old
16
+ class="is-sticky left-nav-bar"
17
+ trees={sidebarContent}
18
+ value={sidebarValue}
19
+ header={sidebarHeader}
20
+ ontogglesidebar={onToggleSidebar}
21
+ languages={languages}
22
+ language={language}
23
+ bail-href={bailHref}
24
+ bail-label={bailLabel}
25
+ dev-center={devCenter}
26
+ brand={brand}
27
+ empty-state-message={emptyStateMessage}
28
+ >
29
+ <slot name="sidebar-header" slot="version-picker"></slot>
30
+ </dx-sidebar-old>
31
+ </template>
32
+ <template lwc:if={showSidebarPlaceholder}>
33
+ <div
34
+ class="sidebar-placeholder is-sticky left-nav-bar"
35
+ aria-hidden="true"
36
+ ></div>
37
+ </template>
30
38
  <div class="content-body-doc-phase-container">
31
39
  <div class="doc-phase-wrapper">
32
40
  <slot name="doc-phase"></slot>
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @lwc/lwc/no-document-query */
2
2
  import { LightningElement, api, track } from "lwc";
3
3
  import { closest } from "kagekiri";
4
+ import { fetchHasResults } from "dxUtils/dataCloudSearch";
4
5
  import { toJson, normalizeBoolean } from "dxUtils/normalizers";
5
6
  import { highlightTerms } from "dxUtils/highlight";
6
7
  import { SearchSyncer } from "docUtils/searchSyncer";
@@ -108,9 +109,29 @@ export default class ContentLayout extends LightningElement {
108
109
  );
109
110
  }
110
111
 
112
+ /** Show Data Cloud sidebar only when not using old sidebar and the page has searchable results. */
113
+ protected get showDataCloudSidebar(): boolean {
114
+ return !this.useOldSidebar && this.hasDataCloudResults === true;
115
+ }
116
+
117
+ /** Show legacy sidebar when explicitly requested or when Data Cloud has no results. Don't show until we know (avoids flash). */
118
+ protected get showOldSidebar(): boolean {
119
+ return (
120
+ this.useOldSidebar === true || this.hasDataCloudResults === false
121
+ );
122
+ }
123
+
124
+ /** Show a space-holding placeholder while we're deciding which sidebar to show (avoids layout shift). */
125
+ protected get showSidebarPlaceholder(): boolean {
126
+ return !this.showDataCloudSidebar && !this.showOldSidebar;
127
+ }
128
+
111
129
  @track
112
130
  protected _sidebarContent: unknown;
113
131
 
132
+ @track
133
+ protected hasDataCloudResults: boolean | null = null;
134
+
114
135
  protected _breadcrumbs = null;
115
136
 
116
137
  @track
@@ -181,6 +202,11 @@ export default class ContentLayout extends LightningElement {
181
202
  }
182
203
 
183
204
  connectedCallback(): void {
205
+ if (!this.useOldSidebar) {
206
+ fetchHasResults().then((hasResults: boolean) => {
207
+ this.hasDataCloudResults = hasResults;
208
+ });
209
+ }
184
210
  const hasParentHighlightListener = closest(
185
211
  "doc-xml-content",
186
212
  this.template.host
@@ -257,7 +283,9 @@ export default class ContentLayout extends LightningElement {
257
283
  We have to account for the global nav changing height due to animations.
258
284
  */
259
285
  adjustNavPosition = () => {
260
- const sidebarEl = this.template.querySelector("dx-sidebar-old");
286
+ const sidebarEl =
287
+ this.template.querySelector("dx-sidebar") ||
288
+ this.template.querySelector("dx-sidebar-old");
261
289
  const globalNavEl = document.querySelector(
262
290
  "hgf-c360nav"
263
291
  ) as HTMLElement;
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <div class="content">
3
3
  <dx-sidebar-old
4
+ lwc:if={useOldSidebar}
4
5
  class="is-sticky left-nav-bar"
5
6
  trees={sidebarContent}
6
7
  value={sidebarValue}
@@ -15,6 +16,16 @@
15
16
  >
16
17
  <slot name="sidebar-header" slot="version-picker"></slot>
17
18
  </dx-sidebar-old>
19
+ <dx-sidebar
20
+ lwc:else
21
+ class="is-sticky left-nav-bar"
22
+ trees={sidebarContent}
23
+ value={sidebarValue}
24
+ header={sidebarHeader}
25
+ ontogglesidebar={onToggleSidebar}
26
+ >
27
+ <slot name="sidebar-header" slot="version-picker"></slot>
28
+ </dx-sidebar>
18
29
  <div class="content-body-doc-phase-container">
19
30
  <div class="doc-phase-wrapper">
20
31
  <slot name="doc-phase"></slot>
@@ -251,17 +251,6 @@ export default class DocXmlContent extends LightningElementWithState<{
251
251
  return this.pageReference.deliverable;
252
252
  }
253
253
 
254
- private get useOldSidebar(): boolean {
255
- // Coveo is enabled and the version is greater than 51 (within the latest 3 versions)
256
- // TODO: we need a better fix for version number check
257
- return !(
258
- !this.version?.releaseVersion ||
259
- (this.version?.releaseVersion &&
260
- parseInt(this.version.releaseVersion.replace("v", ""), 10) >=
261
- 53)
262
- );
263
- }
264
-
265
254
  private get pageHeader(): Header {
266
255
  if (!this._pageHeader) {
267
256
  this._pageHeader = document.querySelector("doc-header")!;