@salesforcedevs/dx-components 1.20.14-cb-loading-1 → 1.20.14-cb-plain-loading-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/dx-components",
3
- "version": "1.20.14-cb-loading-1",
3
+ "version": "1.20.14-cb-plain-loading-1",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -30,11 +30,13 @@ pre {
30
30
  }
31
31
 
32
32
  div.dx-theme-dark {
33
+ position: relative;
33
34
  border: var(--dx-g-dark-mode-toggle-button-border);
34
35
  border-radius: var(--dx-code-block-toolbar-border-radius, 0.3em);
35
36
  }
36
37
 
37
38
  div.dx-theme-light {
39
+ position: relative;
38
40
  border: var(--dx-g-light-mode-code-block-border);
39
41
  border-radius: var(--dx-code-block-toolbar-border-radius, 0.3em);
40
42
  }
@@ -131,56 +133,20 @@ dx-button {
131
133
  --dx-g-button-icon-color: var(--dx-g-cloud-blue-vibrant-50);
132
134
  }
133
135
 
134
- .code-loading-skeleton {
135
- padding: 14px 21px;
136
- background-color: #fff;
136
+ .code-block-loading-container {
137
+ position: absolute;
138
+ top: 0;
139
+ left: 0;
140
+ right: 0;
141
+ bottom: 0;
142
+ display: flex;
143
+ align-items: center;
144
+ justify-content: center;
145
+ background-color: rgb(255 255 255 / 90%);
137
146
  border-radius: 0 0 0.3em 0.3em;
138
- overflow: hidden;
139
- height: var(--dx-code-block-height, auto);
140
- }
141
-
142
- .dx-theme-dark .code-loading-skeleton {
143
- background-color: #000;
144
- }
145
-
146
- .skeleton-line {
147
- height: 16px;
148
- background: linear-gradient(
149
- 90deg,
150
- var(--dx-g-gray-80) 25%,
151
- var(--dx-g-gray-70) 50%,
152
- var(--dx-g-gray-80) 75%
153
- );
154
- background-size: 200% 100%;
155
- animation: skeleton-loading 1.5s infinite;
156
- border-radius: 4px;
157
- margin-bottom: 8px;
147
+ z-index: 10;
158
148
  }
159
149
 
160
- .dx-theme-dark .skeleton-line {
161
- background: linear-gradient(
162
- 90deg,
163
- var(--dx-g-blue-natural-30) 25%,
164
- var(--dx-g-blue-natural-40) 50%,
165
- var(--dx-g-blue-natural-30) 75%
166
- );
167
- background-size: 200% 100%;
168
- }
169
-
170
- .skeleton-line.short {
171
- width: 60%;
172
- }
173
-
174
- .skeleton-line.medium {
175
- width: 80%;
176
- }
177
-
178
- @keyframes skeleton-loading {
179
- 0% {
180
- background-position: 200% 0;
181
- }
182
-
183
- 100% {
184
- background-position: -200% 0;
185
- }
150
+ .dx-theme-dark .code-block-loading-container {
151
+ background-color: rgb(0 0 0 / 90%);
186
152
  }
@@ -73,6 +73,9 @@
73
73
  </div>
74
74
  </div>
75
75
  <div class="code-block-content" lwc:dom="manual"></div>
76
+ <div class="code-block-loading-container" if:true={showLoaderUI}>
77
+ <dx-spinner size="large" variant="brand"></dx-spinner>
78
+ </div>
76
79
  </div>
77
80
  </template>
78
81
  <template if:false={codeBlock}>No content provided</template>
@@ -42,6 +42,7 @@ export default class CodeBlock extends LightningElement {
42
42
 
43
43
  private _codeBlockRendered: boolean = false;
44
44
  private _showLoadingIndicator: boolean = false;
45
+ private _loaderHeightSet: boolean = false;
45
46
  private markupLangs = ["visualforce", "html", "xml"];
46
47
  private componentLoaded: boolean = false;
47
48
  private showLanguageDropdown: boolean = false;
@@ -93,6 +94,7 @@ export default class CodeBlock extends LightningElement {
93
94
  }
94
95
  set codeBlock(value: string) {
95
96
  this._codeBlockRendered = false;
97
+ this._loaderHeightSet = false;
96
98
  let match;
97
99
  this._codeBlock = (
98
100
  (match = preTagRegexp.exec(value.trim())) === null
@@ -113,58 +115,58 @@ export default class CodeBlock extends LightningElement {
113
115
  return cx(`dx-theme-${this.theme}`);
114
116
  }
115
117
 
116
- private calculateSkeletonLines(): number {
118
+ get showLoaderUI(): boolean {
119
+ return (
120
+ this.showLoadingIndicator &&
121
+ !this._codeBlockRendered &&
122
+ this._loaderHeightSet
123
+ );
124
+ }
125
+
126
+ private calculateContainerHeight(): number | null {
117
127
  const computedStyle = window.getComputedStyle(this.template.host);
118
128
  const customHeight = computedStyle.getPropertyValue(
119
129
  "--dx-code-block-height"
120
130
  );
121
131
 
132
+ // If custom height is set, use it
122
133
  if (
123
134
  customHeight &&
124
135
  customHeight !== "unset" &&
125
136
  !customHeight.includes("auto")
126
137
  ) {
127
- const heightValue = parseFloat(customHeight);
128
- const lineHeight = 20;
129
- const verticalPadding = 28;
130
- const availableHeight = heightValue - verticalPadding;
131
- return Math.max(1, Math.floor(availableHeight / lineHeight));
138
+ return parseFloat(customHeight);
132
139
  }
133
140
 
134
- return 4; // Default lines
135
- }
141
+ // If no custom height, calculate from number of lines + padding
142
+ if (this.codeBlock) {
143
+ const lines = this.codeBlock.split("\n").length;
144
+ const lineHeight = 20; // px
145
+ const verticalPadding = 28; // 14px top + 14px bottom
146
+ return lines * lineHeight + verticalPadding;
147
+ }
136
148
 
137
- private generateSkeletonHTML(lines: number): string {
138
- const skeletonLines = Array.from({ length: lines }, (_, i) => {
139
- const widthClass =
140
- i % 3 === 0 ? "short" : i % 3 === 1 ? "medium" : "";
141
- return `<div class="skeleton-line ${widthClass}"></div>`;
142
- }).join("");
143
-
144
- return `
145
- <div class="code-loading-skeleton">
146
- ${skeletonLines}
147
- </div>
148
- `;
149
+ return null; // No height calculation possible
149
150
  }
150
151
 
151
- private showLoadingSkeleton(): void {
152
+ private showPlainLoader(): void {
152
153
  if (!this.showLoadingIndicator) {
153
154
  return;
154
155
  }
155
156
 
156
- const codeBlockContent = this.template.querySelector(
157
- ".code-block-content"
158
- );
159
- if (!codeBlockContent) {
160
- return;
161
- }
162
-
163
- // Calculate lines and generate skeleton
164
- const lines = this.calculateSkeletonLines();
165
- const skeletonHTML = this.generateSkeletonHTML(lines);
157
+ const containerHeight = this.calculateContainerHeight();
158
+ if (containerHeight) {
159
+ // Set height on the content container for proper positioning
160
+ const contentContainer = this.template.querySelector(
161
+ ".code-block-content"
162
+ ) as HTMLElement;
163
+ if (contentContainer) {
164
+ contentContainer.style.height = `${containerHeight}px`;
165
+ }
166
166
 
167
- codeBlockContent.innerHTML = skeletonHTML;
167
+ // Mark that loader height is set, which will show the loader
168
+ this._loaderHeightSet = true;
169
+ }
168
170
  }
169
171
 
170
172
  private initializeTheme() {
@@ -184,8 +186,8 @@ export default class CodeBlock extends LightningElement {
184
186
  }
185
187
 
186
188
  async formatCodeBlock() {
187
- // Show loading skeleton immediately
188
- this.showLoadingSkeleton();
189
+ // Show loading indicator immediately
190
+ this.showPlainLoader();
189
191
 
190
192
  const divEl = this.template.querySelector("div.code-block-content");
191
193
  const templateEl = document.createElement("template");
@@ -284,6 +286,8 @@ export default class CodeBlock extends LightningElement {
284
286
  );
285
287
  }
286
288
  }
289
+ // Content is now rendered, hide the loader
290
+ this._codeBlockRendered = true;
287
291
  }
288
292
  }
289
293
 
@@ -372,7 +376,6 @@ export default class CodeBlock extends LightningElement {
372
376
  this.selectedLanguageLabel = this.selectedLanguage.label;
373
377
  this.selectedLanguageId = this.selectedLanguage.id;
374
378
  this.formatCodeBlock();
375
- this._codeBlockRendered = true;
376
379
  }
377
380
 
378
381
  disconnectedCallback(): void {