@salesforcedevs/docs-components 1.34.0-docs-feedback → 1.34.0-docs-feedback-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.34.0-docs-feedback",
3
+ "version": "1.34.0-docs-feedback-1",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -77,12 +77,6 @@ header:not(.has-brand) > .header_l2 {
77
77
  border-top: 1px solid var(--dx-g-gray-90);
78
78
  }
79
79
 
80
- @media (max-width: 1280px) {
81
- .no-header-content {
82
- border-top: 0;
83
- }
84
- }
85
-
86
80
  @media (max-width: 768px) {
87
81
  .header_l2 {
88
82
  padding: 0;
@@ -74,6 +74,13 @@ export default class Header extends HeaderBase {
74
74
  return (this.hideDocHeader && !this.mobile) || this.showDocDivider;
75
75
  }
76
76
 
77
+ private get isDocsPath(): boolean {
78
+ return (
79
+ window.location.pathname.includes("/docs/") &&
80
+ window.location.pathname !== "/docs/apis"
81
+ );
82
+ }
83
+
77
84
  connectedCallback(): void {
78
85
  super.connectedCallback();
79
86
  this.tabletMatchMedia = window.matchMedia(
@@ -83,9 +90,7 @@ export default class Header extends HeaderBase {
83
90
  this.tabletMatchMedia.addEventListener("change", this.onTabletChange);
84
91
 
85
92
  if (
86
- (!this.shouldHideHeader &&
87
- window.location.pathname.includes("/docs/") &&
88
- window.location.pathname !== "/docs/apis") ||
93
+ (!this.shouldHideHeader && this.isDocsPath) ||
89
94
  window.location.pathname ===
90
95
  "/tableau/embedding-playground/overview" ||
91
96
  isStorybook()
@@ -109,6 +114,12 @@ export default class Header extends HeaderBase {
109
114
  );
110
115
  }
111
116
 
117
+ renderedCallback(): void {
118
+ if (this.hideDocHeader) {
119
+ this.shouldRender = !this.shouldHideHeader && this.isDocsPath;
120
+ }
121
+ }
122
+
112
123
  private onTabletChange = (e: MediaQueryListEvent | MediaQueryList) =>
113
124
  (this.tablet = e.matches);
114
125
 
@@ -10,32 +10,30 @@ import type { OptionWithLink, TreeNode } from "typings/custom";
10
10
  */
11
11
  const TOPIC_TYPE_SPEC = "spec";
12
12
 
13
- function findFirstContentDescendant(node: TreeNode): TreeNode | undefined {
14
- for (const child of node.children ?? []) {
15
- const isSpec =
16
- (child as { topicType?: string }).topicType === TOPIC_TYPE_SPEC;
17
- const isExternal = child.link?.target === "_blank";
18
- if (isSpec || isExternal) {
19
- continue;
20
- }
21
-
22
- if (child.link?.href) {
23
- return child;
24
- }
13
+ /**
14
+ * Returns the parent's first direct child when it is a markdown content
15
+ * page or undefined otherwise.
16
+ */
17
+ function firstChildContentPage(node: TreeNode): TreeNode | undefined {
18
+ const firstChild = node.children?.[0];
19
+ if (!firstChild) {
20
+ return undefined;
21
+ }
25
22
 
26
- const descendant = findFirstContentDescendant(child);
27
- if (descendant) {
28
- return descendant;
29
- }
23
+ const isSpec =
24
+ (firstChild as { topicType?: string }).topicType === TOPIC_TYPE_SPEC;
25
+ const isExternal = firstChild.link?.target === "_blank";
26
+ if (isSpec || isExternal || !firstChild.link?.href) {
27
+ return undefined;
30
28
  }
31
29
 
32
- return undefined;
30
+ return firstChild;
33
31
  }
34
32
 
35
33
  /**
36
34
  * Translates per-topic `topicType` into the generic `showForwardArrow` flag
37
35
  * that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc),
38
- * and redirects content-less parent topics to their first content descendant.
36
+ * and redirects content-less parent topics whose first child is a content page
39
37
  */
40
38
  function decorateTopics(
41
39
  topics: Array<TreeNode & { topicType?: string }> | undefined
@@ -49,15 +47,17 @@ function decorateTopics(
49
47
  decorated.children = decorateTopics(decorated.children);
50
48
  }
51
49
 
52
- // Redirect parent topics without their own content to their first
53
- // available content descendant.
50
+ /** Redirect a parent that has no content of its own to its first child
51
+ * but only when that first child is itself a content page
52
+ */
54
53
  const isContentlessParent =
55
54
  !!decorated.children?.length && !decorated.link?.href;
56
55
 
57
56
  if (isContentlessParent) {
58
- const firstContent = findFirstContentDescendant(topic);
59
- if (firstContent?.link) {
60
- decorated.link = { ...firstContent.link };
57
+ const firstChild = firstChildContentPage(topic);
58
+ if (firstChild?.link) {
59
+ decorated.link = { ...firstChild.link };
60
+ decorated.redirectToChild = true;
61
61
  }
62
62
  }
63
63