@salesforcedevs/dx-components 1.3.46 → 1.3.47

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/dx-components",
3
- "version": "1.3.46",
3
+ "version": "1.3.47",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -40,5 +40,5 @@
40
40
  "eventsourcemock": "^2.0.0",
41
41
  "luxon": "^3.1.0"
42
42
  },
43
- "gitHead": "decc9a3791a30eb8d16fb7cffb3adf7092ab863b"
43
+ "gitHead": "37ecd8ca7dc38636ff3ec336077512ab52065c8d"
44
44
  }
@@ -1,8 +1,6 @@
1
1
  <template>
2
2
  <dx-card-content
3
- author-href={authorHref}
4
- author-img-src={authorImgSrc}
5
- author-label={authorLabel}
3
+ authors={authors}
6
4
  body={body}
7
5
  featured={featured}
8
6
  href={href}
@@ -1,9 +1,6 @@
1
1
  import { LightningElement, api } from "lwc";
2
2
 
3
3
  export default class CardBlogPost extends LightningElement {
4
- @api authorHref?: string | null = null;
5
- @api authorImgSrc!: string | null;
6
- @api authorLabel!: string | null;
7
4
  @api body!: string;
8
5
  @api datetime!: string;
9
6
  @api dateTime?: string | null = null;
@@ -14,6 +11,7 @@ export default class CardBlogPost extends LightningElement {
14
11
  @api label?: string;
15
12
  @api target?: string | null = null;
16
13
  @api title!: string;
14
+ @api authors?: Array<any> | null = null;
17
15
 
18
16
  // LWC is being compiled so that datetime is being interpreted as date-time
19
17
  // ONLY from from the implementation in dx-card-blog-post-provider
@@ -7,6 +7,11 @@
7
7
  height: 100%;
8
8
  }
9
9
 
10
+ .authors > *:not(:last-child) {
11
+ padding-bottom: 6px;
12
+ display: block;
13
+ }
14
+
10
15
  .card-content {
11
16
  display: flex;
12
17
  justify-content: flex-start;
@@ -42,12 +42,16 @@
42
42
  >
43
43
  {subtitle}
44
44
  </span>
45
- <dx-image-and-label
46
- if:true={hasAuthor}
47
- href={authorHref}
48
- img-src={authorImgSrc}
49
- label={authorLabel}
50
- ></dx-image-and-label>
45
+ <div class="authors" if:true={authors}>
46
+ <template for:each={authors} for:item="author">
47
+ <dx-image-and-label
48
+ key={author.key}
49
+ img-src={author.imgSrc}
50
+ label={author.name}
51
+ href={author.href}
52
+ ></dx-image-and-label>
53
+ </template>
54
+ </div>
51
55
  <span if:true={body} class="body dx-text-body-2" part="body">
52
56
  {body}
53
57
  </span>
@@ -3,11 +3,10 @@ import cx from "classnames";
3
3
  import { LightningSlotElement } from "typings/custom";
4
4
  import { isSlotEmpty } from "dxUtils/slot";
5
5
  import { toDxColor } from "dxUtils/css";
6
+ import { toJson } from "dxUtils/normalizers";
7
+ import { ImageAndLabel } from "../imageAndLabel";
6
8
 
7
9
  export default class CardContent extends LightningElement {
8
- @api authorHref?: string | null = null;
9
- @api authorImgSrc?: string | null = null;
10
- @api authorLabel?: string | null = null;
11
10
  @api backgroundColor?: string | null = null;
12
11
  @api body?: string | null = null;
13
12
  @api featured?: boolean = false;
@@ -19,14 +18,30 @@ export default class CardContent extends LightningElement {
19
18
  @api subtitle?: string | null = null;
20
19
  @api target?: string | null = null;
21
20
  @api title!: string;
21
+ @api
22
+ get authors() {
23
+ if (this._authors && this._authors.length) {
24
+ return this._authors!.map((author, index) => ({
25
+ ...author,
26
+ imgSrc: author.avatar_urls?.["24"] || author.image_src,
27
+ key: index
28
+ }));
29
+ }
30
+ return undefined;
31
+ }
32
+
33
+ set authors(value: any) {
34
+ if (value !== "undefined") {
35
+ this._authors = (toJson(value) as Array<any>)?.filter(
36
+ (author) => author.name
37
+ );
38
+ }
39
+ }
40
+ private _authors?: Array<ImageAndLabel>;
22
41
 
23
42
  private isDatetimeEmpty: boolean = true;
24
43
  private isLinkHovered: boolean = false;
25
44
 
26
- private get hasAuthor() {
27
- return this.authorImgSrc && this.authorLabel;
28
- }
29
-
30
45
  private get backgroundStyle(): string {
31
46
  return this.backgroundColor
32
47
  ? `background: ${toDxColor(this.backgroundColor)}`
@@ -12,6 +12,7 @@ dx-formatted-date-time,
12
12
  .podcast-length {
13
13
  /* Push down a little to align with dx-image-and-label */
14
14
  margin-top: 3px;
15
+ margin-right: var(--dx-g-spacing-sm);
15
16
  }
16
17
 
17
18
  .card-body {
@@ -19,8 +20,7 @@ dx-formatted-date-time,
19
20
  }
20
21
 
21
22
  .card-extra-info {
22
- gap: var(--dx-g-spacing-sm);
23
- align-items: center;
23
+ text-align: start;
24
24
  }
25
25
 
26
26
  .card-container {
@@ -28,11 +28,19 @@ dx-formatted-date-time,
28
28
  padding-bottom: var(--dx-g-spacing-xl);
29
29
  flex-direction: column;
30
30
  gap: var(--dx-g-spacing-smd);
31
+ display: flex;
31
32
  }
32
33
 
33
- .card-container,
34
- .card-extra-info {
35
- display: flex;
34
+ .card-extra-info .authors {
35
+ margin-bottom: var(--dx-g-spacing-smd);
36
+ }
37
+
38
+ .card-extra-info .authors > *:not(:last-child) {
39
+ padding-right: var(--dx-g-spacing-md);
40
+ }
41
+
42
+ .card-extra-info .authors > * {
43
+ display: inline-flex;
36
44
  }
37
45
 
38
46
  .card-dot-separator {
@@ -43,6 +51,8 @@ dx-formatted-date-time,
43
51
  background-color: var(--dx-g-text-label-color);
44
52
  border-radius: 100%;
45
53
  margin-bottom: 3px;
54
+ display: inline-block;
55
+ margin-right: var(--dx-g-spacing-sm);
46
56
  }
47
57
 
48
58
  .card-mobile .card-body {
@@ -8,11 +8,15 @@
8
8
  title={title}
9
9
  ></dx-card-title>
10
10
  <div class="card-extra-info dx-text-label-1-dark">
11
- <dx-image-and-label
12
- if:true={renderAuthor}
13
- img-src={authorImage}
14
- label={authorLabel}
15
- ></dx-image-and-label>
11
+ <div class="authors" if:true={renderAuthor}>
12
+ <template for:each={authors} for:item="author">
13
+ <dx-image-and-label
14
+ key={author.key}
15
+ label={author.name}
16
+ img-src={author.imgSrc}
17
+ ></dx-image-and-label>
18
+ </template>
19
+ </div>
16
20
  <span class="podcast-length" if:true={renderLength}>{length}</span>
17
21
  <span if:true={renderDot} class="card-dot-separator"></span>
18
22
  <dx-formatted-date-time
@@ -1,21 +1,45 @@
1
1
  import { api } from "lwc";
2
2
  import { ArchiveCard } from "dxBaseElements/archiveCard";
3
3
  import cx from "classnames";
4
+ import ImageAndLabel from "../imageAndLabel";
5
+ import { toJson } from "dxUtils/normalizers";
4
6
 
5
7
  export default class ExpandedCard extends ArchiveCard {
6
8
  @api body!: string;
7
9
  @api date: string | null = null;
8
10
  @api topics: Array<string> = [];
9
- @api authorLabel?: string | null = null;
10
- @api authorImgSrc?: string | null = null;
11
11
  @api length?: string;
12
+ @api
13
+ get authors() {
14
+ if (this._authors && this._authors.length) {
15
+ return this._authors!.map((author, index) => ({
16
+ ...author,
17
+ imgSrc: !this.mobile
18
+ ? author.avatar_urls?.["24"] ||
19
+ author.image_src ||
20
+ author.imgSrc
21
+ : "",
22
+ key: index
23
+ }));
24
+ }
25
+ return undefined;
26
+ }
27
+
28
+ set authors(value: any) {
29
+ if (value !== "undefined") {
30
+ this._authors = (toJson(value) as Array<any>)?.filter(
31
+ (author) => author.name
32
+ );
33
+ }
34
+ }
35
+ private _authors?: Array<ImageAndLabel>;
12
36
 
13
37
  private get isBlog(): boolean {
14
38
  return this.contentType === "blog";
15
39
  }
16
40
 
17
41
  private get hasAuthor(): boolean {
18
- return !!(this.authorImgSrc && this.authorLabel);
42
+ return this.authors?.length;
19
43
  }
20
44
 
21
45
  private get renderAuthor(): boolean {
@@ -27,17 +51,13 @@ export default class ExpandedCard extends ArchiveCard {
27
51
  }
28
52
 
29
53
  private get renderDot(): boolean {
30
- return !!((this.renderAuthor || this.renderLength) && this.date);
54
+ return !!(this.renderLength && this.date);
31
55
  }
32
56
 
33
57
  private get hasTopics(): boolean {
34
58
  return !!this.topics?.length;
35
59
  }
36
60
 
37
- private get authorImage(): string {
38
- return !this.mobile && this.authorImgSrc ? this.authorImgSrc : "";
39
- }
40
-
41
61
  private get containerClass(): string {
42
62
  return cx("card-container", this.mobile && "card-mobile");
43
63
  }
@@ -58,9 +58,7 @@ export const normalizePost = ({
58
58
  body: description,
59
59
  datetime: date,
60
60
  href: url,
61
- authorHref: get(authors, "[0].link"),
62
- authorImgSrc: get(authors, "[0].avatar_urls.48"),
63
- authorName: get(authors, "[0].name"),
61
+ authors: authors,
64
62
  imgAlt: "Blogpost image",
65
63
  imgSrc: featuredImage,
66
64
  id,