@salesforcedevs/dw-components 1.14.2 → 1.14.7-alpha

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.
@@ -0,0 +1,203 @@
1
+ {
2
+ "name": "@salesforcedevs/dw-components",
3
+ "version": "1.11.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "@salesforcedevs/dw-components",
9
+ "version": "1.11.0",
10
+ "license": "MIT",
11
+ "dependencies": {
12
+ "@types/youtube-player": "5.5.11",
13
+ "classnames": "2.5.1",
14
+ "lodash.clonedeep": "4.5.0",
15
+ "lodash.orderby": "4.6.0",
16
+ "lodash.uniqby": "4.7.0",
17
+ "query-string": "7.1.3",
18
+ "youtube-player": "5.6.0"
19
+ },
20
+ "devDependencies": {
21
+ "@types/classnames": "2.3.1",
22
+ "@types/lodash.clonedeep": "4.5.9",
23
+ "@types/lodash.orderby": "4.6.9",
24
+ "@types/lodash.uniqby": "4.7.9",
25
+ "@types/setimmediate": "1.0.4",
26
+ "setimmediate": "1.0.5"
27
+ },
28
+ "engines": {
29
+ "node": "18.x"
30
+ }
31
+ },
32
+ "node_modules/@types/classnames": {
33
+ "version": "2.3.1",
34
+ "resolved": "https://registry.npmjs.org/@types/classnames/-/classnames-2.3.1.tgz",
35
+ "integrity": "sha512-zeOWb0JGBoVmlQoznvqXbE0tEC/HONsnoUNH19Hc96NFsTAwTXbTqb8FMYkru1F/iqp7a18Ws3nWJvtA1sHD1A==",
36
+ "deprecated": "This is a stub types definition. classnames provides its own type definitions, so you do not need this installed.",
37
+ "dev": true,
38
+ "dependencies": {
39
+ "classnames": "*"
40
+ }
41
+ },
42
+ "node_modules/@types/lodash": {
43
+ "version": "4.17.12",
44
+ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.12.tgz",
45
+ "integrity": "sha512-sviUmCE8AYdaF/KIHLDJBQgeYzPBI0vf/17NaYehBJfYD1j6/L95Slh07NlyK2iNyBNaEkb3En2jRt+a8y3xZQ==",
46
+ "dev": true
47
+ },
48
+ "node_modules/@types/lodash.clonedeep": {
49
+ "version": "4.5.9",
50
+ "resolved": "https://registry.npmjs.org/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.9.tgz",
51
+ "integrity": "sha512-19429mWC+FyaAhOLzsS8kZUsI+/GmBAQ0HFiCPsKGU+7pBXOQWhyrY6xNNDwUSX8SMZMJvuFVMF9O5dQOlQK9Q==",
52
+ "dev": true,
53
+ "dependencies": {
54
+ "@types/lodash": "*"
55
+ }
56
+ },
57
+ "node_modules/@types/lodash.orderby": {
58
+ "version": "4.6.9",
59
+ "resolved": "https://registry.npmjs.org/@types/lodash.orderby/-/lodash.orderby-4.6.9.tgz",
60
+ "integrity": "sha512-T9o2wkIJOmxXwVTPTmwJ59W6eTi2FseiLR369fxszG649Po/xe9vqFNhf/MtnvT5jrbDiyWKxPFPZbpSVK0SVQ==",
61
+ "dev": true,
62
+ "dependencies": {
63
+ "@types/lodash": "*"
64
+ }
65
+ },
66
+ "node_modules/@types/lodash.uniqby": {
67
+ "version": "4.7.9",
68
+ "resolved": "https://registry.npmjs.org/@types/lodash.uniqby/-/lodash.uniqby-4.7.9.tgz",
69
+ "integrity": "sha512-rjrXji/seS6BZJRgXrU2h6FqxRVufsbq/HE0Tx0SdgbtlWr2YmD/M64BlYEYYlaMcpZwy32IYVkMfUMYlPuv0w==",
70
+ "dev": true,
71
+ "dependencies": {
72
+ "@types/lodash": "*"
73
+ }
74
+ },
75
+ "node_modules/@types/setimmediate": {
76
+ "version": "1.0.4",
77
+ "resolved": "https://registry.npmjs.org/@types/setimmediate/-/setimmediate-1.0.4.tgz",
78
+ "integrity": "sha512-rWPw1drMVf5zInxNpgH3nn/h6KkWqwgLT2y/ciAYQ16RAsbXOXe0AmtZ/HyzwPNw+r4GMJuI7IV7YNKO7Fs/xA==",
79
+ "dev": true
80
+ },
81
+ "node_modules/@types/youtube-player": {
82
+ "version": "5.5.11",
83
+ "resolved": "https://registry.npmjs.org/@types/youtube-player/-/youtube-player-5.5.11.tgz",
84
+ "integrity": "sha512-pM41CDBqJqBmTeJWnF7NOGz82IQoYOhqzMYXv5vKCXBqGiYSLldxMtpCk6KAEtADTy49S45AriYaCaZyeUX38Q=="
85
+ },
86
+ "node_modules/classnames": {
87
+ "version": "2.5.1",
88
+ "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz",
89
+ "integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow=="
90
+ },
91
+ "node_modules/debug": {
92
+ "version": "4.3.7",
93
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
94
+ "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
95
+ "dependencies": {
96
+ "ms": "^2.1.3"
97
+ },
98
+ "engines": {
99
+ "node": ">=6.0"
100
+ },
101
+ "peerDependenciesMeta": {
102
+ "supports-color": {
103
+ "optional": true
104
+ }
105
+ }
106
+ },
107
+ "node_modules/decode-uri-component": {
108
+ "version": "0.2.2",
109
+ "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz",
110
+ "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==",
111
+ "engines": {
112
+ "node": ">=0.10"
113
+ }
114
+ },
115
+ "node_modules/filter-obj": {
116
+ "version": "1.1.0",
117
+ "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz",
118
+ "integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==",
119
+ "engines": {
120
+ "node": ">=0.10.0"
121
+ }
122
+ },
123
+ "node_modules/load-script": {
124
+ "version": "1.0.0",
125
+ "resolved": "https://registry.npmjs.org/load-script/-/load-script-1.0.0.tgz",
126
+ "integrity": "sha512-kPEjMFtZvwL9TaZo0uZ2ml+Ye9HUMmPwbYRJ324qF9tqMejwykJ5ggTyvzmrbBeapCAbk98BSbTeovHEEP1uCA=="
127
+ },
128
+ "node_modules/lodash.clonedeep": {
129
+ "version": "4.5.0",
130
+ "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
131
+ "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ=="
132
+ },
133
+ "node_modules/lodash.orderby": {
134
+ "version": "4.6.0",
135
+ "resolved": "https://registry.npmjs.org/lodash.orderby/-/lodash.orderby-4.6.0.tgz",
136
+ "integrity": "sha512-T0rZxKmghOOf5YPnn8EY5iLYeWCpZq8G41FfqoVHH5QDTAFaghJRmAdLiadEDq+ztgM2q5PjA+Z1fOwGrLgmtg=="
137
+ },
138
+ "node_modules/lodash.uniqby": {
139
+ "version": "4.7.0",
140
+ "resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz",
141
+ "integrity": "sha512-e/zcLx6CSbmaEgFHCA7BnoQKyCtKMxnuWrJygbwPs/AIn+IMKl66L8/s+wBUn5LRw2pZx3bUHibiV1b6aTWIww=="
142
+ },
143
+ "node_modules/ms": {
144
+ "version": "2.1.3",
145
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
146
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
147
+ },
148
+ "node_modules/query-string": {
149
+ "version": "7.1.3",
150
+ "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.1.3.tgz",
151
+ "integrity": "sha512-hh2WYhq4fi8+b+/2Kg9CEge4fDPvHS534aOOvOZeQ3+Vf2mCFsaFBYj0i+iXcAq6I9Vzp5fjMFBlONvayDC1qg==",
152
+ "dependencies": {
153
+ "decode-uri-component": "^0.2.2",
154
+ "filter-obj": "^1.1.0",
155
+ "split-on-first": "^1.0.0",
156
+ "strict-uri-encode": "^2.0.0"
157
+ },
158
+ "engines": {
159
+ "node": ">=6"
160
+ },
161
+ "funding": {
162
+ "url": "https://github.com/sponsors/sindresorhus"
163
+ }
164
+ },
165
+ "node_modules/setimmediate": {
166
+ "version": "1.0.5",
167
+ "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
168
+ "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==",
169
+ "dev": true
170
+ },
171
+ "node_modules/sister": {
172
+ "version": "3.0.2",
173
+ "resolved": "https://registry.npmjs.org/sister/-/sister-3.0.2.tgz",
174
+ "integrity": "sha512-p19rtTs+NksBRKW9qn0UhZ8/TUI9BPw9lmtHny+Y3TinWlOa9jWh9xB0AtPSdmOy49NJJJSSe0Ey4C7h0TrcYA=="
175
+ },
176
+ "node_modules/split-on-first": {
177
+ "version": "1.1.0",
178
+ "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz",
179
+ "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==",
180
+ "engines": {
181
+ "node": ">=6"
182
+ }
183
+ },
184
+ "node_modules/strict-uri-encode": {
185
+ "version": "2.0.0",
186
+ "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",
187
+ "integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==",
188
+ "engines": {
189
+ "node": ">=4"
190
+ }
191
+ },
192
+ "node_modules/youtube-player": {
193
+ "version": "5.6.0",
194
+ "resolved": "https://registry.npmjs.org/youtube-player/-/youtube-player-5.6.0.tgz",
195
+ "integrity": "sha512-x95fBbxV7eZ1ZsFtMLMcSGX0Jb/GPPj69RsooyEDVa9bzvvNZ4d5VjnBVBYoY85008VefkLvtaV+b+l38R/LMQ==",
196
+ "dependencies": {
197
+ "debug": "^4.3.4",
198
+ "load-script": "^1.0.0",
199
+ "sister": "^3.0.0"
200
+ }
201
+ }
202
+ }
203
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dw-components",
3
- "version": "1.14.2",
3
+ "version": "1.14.7-alpha",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -25,6 +25,5 @@
25
25
  "@types/lodash.uniqby": "4.7.9",
