@salesforcedevs/docs-components 1.27.22-banner → 1.27.22-banner2

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.27.22-banner",
3
+ "version": "1.27.22-banner2",
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": "c75e59bd77c2c61b628eb54068cd366f486bd6da"
28
+ "gitHead": "3dd735922a8212d293900ef0f0ced8d617e77f1d"
29
29
  }
@@ -2,12 +2,17 @@
2
2
  @import "dxHelpers/text";
3
3
 
4
4
  :host {
5
+ display: block;
6
+
5
7
  --doc-banner-bg: var(--neutral-90, #e5e5e5);
6
8
  --doc-banner-height: 44px;
7
9
  --doc-banner-padding-x-left: 40px;
8
- --doc-banner-padding-x-right: 24px;
9
- --doc-banner-icon-size: 20px;
10
- --doc-banner-close-icon-size: 14px;
10
+ --doc-banner-padding-x-right: var(--dx-g-spacing-lg);
11
+ --doc-banner-icon-size: 18.4615px;
12
+ --doc-banner-icon-frame-width: calc(
13
+ var(--doc-banner-padding-x-left) + var(--doc-banner-icon-size) +
14
+ var(--dx-g-spacing-sm)
15
+ );
11
16
  --doc-banner-close-color: #747474;
12
17
  --doc-banner-primary-bg: #0176d3;
13
18
  --doc-banner-primary-bg-hover: #0160b3;
@@ -15,29 +20,46 @@
15
20
 
16
21
  .doc-notification-bar {
17
22
  display: flex;
18
- align-items: center;
23
+ align-items: flex-start;
19
24
  justify-content: space-between;
20
25
  width: 100%;
21
26
  max-width: 1280px;
22
- height: var(--doc-banner-height);
23
- padding-left: var(--doc-banner-padding-x-left);
24
- padding-right: var(--doc-banner-padding-x-right);
27
+ margin: 0 auto;
28
+ min-height: var(--doc-banner-height);
29
+ padding: 0 var(--doc-banner-padding-x-right) 0
30
+ var(--doc-banner-padding-x-left);
25
31
  background: var(--doc-banner-bg);
26
32
  box-sizing: border-box;
27
33
  }
28
34
 
29
35
  .doc-notification-bar .icon-wrap,
36
+ .doc-notification-bar .main,
37
+ .doc-notification-bar .content,
30
38
  .doc-notification-bar .actions,
31
39
  .doc-notification-bar .close-wrap {
32
40
  display: flex;
33
41
  align-items: center;
42
+ }
43
+
44
+ .doc-notification-bar .icon-wrap,
45
+ .doc-notification-bar .close-wrap {
34
46
  flex-shrink: 0;
35
47
  }
36
48
 
49
+ .doc-notification-bar .main {
50
+ flex: 1 1 0;
51
+ min-width: 0;
52
+ align-self: flex-start;
53
+ padding: 6px 0;
54
+ gap: var(--dx-g-spacing-md);
55
+ }
56
+
37
57
  .doc-notification-bar .icon-wrap {
38
- width: 28px;
39
- height: var(--doc-banner-height);
40
- padding-right: var(--dx-g-spacing-sm);
58
+ width: calc(var(--doc-banner-icon-size) + var(--dx-g-spacing-sm));
59
+ min-height: 32px;
60
+ align-self: flex-start;
61
+ justify-content: flex-start;
62
+ align-items: flex-start;
41
63
  }
42
64
 
43
65
  .doc-notification-bar .icon-wrap dx-icon {
@@ -45,21 +67,25 @@
45
67
 
46
68
  width: var(--doc-banner-icon-size);
47
69
  height: var(--doc-banner-icon-size);
70
+ padding: 12px 8px 0 0;
71
+ box-sizing: content-box;
48
72
  }
49
73
 
50
74
  .doc-notification-bar .content {
51
- flex: 1;
75
+ flex: 0 1 auto;
52
76
  min-width: 0;
53
- max-width: 1136px;
54
- height: var(--doc-banner-height);
55
- padding: 6px 0;
56
- display: flex;
57
- align-items: center;
58
- box-sizing: border-box;
77
+ max-width: 100%;
78
+ min-height: 32px;
79
+ align-items: flex-start;
80
+ gap: var(--dx-g-spacing-sm);
59
81
  }
60
82
 
61
83
  .doc-notification-bar .message {
62
84
  margin: 0;
85
+ padding: 6px 0;
86
+ font-size: 14px;
87
+ font-weight: 400;
88
+ line-height: 20px;
63
89
  color: var(--dx-g-neutral-30, #444);
64
90
  }
65
91
 
@@ -73,9 +99,10 @@
73
99
  }
74
100
 
75
101
  .doc-notification-bar .actions {
76
- width: 215px;
77
- height: 32px;
78
- gap: var(--dx-g-spacing-sm);
102
+ flex-shrink: 0;
103
+ min-height: 32px;
104
+ gap: var(--dx-g-spacing-smd);
105
+ flex-wrap: wrap;
79
106
  }
80
107
 
81
108
  .doc-notification-bar .primary-btn {
@@ -84,52 +111,102 @@
84
111
  --dx-c-button-vertical-spacing: 0;
85
112
  --dx-c-button-horizontal-spacing: var(--dx-g-spacing-md);
86
113
 
87
- min-width: 144px;
114
+ min-width: min(144px, 100%);
88
115
  height: 32px;
89
- border-radius: 4px;
116
+ border-radius: var(--dx-g-spacing-xs);
90
117
  }
91
118
 
92
119
  .doc-notification-bar .primary-btn::part(container) {
93
- min-width: 144px;
120
+ min-width: min(144px, 100%);
94
121
  width: 100%;
95
122
  height: 32px;
96
123
  padding: 0 var(--dx-g-spacing-md);
97
- border-radius: 4px;
98
- box-sizing: border-box;
124
+ border-radius: var(--dx-g-spacing-xs);
125
+ }
126
+
127
+ .doc-notification-bar .secondary-btn {
128
+ font-weight: var(--dx-g-font-normal);
99
129
  }
100
130
 
101
131
  .doc-notification-bar .close-wrap {
132
+ align-self: flex-start;
102
133
  justify-content: center;
134
+ align-items: center;
103
135
  width: 52px;
104
- height: var(--doc-banner-height);
136
+ height: 44px;
137
+ padding: 12px 8px 18px;
138
+ margin-left: auto;
139
+ box-sizing: border-box;
105
140
  }
106
141
 
107
- .doc-notification-bar .close {
108
- display: flex;
109
- align-items: center;
110
- justify-content: center;
142
+ .doc-notification-bar .close-wrap .close-btn {
111
143
  width: 100%;
112
144
  height: 100%;
113
- padding: 2.9px;
114
- margin: 0;
115
- color: var(--doc-banner-close-color);
116
- background: none;
117
- border: none;
118
- cursor: pointer;
119
- border-radius: 0;
120
- box-sizing: border-box;
121
- }
122
-
123
- .doc-notification-bar .close:hover {
124
- background: rgb(0 0 0 / 5%);
125
- }
126
-
127
- .doc-notification-bar .close svg {
128
- width: var(--doc-banner-close-icon-size);
129
- height: var(--doc-banner-close-icon-size);
130
- flex-shrink: 0;
131
- }
132
145
 
133
- .doc-notification-bar .close svg path {
134
- stroke: currentcolor;
146
+ --dx-c-button-custom-color: var(--doc-banner-close-color);
147
+ --dx-c-button-custom-color-hover: var(--doc-banner-close-color);
148
+ --dx-c-button-custom-background: transparent;
149
+ --dx-c-button-custom-background-hover: rgb(0 0 0 / 5%);
150
+ --dx-c-button-custom-border: none;
151
+ --dx-c-button-custom-border-hover: none;
152
+ }
153
+
154
+ @media (max-width: 1279px) {
155
+ :host {
156
+ --doc-banner-padding-x-left: 32px;
157
+ --doc-banner-padding-x-right: var(--dx-g-spacing-md);
158
+ }
159
+
160
+ .doc-notification-bar {
161
+ position: relative;
162
+ max-width: 100%;
163
+ min-height: 78px;
164
+ flex-wrap: wrap;
165
+ align-content: space-between;
166
+ padding: 0 var(--doc-banner-padding-x-right) 0 0;
167
+ }
168
+
169
+ .doc-notification-bar .icon-wrap {
170
+ position: absolute;
171
+ left: 0;
172
+ top: 0;
173
+ bottom: 0;
174
+ width: var(--doc-banner-icon-frame-width);
175
+ min-height: 0;
176
+ padding: 0 0 0 var(--doc-banner-padding-x-left);
177
+ order: 0;
178
+ }
179
+
180
+ .doc-notification-bar .main {
181
+ order: 1;
182
+ flex-wrap: wrap;
183
+ margin-left: var(--doc-banner-icon-frame-width);
184
+ gap: var(--dx-g-spacing-2xs);
185
+ }
186
+
187
+ .doc-notification-bar .content {
188
+ order: 0;
189
+ }
190
+
191
+ .doc-notification-bar .close-wrap {
192
+ order: 2;
193
+ min-height: 44px;
194
+ }
195
+
196
+ .doc-notification-bar .actions {
197
+ order: 1;
198
+ flex: 0 0 100%;
199
+ width: 100%;
200
+ }
201
+ }
202
+
203
+ @media (max-width: 768px) {
204
+ :host {
205
+ --doc-banner-padding-x-left: 24px;
206
+ --doc-banner-padding-x-right: var(--dx-g-spacing-sm);
207
+ }
208
+
209
+ .doc-notification-bar {
210
+ min-height: 44px;
211
+ }
135
212
  }
@@ -1,69 +1,59 @@
1
1
  <template>
2
2
  <div class="doc-notification-bar" part="container">
3
3
  <div class="icon-wrap" part="icon-wrap">
4
- <dx-icon symbol="info" part="icon" color="#9E9E9E"></dx-icon>
4
+ <dx-icon symbol="info" part="icon" color="#747474"></dx-icon>
5
5
  </div>
6
- <div class="content" part="content">
7
- <p class="message dx-text-body-4" part="message">
8
- <template lwc:if={messageText}>{messageText}</template>
9
- <template lwc:if={hasMessageLink}>
10
- <a
11
- href={messageLinkUrl}
12
- target="_blank"
13
- rel="noopener noreferrer"
14
- part="message-link"
6
+ <div class="main" part="main">
7
+ <div class="content" part="content">
8
+ <p class="message dx-text-body-4" part="message">
9
+ <template lwc:if={messageText}>{messageText}</template>
10
+ <template lwc:if={hasMessageLink}>
11
+ <a
12
+ href={messageLinkUrl}
13
+ target="_blank"
14
+ rel="noopener noreferrer"
15
+ part="message-link"
16
+ >
17
+ {messageLinkText}
18
+ </a>
19
+ </template>
20
+ </p>
21
+ </div>
22
+ <div class="actions" part="actions">
23
+ <template lwc:if={hasPrimaryButton}>
24
+ <dx-button
25
+ class="primary-btn"
26
+ href={buttonHref}
27
+ variant="primary"
28
+ size="small"
29
+ part="button"
15
30
  >
16
- {messageLinkText}
17
- </a>
31
+ {buttonLabel}
32
+ </dx-button>
18
33
  </template>
19
- </p>
20
- </div>
21
- <div class="actions" part="actions">
22
- <template lwc:if={hasPrimaryButton}>
23
- <dx-button
24
- class="primary-btn"
25
- href={buttonHref}
26
- variant="primary"
27
- size="small"
28
- part="button"
29
- >
30
- {buttonLabel}
31
- </dx-button>
32
- </template>
33
- <template lwc:if={hasSecondaryAction}>
34
- <dx-button
35
- variant="inline"
36
- onclick={handleSecondaryClick}
37
- part="secondary"
38
- >
39
- {secondaryLabel}
40
- </dx-button>
41
- </template>
34
+ <template lwc:if={hasSecondaryAction}>
35
+ <dx-button
36
+ class="secondary-btn"
37
+ variant="inline"
38
+ onclick={handleSecondaryClick}
39
+ part="secondary"
40
+ >
41
+ {secondaryLabel}
42
+ </dx-button>
43
+ </template>
44
+ </div>
42
45
  </div>
43
46
  <template lwc:if={showCloseButton}>
44
47
  <div class="close-wrap" part="close-wrap">
45
- <button
46
- type="button"
47
- class="close"
48
- part="close"
48
+ <dx-button
49
+ class="close-btn"
50
+ variant="icon-only"
51
+ icon-symbol="close"
52
+ icon-color="#747474"
49
53
  aria-label="Close"
50
54
  onclick={handleCloseClick}
51
- >
52
- <svg
53
- width="14"
54
- height="14"
55
- viewBox="0 0 14 14"
56
- fill="none"
57
- xmlns="http://www.w3.org/2000/svg"
58
- aria-hidden="true"
59
- >
60
- <path
61
- d="M1 1L13 13M13 1L1 13"
62
- stroke-width="2"
63
- stroke-linecap="round"
64
- />
65
- </svg>
66
- </button>
55
+ part="close"
56
+ ></dx-button>
67
57
  </div>
68
58
  </template>
69
59
  </div>
@@ -17,6 +17,9 @@
17
17
  <slot name="sidebar-header" slot="version-picker"></slot>
18
18
  </dx-sidebar-old>
19
19
  <div class="content-body-doc-phase-container">
20
+ <div class="locale-notification-wrapper">
21
+ <slot name="locale-banner"></slot>
22
+ </div>
20
23
  <div class="doc-phase-wrapper">
21
24
  <slot name="doc-phase"></slot>
22
25
  </div>
@@ -268,6 +268,9 @@ export default class ContentLayout extends LightningElement {
268
268
  ".sticky-doc-header"
269
269
  ) as HTMLElement;
270
270
 
271
+ const localeBannerWrapper = this.template.querySelector(
272
+ ".locale-notification-wrapper"
273
+ ) as HTMLElement;
271
274
  const docPhaseWrapper = this.template.querySelector(
272
275
  ".doc-phase-wrapper"
273
276
  ) as HTMLElement;
@@ -275,6 +278,12 @@ export default class ContentLayout extends LightningElement {
275
278
  ".version-wrapper"
276
279
  ) as HTMLElement;
277
280
 
281
+ const localeBannerSlot = localeBannerWrapper?.querySelector(
282
+ "[name=locale-banner]"
283
+ ) as HTMLSlotElement | null;
284
+ const localeBannerEl = localeBannerSlot?.assignedElements?.()[0] as
285
+ | HTMLElement
286
+ | undefined;
278
287
  const docPhaseEl = (
279
288
  docPhaseWrapper.querySelector("[name=doc-phase]")! as any
280
289
  ).assignedElements()[0] as HTMLSlotElement;
@@ -297,6 +306,12 @@ export default class ContentLayout extends LightningElement {
297
306
  const docHeaderHeight = docHeaderEl.getBoundingClientRect().height;
298
307
  const totalHeaderHeight = globalNavHeight + docHeaderHeight;
299
308
 
309
+ const localeBannerHeight = localeBannerEl?.offsetHeight ?? 0;
310
+ const docPhaseElHeight =
311
+ (docPhaseEl?.getBoundingClientRect?.()?.height ?? 0) +
312
+ (verBannerEl?.getBoundingClientRect?.()?.height ?? 0);
313
+ const totalBannerHeight = localeBannerHeight + docPhaseElHeight;
314
+
300
315
  // Selecting the doc section heading and RNB here.
301
316
  const docHeadingEls = Array.from(
302
317
  document.querySelectorAll("doc-heading")
@@ -313,15 +328,10 @@ export default class ContentLayout extends LightningElement {
313
328
  `${globalNavHeight}px`
314
329
  );
315
330
 
316
- const docPhaseElHeight =
317
- docPhaseEl || verBannerEl
318
- ? (docPhaseEl || verBannerEl).getBoundingClientRect().height
319
- : 0;
320
-
321
331
  // Adjusting the doc section heading on scroll.
322
332
  docHeadingEls.forEach((docHeadingEl) => {
323
333
  (docHeadingEl as any).style.scrollMarginTop = `${
324
- totalHeaderHeight + docPhaseElHeight + 40
334
+ totalHeaderHeight + totalBannerHeight + 40
325
335
  }px`;
326
336
  });
327
337
 
@@ -331,10 +341,10 @@ export default class ContentLayout extends LightningElement {
331
341
  const viewportHeight = window.innerHeight;
332
342
  const maxHeight =
333
343
  viewportHeight -
334
- (docPhaseElHeight + totalHeaderHeight + 24); //added some margin of dx-toc
344
+ (totalBannerHeight + totalHeaderHeight + 24); //added some margin of dx-toc
335
345
 
336
346
  rightNavBarEl.style.top = `${
337
- totalHeaderHeight + docPhaseElHeight
347
+ totalHeaderHeight + totalBannerHeight
338
348
  }px`;
339
349
 
340
350
  const toc = rightNavBarEl.querySelector("dx-toc");
@@ -512,13 +522,22 @@ export default class ContentLayout extends LightningElement {
512
522
  globalNavEl?.offsetHeight +
513
523
  contextNavEl?.offsetHeight;
514
524
 
525
+ const localeBannerWrapper = this.template.querySelector(
526
+ ".locale-notification-wrapper"
527
+ ) as HTMLElement;
528
+ const localeBannerSlot = localeBannerWrapper?.querySelector(
529
+ "[name=locale-banner]"
530
+ ) as HTMLSlotElement | null;
531
+ const localeBannerEl = localeBannerSlot?.assignedElements?.()[0] as
532
+ | HTMLElement
533
+ | undefined;
515
534
  const docPhaseEl = (
516
535
  this.template.querySelector("[name=doc-phase]")! as any
517
536
  ).assignedElements()[0] as HTMLSlotElement;
518
537
 
519
- const offset = docPhaseEl
520
- ? headerHeight + docPhaseEl.offsetHeight
521
- : headerHeight;
538
+ const localeBannerHeight = localeBannerEl?.offsetHeight ?? 0;
539
+ const docPhaseHeight = docPhaseEl?.offsetHeight ?? 0;
540
+ const offset = headerHeight + localeBannerHeight + docPhaseHeight;
522
541
 
523
542
  for (const headingElement of headingElements as any) {
524
543
  if (headingElement.getAttribute("id") === hash) {
@@ -15,6 +15,18 @@
15
15
  reading-time={computedReadingTime}
16
16
  origin={origin}
17
17
  >
18
+ <doc-banner
19
+ slot="locale-banner"
20
+ lwc:if={showLocaleBanner}
21
+ message-text="This text was translated using Salesforce's machine translation system. More details can be found "
22
+ message-link-url="https://help.salesforce.com/s/articleView?id=sf.machine_translation.htm"
23
+ message-link-text="here"
24
+ button-label="Switch to English"
25
+ button-href={localeBannerEnUsHref}
26
+ secondary-label="Not Now"
27
+ show-close-button="true"
28
+ ondismiss={handleLocaleBannerDismiss}
29
+ ></doc-banner>
18
30
  <doc-phase
19
31
  slot="version-banner"
20
32
  lwc:if={showVersionBanner}
@@ -78,6 +78,8 @@ export default class DocXmlContent extends LightningElementWithState<{
78
78
  private latestVersion = false;
79
79
  private previewVersion = false;
80
80
 
81
+ @track private localeBannerDismissed = false;
82
+
81
83
  private get enableFooter(): boolean {
82
84
  return !this.hideFooter;
83
85
  }
@@ -251,6 +253,35 @@ export default class DocXmlContent extends LightningElementWithState<{
251
253
  return this.pageReference.deliverable;
252
254
  }
253
255
 
256
+ private get showLocaleBanner(): boolean {
257
+ if (!this.pageReference?.deliverable || this.localeBannerDismissed) {
258
+ return false;
259
+ }
260
+ if (!this.language || this.language.id === "en-us") {
261
+ return false;
262
+ }
263
+ const hasEnUs = this.availableLanguages?.some(
264
+ (lang: DocLanguage) => lang.id === "en-us"
265
+ );
266
+ return !!hasEnUs;
267
+ }
268
+
269
+ private get localeBannerEnUsHref(): string {
270
+ if (!this.pageReference) {
271
+ return "";
272
+ }
273
+ const enUsLanguage = this.availableLanguages?.find(
274
+ (lang: DocLanguage) => lang.id === "en-us"
275
+ );
276
+ if (!enUsLanguage) {
277
+ return "";
278
+ }
279
+ return this.pageReferenceToString({
280
+ ...this.pageReference,
281
+ docId: enUsLanguage.url
282
+ });
283
+ }
284
+
254
285
  private get useOldSidebar(): boolean {
255
286
  // Coveo is enabled and the version is greater than 51 (within the latest 3 versions)
256
287
  // TODO: we need a better fix for version number check
@@ -326,6 +357,16 @@ export default class DocXmlContent extends LightningElementWithState<{
326
357
  this.showVersionBanner = false;
327
358
  }
328
359
 
360
+ handleLocaleBannerDismiss() {
361
+ if (this.pageReference?.deliverable) {
362
+ window.localStorage.setItem(
363
+ `dsc-doc-locale-banner-dismissed-${this.pageReference.deliverable}`,
364
+ "true"
365
+ );
366
+ }
367
+ this.localeBannerDismissed = true;
368
+ }
369
+
329
370
  handleSelect(event: CustomEvent<{ name: string }>): void {
330
371
  event.stopPropagation();
331
372
  const { name } = event.detail;
@@ -479,6 +520,11 @@ export default class DocXmlContent extends LightningElementWithState<{
479
520
  this.updateUrl(HistoryState.REPLACE_STATE);
480
521
  }
481
522
 
523
+ this.localeBannerDismissed =
524
+ window.localStorage.getItem(
525
+ `dsc-doc-locale-banner-dismissed-${this.pageReference.deliverable}`
526
+ ) === "true";
527
+
482
528
  if (this.oldVersionInfo) {
483
529
  this.showVersionBanner = true;
484
530
  } else {