@salesforcedevs/dw-components 1.3.323-alpha.2 → 1.3.323
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 +1 -4
- package/src/modules/dw/blogsGrid/blogsGrid.html +1 -1
- package/src/modules/dw/browseTrials/browseTrials.html +4 -4
- package/src/modules/dw/browseTrials/browseTrials.ts +1 -1
- package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.html +1 -1
- package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.html +1 -1
- package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.css +0 -46
- package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.html +111 -54
- package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.ts +403 -8
- package/src/modules/dw/contentArchive/contentArchive.html +15 -15
- package/src/modules/dw/docsGrid/docsGrid.html +2 -2
- package/src/modules/dw/eventsList/eventsList.html +5 -5
- package/src/modules/dw/podcastsGrid/podcastsGrid.html +1 -1
- package/src/modules/dw/podcastsPromo/podcastsPromo.html +1 -1
- package/src/modules/dw/videoGrid/videoGrid.html +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "1.3.323
|
|
3
|
+
"version": "1.3.323",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -25,8 +25,5 @@
|
|
|
25
25
|
"@types/lodash.uniqby": "^4.7.7",
|
|
26
26
|
"@types/setimmediate": "^1.0.2",
|
|
27
27
|
"setimmediate": "^1.0.5"
|
|
28
|
-
},
|
|
29
|
-
"volta": {
|
|
30
|
-
"node": "16.19.1"
|
|
31
28
|
}
|
|
32
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<dx-section
|
|
2
|
+
<dx-section header={header}>
|
|
3
3
|
<dx-tab-panel-list
|
|
4
4
|
tabs={tabLabels}
|
|
5
5
|
onchange={handleTabChange}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</div>
|
|
27
27
|
<template for:each={filteredCategories} for:item="category">
|
|
28
28
|
<dx-section
|
|
29
|
-
|
|
29
|
+
header={category.title}
|
|
30
30
|
subtitle={category.subtitle}
|
|
31
31
|
heading-level="4"
|
|
32
32
|
subtitle-level="2"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
href={card.href}
|
|
51
51
|
label={card.label}
|
|
52
52
|
terms={card.terms}
|
|
53
|
-
|
|
53
|
+
header={card.title}
|
|
54
54
|
button-one-cta={card.buttonOneCta}
|
|
55
55
|
button-one-href={card.buttonOneHref}
|
|
56
56
|
button-one-icon={card.buttonOneIcon}
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
href={card.href}
|
|
70
70
|
label={card.label}
|
|
71
71
|
terms={card.terms}
|
|
72
|
-
|
|
72
|
+
header={card.title}
|
|
73
73
|
button-one-cta={card.buttonOneCta}
|
|
74
74
|
button-one-href={card.buttonOneHref}
|
|
75
75
|
button-one-icon={card.buttonOneIcon}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
@import "dxHelpers/reset";
|
|
2
|
-
@import "dxHelpers/text";
|
|
3
|
-
@import "dxHelpers/card";
|
|
4
|
-
|
|
5
1
|
dx-section:first-of-type {
|
|
6
2
|
--dx-c-section-padding-bottom: 0;
|
|
7
3
|
}
|
|
@@ -10,58 +6,16 @@ dx-section {
|
|
|
10
6
|
--dx-c-section-position: revert;
|
|
11
7
|
}
|
|
12
8
|
|
|
13
|
-
.feature-card {
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-direction: row;
|
|
16
|
-
padding: 20px;
|
|
17
|
-
border-radius: 15px;
|
|
18
|
-
box-shadow: var(--dx-g-box-shadow-sm);
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
|
|
21
|
-
--dx-c-card-title-color: var(--dx-g-blue-vibrant-20);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.feature-card:hover {
|
|
25
|
-
--dx-c-card-title-color: var(--dx-g-blue-vibrant-40);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.feature-card-body {
|
|
29
|
-
padding-right: 20px;
|
|
30
|
-
display: flex;
|
|
31
|
-
flex-direction: column;
|
|
32
|
-
justify-content: space-between;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.dx-text-display-6 {
|
|
36
|
-
color: var(--dx-c-card-title-color);
|
|
37
|
-
transition: var(--dx-g-transition-hue-1x);
|
|
38
|
-
font-size: var(--dx-g-text-xl);
|
|
39
|
-
line-height: var(--dx-c-card-title-line-height);
|
|
40
|
-
letter-spacing: var(--dx-c-card-title-letter-spacing);
|
|
41
|
-
word-break: var(--dx-c-card-title-word-break, break-word);
|
|
42
|
-
hyphens: auto;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
9
|
.badge-link-container {
|
|
46
10
|
padding-top: var(--dx-g-spacing-md);
|
|
47
|
-
width: 100%;
|
|
48
11
|
}
|
|
49
12
|
|
|
50
13
|
.badge-container {
|
|
51
|
-
display: flex;
|
|
52
|
-
flex-flow: row wrap;
|
|
53
|
-
width: 100%;
|
|
54
|
-
gap: 1em;
|
|
55
14
|
padding-top: 0;
|
|
56
15
|
}
|
|
57
16
|
|
|
58
17
|
.external-link-container {
|
|
59
18
|
padding-top: var(--dx-g-spacing-md);
|
|
60
|
-
display: flex;
|
|
61
|
-
flex-flow: row wrap;
|
|
62
|
-
justify-content: space-between;
|
|
63
|
-
margin-top: 4em;
|
|
64
|
-
gap: 1em;
|
|
65
19
|
}
|
|
66
20
|
|
|
67
21
|
.item-container {
|
|
@@ -1,85 +1,142 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<dx-section>
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
<dx-feature
|
|
4
|
+
header={featuredCodeSample.title}
|
|
5
|
+
button-href={featuredCodeSample.href}
|
|
6
|
+
button-label="Explore on GitHub"
|
|
7
|
+
image-src={featuredCodeSample.imgSrc}
|
|
8
|
+
variant="display"
|
|
9
|
+
label="Featured Demo"
|
|
10
|
+
is-external-link
|
|
11
|
+
class="code-samples-feature"
|
|
12
|
+
>
|
|
13
|
+
{featuredCodeSample.body}
|
|
14
|
+
</dx-feature>
|
|
15
|
+
</dx-section>
|
|
16
|
+
|
|
17
|
+
<dx-section header="Browse Demos">
|
|
18
|
+
<div class="docs-action-bar">
|
|
19
|
+
<div class="records-container">
|
|
20
|
+
<span if:true={endingRecord}>
|
|
21
|
+
Showing { startingRecord } to { endingRecord } of {
|
|
22
|
+
filteredSamples.length }
|
|
9
23
|
</span>
|
|
10
|
-
<div class="badge-link-container">
|
|
11
|
-
<div class="external-link-container">
|
|
12
|
-
<dx-button
|
|
13
|
-
target={target}
|
|
14
|
-
icon-symbol="new_window"
|
|
15
|
-
variant="primary"
|
|
16
|
-
href={featuredCodeSample.githubLink}
|
|
17
|
-
onclick={handleReadItClick}
|
|
18
|
-
>
|
|
19
|
-
Explore on GitHub
|
|
20
|
-
</dx-button>
|
|
21
|
-
<dx-button
|
|
22
|
-
target={target}
|
|
23
|
-
variant="secondary"
|
|
24
|
-
href={featuredCodeSample.trailheadLink}
|
|
25
|
-
onclick={handleReadItClick}
|
|
26
|
-
>
|
|
27
|
-
Learn on Trailhead
|
|
28
|
-
</dx-button>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
24
|
</div>
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
<div class="filters-container">
|
|
26
|
+
<dx-popover if:true={showSourcesFilter} width="max-content">
|
|
27
|
+
<dx-button
|
|
28
|
+
class="filter-button"
|
|
29
|
+
variant="tertiary"
|
|
30
|
+
icon-symbol="chevrondown"
|
|
31
|
+
slot="control"
|
|
32
|
+
>
|
|
33
|
+
Source
|
|
34
|
+
</dx-button>
|
|
35
|
+
<dx-checkbox-group
|
|
36
|
+
legend="Source"
|
|
37
|
+
options={sources}
|
|
38
|
+
slot="content"
|
|
39
|
+
onchange={handleSourceFilterChange}
|
|
40
|
+
value={selectedSourceFilter}
|
|
41
|
+
class="filter-checkbox-group"
|
|
42
|
+
></dx-checkbox-group>
|
|
43
|
+
</dx-popover>
|
|
44
|
+
<dx-popover width="max-content">
|
|
45
|
+
<dx-button
|
|
46
|
+
class="filter-button"
|
|
47
|
+
variant="tertiary"
|
|
48
|
+
icon-symbol="chevrondown"
|
|
49
|
+
slot="control"
|
|
50
|
+
>
|
|
51
|
+
Type
|
|
52
|
+
</dx-button>
|
|
53
|
+
<dx-checkbox-group
|
|
54
|
+
legend="Type"
|
|
55
|
+
options={types}
|
|
56
|
+
slot="content"
|
|
57
|
+
onchange={handleTypeFilterChange}
|
|
58
|
+
value={selectedTypeFilter}
|
|
59
|
+
class="filter-checkbox-group"
|
|
60
|
+
></dx-checkbox-group>
|
|
61
|
+
</dx-popover>
|
|
62
|
+
<dx-popover width="max-content">
|
|
63
|
+
<dx-button
|
|
64
|
+
class="filter-button"
|
|
65
|
+
variant="tertiary"
|
|
66
|
+
icon-symbol="chevrondown"
|
|
67
|
+
slot="control"
|
|
68
|
+
>
|
|
69
|
+
Products
|
|
70
|
+
</dx-button>
|
|
71
|
+
<dx-checkbox-group
|
|
72
|
+
legend="Products"
|
|
73
|
+
options={products}
|
|
74
|
+
slot="content"
|
|
75
|
+
onchange={handleProductFilterChange}
|
|
76
|
+
value={selectedProductFilter}
|
|
77
|
+
class="filter-checkbox-group"
|
|
78
|
+
></dx-checkbox-group>
|
|
79
|
+
</dx-popover>
|
|
80
|
+
</div>
|
|
81
|
+
<dx-input
|
|
82
|
+
size="small"
|
|
83
|
+
placeholder="Search..."
|
|
84
|
+
icon-symbol="search"
|
|
85
|
+
shortcut-key="j"
|
|
86
|
+
class="docs-search-input"
|
|
87
|
+
onchange={handleSearchChange}
|
|
88
|
+
value={searchTerm}
|
|
89
|
+
></dx-input>
|
|
37
90
|
</div>
|
|
38
|
-
</dx-section>
|
|
39
|
-
|
|
40
|
-
<dx-section title="Explore the Apps">
|
|
41
91
|
<dx-grid columns={tileColumns} if:false={showEmptyState}>
|
|
42
92
|
<dx-card-docs
|
|
43
|
-
|
|
93
|
+
class="content-card"
|
|
94
|
+
for:each={currentPageSamples}
|
|
44
95
|
for:item="item"
|
|
45
96
|
for:index="i"
|
|
46
97
|
key={item.id}
|
|
47
98
|
body={item.body}
|
|
48
99
|
label={item.type}
|
|
49
|
-
|
|
50
|
-
href={item.
|
|
51
|
-
img-src={item.img}
|
|
100
|
+
header={item.title}
|
|
101
|
+
href={item.href}
|
|
52
102
|
>
|
|
53
103
|
<div class="badge-link-container">
|
|
54
104
|
<div class="badge-container">
|
|
55
105
|
<dx-metadata-badge
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
key={tag}
|
|
59
|
-
value={tag}
|
|
106
|
+
value={item.product}
|
|
107
|
+
size="small"
|
|
60
108
|
></dx-metadata-badge>
|
|
61
109
|
</div>
|
|
62
110
|
<div class="external-link-container">
|
|
63
111
|
<dx-button
|
|
64
112
|
target={target}
|
|
65
113
|
icon-symbol="new_window"
|
|
66
|
-
variant="
|
|
67
|
-
href={item.
|
|
114
|
+
variant="inline"
|
|
115
|
+
href={item.href}
|
|
68
116
|
onclick={handleReadItClick}
|
|
69
117
|
>
|
|
70
|
-
|
|
71
|
-
</dx-button>
|
|
72
|
-
<dx-button
|
|
73
|
-
target={target}
|
|
74
|
-
variant="secondary"
|
|
75
|
-
href={item.trailheadLink}
|
|
76
|
-
onclick={handleReadItClick}
|
|
77
|
-
>
|
|
78
|
-
Learn on Trailhead
|
|
118
|
+
{item.buttonText}
|
|
79
119
|
</dx-button>
|
|
80
120
|
</div>
|
|
81
121
|
</div>
|
|
82
122
|
</dx-card-docs>
|
|
83
123
|
</dx-grid>
|
|
124
|
+
<div if:false={hidePagination} class="pagination-container">
|
|
125
|
+
<dx-pagination
|
|
126
|
+
if:false={showEmptyState}
|
|
127
|
+
current-page={page}
|
|
128
|
+
total-pages={totalPages}
|
|
129
|
+
pages-to-show={pagesToShow}
|
|
130
|
+
onpagechange={goToPage}
|
|
131
|
+
></dx-pagination>
|
|
132
|
+
</div>
|
|
133
|
+
<dx-empty-state
|
|
134
|
+
variant="alt"
|
|
135
|
+
header="Beep boop. That did not compute."
|
|
136
|
+
subtitle={emptyStateSubtitle}
|
|
137
|
+
body={emptyStateBody}
|
|
138
|
+
suggestions={emptyStateSuggestions}
|
|
139
|
+
if:true={showEmptyState}
|
|
140
|
+
></dx-empty-state>
|
|
84
141
|
</dx-section>
|
|
85
142
|
</template>
|
|
@@ -1,20 +1,128 @@
|
|
|
1
1
|
import { api, LightningElement } from "lwc";
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
import qs from "query-string";
|
|
3
|
+
import uniqBy from "lodash.uniqby";
|
|
4
|
+
import orderBy from "lodash.orderby";
|
|
5
|
+
import cloneDeep from "lodash.clonedeep";
|
|
6
|
+
import { DropdownItem, CodeSample } from "typings/custom";
|
|
4
7
|
import { toJson } from "dxUtils/normalizers";
|
|
8
|
+
import { track } from "dxUtils/analytics";
|
|
5
9
|
|
|
10
|
+
const PRODUCT_FILTER_ALL_PRODUCTS = "all products";
|
|
11
|
+
const WAIT_TIME = 500;
|
|
6
12
|
const DEFAULT_BUTTON_TEXT = "Explore on GitHub";
|
|
7
13
|
export default class CodeSamplesGrid extends LightningElement {
|
|
14
|
+
private searchTerm = "";
|
|
15
|
+
private selectedProductFilter: string[] | null = null;
|
|
16
|
+
private selectedTypeFilter: string[] | null = null;
|
|
17
|
+
private selectedSourceFilter: string[] | null = null;
|
|
18
|
+
private page = 1;
|
|
19
|
+
private pageSize = 9;
|
|
20
|
+
private startingRecord = 1;
|
|
21
|
+
private endingRecord = 24;
|
|
22
|
+
private totalRecountCount = 0;
|
|
23
|
+
private totalPages = 1;
|
|
8
24
|
private _featuredCodeSample?: CodeSample = undefined;
|
|
9
25
|
private _samplesList: CodeSample[] = [];
|
|
26
|
+
private _typesFiltersList: DropdownItem[] = [];
|
|
27
|
+
private _sourceFiltersList: DropdownItem[] = [];
|
|
28
|
+
private _productFiltersList: DropdownItem[] = [];
|
|
29
|
+
private matchDesktop!: MediaQueryList;
|
|
30
|
+
private matchMobile!: MediaQueryList;
|
|
31
|
+
private matchMobileSmall!: MediaQueryList;
|
|
10
32
|
private deviceType: "desktop" | "mobile" | "mobile-small" = "desktop";
|
|
33
|
+
private _searchTimeout?: number;
|
|
11
34
|
private target = "_blank";
|
|
12
35
|
private isDesktop = "(min-width: 1024px)";
|
|
13
36
|
private isMobile = "(min-width: 401px) and (max-width: 1023px)";
|
|
14
37
|
private isMobileSmall = "(max-width: 400px)";
|
|
38
|
+
private showSourcesFilter = false;
|
|
39
|
+
private filteredItemsSelected: boolean = false;
|
|
40
|
+
private filtersDefaultValue = {
|
|
41
|
+
selectedSourceFilter: [] as string[],
|
|
42
|
+
selectedTypeFilter: [] as string[],
|
|
43
|
+
selectedProductFilter: [] as string[],
|
|
44
|
+
searchTerm: "",
|
|
45
|
+
page: "1"
|
|
46
|
+
};
|
|
15
47
|
|
|
16
48
|
connectedCallback(): void {
|
|
17
|
-
|
|
49
|
+
this.matchDesktop = window.matchMedia(this.isDesktop);
|
|
50
|
+
this.matchDesktop.addEventListener("change", this.handleView);
|
|
51
|
+
|
|
52
|
+
this.matchMobile = window.matchMedia(this.isMobile);
|
|
53
|
+
this.matchMobile.addEventListener("change", this.handleView);
|
|
54
|
+
|
|
55
|
+
this.matchMobileSmall = window.matchMedia(this.isMobileSmall);
|
|
56
|
+
this.matchMobileSmall.addEventListener("change", this.handleView);
|
|
57
|
+
window.addEventListener("popstate", this.handleURLStateChange);
|
|
58
|
+
if (this.matchDesktop.matches) {
|
|
59
|
+
this.deviceType = "desktop";
|
|
60
|
+
}
|
|
61
|
+
if (this.matchMobile.matches) {
|
|
62
|
+
this.deviceType = "mobile";
|
|
63
|
+
}
|
|
64
|
+
if (this.matchMobileSmall.matches) {
|
|
65
|
+
this.deviceType = "mobile-small";
|
|
66
|
+
}
|
|
67
|
+
this.evaluateQueryParams(false);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
handleURLStateChange(): void {
|
|
71
|
+
this.evaluateQueryParams(true);
|
|
72
|
+
this.scrollToTop();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
evaluateQueryParams(resetFilters: boolean): void {
|
|
76
|
+
let page = "1";
|
|
77
|
+
if (resetFilters) {
|
|
78
|
+
this.selectedSourceFilter =
|
|
79
|
+
this.filtersDefaultValue.selectedSourceFilter;
|
|
80
|
+
this.selectedTypeFilter =
|
|
81
|
+
this.filtersDefaultValue.selectedTypeFilter;
|
|
82
|
+
this.selectedProductFilter =
|
|
83
|
+
this.filtersDefaultValue.selectedProductFilter;
|
|
84
|
+
}
|
|
85
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
86
|
+
if (urlParams.toString()) {
|
|
87
|
+
if (urlParams.has("source")) {
|
|
88
|
+
this.selectedSourceFilter = urlParams.getAll("source");
|
|
89
|
+
}
|
|
90
|
+
if (urlParams.has("type")) {
|
|
91
|
+
this.selectedTypeFilter = urlParams.getAll("type");
|
|
92
|
+
}
|
|
93
|
+
if (urlParams.get("service")) {
|
|
94
|
+
this.selectedProductFilter = urlParams
|
|
95
|
+
.get("service")!
|
|
96
|
+
.split(",");
|
|
97
|
+
}
|
|
98
|
+
if (urlParams.get("filter_text")) {
|
|
99
|
+
this.searchTerm = (
|
|
100
|
+
urlParams.get("filter_text") || ""
|
|
101
|
+
).toLowerCase();
|
|
102
|
+
}
|
|
103
|
+
if (urlParams.has("page")) {
|
|
104
|
+
page = urlParams.get("page")!;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
this.calculatePagination(page, true);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
disconnectedCallback(): void {
|
|
111
|
+
this.matchDesktop.removeEventListener("change", this.handleView);
|
|
112
|
+
this.matchMobile.removeEventListener("change", this.handleView);
|
|
113
|
+
this.matchMobileSmall.removeEventListener("change", this.handleView);
|
|
114
|
+
window.removeEventListener("popstate", this.handleURLStateChange);
|
|
115
|
+
|
|
116
|
+
if (!this.filteredItemsSelected) {
|
|
117
|
+
this.selectedProductFilter?.forEach((filter) => {
|
|
118
|
+
track(document, "custEv_filterAbandoned", {
|
|
119
|
+
click_text: filter,
|
|
120
|
+
element_title: "CodeSamplesGrid",
|
|
121
|
+
element_type: "filter abandoned",
|
|
122
|
+
content_category: "filter"
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
18
126
|
}
|
|
19
127
|
|
|
20
128
|
@api
|
|
@@ -33,10 +141,12 @@ export default class CodeSamplesGrid extends LightningElement {
|
|
|
33
141
|
title: sample.title,
|
|
34
142
|
body: sample.body,
|
|
35
143
|
buttonText: DEFAULT_BUTTON_TEXT,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
144
|
+
href: sample.href,
|
|
145
|
+
imgSrc: sample.imgSrc,
|
|
146
|
+
product: sample.product,
|
|
147
|
+
type: sample.type,
|
|
148
|
+
// source: sample.source,
|
|
149
|
+
source: "none",
|
|
40
150
|
target: this.target
|
|
41
151
|
}));
|
|
42
152
|
}
|
|
@@ -45,8 +155,128 @@ export default class CodeSamplesGrid extends LightningElement {
|
|
|
45
155
|
return this._samplesList;
|
|
46
156
|
}
|
|
47
157
|
|
|
158
|
+
@api
|
|
159
|
+
set products(value: string) {
|
|
160
|
+
const productsFilters = toJson(value).map((sample: string) => ({
|
|
161
|
+
label: sample,
|
|
162
|
+
value: sample.toLowerCase()
|
|
163
|
+
}));
|
|
164
|
+
|
|
165
|
+
this._productFiltersList = orderBy(
|
|
166
|
+
uniqBy([...productsFilters] as any, "value"),
|
|
167
|
+
["value"],
|
|
168
|
+
["asc"]
|
|
169
|
+
) as any[];
|
|
170
|
+
this.selectedProductFilter = this._productFiltersList.map(
|
|
171
|
+
(filter) => filter.value
|
|
172
|
+
);
|
|
173
|
+
this.filtersDefaultValue.selectedProductFilter = cloneDeep(
|
|
174
|
+
this.selectedProductFilter
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
get products(): DropdownItem[] {
|
|
178
|
+
return this._productFiltersList;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@api
|
|
182
|
+
set types(value: string) {
|
|
183
|
+
const typesFilter = toJson(value).map((sample: string) => ({
|
|
184
|
+
label: sample,
|
|
185
|
+
value: sample.toLowerCase()
|
|
186
|
+
}));
|
|
187
|
+
|
|
188
|
+
this._typesFiltersList = orderBy(
|
|
189
|
+
uniqBy([...typesFilter] as any, "value"),
|
|
190
|
+
["value"],
|
|
191
|
+
["asc"]
|
|
192
|
+
) as any[];
|
|
193
|
+
this.selectedTypeFilter = this._typesFiltersList.map(
|
|
194
|
+
(filter) => filter.value
|
|
195
|
+
);
|
|
196
|
+
this.filtersDefaultValue.selectedTypeFilter = cloneDeep(
|
|
197
|
+
this.selectedTypeFilter
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
get types(): DropdownItem[] {
|
|
201
|
+
return this._typesFiltersList;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@api
|
|
205
|
+
set sources(value: string) {
|
|
206
|
+
const parsedValues = toJson(value);
|
|
207
|
+
this.showSourcesFilter = parsedValues.length > 0;
|
|
208
|
+
const sourcesFilter = parsedValues.map((sample: string) => ({
|
|
209
|
+
label: sample,
|
|
210
|
+
value: sample.toLowerCase()
|
|
211
|
+
}));
|
|
212
|
+
|
|
213
|
+
this._sourceFiltersList = orderBy(
|
|
214
|
+
uniqBy([...sourcesFilter] as any, "value"),
|
|
215
|
+
["value"],
|
|
216
|
+
["asc"]
|
|
217
|
+
) as any;
|
|
218
|
+
this.selectedSourceFilter = this._sourceFiltersList.map(
|
|
219
|
+
(filter) => filter.value
|
|
220
|
+
);
|
|
221
|
+
this.filtersDefaultValue.selectedSourceFilter = cloneDeep(
|
|
222
|
+
this.selectedSourceFilter
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
get sources(): DropdownItem[] {
|
|
226
|
+
return this._sourceFiltersList;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
get filteredSamples(): CodeSample[] {
|
|
230
|
+
return this.filterSamples([...this.samples]);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
get currentPageSamples(): CodeSample[] {
|
|
234
|
+
return this.filteredSamples.slice(
|
|
235
|
+
this.startingRecord - 1,
|
|
236
|
+
this.endingRecord
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
get typesList(): DropdownItem[] {
|
|
241
|
+
return this._typesFiltersList || [];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
get productFiltersList(): DropdownItem[] {
|
|
245
|
+
return this._productFiltersList || [];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
get showEmptyState(): boolean {
|
|
249
|
+
return !this.filteredSamples.length;
|
|
250
|
+
}
|
|
251
|
+
|
|
48
252
|
get tileColumns(): string {
|
|
49
|
-
return this.deviceType === "desktop" ? "
|
|
253
|
+
return this.deviceType === "desktop" ? "three" : "two";
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
get pagesToShow(): number {
|
|
257
|
+
return this.deviceType === "mobile-small" ? 3 : 5;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
get hidePagination(): boolean {
|
|
261
|
+
return this.totalPages < 2;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
get emptyStateSubtitle() {
|
|
265
|
+
return (
|
|
266
|
+
"Sorry, no results were found for your search" +
|
|
267
|
+
(this.searchTerm !== "" ? ` "${this.searchTerm}"` : "")
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
get emptyStateBody() {
|
|
272
|
+
return "Search Tips:";
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
get emptyStateSuggestions() {
|
|
276
|
+
return JSON.stringify([
|
|
277
|
+
"Please consider misspellings",
|
|
278
|
+
"Try different search keywords"
|
|
279
|
+
]);
|
|
50
280
|
}
|
|
51
281
|
|
|
52
282
|
handleView = (e: MediaQueryListEvent | MediaQueryList): void => {
|
|
@@ -64,4 +294,169 @@ export default class CodeSamplesGrid extends LightningElement {
|
|
|
64
294
|
this.deviceType = "mobile-small";
|
|
65
295
|
}
|
|
66
296
|
};
|
|
297
|
+
|
|
298
|
+
goToPage(e: CustomEvent): void {
|
|
299
|
+
const page = e.detail;
|
|
300
|
+
this.displayRecordsPerPage(page);
|
|
301
|
+
this.setSearchParams("page", page ? page.toString() : "1");
|
|
302
|
+
this.scrollToTop();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
displayRecordsPerPage(page: number): void {
|
|
306
|
+
this.page = page;
|
|
307
|
+
this.startingRecord =
|
|
308
|
+
page === 1 ? page : (page - 1) * this.pageSize + 1;
|
|
309
|
+
this.endingRecord = this.pageSize * page;
|
|
310
|
+
this.endingRecord =
|
|
311
|
+
this.endingRecord > this.totalRecountCount
|
|
312
|
+
? this.totalRecountCount
|
|
313
|
+
: this.endingRecord;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
handleSearchChange(event: CustomEvent): void {
|
|
317
|
+
const value = event.detail;
|
|
318
|
+
this.searchTerm = value.toLowerCase();
|
|
319
|
+
window.clearTimeout(this._searchTimeout);
|
|
320
|
+
this._searchTimeout = window.setTimeout(() => {
|
|
321
|
+
this.calculatePagination();
|
|
322
|
+
}, WAIT_TIME);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
handleSourceFilterChange(event: CustomEvent): void {
|
|
326
|
+
this.selectedSourceFilter = event.detail.value;
|
|
327
|
+
this.calculatePagination();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
handleTypeFilterChange(event: CustomEvent): void {
|
|
331
|
+
this.selectedTypeFilter = event.detail.value;
|
|
332
|
+
this.calculatePagination();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
handleProductFilterChange(event: CustomEvent): void {
|
|
336
|
+
if (event.detail.checkedValue === PRODUCT_FILTER_ALL_PRODUCTS) {
|
|
337
|
+
if (event.detail.checked) {
|
|
338
|
+
this.selectedProductFilter = this.productFiltersList.map(
|
|
339
|
+
(filter) => filter.value
|
|
340
|
+
);
|
|
341
|
+
} else {
|
|
342
|
+
this.selectedProductFilter = [];
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
let newList = event.detail.value;
|
|
346
|
+
if (!event.detail.checked) {
|
|
347
|
+
newList = newList.filter(
|
|
348
|
+
(val: typeof PRODUCT_FILTER_ALL_PRODUCTS) =>
|
|
349
|
+
val !== PRODUCT_FILTER_ALL_PRODUCTS
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
this.selectedProductFilter = newList;
|
|
353
|
+
}
|
|
354
|
+
this.calculatePagination();
|
|
355
|
+
this.filteredItemsSelected = false;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
handleLanguageFilterChange(event: CustomEvent): void {
|
|
359
|
+
this.selectedTypeFilter = event.detail.value;
|
|
360
|
+
this.setSearchParams("type", this.selectedTypeFilter);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
filterSamples(samples: CodeSample[]): CodeSample[] {
|
|
364
|
+
const filtered = samples
|
|
365
|
+
.filter((contentItem) => {
|
|
366
|
+
const matchesSearchTerm =
|
|
367
|
+
contentItem.body.toLowerCase().includes(this.searchTerm) ||
|
|
368
|
+
contentItem.title.toLowerCase().includes(this.searchTerm);
|
|
369
|
+
const matchesProductFilters =
|
|
370
|
+
!this.selectedProductFilter ||
|
|
371
|
+
!this.selectedProductFilter.length ||
|
|
372
|
+
this.selectedProductFilter.includes(
|
|
373
|
+
PRODUCT_FILTER_ALL_PRODUCTS
|
|
374
|
+
) ||
|
|
375
|
+
(typeof contentItem.product === "string" &&
|
|
376
|
+
this.selectedProductFilter.includes(
|
|
377
|
+
contentItem.product.toLowerCase()
|
|
378
|
+
));
|
|
379
|
+
const matchesTypeFilters =
|
|
380
|
+
!this.selectedTypeFilter ||
|
|
381
|
+
!this.selectedTypeFilter.length ||
|
|
382
|
+
(typeof contentItem.type === "string" &&
|
|
383
|
+
this.selectedTypeFilter.includes(
|
|
384
|
+
contentItem.type.toLowerCase()
|
|
385
|
+
));
|
|
386
|
+
const matchesSourceFilters =
|
|
387
|
+
!this.selectedSourceFilter ||
|
|
388
|
+
!this.selectedSourceFilter.length ||
|
|
389
|
+
(typeof contentItem.source === "string" &&
|
|
390
|
+
this.selectedSourceFilter.includes(
|
|
391
|
+
contentItem.source.toLowerCase()
|
|
392
|
+
));
|
|
393
|
+
|
|
394
|
+
return (
|
|
395
|
+
matchesSearchTerm &&
|
|
396
|
+
matchesProductFilters &&
|
|
397
|
+
matchesTypeFilters &&
|
|
398
|
+
matchesSourceFilters
|
|
399
|
+
);
|
|
400
|
+
})
|
|
401
|
+
.sort((a: CodeSample, b: CodeSample) => {
|
|
402
|
+
return a.title.localeCompare(b.title);
|
|
403
|
+
});
|
|
404
|
+
return filtered;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
calculatePagination(page?: string, skipSetSearchParams = false): void {
|
|
408
|
+
if (page) {
|
|
409
|
+
this.page = parseInt(page, 10) || 1;
|
|
410
|
+
}
|
|
411
|
+
this.totalRecountCount = this.filteredSamples.length;
|
|
412
|
+
this.totalPages = Math.ceil(this.totalRecountCount / this.pageSize);
|
|
413
|
+
this.displayRecordsPerPage(this.page);
|
|
414
|
+
if (!skipSetSearchParams) {
|
|
415
|
+
this.setSearchParams();
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
scrollToTop(): void {
|
|
420
|
+
this.template
|
|
421
|
+
.querySelector(".docs-grid-container")!
|
|
422
|
+
.scrollIntoView({ behavior: "smooth" });
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
setSearchParams(key?: string | null, val?: string[] | null): void {
|
|
426
|
+
const service =
|
|
427
|
+
this.selectedProductFilter!.length ===
|
|
428
|
+
this.productFiltersList.length
|
|
429
|
+
? ""
|
|
430
|
+
: this.selectedProductFilter!.join(",");
|
|
431
|
+
const params: { [key: string]: any } = {
|
|
432
|
+
filter_text: this.searchTerm,
|
|
433
|
+
service,
|
|
434
|
+
type: this.selectedTypeFilter,
|
|
435
|
+
page: this.page.toString(),
|
|
436
|
+
source: this.selectedSourceFilter
|
|
437
|
+
};
|
|
438
|
+
if (key) {
|
|
439
|
+
params[key] = key === "service" ? val!.join(",") : val;
|
|
440
|
+
}
|
|
441
|
+
for (const _key in params) {
|
|
442
|
+
if (!params[_key]) {
|
|
443
|
+
delete params[_key];
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const searchParams = qs.stringify(params);
|
|
447
|
+
const newurl = `${window.location.pathname}?${searchParams}`;
|
|
448
|
+
window.history.pushState({ path: newurl }, "", newurl);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
handleReadItClick() {
|
|
452
|
+
this.filteredItemsSelected = true;
|
|
453
|
+
this.selectedProductFilter?.forEach((filter) => {
|
|
454
|
+
track(document, "custEv_filterApplied", {
|
|
455
|
+
click_text: filter,
|
|
456
|
+
click_url: `${window.location.origin}${filter}`,
|
|
457
|
+
element_type: "filter applied",
|
|
458
|
+
content_category: "filter"
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
}
|
|
67
462
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<dx-featured-content-header
|
|
3
3
|
class="documentation_header"
|
|
4
|
-
|
|
4
|
+
header="Content Archive"
|
|
5
5
|
body="Learn more about the topics that interest you most by exploring the full collection of Salesforce Developers blog and podcast content."
|
|
6
6
|
dark="true"
|
|
7
7
|
no-swoop={isMobile}
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
</div>
|
|
28
28
|
<dx-filter-menu
|
|
29
29
|
name="content-type"
|
|
30
|
-
|
|
30
|
+
header={contentTypeTitle}
|
|
31
31
|
options={contentTypeList}
|
|
32
32
|
onchange={handleUpdateSiteFilter}
|
|
33
33
|
></dx-filter-menu>
|
|
34
34
|
<dx-filter-menu
|
|
35
35
|
name="dates"
|
|
36
|
-
|
|
36
|
+
header={dateTitle}
|
|
37
37
|
options={dateList}
|
|
38
38
|
variant="nested"
|
|
39
39
|
filters-dates-loading={filtersDatesLoading}
|
|
@@ -42,20 +42,20 @@
|
|
|
42
42
|
<template if:false={hideBlogFilters}>
|
|
43
43
|
<dx-filter-menu
|
|
44
44
|
name="authors"
|
|
45
|
-
|
|
45
|
+
header={authorTitle}
|
|
46
46
|
options={authorList}
|
|
47
47
|
onchange={handleFiltersEvent}
|
|
48
48
|
></dx-filter-menu>
|
|
49
49
|
</template>
|
|
50
50
|
<dx-filter-menu
|
|
51
51
|
name="categories"
|
|
52
|
-
|
|
52
|
+
header={categoryTitle}
|
|
53
53
|
options={categoryList}
|
|
54
54
|
onchange={handleFiltersEvent}
|
|
55
55
|
></dx-filter-menu>
|
|
56
56
|
<dx-filter-menu
|
|
57
57
|
name="language"
|
|
58
|
-
|
|
58
|
+
header={languageTitle}
|
|
59
59
|
options={languagesList}
|
|
60
60
|
onchange={handleFiltersEvent}
|
|
61
61
|
></dx-filter-menu>
|
|
@@ -81,13 +81,13 @@
|
|
|
81
81
|
</div>
|
|
82
82
|
<dx-filter-menu
|
|
83
83
|
name="contentType"
|
|
84
|
-
|
|
84
|
+
header={contentTypeTitle}
|
|
85
85
|
options={contentTypeList}
|
|
86
86
|
onchange={handleUpdateSiteFilter}
|
|
87
87
|
></dx-filter-menu>
|
|
88
88
|
<dx-filter-menu
|
|
89
89
|
name="dates"
|
|
90
|
-
|
|
90
|
+
header={dateTitle}
|
|
91
91
|
options={dateList}
|
|
92
92
|
filters-dates-loading={filtersDatesLoading}
|
|
93
93
|
variant="nested"
|
|
@@ -96,20 +96,20 @@
|
|
|
96
96
|
<template if:false={hideBlogFilters}>
|
|
97
97
|
<dx-filter-menu
|
|
98
98
|
name="authors"
|
|
99
|
-
|
|
99
|
+
header={authorTitle}
|
|
100
100
|
options={authorList}
|
|
101
101
|
onchange={handleFiltersEvent}
|
|
102
102
|
></dx-filter-menu>
|
|
103
103
|
</template>
|
|
104
104
|
<dx-filter-menu
|
|
105
105
|
name="categories"
|
|
106
|
-
|
|
106
|
+
header={categoryTitle}
|
|
107
107
|
options={categoryList}
|
|
108
108
|
onchange={handleFiltersEvent}
|
|
109
109
|
></dx-filter-menu>
|
|
110
110
|
<dx-filter-menu
|
|
111
111
|
name="language"
|
|
112
|
-
|
|
112
|
+
header={languageTitle}
|
|
113
113
|
options={languagesList}
|
|
114
114
|
onchange={handleFiltersEvent}
|
|
115
115
|
></dx-filter-menu>
|
|
@@ -312,7 +312,7 @@
|
|
|
312
312
|
<dx-card-minimal
|
|
313
313
|
key={post.id}
|
|
314
314
|
content-type={post.contentType}
|
|
315
|
-
|
|
315
|
+
header={post.title}
|
|
316
316
|
href={post.href}
|
|
317
317
|
></dx-card-minimal>
|
|
318
318
|
</template>
|
|
@@ -324,7 +324,7 @@
|
|
|
324
324
|
<template if:true={post.authors}>
|
|
325
325
|
<dx-card-expanded
|
|
326
326
|
key={post.id}
|
|
327
|
-
|
|
327
|
+
header={post.title}
|
|
328
328
|
content-type={post.contentType}
|
|
329
329
|
href={post.href}
|
|
330
330
|
date={post.date}
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
<template if:false={post.authors}>
|
|
338
338
|
<dx-card-expanded
|
|
339
339
|
key={post.id}
|
|
340
|
-
|
|
340
|
+
header={post.title}
|
|
341
341
|
content-type={post.contentType}
|
|
342
342
|
href={post.href}
|
|
343
343
|
date={post.date}
|
|
@@ -363,7 +363,7 @@
|
|
|
363
363
|
<template if:true={isEmptyState}>
|
|
364
364
|
<dx-empty-state
|
|
365
365
|
variant="alt"
|
|
366
|
-
|
|
366
|
+
header="Beep boop. That did not compute."
|
|
367
367
|
subtitle={emptyStateSubtitle}
|
|
368
368
|
body={emptyStateBody}
|
|
369
369
|
suggestions={emptyStateSuggestions}
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
for:item="item"
|
|
46
46
|
for:index="i"
|
|
47
47
|
key={item.id}
|
|
48
|
-
|
|
48
|
+
header={item.title}
|
|
49
49
|
body={item.description}
|
|
50
50
|
href={item.guidesHref}
|
|
51
51
|
class="docs-card"
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
</div>
|
|
85
85
|
<dx-empty-state
|
|
86
86
|
variant="alt"
|
|
87
|
-
|
|
87
|
+
header="Beep boop. That did not compute."
|
|
88
88
|
subtitle={emptyStateSubtitle}
|
|
89
89
|
body={emptyStateBody}
|
|
90
90
|
suggestions={emptyStateSuggestions}
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
</dx-section>
|
|
50
50
|
<dx-section
|
|
51
51
|
class="events-list upcoming-events"
|
|
52
|
-
|
|
52
|
+
header="Upcoming Events"
|
|
53
53
|
if:true={upcomingEvents.length}
|
|
54
54
|
>
|
|
55
55
|
<dx-card-event
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
for:item="item"
|
|
58
58
|
key={item.id}
|
|
59
59
|
href={item.urlStub}
|
|
60
|
-
|
|
60
|
+
header={item.name}
|
|
61
61
|
end-datetime={item.endDate}
|
|
62
62
|
start-datetime={item.startDate}
|
|
63
63
|
short-description={item.shortDescription}
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
|
|
72
72
|
<dx-section
|
|
73
73
|
class="events-list past-events"
|
|
74
|
-
|
|
74
|
+
header="Past Events"
|
|
75
75
|
if:true={pastEvents.length}
|
|
76
76
|
>
|
|
77
77
|
<dx-card-event
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
for:item="item"
|
|
80
80
|
key={item.id}
|
|
81
81
|
href={item.urlStub}
|
|
82
|
-
|
|
82
|
+
header={item.name}
|
|
83
83
|
end-datetime={item.endDate}
|
|
84
84
|
start-datetime={item.startDate}
|
|
85
85
|
short-description={item.shortDescription}
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
</dx-section>
|
|
91
91
|
<div class="events-empty" if:true={showEmptyState}>
|
|
92
92
|
<dx-empty-state
|
|
93
|
-
|
|
93
|
+
header="Beep boop. That did not compute."
|
|
94
94
|
subtitle={emptyStateSubtitle}
|
|
95
95
|
></dx-empty-state>
|
|
96
96
|
</div>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
key={cardData.id}
|
|
7
7
|
type="twitter"
|
|
8
8
|
video-id={cardData.videoId}
|
|
9
|
-
|
|
9
|
+
header={cardData.title}
|
|
10
10
|
body={cardData.body}
|
|
11
11
|
has-social={cardData.hasSocial}
|
|
12
12
|
social-name={cardData.socialName}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
key={cardData.id}
|
|
21
21
|
type="linkedin"
|
|
22
22
|
video-id={cardData.videoId}
|
|
23
|
-
|
|
23
|
+
header={cardData.title}
|
|
24
24
|
body={cardData.body}
|
|
25
25
|
has-social={cardData.hasSocial}
|
|
26
26
|
social-name={cardData.socialName}
|