@salesforcedevs/dx-components 1.3.278 → 1.3.280

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.278",
3
+ "version": "1.3.280",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -46,5 +46,5 @@
46
46
  "volta": {
47
47
  "node": "16.19.1"
48
48
  },
49
- "gitHead": "fc7c783d0f8e455386c79083ceb9e14b1f38908f"
49
+ "gitHead": "432edded557f66e65958e1dc04568eeb0cdc713d"
50
50
  }
@@ -27,5 +27,6 @@
27
27
  <img src={flourish} alt={flourishAlt} />
28
28
  </div>
29
29
  </div>
30
+ <slot name="cta"></slot>
30
31
  </div>
31
32
  </template>
@@ -5,6 +5,7 @@
5
5
  :host {
6
6
  --dx-c-heading-max-lines: 4;
7
7
  --dx-c-card-grid-max-width: 60px;
8
+ --dx-c-card-title-word-break: keep-all;
8
9
  }
9
10
 
10
11
  .card {
@@ -16,27 +17,59 @@
16
17
  cursor: default;
17
18
  }
18
19
 
20
+ /* Specificity of this rule is required to override default "base" card behavior */
21
+ .card.dx-card-base.not-clickable:hover {
22
+ box-shadow: var(--dx-g-box-shadow-sm); /* no shadow as if clickable */
23
+ }
24
+
19
25
  .image {
20
26
  width: 100%;
21
27
  height: 160px;
22
28
  }
23
29
 
24
30
  :not(.not-clickable) .body {
25
- padding-right: var(--dx-c-card-clickthrough-body-right-padding, 64px); /* leave room for the control */
31
+ padding-right: var(
32
+ --dx-c-card-clickthrough-body-right-padding,
33
+ 64px
34
+ ); /* leave room for the control */
35
+ }
36
+
37
+ .card-body {
38
+ display: flex;
39
+ flex-direction: row;
40
+ }
41
+
42
+ .card-label {
43
+ display: block;
44
+ margin-bottom: var(--dx-g-card-item-spacing);
26
45
  }
27
46
 
