@salesforcedevs/dw-components 1.3.261 → 1.3.265-alpha.0

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,7 @@
6
6
  "expose": [
7
7
  "dw/blogsGrid",
8
8
  "dw/videoGrid",
9
+ "dw/youtubeVideoGrid",
9
10
  "dw/browseTrials",
10
11
  "dw/cardBlogPostProvider",
11
12
  "dw/cardPodcastEpisodeProvider",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dw-components",
3
- "version": "1.3.261",
3
+ "version": "1.3.265-alpha.0",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -10,11 +10,13 @@
10
10
  "access": "public"
11
11
  },
12
12
  "dependencies": {
13
+ "@types/youtube-player": "^5.5.11",
13
14
  "classnames": "^2.2.6",
14
15
  "lodash.clonedeep": "^4.5.0",
15
16
  "lodash.orderby": "^4.6.0",
16
17
  "lodash.uniqby": "^4.7.0",
17
- "query-string": "^7.1.3"
18
+ "query-string": "^7.1.3",
19
+ "youtube-player": "^5.6.0"
18
20
  },
19
21
  "devDependencies": {
20
22
  "@types/classnames": "^2.2.10",
@@ -23,6 +25,5 @@
23
25
  "@types/lodash.uniqby": "^4.7.7",
24
26
  "@types/setimmediate": "^1.0.2",
25
27
  "setimmediate": "^1.0.5"
26
- },
27
- "gitHead": "8f326de081fbbef38ac44074ed4f54190e6416c1"
28
+ }
28
29
  }
@@ -5,10 +5,8 @@
5
5
  <div class="subscription-box">
6
6
  <div class="box">
7
7
  <div class="content">
8
- <h2 class="title">
9
- Get the latest Salesforce Developer blog posts and
10
- podcast episodes via Slack or RSS.
11
- </h2>
8
+ <h2 class="title">{rssTitle}</h2>
9
+ <p lwc:if={rssBody}>{rssBody}</p>
12
10
  <div class="cta-container">
13
11
  <dx-button
14
12
  size="small"
@@ -19,7 +17,7 @@
19
17
  href="/slack/install"
20
18
  class="button"
21
19
  >
22
- Add to Slack
20
+ {rssBtnOneLabel}
23
21
  </dx-button>
24
22
  <dx-button
25
23
  size="small"
@@ -31,7 +29,7 @@
31
29
  class="button"
32
30
  onclick={rssOnClick}
33
31
  >
34
- Subscribe to RSS
32
+ {rssBtnTwoLabel}
35
33
  </dx-button>
36
34
  </div>
37
35
  </div>
@@ -65,14 +63,14 @@
65
63
  if:true={showLoadMore}
66
64
  onclick={onClick}
67
65
  variant="load-more"
68
- text="SHOW MORE"
66
+ text={showMoreLabel}
69
67
  ></dx-hr>
70
68
  <dx-hr
71
69
  if:true={showArchives}
72
70
  onclick={onClick}
73
71
  variant="link"
74
72
  href="/content-archive?content-type=Blogs"
75
- text="VIEW ARCHIVES"
73
+ text={viewArchivesLabel}
76
74
  ></dx-hr>
77
75
  </div>
78
76
  </template>
@@ -1,3 +1,4 @@
1
+ import { api } from "lwc";
1
2
  import { normalizePost } from "dxUtils/normalizers";
2
3
  import { track } from "dxUtils/analytics";
3
4
  import { WordpressBlogPost, NormalizedPost } from "typings/custom";
@@ -13,6 +14,14 @@ const ANALYTICS_INFO = {
13
14
  };
14
15
 
15
16
  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
+
16
25
  _loadMoreAmount = 21;
17
26
 
18
27
  normalizePost(post: WordpressBlogPost): NormalizedPost {
@@ -0,0 +1,8 @@
1
+ export type VideoData = {
2
+ id: string;
3
+ iframeTitle: string;
4
+ title: string;
5
+ body?: string;
6
+ src: string;
7
+ date?: string;
8
+ };
@@ -0,0 +1,14 @@
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
+
4
+ h3 {
5
+ margin: var(--dx-g-spacing-md) 0;
6
+ }
7
+
8
+ p {
9
+ margin-bottom: var(--dx-g-spacing-md);
10
+ }
11
+
12
+ .video-container iframe {
13
+ border-radius: 16px;
14
+ }
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <dx-grid columns="dynamic">
3
+ <template for:each={videosData} for:item="videoData">
4
+ <div class="video-container" key={videoData.id}>
5
+ <iframe
6
+ id={videoData.id}
7
+ src={videoData.src}
8
+ width={width}
9
+ height={height}
10
+ title={videoData.iframeTitle}
11
+ allowfullscreen
12
+ ></iframe>
13
+ <h3 lwc:if={videoData.title} class="dx-text-display-6">
14
+ {videoData.title}
15
+ </h3>
16
+ <p lwc:if={videoData.body}>{videoData.body}</p>
17
+ <dx-formatted-date-time
18
+ lwc:if={videoData.date}
19
+ value={videoData.date}
20
+ ></dx-formatted-date-time>
21
+ </div>
22
+ </template>
23
+ </dx-grid>
24
+ </template>
@@ -0,0 +1,66 @@
1
+ import { api, LightningElement } from "lwc";
2
+ import YoutubePlayer from "youtube-player";
3
+ import { VideoData } from "./types";
4
+
5
+ const PLAYING = 1;
6
+
7
+ export default class YoutubeVideoGrid extends LightningElement {
8
+ @api width = 382;
9
+ @api height = 215;
10
+
11
+ @api
12
+ get videosData(): Array<VideoData> {
13
+ return this._videosData;
14
+ }
15
+
16
+ set videosData(value: string | Array<VideoData>) {
17
+ if (typeof value === "string") {
18
+ try {
19
+ this._videosData = JSON.parse(value) as Array<VideoData>;
20
+ } catch (error) {
21
+ console.error("Error parsing cards data:", error);
22
+ this._videosData = [];
23
+ }
24
+ } else {
25
+ this._videosData = value;
26
+ }
27
+ }
28
+
29
+ private _videosData: Array<VideoData> = [];
30
+ private players: any = [];
31
+ private _hasRendered = false;
32
+
33
+ private pauseAllExceptCurrent(id: any) {
34
+ this.players.forEach((currentPlayer: any) => {
35
+ if (currentPlayer.id !== id) {
36
+ currentPlayer.player.pauseVideo();
37
+ }
38
+ });
39
+ }
40
+
41
+ renderedCallback() {
42
+ if (this._hasRendered) {
43
+ return;
44
+ }
45
+
46
+ const iframeEls = this.template.querySelectorAll("iframe");
47
+
48
+ iframeEls.forEach((el, index) => {
49
+ // The YoutubePlayer package is a wrapper around the Youtube embedded API without the need for script tags (which aren't allowed in LWC templates)
50
+ // https://developers.google.com/youtube/iframe_api_reference
51
+ const player = YoutubePlayer(el);
52
+
53
+ this.players.push({ id: index, player });
54
+
55
+ // Listener for state change events (play, pause, etc).
56
+ player.on("stateChange", (event: any) => {
57
+ if (event.data === PLAYING) {
58
+ // Pause all other players when a new one starts playing.
59
+ this.pauseAllExceptCurrent(index);
60
+ }
61
+ });
62
+ });
63
+
64
+ this._hasRendered = true;
65
+ }
66
+ }
package/LICENSE DELETED
@@ -1,12 +0,0 @@
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.