26
26
  "@types/setimmediate": "1.0.4",
27
27
  "setimmediate": "1.0.5"
28
- },
29
- "gitHead": "5ceecca5be7104a277cacc732f83b8cc734c4754"
28
+ }
30
29
  }
@@ -3,3 +3,19 @@
3
3
  :host {
4
4
  display: contents;
5
5
  }
6
+
7
+ .featured-posts {
8
+ margin-bottom: var(--dx-g-spacing-xl);
9
+ }
10
+
11
+ @media screen and (min-width: 1025px) {
12
+ .hide-on-desktop {
13
+ display: none;
14
+ }
15
+ }
16
+
17
+ @media screen and (max-width: 1024px) {
18
+ .hide-on-small-screen {
19
+ display: none;
20
+ }
21
+ }
@@ -1,16 +1,94 @@
1
1
  <template>
2
- <template for:each={posts} for:item="post">
3
- <dx-card-blog-post
4
- label="BLOG POST"
5
- body={post.body}
6
- datetime={post.datetime}
7
- href={post.href}
8
- img-alt={post.imgAlt}
9
- img-src={post.imgSrc}
10
- key={post.id}
11
- header={post.title}
12
- authors={post.authors}
13
- ></dx-card-blog-post>
14
- <dx-hr spacing="2xs" class="mobile-divider_posts" key={post.id}></dx-hr>
2
+ <template lwc:if={hasBlogPosts}>
3
+ <div class="hide-on-small-screen">
4
+ <div class="featured-posts">
5
+ <dx-grid columns="two">
6
+ <dx-card-blog-post
7
+ label="BLOG POST"
8
+ body={featuredPost.body}
9
+ datetime={featuredPost.datetime}
10
+ href={featuredPost.href}
11
+ img-alt={featuredPost.imgAlt}
12
+ img-src={featuredPost.imgSrc}
13
+ key={featuredPost.id}
14
+ header={featuredPost.title}
15
+ authors={featuredPost.authors}
16
+ ></dx-card-blog-post>
17
+ <dx-grid columns="one">
18
+ <template for:each={secondAndThird} for:item="post">
19
+ <dx-card-blog-post
20
+ layout="horizontal"
21
+ datetime={post.datetime}
22
+ href={post.href}
23
+ img-alt={post.imgAlt}
24
+ img-src={post.imgSrc}
25
+ key={post.id}
26
+ header={post.title}
27
+ authors={post.authors}
28
+ ></dx-card-blog-post>
29
+ </template>
30
+ </dx-grid>
31
+ </dx-grid>
32
+ </div>
33
+ <dx-grid columns="four">
34
+ <template for:each={restOfBlogPosts} for:item="post">
35
+ <dx-card-blog-post
36
+ label="BLOG POST"
37
+ body={post.body}
38
+ datetime={post.datetime}
39
+ href={post.href}
40
+ img-alt={post.imgAlt}
41
+ img-src={post.imgSrc}
42
+ key={post.id}
43
+ header={post.title}
44
+ authors={post.authors}
45
+ ></dx-card-blog-post>
46
+ <dx-hr
47
+ spacing="2xs"
48
+ class="mobile-divider_posts"
49
+ key={post.id}
50
+ ></dx-hr>
51
+ </template>
52
+ </dx-grid>
53
+ </div>
54
+
55
+ <div class="hide-on-desktop">
56
+ <dx-grid columns="three">
57
+ <dx-card-blog-post
58
+ label="BLOG POST"
59
+ body={featuredPost.body}
60
+ datetime={featuredPost.datetime}
61
+ href={featuredPost.href}
62
+ img-alt={featuredPost.imgAlt}
63
+ img-src={featuredPost.imgSrc}
64
+ key={featuredPost.id}
65
+ header={featuredPost.title}
66
+ authors={featuredPost.authors}
67
+ ></dx-card-blog-post>
68
+ <dx-hr
69
+ spacing="2xs"
70
+ class="mobile-divider_posts"
71
+ key={post.id}
72
+ ></dx-hr>
73
+ <template for:each={filteredPosts} for:item="post">
74
+ <dx-card-blog-post
75
+ label="BLOG POST"
76
+ body={post.body}
77
+ datetime={post.datetime}
78
+ href={post.href}
79
+ img-alt={post.imgAlt}
80
+ img-src={post.imgSrc}
81
+ key={post.id}
82
+ header={post.title}
83
+ authors={post.authors}
84
+ ></dx-card-blog-post>
85
+ <dx-hr
86
+ spacing="2xs"
87
+ class="mobile-divider_posts"
88
+ key={post.id}
89
+ ></dx-hr>
90
+ </template>
91
+ </dx-grid>
92
+ </div>
15
93
  </template>
