@salesforcedevs/dx-components 0.34.0 → 0.37.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 +1 -0
- package/package.json +2 -2
- package/src/modules/dx/button/button.ts +2 -0
- package/src/modules/dx/cardTrial/cardTrial.css +71 -0
- package/src/modules/dx/cardTrial/cardTrial.html +31 -0
- package/src/modules/dx/cardTrial/cardTrial.ts +34 -0
- package/src/modules/dx/contentArchive/contentArchive.html +8 -8
- package/src/modules/dx/contentArchive/contentArchive.ts +65 -7
- package/src/modules/dx/contentArchive/contentArchive.types.ts +6 -0
- package/src/modules/dx/filterMenu/filterMenu.html +1 -0
- package/src/modules/dx/filterMenu/filterMenu.ts +6 -2
- package/src/modules/helpers/card/card.css +5 -5
- package/src/modules/utils/queryCoordinator/queryCoordinator.ts +17 -0
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"@types/debounce": "^1.2.0",
|
|
27
27
|
"@types/lodash.get": "^4.4.6"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "afae7d1e2e986271f9f496635b39ab5f3c193b5e"
|
|
30
30
|
}
|
|
@@ -21,6 +21,8 @@ export default class Button extends LightningElement {
|
|
|
21
21
|
@api variant: ButtonVariant = "primary";
|
|
22
22
|
@api inlineTextColor: ButtonTextColor = "dark";
|
|
23
23
|
@api font: "display" | "sans" = "display";
|
|
24
|
+
@api name?: string;
|
|
25
|
+
@api value?: any;
|
|
24
26
|
|
|
25
27
|
// button props
|
|
26
28
|
@api type: "submit" | "reset" | "button" = "button";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
@import "helpers/reset";
|
|
2
|
+
@import "helpers/text";
|
|
3
|
+
@import "helpers/card";
|
|
4
|
+
|
|
5
|
+
.card-trial {
|
|
6
|
+
position: relative;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.card-trial.has-image {
|
|
12
|
+
padding-bottom: 80px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
dx-icon-badge.badge-main {
|
|
16
|
+
--dx-c-icon-badge-icon-size: var(--dx-g-spacing-mlg);
|
|
17
|
+
--dx-c-icon-badge-size: var(--dx-g-spacing-2xl);
|
|
18
|
+
|
|
19
|
+
margin-bottom: var(--dx-g-spacing-md);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.label {
|
|
23
|
+
margin-bottom: var(--dx-g-spacing-sm);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
dx-card-title {
|
|
27
|
+
margin-bottom: var(--dx-g-spacing-xs);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.body {
|
|
31
|
+
margin-bottom: var(--dx-g-spacing-sm);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.terms {
|
|
35
|
+
font-weight: var(--dx-g-font-bold);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
dx-hr {
|
|
39
|
+
--dx-c-hr-padding-horizontal: 0;
|
|
40
|
+
|
|
41
|
+
width: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.details {
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.detail {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: row;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.detail:not(:last-of-type) {
|
|
55
|
+
margin-bottom: var(--dx-g-spacing-smd);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.detail dx-icon-badge {
|
|
59
|
+
--dx-c-icon-badge-icon-size: 10px;
|
|
60
|
+
--dx-c-icon-badge-size: 18px;
|
|
61
|
+
--dx-c-icon-badge-color: var(--dx-g-blue-vibrant-40);
|
|
62
|
+
|
|
63
|
+
padding-right: var(--dx-g-spacing-sm);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
img {
|
|
67
|
+
position: absolute;
|
|
68
|
+
bottom: 0;
|
|
69
|
+
right: var(--dx-g-spacing-mlg);
|
|
70
|
+
width: var(--dx-g-spacing-6xl);
|
|
71
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<a class={className} href={href} target={target}>
|
|
3
|
+
<dx-icon-badge
|
|
4
|
+
class="badge-main"
|
|
5
|
+
background-color={badgeBackgroundColor}
|
|
6
|
+
symbol={badgeSymbol}
|
|
7
|
+
sprite={badgeSprite}
|
|
8
|
+
></dx-icon-badge>
|
|
9
|
+
<span class="label dx-text-label-3">{label}</span>
|
|
10
|
+
<dx-card-title
|
|
11
|
+
href={href}
|
|
12
|
+
target={target}
|
|
13
|
+
title={title}
|
|
14
|
+
></dx-card-title>
|
|
15
|
+
<p class="body dx-text-body-3 static-font">{body}</p>
|
|
16
|
+
<span class="terms dx-text-body-3 static-font">{terms}</span>
|
|
17
|
+
<dx-hr spacing="md"></dx-hr>
|
|
18
|
+
<ul class="details">
|
|
19
|
+
<template for:each={details} for:item="detail">
|
|
20
|
+
<li class="detail" key={detail}>
|
|
21
|
+
<dx-icon-badge
|
|
22
|
+
background-color={badgeBackgroundColor}
|
|
23
|
+
symbol="check"
|
|
24
|
+
></dx-icon-badge>
|
|
25
|
+
<span class="detail-text dx-text-body-4">{detail}</span>
|
|
26
|
+
</li>
|
|
27
|
+
</template>
|
|
28
|
+
</ul>
|
|
29
|
+
<img if:true={imgSrc} src={imgSrc} alt="" />
|
|
30
|
+
</a>
|
|
31
|
+
</template>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import { toJson } from "utils/normalizers";
|
|
4
|
+
|
|
5
|
+
export default class CardTrial extends LightningElement {
|
|
6
|
+
@api badgeBackgroundColor?: string = "indigo-vibrant-90";
|
|
7
|
+
@api badgeSprite?: string = "salesforcebrand";
|
|
8
|
+
@api badgeSymbol!: string;
|
|
9
|
+
@api body!: string;
|
|
10
|
+
@api href!: string;
|
|
11
|
+
@api label!: string;
|
|
12
|
+
@api imgSrc?: string;
|
|
13
|
+
@api target?: string;
|
|
14
|
+
@api terms!: string;
|
|
15
|
+
@api title!: string;
|
|
16
|
+
@api
|
|
17
|
+
get details() {
|
|
18
|
+
return this._details;
|
|
19
|
+
}
|
|
20
|
+
set details(value) {
|
|
21
|
+
this._details = toJson(value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private _details!: string[];
|
|
25
|
+
|
|
26
|
+
private get className() {
|
|
27
|
+
return cx(
|
|
28
|
+
"card-trial",
|
|
29
|
+
"dx-card-base",
|
|
30
|
+
"dx-card-base_section-vertical",
|
|
31
|
+
this.imgSrc && "has-image"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -29,28 +29,28 @@
|
|
|
29
29
|
name="site"
|
|
30
30
|
title={contentTypeTitle}
|
|
31
31
|
options={contentTypeList}
|
|
32
|
-
onchange={
|
|
32
|
+
onchange={handleUpdateSiteFilter}
|
|
33
33
|
></dx-filter-menu>
|
|
34
34
|
<dx-filter-menu
|
|
35
35
|
name="dates"
|
|
36
36
|
title={dateTitle}
|
|
37
37
|
options={dateList}
|
|
38
38
|
variant="nested"
|
|
39
|
-
onchange={
|
|
39
|
+
onchange={handleFiltersEvent}
|
|
40
40
|
></dx-filter-menu>
|
|
41
41
|
<template if:false={hideBlogFilters}>
|
|
42
42
|
<dx-filter-menu
|
|
43
43
|
name="authors"
|
|
44
44
|
title={authorTitle}
|
|
45
45
|
options={authorList}
|
|
46
|
-
onchange={
|
|
46
|
+
onchange={handleFiltersEvent}
|
|
47
47
|
></dx-filter-menu>
|
|
48
48
|
</template>
|
|
49
49
|
<dx-filter-menu
|
|
50
50
|
name="categories"
|
|
51
51
|
title={categoryTitle}
|
|
52
52
|
options={categoryList}
|
|
53
|
-
onchange={
|
|
53
|
+
onchange={handleFiltersEvent}
|
|
54
54
|
></dx-filter-menu>
|
|
55
55
|
</template>
|
|
56
56
|
</dx-modal-drawer>
|
|
@@ -76,28 +76,28 @@
|
|
|
76
76
|
name="site"
|
|
77
77
|
title={contentTypeTitle}
|
|
78
78
|
options={contentTypeList}
|
|
79
|
-
onchange={
|
|
79
|
+
onchange={handleUpdateSiteFilter}
|
|
80
80
|
></dx-filter-menu>
|
|
81
81
|
<dx-filter-menu
|
|
82
82
|
name="dates"
|
|
83
83
|
title={dateTitle}
|
|
84
84
|
options={dateList}
|
|
85
85
|
variant="nested"
|
|
86
|
-
onchange={
|
|
86
|
+
onchange={handleFiltersEvent}
|
|
87
87
|
></dx-filter-menu>
|
|
88
88
|
<template if:false={hideBlogFilters}>
|
|
89
89
|
<dx-filter-menu
|
|
90
90
|
name="authors"
|
|
91
91
|
title={authorTitle}
|
|
92
92
|
options={authorList}
|
|
93
|
-
onchange={
|
|
93
|
+
onchange={handleFiltersEvent}
|
|
94
94
|
></dx-filter-menu>
|
|
95
95
|
</template>
|
|
96
96
|
<dx-filter-menu
|
|
97
97
|
name="categories"
|
|
98
98
|
title={categoryTitle}
|
|
99
99
|
options={categoryList}
|
|
100
|
-
onchange={
|
|
100
|
+
onchange={handleFiltersEvent}
|
|
101
101
|
></dx-filter-menu>
|
|
102
102
|
</template>
|
|
103
103
|
</template>
|
|
@@ -2,10 +2,19 @@ import { LightningElement } from "lwc";
|
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import { getArchivePosts, getArchiveFilterList } from "utils/contentArchive";
|
|
4
4
|
import { sortSplittedPostsByMonth } from "utils/dates";
|
|
5
|
+
import { Filters } from "./contentArchive.types";
|
|
6
|
+
import { QueryCoordinator } from "utils/queryCoordinator";
|
|
5
7
|
|
|
6
8
|
const MOBILE_MATCH = "767px";
|
|
7
9
|
|
|
10
|
+
const QUERY_SITE_FILTER = "c__filter";
|
|
11
|
+
const PODCASTS = { id: 2, name: "Podcasts" };
|
|
12
|
+
const BLOGS = { id: 1, name: "Blogs" };
|
|
8
13
|
export default class ContentArchive extends LightningElement {
|
|
14
|
+
private _contentTypeList = [
|
|
15
|
+
{ ...BLOGS, checked: false },
|
|
16
|
+
{ ...PODCASTS, checked: false }
|
|
17
|
+
];
|
|
9
18
|
private totalResults: number | null = null;
|
|
10
19
|
private currentPage: number = 1;
|
|
11
20
|
private totalPages: number = 1;
|
|
@@ -22,7 +31,7 @@ export default class ContentArchive extends LightningElement {
|
|
|
22
31
|
private isMobile: boolean = false;
|
|
23
32
|
private mobileMatchMedia!: MediaQueryList;
|
|
24
33
|
|
|
25
|
-
private selectedFilterMenuData:
|
|
34
|
+
private selectedFilterMenuData: Filters = {
|
|
26
35
|
site: [],
|
|
27
36
|
dates: [],
|
|
28
37
|
authors: [],
|
|
@@ -88,10 +97,7 @@ export default class ContentArchive extends LightningElement {
|
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
get contentTypeList() {
|
|
91
|
-
return
|
|
92
|
-
{ id: 1, name: "Blogs" },
|
|
93
|
-
{ id: 2, name: "Podcasts" }
|
|
94
|
-
];
|
|
100
|
+
return this._contentTypeList;
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
get hideBlogFilters() {
|
|
@@ -146,9 +152,37 @@ export default class ContentArchive extends LightningElement {
|
|
|
146
152
|
});
|
|
147
153
|
}
|
|
148
154
|
|
|
149
|
-
private
|
|
155
|
+
private handleUpdateSiteFilter(e: CustomEvent) {
|
|
150
156
|
const { value, name, checked } = e.detail;
|
|
151
157
|
|
|
158
|
+
let selectedFilters: string[] | null = [];
|
|
159
|
+
this._contentTypeList.forEach((option) => {
|
|
160
|
+
if (option.name === value.name) {
|
|
161
|
+
option.checked = checked;
|
|
162
|
+
}
|
|
163
|
+
if (option.checked) {
|
|
164
|
+
selectedFilters?.push(option.name);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
if (selectedFilters?.length === 0) {
|
|
169
|
+
selectedFilters = null;
|
|
170
|
+
}
|
|
171
|
+
QueryCoordinator.setUrlParamValue(QUERY_SITE_FILTER, selectedFilters);
|
|
172
|
+
|
|
173
|
+
this.updateSelectedFilters(value, name, checked);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private handleFiltersEvent(e: CustomEvent) {
|
|
177
|
+
const { value, name, checked } = e.detail;
|
|
178
|
+
this.updateSelectedFilters(value, name, checked);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private updateSelectedFilters(
|
|
182
|
+
value: any,
|
|
183
|
+
name: keyof Filters,
|
|
184
|
+
checked: any
|
|
185
|
+
) {
|
|
152
186
|
let copy = {
|
|
153
187
|
...this.selectedFilterMenuData
|
|
154
188
|
};
|
|
@@ -217,7 +251,7 @@ export default class ContentArchive extends LightningElement {
|
|
|
217
251
|
private removeFilterItem(e: any) {
|
|
218
252
|
const { name, value } = e.target;
|
|
219
253
|
|
|
220
|
-
this.
|
|
254
|
+
this.handleUpdateSiteFilter(
|
|
221
255
|
new CustomEvent("updateselectedfilters", {
|
|
222
256
|
detail: {
|
|
223
257
|
name,
|
|
@@ -395,8 +429,32 @@ export default class ContentArchive extends LightningElement {
|
|
|
395
429
|
this.onMobileChange(this.mobileMatchMedia);
|
|
396
430
|
this.mobileMatchMedia.addEventListener("change", this.onMobileChange);
|
|
397
431
|
|
|
432
|
+
const presetFilters: string[] =
|
|
433
|
+
QueryCoordinator.getUrlParamValue(QUERY_SITE_FILTER);
|
|
434
|
+
if (
|
|
435
|
+
presetFilters?.some((filterString) => filterString === BLOGS.name)
|
|
436
|
+
) {
|
|
437
|
+
this.presetSiteFilter(BLOGS);
|
|
438
|
+
}
|
|
439
|
+
if (
|
|
440
|
+
presetFilters?.some(
|
|
441
|
+
(filterString) => filterString === PODCASTS.name
|
|
442
|
+
)
|
|
443
|
+
) {
|
|
444
|
+
this.presetSiteFilter(PODCASTS);
|
|
445
|
+
}
|
|
446
|
+
|
|
398
447
|
if (this.posts.length === 0) {
|
|
399
448
|
this.fetchPostsByCardType();
|
|
400
449
|
}
|
|
401
450
|
}
|
|
451
|
+
|
|
452
|
+
presetSiteFilter(filter: any) {
|
|
453
|
+
this._contentTypeList.forEach((option) => {
|
|
454
|
+
if (option.name === filter.name) {
|
|
455
|
+
option.checked = true;
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
this.updateSelectedFilters(filter, "site", true);
|
|
459
|
+
}
|
|
402
460
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
2
|
|
|
3
|
+
interface Option {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
checked: boolean;
|
|
7
|
+
}
|
|
3
8
|
export default class FilterMenu extends LightningElement {
|
|
4
9
|
@api name: string = "";
|
|
5
10
|
@api title: string = "Filter Menu";
|
|
6
|
-
@api options:
|
|
11
|
+
@api options: Option[] = [];
|
|
7
12
|
@api variant: string = "base";
|
|
8
13
|
|
|
9
14
|
private showMore: boolean = false;
|
|
@@ -80,7 +85,6 @@ export default class FilterMenu extends LightningElement {
|
|
|
80
85
|
|
|
81
86
|
private onChange(e: any) {
|
|
82
87
|
const { checked, value } = e.detail;
|
|
83
|
-
|
|
84
88
|
this.dispatchEvent(
|
|
85
89
|
new CustomEvent("change", {
|
|
86
90
|
detail: {
|
|
@@ -233,26 +233,26 @@ a.dx-card-base:hover dx-card-title {
|
|
|
233
233
|
-webkit-line-clamp: 3;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
.dx-text-body-2 {
|
|
236
|
+
.dx-text-body-2:not(.static-font) {
|
|
237
237
|
font-size: var(--dx-g-text-sm);
|
|
238
238
|
line-height: 20px;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
.dx-text-body-3 {
|
|
241
|
+
.dx-text-body-3:not(.static-font) {
|
|
242
242
|
font-size: var(--dx-g-text-xs);
|
|
243
243
|
line-height: 16px;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
.dx-text-heading-3 {
|
|
246
|
+
.dx-text-heading-3:not(.static-font) {
|
|
247
247
|
font-size: 24px;
|
|
248
248
|
line-height: 28px;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
.dx-text-heading-5 {
|
|
251
|
+
.dx-text-heading-5:not(.static-font) {
|
|
252
252
|
font-size: 12px;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
.dx-text-heading-6 {
|
|
255
|
+
.dx-text-heading-6:not(.static-font) {
|
|
256
256
|
font-size: var(--dx-g-text-sm);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class QueryCoordinator {
|
|
2
|
+
static getUrlParamValue(key: string) {
|
|
3
|
+
return JSON.parse(
|
|
4
|
+
new URL(window.location.href).searchParams.get(key) || "null"
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
static setUrlParamValue(key: string, value: any) {
|
|
9
|
+
const newUrl = new URL(window.location.href);
|
|
10
|
+
if (value) {
|
|
11
|
+
newUrl.searchParams.set(key, JSON.stringify(value));
|
|
12
|
+
} else {
|
|
13
|
+
newUrl.searchParams.delete(key);
|
|
14
|
+
}
|
|
15
|
+
window.history.replaceState(null, "", newUrl.href);
|
|
16
|
+
}
|
|
17
|
+
}
|