@salesforcedevs/docs-components 1.22.0-responsive-4 → 1.26.0-alpha

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.22.0-responsive-4",
3
+ "version": "1.26.0-alpha",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -1 +1,35 @@
1
1
  @import "docHelpers/contentLayoutStyle";
2
+
3
+ /* New Theme Test Styles */
4
+ @keyframes scroll-text {
5
+ 0% {
6
+ transform: translateX(100%);
7
+ }
8
+
9
+ 100% {
10
+ transform: translateX(-100%);
11
+ }
12
+ }
13
+
14
+ .new-theme-test {
15
+ background: linear-gradient(135deg, #d4cd00 0%, #83d400 50%, #19a700 100%);
16
+ color: white;
17
+ padding: 12px 24px;
18
+ margin: 0 var(--dx-g-global-header-padding-horizontal, 24px);
19
+ margin-top: var(--dx-g-spacing-md, 16px);
20
+ font-weight: 600;
21
+ font-size: 16px;
22
+ box-shadow: 0 4px 12px rgb(4 212 0 / 30%);
23
+ overflow: hidden;
24
+ white-space: nowrap;
25
+ border-radius: 8px;
26
+ text-align: center;
27
+ max-width: var(--dx-g-doc-content-max-width);
28
+ margin-left: auto;
29
+ margin-right: auto;
30
+ }
31
+
32
+ .new-theme-banner span {
33
+ display: inline-block;
34
+ animation: scroll-text 10s linear infinite;
35
+ }
@@ -23,12 +23,32 @@
23
23
  <div class="version-wrapper">
24
24
  <slot name="version-banner"></slot>
25
25
  </div>
26
+ <div class="new-theme-test">
27
+ <span>
28
+ ✨ SFDocs is Awesome 🥰 New Theme Update inside Component!!
29
+ </span>
30
+ </div>
26
31
  <div class="content-body-container">
27
32
  <div class="content-body">
28
33
  <doc-breadcrumbs
29
34
  lwc:if={showBreadcrumbs}
30
35
  breadcrumbs={breadcrumbs}
31
36
  ></doc-breadcrumbs>
37
+ <div class="read" lwc:if={showReadingTime}>
38
+ <svg
39
+ xmlns="http://www.w3.org/2000/svg"
40
+ width="18"
41
+ height="18"
42
+ viewBox="0 0 52 52"
43
+ >
44
+ <g fill="#3e3e3c">
45
+ <path
46
+ d="m26 2c-13.2 0-24 10.8-24 24s10.8 24 24 24 24-10.8 24-24-10.8-24-24-24z m0 42c-9.9 0-18-8.1-18-18s8.1-18 18-18 18 8.1 18 18-8.1 18-18 18z m3.4-17.8c-0.3-0.3-0.4-0.7-0.4-1.1v-9.6c0-0.8-0.7-1.5-1.5-1.5h-3c-0.8 0-1.5 0.7-1.5 1.5v12.1c0 0.4 0.2 0.8 0.4 1.1l7.4 7.4c0.6 0.6 1.5 0.6 2.1 0l2.1-2.1c0.6-0.6 0.6-1.5 0-2.1l-5.6-5.7z"
47
+ ></path>
48
+ </g>
49
+ </svg>
50
+ {readingTime} minute read
51
+ </div>
32
52
  <slot onslotchange={onSlotChange}></slot>
33
53
  <doc-sprig-survey
34
54
  lwc:if={shouldDisplayFeedback}
@@ -45,6 +45,8 @@ export default class ContentLayout extends LightningElement {
45
45
  // This is needed for now to prevent failing snapshot tests due to links in the footer
46
46
  @api showFooter = false;
47
47
 
48
+ @api readingTime?: number;
49
+
48
50
  @api
49
51
  get breadcrumbs() {
50
52
  return this._breadcrumbs;
@@ -137,6 +139,10 @@ export default class ContentLayout extends LightningElement {
137
139
  );
138
140
  }
139
141
 
142
+ get showReadingTime(): boolean {
143
+ return this.readingTime != null && this.readingTime > 0;
144
+ }
145
+
140
146
  connectedCallback(): void {
141
147
  const hasParentHighlightListener = closest(
142
148
  "doc-xml-content",
@@ -28,6 +28,21 @@
28
28
  lwc:if={showBreadcrumbs}
29
29
  breadcrumbs={breadcrumbs}
30
30
  ></doc-breadcrumbs>
31
+ <div class="read" lwc:if={showReadingTime}>
32
+ <svg
33
+ xmlns="http://www.w3.org/2000/svg"
34
+ width="18"
35
+ height="18"
36
+ viewBox="0 0 52 52"
37
+ >
38
+ <g fill="#3e3e3c">
39
+ <path
40
+ d="m26 2c-13.2 0-24 10.8-24 24s10.8 24 24 24 24-10.8 24-24-10.8-24-24-24z m0 42c-9.9 0-18-8.1-18-18s8.1-18 18-18 18 8.1 18 18-8.1 18-18 18z m3.4-17.8c-0.3-0.3-0.4-0.7-0.4-1.1v-9.6c0-0.8-0.7-1.5-1.5-1.5h-3c-0.8 0-1.5 0.7-1.5 1.5v12.1c0 0.4 0.2 0.8 0.4 1.1l7.4 7.4c0.6 0.6 1.5 0.6 2.1 0l2.1-2.1c0.6-0.6 0.6-1.5 0-2.1l-5.6-5.7z"
41
+ ></path>
42
+ </g>
43
+ </svg>
44
+ {readingTime} minute read
45
+ </div>
31
46
  <slot onslotchange={onSlotChange}></slot>
32
47
  <doc-sprig-survey
33
48
  lwc:if={shouldDisplayFeedback}
@@ -12,6 +12,7 @@
12
12
  bail-href={sidebarFooterContent.bailHref}
13
13
  bail-label={sidebarFooterContent.bailLabel}
14
14
  show-footer={enableFooter}
15
+ reading-time={computedReadingTime}
15
16
  >
16
17
  <doc-phase
17
18
  slot="version-banner"
@@ -41,6 +41,7 @@ export default class DocXmlContent extends LightningElementWithState<{
41
41
  }> {
42
42
  @api apiDomain = "https://developer.salesforce.com";
43
43
  @api hideFooter = false;
44
+ @api displayReadingTime = false;
44
45
 
45
46
  @api
46
47
  get allLanguages(): Array<Language> {
@@ -76,6 +77,10 @@ export default class DocXmlContent extends LightningElementWithState<{
76
77
  return !this.hideFooter;
77
78
  }
78
79
 
80
+ private get computedReadingTime(): number | undefined {
81
+ return this.displayReadingTime ? this.readingTime : undefined;
82
+ }
83
+
79
84
  private searchSyncer = new SearchSyncer({
80
85
  callbacks: {
81
86
  onSearchChange: (nextSearchString: string): void => {
@@ -147,6 +152,7 @@ export default class DocXmlContent extends LightningElementWithState<{
147
152
 
148
153
  @track private pageReference: PageReference = {};
149
154
  @track breadcrumbs: Array<Breadcrumb> = [];
155
+ @track readingTime?: number;
150
156
 
151
157
  constructor() {
152
158
  super();
@@ -493,6 +499,7 @@ export default class DocXmlContent extends LightningElementWithState<{
493
499
  }
494
500
 
495
501
  this.docContent = data.content;
502
+ this.calculateReadingTime(data.content);
496
503
  this.addMetatags();
497
504
  this.setState({
498
505
  isFetchingDocument: false
@@ -515,6 +522,7 @@ export default class DocXmlContent extends LightningElementWithState<{
515
522
 
516
523
  if (data) {
517
524
  this.docContent = data.content;
525
+ this.calculateReadingTime(data.content);
518
526
  this.addMetatags();
519
527
 
520
528
  if (!this.pageReference.hash) {
@@ -760,4 +768,32 @@ export default class DocXmlContent extends LightningElementWithState<{
760
768
  private get showVersionPicker(): boolean {
761
769
  return !this.disableVersion;
762
770
  }
771
+
772
+ private calculateReadingTime(content: string): void {
773
+ if (!this.displayReadingTime) {
774
+ this.readingTime = undefined;
775
+ return;
776
+ }
777
+
778
+ if (!content) {
779
+ this.readingTime = undefined;
780
+ return;
781
+ }
782
+
783
+ // Strip HTML tags and get text content
784
+ const div = document.createElement("div");
785
+ div.innerHTML = DOMPurify.sanitize(content);
786
+ const textContent = div.textContent || div.innerText || "";
787
+
788
+ // Count words (split by whitespace and filter out empty strings)
789
+ const wordCount = textContent
790
+ .trim()
791
+ .split(/\s+/)
792
+ .filter((word) => word.length > 0).length;
793
+
794
+ // Calculate reading time: (wordCount / 240) + 1, rounded
795
+ const readingTimeMinutes = Math.round(wordCount / 240 + 1);
796
+ this.readingTime =
797
+ readingTimeMinutes > 0 ? readingTimeMinutes : undefined;
798
+ }
763
799
  }
@@ -24,6 +24,19 @@ doc-breadcrumbs {
24
24
  margin-bottom: var(--dx-g-spacing-2xl);
25
25
  }
26
26
 
27
+ .read {
28
+ display: flex;
29
+ align-items: center;
30
+ gap: var(--dx-g-spacing-xs, 8px);
31
+ margin-bottom: var(--dx-g-spacing-lg, 16px);
32
+ color: var(--dx-g-gray-30, #3e3e3c);
33
+ font-size: var(--dx-g-font-size-sm, 14px);
34
+ }
35
+
36
+ .read svg {
37
+ flex-shrink: 0;
38
+ }
39
+
27
40
  dx-sidebar,
28
41
  dx-sidebar-old {
29
42
  --dx-c-sidebar-vertical-padding: var(--dx-g-spacing-md);
@@ -92,7 +105,6 @@ dx-toc {
92
105
  max-width: 1000px;
93
106
  flex: 1;
94
107
  width: 0;
95
- overflow-wrap: break-word;
96
108
  }
97
109
 
98
110
  .is-sticky {
@@ -131,9 +143,10 @@ dx-toc {
131
143
  }
132
144
 
133
145
  .content-body-container {
146
+ padding-right: 0;
147
+ padding-left: 0;
134
148
  overflow-x: auto;
135
149
  margin-bottom: calc(var(--dx-g-spacing-5xl) + 4px);
136
- padding: 0 var(--dx-g-spacing-lg);
137
150
  }
138
151
 
139
152
  .left-nav-bar {