16
94
  </template>
@@ -1,5 +1,5 @@
1
1
  import { LightningElement, api, track } from "lwc";
2
- import { fetchWordpressPosts } from "dxUtils/wordpress";
2
+ import { fetchSingleWordpressPost, fetchWordpressPosts } from "dxUtils/wordpress";
3
3
  import { normalizePost } from "dxUtils/normalizers";
4
4
 
5
5
  type BlogPost = {
@@ -11,19 +11,74 @@ type BlogPost = {
11
11
  };
12
12
 
13
13
  export default class CardBlogPostProvider extends LightningElement {
14
- @api count?: string;
14
+ @api count: string = "7";
15
+ @api featuredPostId?: string;
16
+ _featuredPost!: BlogPost;
15
17
 
16
- @track posts: BlogPost[] = [];
18
+ private _posts: BlogPost[] = [];
19
+ @track _filteredPosts: BlogPost[] = [];
20
+
21
+ set posts(posts: BlogPost[]) {
22
+ if (!this._featuredPost) {
23
+ this._featuredPost = posts[0];
24
+ }
25
+ this._filteredPosts = this.filterOutFeaturedPost(posts);
26
+ this._posts = posts;
27
+ }
28
+
29
+ get filteredPosts() {
30
+ return this._filteredPosts;
31
+ }
32
+
33
+ set featuredPost(featuredPost: BlogPost) {
34
+ this._featuredPost = featuredPost;
35
+ this._filteredPosts = this.filterOutFeaturedPost(this._posts);
36
+ }
37
+
38
+ get featuredPost() {
39
+ return this._featuredPost;
40
+ }
41
+
42
+ get hasBlogPosts() {
43
+ return this._posts && this._posts.length > 0;
44
+ }
45
+
46
+ get secondAndThird() {
47
+ return this._filteredPosts.slice(0, 2);
48
+ }
49
+
50
+ get restOfBlogPosts() {
51
+ return this._filteredPosts.slice(2);
52
+ }
53
+
54
+ private filterOutFeaturedPost(posts: BlogPost[]) {
55
+ // the featured post + the rest should be equal to the count
56
+ const numberOfPostsMinusOne = parseInt(this.count, 10) - 1;
57
+ return posts.filter((post) => post.id !== this._featuredPost.id).slice(0, numberOfPostsMinusOne);
58
+ }
17
59
 
18
60
  private fetchPosts = async () => {
61
+ // in case we get the featured post, we may need an extra
62
+ const numberOfPostsPlusOne = parseInt(this.count, 10) + 1;
19
63
  this.posts = await fetchWordpressPosts(
20
64
  "/blogs/api",
21
65
  normalizePost,
22
- this.count
66
+ String(numberOfPostsPlusOne)
23
67
  );
24
68
  };
25
69
 
70
+ private fetchFeaturedPost = async () => {
71
+ if (this.featuredPostId) {
72
+ this.featuredPost = await fetchSingleWordpressPost(
73
+ "/blogs/wp-json/wp/v2/posts",
74
+ this.featuredPostId,
75
+ normalizePost
76
+ );
77
+ }
78
+ }
79
+
26
80
  connectedCallback() {
81
+ this.fetchFeaturedPost();
27
82
  this.fetchPosts();
28
83
  }
29
84
  }
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.