@salesforcedevs/docs-components 1.28.0 → 1.28.1-banner-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/lwc.config.json CHANGED
@@ -6,6 +6,8 @@
6
6
  ],
7
7
  "expose": [
8
8
  "doc/amfReference",
9
+ "doc/banner",
10
+ "doc/localeBanner",
9
11
  "doc/breadcrumbs",
10
12
  "doc/componentPlayground",
11
13
  "doc/content",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.28.0",
3
+ "version": "1.28.1-banner-1",
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": "4027270163b2eb9610b911a09bfa31f536061fe4"
28
+ "gitHead": "66d2158d53e1ed5e503f558021b0e1e0b0206d52"
29
29
  }
@@ -0,0 +1,87 @@
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
+
4
+ :host {
5
+ display: block;
6
+
7
+ --doc-banner-padding-left: var(--dx-g-spacing-2xl);
8
+ --doc-banner-padding-right: var(--dx-g-spacing-lg);
9
+ }
10
+
11
+ .container {
12
+ display: flex;
13
+ align-items: flex-start;
14
+ background: var(--dx-g-gray-90);
15
+ padding: 0 var(--doc-banner-padding-right) 0 var(--doc-banner-padding-left);
16
+ }
17
+
18
+ .icon {
19
+ --dx-c-icon-size: var(--dx-g-icon-size-lg);
20
+
21
+ flex-shrink: 0;
22
+ margin-top: var(--dx-g-spacing-smd);
23
+ margin-right: var(--dx-g-spacing-sm);
24
+ }
25
+
26
+ .main {
27
+ flex: 1;
28
+ min-width: 0;
29
+ display: flex;
30
+ flex-wrap: wrap;
31
+ align-items: flex-start;
32
+ column-gap: var(--dx-g-spacing-md);
33
+ padding: calc((var(--dx-g-spacing-xs) + var(--dx-g-spacing-sm)) / 2) 0;
34
+ }
35
+
36
+ .message {
37
+ flex: 0 1 auto;
38
+ font-size: var(--dx-g-text-sm);
39
+ color: var(--dx-g-gray-10);
40
+ padding: calc((var(--dx-g-spacing-xs) + var(--dx-g-spacing-sm)) / 2) 0;
41
+ }
42
+
43
+ .message a {
44
+ color: var(--dx-g-cloud-blue-vibrant-50);
45
+ text-decoration: underline;
46
+ }
47
+
48
+ .actions {
49
+ flex: 0 0 auto;
50
+ display: flex;
51
+ align-items: center;
52
+ gap: var(--dx-g-spacing-smd);
53
+ }
54
+
55
+ .actions dx-button {
56
+ --dx-c-button-font-size: var(--dx-g-text-sm);
57
+ --dx-c-button-font-weight: var(--dx-g-font-normal);
58
+
59
+ flex: 0 0 auto;
60
+ }
61
+
62
+ .close {
63
+ --dx-c-icon-size: var(--dx-g-icon-size-lg);
64
+
65
+ flex-shrink: 0;
66
+ align-self: flex-start;
67
+ width: calc(var(--dx-g-spacing-3xl) + var(--dx-g-spacing-xs));
68
+ height: calc(var(--dx-g-spacing-2xl) + var(--dx-g-spacing-xs));
69
+ margin-left: auto;
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: center;
73
+ }
74
+
75
+ @media (max-width: 1279px) {
76
+ :host {
77
+ --doc-banner-padding-left: var(--dx-g-spacing-xl);
78
+ --doc-banner-padding-right: var(--dx-g-spacing-md);
79
+ }
80
+ }
81
+
82
+ @media (max-width: 768px) {
83
+ :host {
84
+ --doc-banner-padding-left: var(--dx-g-spacing-lg);
85
+ --doc-banner-padding-right: var(--dx-g-spacing-sm);
86
+ }
87
+ }
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <template lwc:if={showBanner}>
3
+ <div class="container" part="container">
4
+ <dx-icon
5
+ class="icon"
6
+ symbol="info"
7
+ size="override"
8
+ color="gray-50"
9
+ part="icon"
10
+ ></dx-icon>
11
+ <div class="main">
12
+ <div class="message" part="message" lwc:dom="manual"></div>
13
+ <div class="actions" part="actions">
14
+ <template lwc:if={hasPrimaryButton}>
15
+ <dx-button
16
+ href={buttonHref}
17
+ variant="primary"
18
+ size="small"
19
+ part="button"
20
+ >
21
+ {buttonLabel}
22
+ </dx-button>
23
+ </template>
24
+ <template lwc:if={hasSecondaryAction}>
25
+ <dx-button
26
+ variant="inline"
27
+ onclick={handleSecondaryClick}
28
+ part="secondary"
29
+ >
30
+ {secondaryLabel}
31
+ </dx-button>
32
+ </template>
33
+ </div>
34
+ </div>
35
+ <dx-button
36
+ class="close"
37
+ variant="icon-only"
38
+ icon-symbol="close"
39
+ icon-size="override"
40
+ icon-color="gray-50"
41
+ aria-label="Close"
42
+ onclick={handleCloseClick}
43
+ part="close"
44
+ ></dx-button>
45
+ </div>
46
+ </template>
47
+ </template>
@@ -0,0 +1,81 @@
1
+ import { LightningElement, api } from "lwc";
2
+
3
+ const BANNER_STORAGE_PREFIX = "doc-banner-";
4
+
5
+ export default class Banner extends LightningElement {
6
+ @api message = "";
7
+
8
+ @api buttonLabel = "";
9
+
10
+ @api buttonHref = "";
11
+
12
+ @api secondaryLabel = "";
13
+
14
+ @api dismissStorageKey = "";
15
+
16
+ private _dismissed = false;
17
+
18
+ connectedCallback() {
19
+ if (
20
+ this.dismissStorageKey &&
21
+ typeof window !== "undefined" &&
22
+ window.sessionStorage
23
+ ) {
24
+ this._dismissed =
25
+ window.sessionStorage.getItem(
26
+ `${BANNER_STORAGE_PREFIX}${this.dismissStorageKey}`
27
+ ) === "true";
28
+ }
29
+ }
30
+
31
+ renderedCallback() {
32
+ if (this.message) {
33
+ const messageElement = this.template.querySelector(".message");
34
+ if (messageElement) {
35
+ messageElement.innerHTML = this.message;
36
+ }
37
+ }
38
+ }
39
+
40
+ get showBanner(): boolean {
41
+ return !this._dismissed;
42
+ }
43
+
44
+ get hasPrimaryButton(): boolean {
45
+ return !!(this.buttonLabel && this.buttonHref);
46
+ }
47
+
48
+ get hasSecondaryAction(): boolean {
49
+ return !!this.secondaryLabel;
50
+ }
51
+
52
+ private dismissBanner() {
53
+ if (
54
+ this.dismissStorageKey &&
55
+ typeof window !== "undefined" &&
56
+ window.sessionStorage
57
+ ) {
58
+ window.sessionStorage.setItem(
59
+ `${BANNER_STORAGE_PREFIX}${this.dismissStorageKey}`,
60
+ "true"
61
+ );
62
+ }
63
+ this._dismissed = true;
64
+ this.dispatchEvent(
65
+ new CustomEvent("dismissbanner", {
66
+ bubbles: true,
67
+ composed: true
68
+ })
69
+ );
70
+ }
71
+
72
+ @api
73
+ handleSecondaryClick() {
74
+ this.dismissBanner();
75
+ }
76
+
77
+ @api
78
+ handleCloseClick() {
79
+ this.dismissBanner();
80
+ }
81
+ }
@@ -0,0 +1,3 @@
1
+ :host {
2
+ display: block;
3
+ }
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <doc-banner
3
+ message={bannerMessage}
4
+ button-label={bannerButtonLabel}
5
+ button-href={bannerButtonHref}
6
+ secondary-label={bannerSecondaryLabel}
7
+ dismiss-storage-key={dismissStorageKey}
8
+ ></doc-banner>
9
+ </template>
@@ -0,0 +1,132 @@
1
+ import { LightningElement, api } from "lwc";
2
+
3
+ interface LocaleStrings {
4
+ messageText: string;
5
+ linkUrl: string;
6
+ linkText: string;
7
+ buttonLabel: string;
8
+ secondaryLabel: string;
9
+ }
10
+
11
+ const DEFAULT_LOCALE = "en-us";
12
+
13
+ const LOCALE_STRINGS: Record<string, LocaleStrings> = {
14
+ "en-us": {
15
+ messageText:
16
+ "This text has been translated using Salesforce machine translation system. More details {link}.",
17
+ linkUrl:
18
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1",
19
+ linkText: "here",
20
+ buttonLabel: "Switch to English",
21
+ secondaryLabel: "Not Now"
22
+ },
23
+ "ja-jp": {
24
+ messageText:
25
+ "この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細は{link}をご参照ください。",
26
+ linkUrl:
27
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=ja",
28
+ linkText: "こちら",
29
+ buttonLabel: "英語に切り替える",
30
+ secondaryLabel: "今はしません"
31
+ },
32
+ "zh-cn": {
33
+ messageText:
34
+ "此文本已使用 Salesforce 机器翻译系统进行翻译。如需了解更多详情,请点击{link}。",
35
+ linkUrl:
36
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=zh_CN",
37
+ linkText: "此处",
38
+ buttonLabel: "切换为英语",
39
+ secondaryLabel: "而非现在"
40
+ },
41
+ "zh-tw": {
42
+ messageText:
43
+ "此文已使用 Salesforce 機器翻譯系統翻譯。更多詳細資料請參見{link}。",
44
+ linkUrl:
45
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=zh_TW",
46
+ linkText: "此處",
47
+ buttonLabel: "切換至英文",
48
+ secondaryLabel: "不要現在"
49
+ },
50
+ "fr-fr": {
51
+ messageText:
52
+ "Ce texte a été traduit à l’aide du système de traduction automatique de Salesforce. Plus de détails, consultez {link}.",
53
+ linkUrl:
54
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=fr",
55
+ linkText: "cette page",
56
+ buttonLabel: "Basculer vers la page en anglais",
57
+ secondaryLabel: "Pas maintenant"
58
+ },
59
+ "de-de": {
60
+ messageText:
61
+ "Dieser Text wurde mit dem maschinellen Übersetzungssystem von Salesforce übersetzt. Weitere Details finden Sie {link}.",
62
+ linkUrl:
63
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=de",
64
+ linkText: "hier",
65
+ buttonLabel: "Zu Englisch wechseln",
66
+ secondaryLabel: "Nicht jetzt"
67
+ },
68
+ "it-it": {
69
+ messageText:
70
+ "Questo testo è stato tradotto utilizzando il sistema di traduzione automatica di Salesforce. Ulteriori dettagli sono disponibili {link}.",
71
+ linkUrl:
72
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=it",
73
+ linkText: "qui",
74
+ buttonLabel: "Passa all'inglese",
75
+ secondaryLabel: "Non ora"
76
+ },
77
+ "ko-kr": {
78
+ messageText:
79
+ "본 텍스트는 Salesforce 기계 번역 시스템으로 번역되었습니다. 자세한 내용은 {link}를 참조하세요.",
80
+ linkUrl:
81
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=ko",
82
+ linkText: "여기",
83
+ buttonLabel: "영어로 전환",
84
+ secondaryLabel: "지금 안 함"
85
+ },
86
+ "pt-br": {
87
+ messageText:
88
+ "Este texto foi traduzido pelo sistema de tradução automática da Salesforce. Mais detalhes {link}.",
89
+ linkUrl:
90
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=pt_BR",
91
+ linkText: "aqui",
92
+ buttonLabel: "Alternar para inglês",
93
+ secondaryLabel: "Agora não"
94
+ },
95
+ "es-mx": {
96
+ messageText:
97
+ "Este texto se tradujo con el sistema de traducción automática de Salesforce. Obtenga más detalles {link}.",
98
+ linkUrl:
99
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=es_MX",
100
+ linkText: "aquí",
101
+ buttonLabel: "Cambiar a inglés",
102
+ secondaryLabel: "Ahora no"
103
+ }
104
+ };
105
+
106
+ export default class LocaleBanner extends LightningElement {
107
+ @api locale = DEFAULT_LOCALE;
108
+ @api targetHref = "";
109
+ @api dismissStorageKey = "";
110
+
111
+ get localeData(): LocaleStrings {
112
+ return LOCALE_STRINGS[this.locale] || LOCALE_STRINGS[DEFAULT_LOCALE];
113
+ }
114
+
115
+ get bannerMessage(): string {
116
+ const data = this.localeData;
117
+ const link = `<a href="${data.linkUrl}">${data.linkText}</a>`;
118
+ return data.messageText.replace("{link}", link);
119
+ }
120
+
121
+ get bannerButtonLabel(): string {
122
+ return this.localeData.buttonLabel;
123
+ }
124
+
125
+ get bannerButtonHref(): string {
126
+ return this.targetHref;
127
+ }
128
+
129
+ get bannerSecondaryLabel(): string {
130
+ return this.localeData.secondaryLabel;
131
+ }
132
+ }
@@ -57,7 +57,10 @@
57
57
  </div>
