@salesforcedevs/dw-components 1.3.265-alpha.1 → 1.3.275
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/LICENSE +12 -0
- package/lwc.config.json +1 -0
- package/package.json +3 -2
- package/src/modules/dw/blogsGrid/blogsGrid.css +5 -0
- package/src/modules/dw/blogsGrid/blogsGrid.html +8 -6
- package/src/modules/dw/blogsGrid/blogsGrid.ts +0 -9
- package/src/modules/dw/languageSelector/languageSelector.html +9 -0
- package/src/modules/dw/languageSelector/languageSelector.ts +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
|
|
10
|
+
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.275",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -25,5 +25,6 @@
|
|
|
25
25
|
"@types/lodash.uniqby": "^4.7.7",
|
|
26
26
|
"@types/setimmediate": "^1.0.2",
|
|
27
27
|
"setimmediate": "^1.0.5"
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
|
+
"gitHead": "cc149575eeab5262859690f9ecdb87309eb84550"
|
|
29
30
|
}
|
|
@@ -24,6 +24,10 @@ dx-section.section-reduced-padding {
|
|
|
24
24
|
line-height: 32px;
|
|
25
25
|
width: 500px;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
.box {
|
|
29
|
+
height: 162px;
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
@media only screen and (max-width: 640px) {
|
|
@@ -36,6 +40,7 @@ dx-section.section-reduced-padding {
|
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
.box {
|
|
43
|
+
height: 162px;
|
|
39
44
|
background-position: 0% 25%, 90% 75%;
|
|
40
45
|
}
|
|
41
46
|
}
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
<div class="subscription-box">
|
|
6
6
|
<div class="box">
|
|
7
7
|
<div class="content">
|
|
8
|
-
<h2 class="title">
|
|
9
|
-
|
|
8
|
+
<h2 class="title">
|
|
9
|
+
Get the latest Salesforce Developer blog posts and
|
|
10
|
+
podcast episodes via Slack or RSS.
|
|
11
|
+
</h2>
|
|
10
12
|
<div class="cta-container">
|
|
11
13
|
<dx-button
|
|
12
14
|
size="small"
|
|
@@ -17,7 +19,7 @@
|
|
|
17
19
|
href="/slack/install"
|
|
18
20
|
class="button"
|
|
19
21
|
>
|
|
20
|
-
|
|
22
|
+
Add to Slack
|
|
21
23
|
</dx-button>
|
|
22
24
|
<dx-button
|
|
23
25
|
size="small"
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
class="button"
|
|
30
32
|
onclick={rssOnClick}
|
|
31
33
|
>
|
|
32
|
-
|
|
34
|
+
Subscribe to RSS
|
|
33
35
|
</dx-button>
|
|
34
36
|
</div>
|
|
35
37
|
</div>
|
|
@@ -63,14 +65,14 @@
|
|
|
63
65
|
if:true={showLoadMore}
|
|
64
66
|
onclick={onClick}
|
|
65
67
|
variant="load-more"
|
|
66
|
-
text=
|
|
68
|
+
text="SHOW MORE"
|
|
67
69
|
></dx-hr>
|
|
68
70
|
<dx-hr
|
|
69
71
|
if:true={showArchives}
|
|
70
72
|
onclick={onClick}
|
|
71
73
|
variant="link"
|
|
72
74
|
href="/content-archive?content-type=Blogs"
|
|
73
|
-
text=
|
|
75
|
+
text="VIEW ARCHIVES"
|
|
74
76
|
></dx-hr>
|
|
75
77
|
</div>
|
|
76
78
|
</template>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { api } from "lwc";
|
|
2
1
|
import { normalizePost } from "dxUtils/normalizers";
|
|
3
2
|
import { track } from "dxUtils/analytics";
|
|
4
3
|
import { WordpressBlogPost, NormalizedPost } from "typings/custom";
|
|
@@ -14,14 +13,6 @@ const ANALYTICS_INFO = {
|
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
export default class BlogsGrid extends PostsGrid {
|
|
17
|
-
@api showMoreLabel = "SHOW MORE";
|
|
18
|
-
@api viewArchivesLabel = "VIEW ARCHIVES";
|
|
19
|
-
@api rssTitle =
|
|
20
|
-
"Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.";
|
|
21
|
-
@api rssBody?: string;
|
|
22
|
-
@api rssBtnOneLabel = "Add to Slack";
|
|
23
|
-
@api rssBtnTwoLabel = "Subscribe to RSS";
|
|
24
|
-
|
|
25
16
|
_loadMoreAmount = 21;
|
|
26
17
|
|
|
27
18
|
normalizePost(post: WordpressBlogPost): NormalizedPost {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { track as trackClick } from "dxUtils/analytics";
|
|
2
|
+
import { api, LightningElement, track } from "lwc";
|
|
3
|
+
import { SelectOption } from "typings/custom";
|
|
4
|
+
|
|
5
|
+
const ANALYTICS_INFO = {
|
|
6
|
+
element_title: "Select Language",
|
|
7
|
+
content_category: "cta"
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const language_local_names_map: any = {
|
|
11
|
+
japanese: "日本語",
|
|
12
|
+
english: "english"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default class LanguageSelector extends LightningElement {
|
|
16
|
+
@track languages = [] as SelectOption[];
|
|
17
|
+
@track selectedLanguage?: string;
|
|
18
|
+
@api postAcf!: string;
|
|
19
|
+
@api postId?: string;
|
|
20
|
+
|
|
21
|
+
_languageMap = {} as any;
|
|
22
|
+
|
|
23
|
+
generateTranslationOptions = async () => {
|
|
24
|
+
const acf = JSON.parse(this.postAcf);
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const canonicalId = acf?.canonicalid;
|
|
28
|
+
|
|
29
|
+
const alternatePosts: any[] = await (
|
|
30
|
+
await fetch(
|
|
31
|
+
`https://developer.salesforce.com/blogs/wp-json/wp/v2/post-translations/${
|
|
32
|
+
canonicalId || this.postId
|
|
33
|
+
}`
|
|
34
|
+
)
|
|
35
|
+
).json();
|
|
36
|
+
|
|
37
|
+
alternatePosts.forEach(
|
|
38
|
+
(post: { acf: { language: string }; link: string }) => {
|
|
39
|
+
const localLanguageName =
|
|
40
|
+
language_local_names_map[post.acf.language] ||
|
|
41
|
+
language_local_names_map.english;
|
|
42
|
+
this._languageMap[localLanguageName] = post.link;
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
this.languages = alternatePosts.map((post) => {
|
|
47
|
+
return {
|
|
48
|
+
value:
|
|
49
|
+
language_local_names_map[post.acf.language] ||
|
|
50
|
+
language_local_names_map.english,
|
|
51
|
+
label:
|
|
52
|
+
language_local_names_map[post.acf.language] ||
|
|
53
|
+
language_local_names_map.english,
|
|
54
|
+
disabled: false
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.error(e);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this.selectedLanguage =
|
|
62
|
+
language_local_names_map[acf?.language] ||
|
|
63
|
+
language_local_names_map.english;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
connectedCallback() {
|
|
67
|
+
this.generateTranslationOptions();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
handleLanguageChange(evt: CustomEvent): void {
|
|
71
|
+
const selectedLanguage = evt.detail.value;
|
|
72
|
+
const url = this._languageMap[selectedLanguage];
|
|
73
|
+
trackClick(this.template.activeElement!, "custEv_ctaButtonClick", {
|
|
74
|
+
...ANALYTICS_INFO,
|
|
75
|
+
element_type: "button",
|
|
76
|
+
click_text: selectedLanguage,
|
|
77
|
+
click_url: url
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
window.location.href = url;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
get noTranslationsAvailable() {
|
|
84
|
+
return this.languages.length <= 1;
|
|
85
|
+
}
|
|
86
|
+
}
|