28
- .control {
47
+ .body-text-container {
48
+ flex: 1;
49
+ margin-bottom: 0;
50
+ }
51
+
52
+ .widget {
53
+ align-self: center;
54
+ margin-left: 18px;
55
+ }
56
+
57
+ .icon-button {
29
58
  border-radius: var(--dx-c-card-clickthrough-control-border-radius, 50%);
30
- background-color: var(--dx-g-cloud-blue-vibrant-95);
31
- color: var(--dx-g-blue-vibrant-40);
32
- width: var(--dx-c-card-clickthrough-control-width, 48px);
33
59
  height: var(--dx-c-card-clickthrough-control-height, 48px);
60
+ width: var(--dx-c-card-clickthrough-control-width, 48px);
34
61
  display: flex;
35
62
  align-items: center;
36
63
  justify-content: center;
37
- position: absolute;
38
- bottom: var(--dx-c-card-clickthrough-control-bottom, 32px);
39
- right: var(--dx-c-card-clickthrough-control-right, 20px);
64
+ }
65
+
66
+ .badge {
67
+ border-radius: 12px;
68
+ font-weight: bold;
69
+ height: fit-content;
70
+ line-height: 24px;
71
+ padding: 0 12px;
72
+ text-wrap: nowrap;
40
73
  }
41
74
 
42
75
  /* text section */
@@ -6,13 +6,37 @@
6
6
  src={imgSrc}
7
7
  class="image dx-card-base_image"
8
8
  />
9
- <div
10
- class="dx-card-base_section-vertical dx-card-base_column card_section-text"
11
- >
12
- <span class="dx-text-label-3" part="label">{label}</span>
13
- <dx-card-title title={title} target={target} onclick={handleLinkClick}></dx-card-title>
14
- <span lwc:if={body} class="dx-text-body-2 body" onclick={handleTextClick}>{body}</span>
15
- <span lwc:if={href} class="control"><dx-icon size="medium" symbol="forward"></dx-icon></span>
9
+ <div class="dx-card-base_section-vertical card_section-text card-body">
10
+ <div class="body-text-container">
11
+ <span class="dx-text-label-3 card-label" part="label">
12
+ {label}
13
+ </span>
14
+ <dx-card-title
15
+ title={title}
16
+ target={target}
17
+ onclick={handleLinkClick}
18
+ ></dx-card-title>
19
+ </div>
20
+ <span
21
+ lwc:if={isWidgetIconButton}
22
+ class="widget icon-button"
23
+ style={iconStyle}
24
+ >
25
+ <dx-icon
26
+ alt={iconAlt}
27
+ color={iconColor}
28
+ size="medium"
29
+ sprite={iconSprite}
30
+ symbol={iconSymbol}
31
+ ></dx-icon>
32
+ </span>
33
+ <span
34
+ lwc:elseif={isWidgetBadge}
35
+ class="dx-text-body-4 widget badge"
36
+ style={badgeStyle}
37
+ >
38
+ {badgeText}
39
+ </span>
16
40
  </div>
17
41
  </a>
18
42
  </template>
@@ -1,8 +1,40 @@
1
1
  import { LightningElement, api } from "lwc";
2
2
  import cx from "classnames";
3
3
  import { track } from "dxUtils/analytics";
4
+ import { IconSprite, IconSymbol } from "typings/custom";
5
+ import { toDxColor } from "dxUtils/css";
6
+ import { toJson } from "dxUtils/normalizers";
7
+
8
+ export type WidgetConfig<T extends "icon-button" | "badge"> =
9
+ T extends "icon-button"
10
+ ? {
11
+ backgroundColor?: string;
12
+ color: string;
13
+ iconAlt?: string;
14
+ iconSprite?: IconSprite;
15
+ iconSymbol: IconSymbol;
16
+ type: "icon-button";
17
+ }
18
+ : {
19
+ backgroundColor: string;
20
+ color: string;
21
+ text: string;
22
+ type: "badge";
23
+ };
24
+
25
+ const defaultWidgetConfig: WidgetConfig<"icon-button"> = {
26
+ backgroundColor: "cloud-blue-vibrant-95",
27
+ color: "blue-vibrant-40",
28
+ iconAlt: "forward",
29
+ iconSymbol: "forward",
30
+ type: "icon-button"
31
+ };
32
+
33
+ export default class CardClickthrough<
34
+ T extends "icon-button" | "badge"
35
+ > extends LightningElement {
36
+ private _widgetConfig?: WidgetConfig<T>;
4
37
 
5
- export default class CardClickthrough extends LightningElement {
6
38
  @api body!: string;
7
39
  @api href?: string;
8
40
  @api imgAlt?: string = "";
@@ -12,13 +44,75 @@ export default class CardClickthrough extends LightningElement {
12
44
  @api target?: string | null = null;
13
45
  @api showMobileImg?: boolean = false;
14
46
 
47
+ @api
48
+ get widgetConfig() {
49
+ return this._widgetConfig || (this.href ? defaultWidgetConfig : {});
50
+ }
51
+ set widgetConfig(jsonIsh: any) {
52
+ this._widgetConfig = toJson(jsonIsh);
53
+ }
54
+
55
+ private get isWidgetBadge() {
56
+ return Boolean(this.widgetConfig?.type === "badge");
57
+ }
58
+
59
+ private get isWidgetIconButton() {
60
+ return Boolean(this.widgetConfig?.type === "icon-button");
61
+ }
62
+
63
+ private get badgeConfig() {
64
+ return (this.widgetConfig as WidgetConfig<"badge">) || {};
65
+ }
66
+
67
+ private get badgeStyle() {
68
+ let style = "";
69
+ const { backgroundColor, color } = this.badgeConfig;
70
+ if (backgroundColor) {
71
+ style += `background-color: ${toDxColor(backgroundColor)};`;
72
+ }
73
+ if (color) {
74
+ style += `color: ${toDxColor(color)};`;
75
+ }
76
+ return style;
77
+ }
78
+
79
+ private get badgeText() {
80
+ return this.badgeConfig.text;
81
+ }
82
+
83
+ private get iconConfig() {
84
+ return (this.widgetConfig as WidgetConfig<"icon-button">) || {};
85
+ }
86
+
87
+ private get iconAlt() {
88
+ return this.iconConfig.iconAlt || "";
89
+ }
90
+
91
+ private get iconColor() {
92
+ return this.iconConfig.color;
93
+ }
94
+
95
+ private get iconSprite() {
96
+ return this.iconConfig.iconSprite || "utility";
97
+ }
98
+
99
+ private get iconStyle() {
100
+ return this.iconConfig.backgroundColor
101
+ ? `background-color: ${toDxColor(this.iconConfig.backgroundColor)}`
102
+ : "";
103
+ }
104
+
105
+ private get iconSymbol() {
106
+ return this.iconConfig.iconSymbol || "forward";
107
+ }
108
+
15
109
  private get className(): string {
16
110
  return cx(
17
111
  "card",
18
112
  "dx-card-base",
19
113
  this.imgSrc && "has-image",
20
114
  this.showMobileImg && "show-mobile-image",
21
- !this.href && "not-clickable" // for "coming soon" cards
115
+ !this.href && "not-clickable"
22
116
  );
23
117
  }
24
118
 
@@ -42,19 +136,4 @@ export default class CardClickthrough extends LightningElement {
42
136
  track(event.currentTarget!, "custEv_cardClick", payloadCardInfo);
43
137
  track(event.currentTarget!, "custEv_linkClick", payloadCardInfo);
44
138
  }
45
-
46
- private handleTextClick(event: PointerEvent) {
47
- if (!this.href) {
48
- return;
49
- }
50
- const payloadCardTextInfo = {
51
- click_text: this.body,
52
- element_title: this.title,
53
- click_url: `${window.location.origin}${this.href}`,
54
- element_type: "tile",
55
- content_category: "cta"
56
- };
57
- track(event.currentTarget!, "custEv_ctaTile", payloadCardTextInfo);
58
- track(event.currentTarget!, "custEv_linkClick", payloadCardTextInfo);
59
- }
60
139
  }
@@ -11,8 +11,8 @@
11
11
  title={card.title}
12
12
  target={card.target}
13
13
  show-mobile-img={card.showMobileImg}
14
- >
15
- </dx-card-clickthrough>
14
+ widget-config={card.widgetConfig}
15
+ ></dx-card-clickthrough>
16
16
  </template>
17
17
  </dx-grid>
18
18
  </template>
@@ -2,17 +2,31 @@ import { api, LightningElement } from "lwc";
2
2
  import Grid from "dx/grid";
3
3
  import { DocsCard } from "typings/custom";
4
4
  import { toJson } from "dxUtils/normalizers";
5
+ import { WidgetConfig } from "dx/cardClickthrough";
5
6
 
6
- export default class CardGrid extends LightningElement {
7
- // DocsCard[] with _optional_ href
8
- private _cards: ({ href?: string } & Omit<DocsCard, "href">)[] = [];
7
+ export type CardConfig<T extends "badge" | "icon-button"> = Omit<
8
+ DocsCard,
9
+ "href"
10
+ > & {
11
+ href?: string;
12
+ widgetConfig: WidgetConfig<T>;
13
+ };
14
+
15
+ export default class CardGrid<
16
+ T extends "badge" | "icon-button"
17
+ > extends LightningElement {
18
+ private _cards: CardConfig<T>[] = [];
9
19
 
10
20
  @api
11
21
  get cards() {
12
22
  return this._cards;
13
23
  }
14
24
  set cards(value: any) {
15
- this._cards = toJson(value);
25
+ const cards = toJson(value);
26
+ this._cards = cards.map((card: any) => ({
27
+ ...card,
28
+ widgetConfig: JSON.stringify(card.widgetConfig)
29
+ }));
16
30
  }
17
31
 
18
32
  @api numColumns: Grid["columns"] = "three";
@@ -15,7 +15,7 @@ h3.dx-text-display-6 {
15
15
  font-size: var(--dx-c-card-title-font-size);
16
16
  line-height: var(--dx-c-card-title-line-height);
17
17
  letter-spacing: var(--dx-c-card-title-letter-spacing);
18
- word-break: break-word;
18
+ word-break: var(--dx-c-card-title-word-break, break-word);
19
19
  hyphens: auto;
20
20
  }
21
21
 
@@ -401,6 +401,7 @@ footer.signup-variant-no-signup {
401
401
  display: none;
402
402
  }
403
403
 
404
+ .content-container_top_large_no_signup .graphic-large,
404
405
  .graphic-large {
405
406
  background-size: 160%;
406
407
  background-position: right 50% bottom 0;
@@ -190,12 +190,6 @@ export const socialLinks = [
190
190
  iconSprite: "brand",
191
191
  label: "Github"
192
192
  },
193
- {
194
- href: "https://www.facebook.com/salesforcedevs",
195
- iconSymbol: "facebook-f",
196
- iconSprite: "brand",
197
- label: "Facebook"
198
- },
199
193
  {
200
194
  href: "https://twitter.com/salesforcedevs",
201
195
  iconSymbol: "twitter",
@@ -7,11 +7,6 @@ const URL_TOKEN = "{url}";
7
7
  const TEXT_TOKEN = "{text}";
8
8
 
9
9
  const SOCIAL_ICONS: Array<Icon> = [
10
- {
11
- name: "Facebook",
12
- symbol: "facebook-f",
13
- baseShareUrl: `https://www.facebook.com/sharer/sharer.php?u=${URL_TOKEN}`
14
- },
15
10
  {
16
11
  name: "Twitter",
17
12
  symbol: "twitter",