58
58
  </div>
59
59
  <div lwc:if={showFooter} class="footer-container">
60
- <dx-footer variant="no-signup" mfe-config-origin={effectiveFooterOrigin}></dx-footer>
60
+ <dx-footer
61
+ variant="no-signup"
62
+ mfe-config-origin={effectiveFooterOrigin}
63
+ ></dx-footer>
61
64
  </div>
62
65
  </div>
63
66
  </div>
@@ -53,7 +53,7 @@
53
53
  </doc-content-layout>
54
54
  <div lwc:if={display404}>
55
55
  <dx-error
56
- image="https://a.sfdcstatic.com/developer-website/prod/images/404.svg"
56
+ image="https://developer.salesforce.com/ns-assets/404.svg"
57
57
  code="404"
58
58
  header="Beep boop. That did not compute."
59
59
  subtitle="The document you're looking for doesn't seem to exist."
@@ -322,8 +322,10 @@ export default class DocXmlContent extends LightningElementWithState<{
322
322
  };
323
323
  }
324
324
 
325
- private handlePopState = (event: PopStateEvent): void =>
325
+ private handlePopState = (event: PopStateEvent): void => {
326
326
  this.updatePageReference(this.getReferenceFromUrl(), event);
327
+ this.handleLocaleReload();
328
+ };
327
329
 
328
330
  handleDismissVersionBanner() {
329
331
  this.showVersionBanner = false;
@@ -598,6 +600,31 @@ export default class DocXmlContent extends LightningElementWithState<{
598
600
  "docs",
599
601
  this.pageReferenceToString(this.pageReference)
600
602
  );
603
+ this.handleLocaleReload();
604
+ }
605
+
606
+ /* This method reloads the page as locale banner context is not available in developer-website. */
607
+ private handleLocaleReload(): void {
608
+ const targetLocale = this.language?.id;
609
+ if (!targetLocale) {
610
+ return;
611
+ }
612
+
613
+ const currentPath = window.location.pathname;
614
+ const localePattern = /atlas\.[a-z]{2}-[a-z]{2}\./;
615
+
616
+ if (localePattern.test(currentPath)) {
617
+ const newPath = currentPath.replace(
618
+ localePattern,
619
+ `atlas.${targetLocale}.`
620
+ );
621
+ const newUrl =
622
+ window.location.origin +
623
+ newPath +
624
+ window.location.search +
625
+ window.location.hash;
626
+ window.location.href = newUrl;
627
+ }
601
628
  }
602
629
 
603
630
  private updateHighlighting(searchParam: string): void {