@salesforcedevs/dw-components 0.79.1 → 1.0.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 +10 -1
- package/package.json +16 -12
- package/src/modules/dw/blogsGrid/blogsGrid.css +14 -7
- package/src/modules/dw/blogsGrid/blogsGrid.html +15 -12
- package/src/modules/dw/blogsGrid/blogsGrid.ts +23 -9
- package/src/modules/dw/browseTrials/browseTrials.css +35 -0
- package/src/modules/dw/browseTrials/browseTrials.html +86 -0
- package/src/modules/dw/browseTrials/browseTrials.ts +116 -0
- package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.css +2 -0
- package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.html +3 -3
- package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.css +2 -0
- package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.html +2 -1
- package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.css +85 -9
- package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.html +74 -112
- package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.ts +14 -376
- package/src/modules/dw/contentArchive/contentArchive.css +5 -4
- package/src/modules/dw/contentArchive/contentArchive.html +58 -24
- package/src/modules/dw/contentArchive/contentArchive.ts +46 -8
- package/src/modules/dw/contentArchive/contentArchive.types.ts +8 -4
- package/src/modules/dw/contentArchive/utils.ts +30 -14
- package/src/modules/dw/deSignupForm/deSignupForm.css +11 -10
- package/src/modules/dw/deSignupForm/deSignupForm.html +39 -25
- package/src/modules/dw/deSignupForm/deSignupForm.ts +205 -133
- package/src/modules/dw/deSignupForm/submitForm.ts +7 -3
- package/src/modules/dw/docsGrid/docsGrid.css +0 -1
- package/src/modules/dw/docsGrid/docsGrid.html +6 -2
- package/src/modules/dw/docsGrid/docsGrid.ts +103 -38
- package/src/modules/dw/eventsList/eventsList.css +4 -4
- package/src/modules/dw/eventsList/eventsList.html +5 -5
- package/src/modules/dw/eventsList/eventsList.ts +47 -48
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.css +14 -0
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.html +41 -0
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.ts +487 -0
- package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.css +76 -0
- package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.html +64 -0
- package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.ts +157 -0
- package/src/modules/dw/j2sForm/j2sForm.css +65 -0
- package/src/modules/dw/j2sForm/j2sForm.html +217 -0
- package/src/modules/dw/j2sForm/j2sForm.ts +371 -0
- package/src/modules/dw/j2sForm/mockProps.ts +3102 -0
- package/src/modules/dw/languageSelector/languageSelector.css +86 -0
- package/src/modules/dw/languageSelector/languageSelector.html +36 -0
- package/src/modules/dw/languageSelector/languageSelector.ts +119 -0
- package/src/modules/dw/newsletterForm/newsletterForm.css +2 -2
- package/src/modules/dw/newsletterForm/newsletterForm.html +35 -10
- package/src/modules/dw/newsletterForm/newsletterForm.ts +107 -78
- package/src/modules/dw/podcastSubscription/podcastSubscription.css +8 -8
- package/src/modules/dw/podcastSubscription/podcastSubscription.html +2 -2
- package/src/modules/dw/podcastSubscription/podcastSubscription.ts +4 -4
- package/src/modules/dw/podcastsGrid/podcastsGrid.css +7 -0
- package/src/modules/dw/podcastsGrid/podcastsGrid.html +6 -1
- package/src/modules/dw/podcastsGrid/podcastsGrid.ts +3 -3
- package/src/modules/dw/podcastsPromo/podcastsPromo.css +14 -0
- package/src/modules/dw/podcastsPromo/podcastsPromo.html +16 -8
- package/src/modules/dw/podcastsPromo/podcastsPromo.ts +11 -2
- package/src/modules/dw/rcgTable/altData.ts +72 -9
- package/src/modules/dw/rcgTable/getTableData.ts +1 -1
- package/src/modules/dw/rcgTable/rcgTable.ts +3 -3
- package/src/modules/dw/slackCta/slackCta.css +5 -6
- package/src/modules/dw/slackCta/slackCta.html +1 -1
- package/src/modules/dw/slackSuccess/slackSuccess.css +1 -1
- package/src/modules/dw/slackSuccess/slackSuccess.html +2 -2
- package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.css +119 -0
- package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.html +192 -0
- package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.ts +148 -0
- package/src/modules/dw/videoGrid/types.ts +12 -0
- package/src/modules/dw/videoGrid/videoGrid.css +24 -0
- package/src/modules/dw/videoGrid/videoGrid.html +41 -0
- package/src/modules/dw/videoGrid/videoGrid.ts +41 -0
- package/src/modules/dw/youtubeVideoGrid/types.ts +8 -0
- package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.css +18 -0
- package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.html +40 -0
- package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.ts +66 -0
- package/src/modules/dwHelpers/mobileDividers/mobileDividers.css +19 -0
- package/src/modules/dwUtils/forms/forms.ts +514 -0
- package/src/modules/{dwBaseElements → dwUtils}/postsGrid/postsGrid.ts +10 -13
package/lwc.config.json
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
],
|
|
6
6
|
"expose": [
|
|
7
7
|
"dw/blogsGrid",
|
|
8
|
+
"dw/videoGrid",
|
|
9
|
+
"dw/youtubeVideoGrid",
|
|
10
|
+
"dw/browseTrials",
|
|
8
11
|
"dw/cardBlogPostProvider",
|
|
9
12
|
"dw/cardPodcastEpisodeProvider",
|
|
10
13
|
"dw/codeSamplesGrid",
|
|
@@ -13,12 +16,18 @@
|
|
|
13
16
|
"dw/docsGrid",
|
|
14
17
|
"dw/eventsList",
|
|
15
18
|
"dw/instrumentation",
|
|
19
|
+
"dw/j2sCardSequence",
|
|
20
|
+
"dw/j2sCardSequenceStep",
|
|
21
|
+
"dw/j2sForm",
|
|
22
|
+
"dw/languageSelector",
|
|
16
23
|
"dw/newsletterForm",
|
|
17
24
|
"dw/podcastSubscription",
|
|
18
25
|
"dw/podcastsGrid",
|
|
19
26
|
"dw/podcastsPromo",
|
|
20
27
|
"dw/rcgTable",
|
|
21
28
|
"dw/slackCta",
|
|
22
|
-
"dw/slackSuccess"
|
|
29
|
+
"dw/slackSuccess",
|
|
30
|
+
"dw/tbidLoginMenu",
|
|
31
|
+
"dwUtils/forms"
|
|
23
32
|
]
|
|
24
33
|
}
|
package/package.json
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": "
|
|
7
|
+
"node": "18.x"
|
|
8
8
|
},
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"lodash.
|
|
16
|
-
"lodash.
|
|
17
|
-
"
|
|
13
|
+
"@types/youtube-player": "5.5.11",
|
|
14
|
+
"classnames": "2.5.1",
|
|
15
|
+
"lodash.clonedeep": "4.5.0",
|
|
16
|
+
"lodash.orderby": "4.6.0",
|
|
17
|
+
"lodash.uniqby": "4.7.0",
|
|
18
|
+
"query-string": "7.1.3",
|
|
19
|
+
"youtube-player": "5.6.0"
|
|
18
20
|
},
|
|
19
21
|
"devDependencies": {
|
|
20
|
-
"@types/classnames": "
|
|
21
|
-
"@types/lodash.clonedeep": "
|
|
22
|
-
"@types/lodash.orderby": "
|
|
23
|
-
"@types/lodash.uniqby": "
|
|
22
|
+
"@types/classnames": "2.3.1",
|
|
23
|
+
"@types/lodash.clonedeep": "4.5.9",
|
|
24
|
+
"@types/lodash.orderby": "4.6.9",
|
|
25
|
+
"@types/lodash.uniqby": "4.7.9",
|
|
26
|
+
"@types/setimmediate": "1.0.4",
|
|
27
|
+
"setimmediate": "1.0.5"
|
|
24
28
|
},
|
|
25
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "da61b1a4ea73c7d621be4b0be39c01afe8de7541"
|
|
26
30
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@import "dwHelpers/postsGrid";
|
|
2
|
+
@import "dwHelpers/mobileDividers";
|
|
2
3
|
|
|
3
4
|
:host {
|
|
4
5
|
--dx-c-post-list-padding-horizontal: var(--dx-g-page-padding-horizontal);
|
|
@@ -23,10 +24,6 @@ dx-section.section-reduced-padding {
|
|
|
23
24
|
line-height: 32px;
|
|
24
25
|
width: 500px;
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
.box {
|
|
28
|
-
height: 162px;
|
|
29
|
-
}
|
|
30
27
|
}
|
|
31
28
|
|
|
32
29
|
@media only screen and (max-width: 640px) {
|
|
@@ -39,7 +36,6 @@ dx-section.section-reduced-padding {
|
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
.box {
|
|
42
|
-
height: 162px;
|
|
43
39
|
background-position: 0% 25%, 90% 75%;
|
|
44
40
|
}
|
|
45
41
|
}
|
|
@@ -58,6 +54,10 @@ dx-section.section-reduced-padding {
|
|
|
58
54
|
flex-direction: column;
|
|
59
55
|
}
|
|
60
56
|
|
|
57
|
+
.subscription-box > .box > .content > .title {
|
|
58
|
+
color: var(--dx-g-text-heading-color);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
61
|
.content {
|
|
62
62
|
align-items: center;
|
|
63
63
|
display: flex;
|
|
@@ -72,8 +72,8 @@ dx-section.section-reduced-padding {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
.box {
|
|
75
|
-
background-image:
|
|
76
|
-
|
|
75
|
+
background-image: var(--dx-blog-grid-themed-left-subscribe-image),
|
|
76
|
+
var(--dx-blog-grid-themed-right-subscribe-image);
|
|
77
77
|
background-position: 4% 25%, 90% 60%;
|
|
78
78
|
background-repeat: no-repeat;
|
|
79
79
|
width: 100%;
|
|
@@ -87,3 +87,10 @@ dx-section.section-reduced-padding {
|
|
|
87
87
|
h2 {
|
|
88
88
|
padding: 0;
|
|
89
89
|
}
|
|
90
|
+
|
|
91
|
+
/* MOBILE BREAKPOINT FOR POSTS */
|
|
92
|
+
@media screen and (max-width: 600px) {
|
|
93
|
+
.mobile-divider_posts:last-child {
|
|
94
|
+
display: none;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
<div class="subscription-box">
|
|
6
6
|
<div class="box">
|
|
7
7
|
<div class="content">
|
|
8
|
-
<h2 class="title">
|
|
9
|
-
|
|
10
|
-
podcast episodes via Slack or RSS.
|
|
11
|
-
</h2>
|
|
8
|
+
<h2 class="title">{rssTitle}</h2>
|
|
9
|
+
<p lwc:if={rssBody}>{rssBody}</p>
|
|
12
10
|
<div class="cta-container">
|
|
13
11
|
<dx-button
|
|
14
12
|
size="small"
|
|
@@ -19,7 +17,7 @@
|
|
|
19
17
|
href="/slack/install"
|
|
20
18
|
class="button"
|
|
21
19
|
>
|
|
22
|
-
|
|
20
|
+
{rssBtnOneLabel}
|
|
23
21
|
</dx-button>
|
|
24
22
|
<dx-button
|
|
25
23
|
size="small"
|
|
@@ -29,8 +27,9 @@
|
|
|
29
27
|
icon-sprite="general"
|
|
30
28
|
href="https://developer.salesforce.com/blogs/feed"
|
|
31
29
|
class="button"
|
|
30
|
+
onclick={rssOnClick}
|
|
32
31
|
>
|
|
33
|
-
|
|
32
|
+
{rssBtnTwoLabel}
|
|
34
33
|
</dx-button>
|
|
35
34
|
</div>
|
|
36
35
|
</div>
|
|
@@ -44,30 +43,34 @@
|
|
|
44
43
|
<dx-grid columns={columns}>
|
|
45
44
|
<template for:each={postList} for:item="post">
|
|
46
45
|
<dx-card-blog-post
|
|
47
|
-
|
|
48
|
-
author-label={post.authorName}
|
|
46
|
+
authors={post.authors}
|
|
49
47
|
body={post.body}
|
|
50
48
|
datetime={post.datetime}
|
|
51
49
|
href={post.href}
|
|
52
50
|
img-alt={post.imgAlt}
|
|
53
51
|
img-src={post.imgSrc}
|
|
54
52
|
key={post.id}
|
|
55
|
-
|
|
53
|
+
header={post.title}
|
|
56
54
|
></dx-card-blog-post>
|
|
55
|
+
<dx-hr
|
|
56
|
+
spacing="2xs"
|
|
57
|
+
class="mobile-divider_posts"
|
|
58
|
+
key={post.id}
|
|
59
|
+
></dx-hr>
|
|
57
60
|
</template>
|
|
58
61
|
</dx-grid>
|
|
59
62
|
<dx-hr
|
|
60
63
|
if:true={showLoadMore}
|
|
61
64
|
onclick={onClick}
|
|
62
65
|
variant="load-more"
|
|
63
|
-
text=
|
|
66
|
+
text={showMoreLabel}
|
|
64
67
|
></dx-hr>
|
|
65
68
|
<dx-hr
|
|
66
69
|
if:true={showArchives}
|
|
67
70
|
onclick={onClick}
|
|
68
71
|
variant="link"
|
|
69
|
-
href=
|
|
70
|
-
text=
|
|
72
|
+
href={archiveCta}
|
|
73
|
+
text={viewArchivesLabel}
|
|
71
74
|
></dx-hr>
|
|
72
75
|
</div>
|
|
73
76
|
</template>
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
+
import { api } from "lwc";
|
|
1
2
|
import { normalizePost } from "dxUtils/normalizers";
|
|
2
3
|
import { track } from "dxUtils/analytics";
|
|
3
4
|
import { WordpressBlogPost, NormalizedPost } from "typings/custom";
|
|
4
|
-
import { PostsGrid } from "
|
|
5
|
+
import { PostsGrid } from "dwUtils/postsGrid";
|
|
5
6
|
|
|
6
7
|
const BLOG_SUBSCRIBE_HREF = "https://developer.salesforce.com/blogs/feed";
|
|
7
8
|
|
|
8
9
|
const ANALYTICS_INFO = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
clickUrl: BLOG_SUBSCRIBE_HREF,
|
|
14
|
-
ctaClick: true
|
|
10
|
+
click_text: "Subscribe to RSS",
|
|
11
|
+
element_title: "Subscribe to RSS",
|
|
12
|
+
click_url: BLOG_SUBSCRIBE_HREF,
|
|
13
|
+
content_category: "cta"
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
export default class BlogsGrid extends PostsGrid {
|
|
17
|
+
@api showMoreLabel = "SHOW MORE";
|
|
18
|
+
@api viewArchivesLabel = "VIEW ARCHIVES";
|
|
19
|
+
@api rssTitle =
|
|
20
|
+
"Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.";
|
|
21
|
+
@api rssBody?: string;
|
|
22
|
+
@api rssBtnOneLabel = "Add to Slack";
|
|
23
|
+
@api rssBtnTwoLabel = "Subscribe to RSS";
|
|
24
|
+
@api archiveCta = "/content-archive?content-type=Blogs";
|
|
25
|
+
|
|
18
26
|
_loadMoreAmount = 21;
|
|
19
27
|
|
|
20
28
|
normalizePost(post: WordpressBlogPost): NormalizedPost {
|
|
@@ -22,7 +30,13 @@ export default class BlogsGrid extends PostsGrid {
|
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
rssOnClick(event: Event): void {
|
|
25
|
-
track(event.target!, "custEv_ctaButtonClick",
|
|
26
|
-
|
|
33
|
+
track(event.target!, "custEv_ctaButtonClick", {
|
|
34
|
+
...ANALYTICS_INFO,
|
|
35
|
+
element_type: "button"
|
|
36
|
+
});
|
|
37
|
+
track(event.target!, "custEv_linkClick", {
|
|
38
|
+
...ANALYTICS_INFO,
|
|
39
|
+
element_type: "link"
|
|
40
|
+
});
|
|
27
41
|
}
|
|
28
42
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
@import "dxHelpers/text";
|
|
3
|
+
|
|
4
|
+
:host {
|
|
5
|
+
--dw-browse-trials-padding-top: 0;
|
|
6
|
+
--dw-browse-trials-padding-bottom: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.category-section {
|
|
10
|
+
--dx-c-section-padding-horizontal: 0;
|
|
11
|
+
--dx-c-section-padding-bottom: 0;
|
|
12
|
+
--dx-c-section-padding-top: var(--dx-g-spacing-4xl);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.panel-list-container {
|
|
16
|
+
padding: var(--dw-browse-trials-padding-top)
|
|
17
|
+
var(--dx-g-page-padding-horizontal)
|
|
18
|
+
var(--dw-browse-trials-padding-bottom)
|
|
19
|
+
var(--dx-g-page-padding-horizontal);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
dx-tab-panel-list {
|
|
23
|
+
--dx-c-tab-panel-list-horizontal-padding: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.category-text-container {
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.button-toggle-container {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
gap: var(--dx-g-spacing-md);
|
|
34
|
+
margin-top: var(--dx-g-spacing-3xl);
|
|
35
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<dx-section header={header}>
|
|
3
|
+
<dx-tab-panel-list
|
|
4
|
+
tabs={tabLabels}
|
|
5
|
+
onchange={handleTabChange}
|
|
6
|
+
initial-index={activeTabIndex}
|
|
7
|
+
>
|
|
8
|
+
<template for:each={trials} for:item="trial">
|
|
9
|
+
<dx-tab-panel key={trial.label}>
|
|
10
|
+
<div
|
|
11
|
+
key={trial.label}
|
|
12
|
+
class="button-toggle-container"
|
|
13
|
+
if:false={trial.hideFilters}
|
|
14
|
+
>
|
|
15
|
+
<template
|
|
16
|
+
for:each={buttonToggleStates}
|
|
17
|
+
for:item="buttonToggleState"
|
|
18
|
+
>
|
|
19
|
+
<dx-button-toggle
|
|
20
|
+
label={buttonToggleState.label}
|
|
21
|
+
key={buttonToggleState.label}
|
|
22
|
+
value={buttonToggleState.value}
|
|
23
|
+
ontoggle={handleFilters}
|
|
24
|
+
></dx-button-toggle>
|
|
25
|
+
</template>
|
|
26
|
+
</div>
|
|
27
|
+
<template for:each={filteredCategories} for:item="category">
|
|
28
|
+
<dx-section
|
|
29
|
+
header={category.title}
|
|
30
|
+
subtitle={category.subtitle}
|
|
31
|
+
heading-level="4"
|
|
32
|
+
subtitle-level="2"
|
|
33
|
+
key={category.title}
|
|
34
|
+
class="category-section"
|
|
35
|
+
>
|
|
36
|
+
<dx-grid columns="three">
|
|
37
|
+
<template
|
|
38
|
+
for:each={category.cards}
|
|
39
|
+
for:item="card"
|
|
40
|
+
>
|
|
41
|
+
<template if:true={card.hasModal}>
|
|
42
|
+
<dx-card-trial
|
|
43
|
+
key={card.title}
|
|
44
|
+
badge-background-color={card.badgeBackgroundColor}
|
|
45
|
+
badge-symbol={card.badgeSymbol}
|
|
46
|
+
body={card.body}
|
|
47
|
+
details={card.details}
|
|
48
|
+
modal-title={card.modalTitle}
|
|
49
|
+
modal-details={card.modalDetails}
|
|
50
|
+
href={card.href}
|
|
51
|
+
label={card.label}
|
|
52
|
+
terms={card.terms}
|
|
53
|
+
header={card.title}
|
|
54
|
+
button-one-cta={card.buttonOneCta}
|
|
55
|
+
button-one-href={card.buttonOneHref}
|
|
56
|
+
button-one-icon={card.buttonOneIcon}
|
|
57
|
+
button-two-cta={card.buttonTwoCta}
|
|
58
|
+
modal-type-badge-value={card.modalTypeBadgeValue}
|
|
59
|
+
modal-type-badge-dark={card.modalTypeBadgeDark}
|
|
60
|
+
hide-card-details="true"
|
|
61
|
+
></dx-card-trial>
|
|
62
|
+
</template>
|
|
63
|
+
<template if:false={card.hasModal}>
|
|
64
|
+
<dx-card-trial
|
|
65
|
+
key={card.title}
|
|
66
|
+
badge-background-color={card.badgeBackgroundColor}
|
|
67
|
+
badge-symbol={card.badgeSymbol}
|
|
68
|
+
body={card.body}
|
|
69
|
+
href={card.href}
|
|
70
|
+
label={card.label}
|
|
71
|
+
terms={card.terms}
|
|
72
|
+
header={card.title}
|
|
73
|
+
button-one-cta={card.buttonOneCta}
|
|
74
|
+
button-one-href={card.buttonOneHref}
|
|
75
|
+
button-one-icon={card.buttonOneIcon}
|
|
76
|
+
></dx-card-trial>
|
|
77
|
+
</template>
|
|
78
|
+
</template>
|
|
79
|
+
</dx-grid>
|
|
80
|
+
</dx-section>
|
|
81
|
+
</template>
|
|
82
|
+
</dx-tab-panel>
|
|
83
|
+
</template>
|
|
84
|
+
</dx-tab-panel-list>
|
|
85
|
+
</dx-section>
|
|
86
|
+
</template>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { LightningElement, api, track } from "lwc";
|
|
2
|
+
import { toJson } from "dxUtils/normalizers";
|
|
3
|
+
|
|
4
|
+
const STORED_TAB_SELECTED_KEY = "storedTabIndex";
|
|
5
|
+
|
|
6
|
+
export default class BrowseTrials extends LightningElement {
|
|
7
|
+
@api header = "Browse Trials";
|
|
8
|
+
|
|
9
|
+
@api
|
|
10
|
+
get trials() {
|
|
11
|
+
return this._trials;
|
|
12
|
+
}
|
|
13
|
+
set trials(
|
|
14
|
+
value: [{ label: string; hideFilters: boolean; buttonLabels: string[] }]
|
|
15
|
+
) {
|
|
16
|
+
this._trials = toJson(value);
|
|
17
|
+
this.tabLabels = this._trials.map((trial) => ({ label: trial.label }));
|
|
18
|
+
this.buttonLabels = this._trials.map((trial) =>
|
|
19
|
+
!trial.hideFilters ? trial.buttonLabels : []
|
|
20
|
+
);
|
|
21
|
+
this._filteredTitles = this._trials.map(() => []);
|
|
22
|
+
this._filteredCategories = this._trials.map(
|
|
23
|
+
(trial) => trial.categories
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get buttonToggleStates() {
|
|
28
|
+
return this.buttonLabels[this.activeTabIndex].map((label) => ({
|
|
29
|
+
label,
|
|
30
|
+
value: this.activeFilteredTitles.includes(label)
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get activeFilteredTitles() {
|
|
35
|
+
return this._filteredTitles[this.activeTabIndex];
|
|
36
|
+
}
|
|
37
|
+
set activeFilteredTitles(value: string[]) {
|
|
38
|
+
this._filteredTitles[this.activeTabIndex] = value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get activeCategories() {
|
|
42
|
+
return this._trials[this.activeTabIndex].categories;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get filteredCategories() {
|
|
46
|
+
return this._filteredCategories[this.activeTabIndex];
|
|
47
|
+
}
|
|
48
|
+
set filteredCategories(value: any) {
|
|
49
|
+
this._filteredCategories[this.activeTabIndex] = value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@track
|
|
53
|
+
private _filteredCategories!: Array<any>;
|
|
54
|
+
|
|
55
|
+
private activeTabIndex = 0;
|
|
56
|
+
private buttonLabels!: string[][];
|
|
57
|
+
private _filteredTitles!: string[][];
|
|
58
|
+
private tabLabels!: Array<{ label: string }>;
|
|
59
|
+
private _trials!: [
|
|
60
|
+
{
|
|
61
|
+
label: string;
|
|
62
|
+
hideFilters: boolean;
|
|
63
|
+
buttonLabels: string[];
|
|
64
|
+
categories: Array<{ title: string }>;
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
connectedCallback() {
|
|
69
|
+
const storedTabIndex = window.localStorage.getItem(
|
|
70
|
+
STORED_TAB_SELECTED_KEY
|
|
71
|
+
);
|
|
72
|
+
if (storedTabIndex) {
|
|
73
|
+
this.activeTabIndex = +storedTabIndex;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
handleTabChange(e: CustomEvent) {
|
|
78
|
+
this.activeTabIndex = e.detail;
|
|
79
|
+
window.localStorage.setItem(STORED_TAB_SELECTED_KEY, e.detail);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
filterCategories() {
|
|
83
|
+
this.filteredCategories = this.activeCategories.filter((category) =>
|
|
84
|
+
this.activeFilteredTitles.includes(category.title)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
addLabelToFilter(label: string) {
|
|
89
|
+
this.activeFilteredTitles.push(label);
|
|
90
|
+
this.filterCategories();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
removeLabelFromFilter(label: string) {
|
|
94
|
+
this.activeFilteredTitles = this.activeFilteredTitles.filter(
|
|
95
|
+
(filterTitle) => filterTitle !== label
|
|
96
|
+
);
|
|
97
|
+
this.filterCategories();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
resetFilters() {
|
|
101
|
+
this.activeFilteredTitles = [];
|
|
102
|
+
this.filteredCategories = this.activeCategories;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
handleFilters(e: CustomEvent) {
|
|
106
|
+
const { label, value } = e.detail;
|
|
107
|
+
|
|
108
|
+
if (value) {
|
|
109
|
+
this.addLabelToFilter(label);
|
|
110
|
+
} else if (this.activeFilteredTitles.length !== 1) {
|
|
111
|
+
this.removeLabelFromFilter(label);
|
|
112
|
+
} else {
|
|
113
|
+
this.resetFilters();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
<template for:each={posts} for:item="post">
|
|
3
3
|
<dx-card-blog-post
|
|
4
4
|
label="BLOG POST"
|
|
5
|
-
author-img-src={post.authorImgSrc}
|
|
6
|
-
author-label={post.authorName}
|
|
7
5
|
body={post.body}
|
|
8
6
|
datetime={post.datetime}
|
|
9
7
|
href={post.href}
|
|
10
8
|
img-alt={post.imgAlt}
|
|
11
9
|
img-src={post.imgSrc}
|
|
12
10
|
key={post.id}
|
|
13
|
-
|
|
11
|
+
header={post.title}
|
|
12
|
+
authors={post.authors}
|
|
14
13
|
></dx-card-blog-post>
|
|
14
|
+
<dx-hr spacing="2xs" class="mobile-divider_posts" key={post.id}></dx-hr>
|
|
15
15
|
</template>
|
|
16
16
|
</template>
|