@salesforcedevs/dw-components 1.3.261-alpha.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dw-components",
3
- "version": "1.3.261-alpha.1",
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,12 +10,12 @@
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
18
  "query-string": "^7.1.3",
18
- "@types/youtube-player": "^5.5.11",
19
19
  "youtube-player": "^5.6.0"
20
20
  },
21
21
  "devDependencies": {
@@ -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 {
@@ -2,6 +2,8 @@ import { api, LightningElement } from "lwc";
2
2
  import YoutubePlayer from "youtube-player";
3
3
  import { VideoData } from "./types";
4
4
 
5
+ const PLAYING = 1;
6
+
5
7
  export default class YoutubeVideoGrid extends LightningElement {
6
8
  @api width = 382;
7
9
  @api height = 215;
@@ -26,28 +28,39 @@ export default class YoutubeVideoGrid extends LightningElement {
26
28
 
27
29
  private _videosData: Array<VideoData> = [];
28
30
  private players: any = [];
31
+ private _hasRendered = false;
29
32
 
30
33
  private pauseAllExceptCurrent(id: any) {
31
- this.players.forEach((player: any) => {
32
- if (player.id !== id) {
33
- player.player.pauseVideo();
34
+ this.players.forEach((currentPlayer: any) => {
35
+ if (currentPlayer.id !== id) {
36
+ currentPlayer.player.pauseVideo();
34
37
  }
35
38
  });
36
39
  }
37
40
 
38
41
  renderedCallback() {
42
+ if (this._hasRendered) {
43
+ return;
44
+ }
45
+
39
46
  const iframeEls = this.template.querySelectorAll("iframe");
40
47
 
41
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
42
51
  const player = YoutubePlayer(el);
43
52
 
44
53
  this.players.push({ id: index, player });
45
54
 
55
+ // Listener for state change events (play, pause, etc).
46
56
  player.on("stateChange", (event: any) => {
47
- if (event.data === 1) {
57
+ if (event.data === PLAYING) {
58
+ // Pause all other players when a new one starts playing.
48
59
  this.pauseAllExceptCurrent(index);
49
60
  }
50
61
  });
51
62
  });
63
+
64
+ this._hasRendered = true;
52
65
  }
53
66
  }