@salesforcedevs/dw-components 1.1.2-alpha.1 → 1.1.2-alpha.4

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/dw-components",
3
- "version": "1.1.2-alpha.1",
3
+ "version": "1.1.2-alpha.4",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -1,33 +1,48 @@
1
- dx-section.browse {
2
- --dx-c-section-heading-font-color: var(--dx-g-blue-vibrant-20);
3
- --dx-c-section-heading-font-family: var(--dx-g-font-display);
4
- --dx-c-section-heading-font-size: 32px;
5
- --dx-c-section-padding-top: 0;
6
- --dx-c-section-heading-margin-bottom: var(--dx-g-spacing-md);
7
- z-index: 1;
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
+ .title {
10
+ color: var(--dx-g-blue-vibrant-20);
11
+ font-family: var(--dx-g-font-display);
12
+ font-weight: var(--dx-g-font-weight-demi);
13
+ font-size: 32px;
14
+ letter-spacing: -0.4px;
15
+ line-height: 40px;
16
+ margin-bottom: var(--dx-g-spacing-md);
17
+ }
18
+
19
+ .panel-list-container {
20
+ padding: var(--dw-browse-trials-padding-top)
21
+ var(--dx-g-page-padding-horizontal)
22
+ var(--dw-browse-trials-padding-bottom)
23
+ var(--dx-g-page-padding-horizontal);
8
24
  }
9
25
 
10
26
  dx-tab-panel-list {
11
27
  --dx-c-tab-panel-list-horizontal-padding: 0;
12
28
  }
13
29
 
14
- dx-section.section-container {
15
- --dx-c-section-padding-vertical: 0;
16
- --dx-c-section-padding-horizontal: 0;
30
+ .category-title {
17
31
  width: 100%;
18
32
  }
19
33
 
20
- dx-section.section-container:not(:first-of-type) {
21
- margin-top: var(--dx-g-spacing-4xl);
22
- z-index: 1;
23
- }
24
-
25
34
  .button-toggle-container {
26
- margin-bottom: var(--dx-g-spacing-4xl);
35
+ display: flex;
36
+ gap: var(--dx-g-spacing-md);
37
+ margin-top: var(--dx-g-spacing-3xl);
27
38
  }
28
39
 
29
- .card-container {
40
+ .category-container {
30
41
  display: flex;
31
42
  flex-wrap: wrap;
32
43
  gap: 40px;
33
44
  }
45
+
46
+ .category-container {
47
+ margin-top: var(--dx-g-spacing-4xl);
48
+ }
@@ -1,28 +1,30 @@
1
1
  <template>
2
- <dx-tab-panel-list tabs={_tabs} onchange={handleTabChange}>
3
- <template for:each={trials} for:item="trial">
4
- <dx-tab-panel key={trial.label}>
5
- <div
6
- key={trial.label}
7
- class="button-toggle-container"
8
- if:false={trial.hideFilters}
9
- for:each={buttonLabels}
10
- for:item="buttonLabel"
11
- >
12
- <dx-button-toggle
13
- label={buttonLabel.title}
14
- key={buttonLabel.title}
15
- ontoggle={handleFilters}
16
- ></dx-button-toggle>
17
- </div>
18
- <template for:each={trial.categories} for:item="category">
19
- <dx-section
20
- key={category.title}
21
- class="section-container"
22
- title={category.title}
23
- heading-level="4"
2
+ <div class="panel-list-container">
3
+ <h2 class="title">{title}</h2>
4
+ <dx-tab-panel-list tabs={tabLabels} onchange={handleTabChange}>
5
+ <template for:each={trials} for:item="trial">
6
+ <dx-tab-panel key={trial.label}>
7
+ <div
8
+ key={trial.label}
9
+ class="button-toggle-container"
10
+ if:false={trial.hideFilters}
24
11
  >
25
- <div class="card-container">
12
+ <template
13
+ for:each={buttonLabelsForActiveTab}
14
+ for:item="buttonLabel"
15
+ >
16
+ <dx-button-toggle
17
+ label={buttonLabel}
18
+ key={buttonLabel}
19
+ ontoggle={handleFilters}
20
+ ></dx-button-toggle>
21
+ </template>
22
+ </div>
23
+ <template for:each={filteredCategories} for:item="category">
24
+ <div key={category.title} class="category-container">
25
+ <h2 class="dx-text-heading-4 category-title">
26
+ {category.title}
27
+ </h2>
26
28
  <template for:each={category.cards} for:item="card">
27
29
  <template if:true={card.hasModal}>
28
30
  <dx-card-trial
@@ -59,9 +61,9 @@
59
61
  </template>
60
62
  </template>
61
63
  </div>
62
- </dx-section>
63
- </template>
64
- </dx-tab-panel>
65
- </template>
66
- </dx-tab-panel-list>
64
+ </template>
65
+ </dx-tab-panel>
66
+ </template>
67
+ </dx-tab-panel-list>
68
+ </div>
67
69
  </template>
@@ -2,44 +2,94 @@ import { LightningElement, api, track } from "lwc";
2
2
  import { toJson } from "dxUtils/normalizers";
3
3
 
4
4
  export default class BrowseTrials extends LightningElement {
5
+ @api title = "Browse Trials";
6
+
5
7
  @api
6
8
  get trials() {
7
9
  return this._trials;
8
10
  }
9
- set trials(value: [{ label: string }]) {
11
+ set trials(
12
+ value: [{ label: string; hideFilters: boolean; buttonLabels: string[] }]
13
+ ) {
10
14
  this._trials = toJson(value);
11
- this._tabs = this._trials.map((trial) => ({ label: trial.label }));
15
+ this.tabLabels = this._trials.map((trial) => ({ label: trial.label }));
16
+ this.buttonLabels = this._trials.map((trial) =>
17
+ trial.hideFilters ? [] : trial.buttonLabels
18
+ );
19
+ this._filteredCategories = this._trials.map(
20
+ (trial) => trial.categories
21
+ );
22
+
23
+ console.log(this._filteredCategories);
24
+ }
25
+
26
+ get buttonLabelsForActiveTab() {
27
+ return this.buttonLabels[this.activeTabIndex];
28
+ }
29
+
30
+ get activeCategories() {
31
+ return this._trials[this.activeTabIndex].categories;
32
+ }
33
+
34
+ get filteredCategories() {
35
+ return this._filteredCategories[this.activeTabIndex];
36
+ }
37
+ set filteredCategories(value: any) {
38
+ this._filteredCategories[this.activeTabIndex] = value;
12
39
  }
13
40
 
14
41
  @track
15
- private _trials!: [{ label: string; categories: Array<{ title: string }> }];
16
- private buttonLabels!: Array<{ title: string }>;
42
+ private _filteredCategories!: Array<any>;
17
43
 
18
- private _tabs!: Array<{ label: string }>;
19
- private filters: Array<{ label: string }> = [];
20
44
  private activeTabIndex = 0;
45
+ private buttonLabels!: string[][];
46
+ private filteredTitles: string[] = [];
47
+ private tabLabels!: Array<{ label: string }>;
48
+ private _trials!: [
49
+ {
50
+ label: string;
51
+ hideFilters: boolean;
52
+ buttonLabels: string[];
53
+ categories: Array<{ title: string }>;
54
+ }
55
+ ];
21
56
 
22
57
  handleTabChange(e: CustomEvent) {
23
58
  this.activeTabIndex = e.detail;
24
59
  }
25
60
 
61
+ filterCategories() {
62
+ this.filteredCategories = this.activeCategories.filter((category) =>
63
+ this.filteredTitles.includes(category.title)
64
+ );
65
+ }
66
+
67
+ addLabelToFilter(label: string) {
68
+ this.filteredTitles.push(label);
69
+ this.filterCategories();
70
+ }
71
+
72
+ removeLabelFromFilter(label: string) {
73
+ this.filteredTitles = this.filteredTitles.filter(
74
+ (filterTitle) => filterTitle !== label
75
+ );
76
+ this.filterCategories();
77
+ }
78
+
79
+ resetFilters() {
80
+ this.filteredTitles = [];
81
+ this.filteredCategories = this.activeCategories;
82
+ }
83
+
26
84
  handleFilters(e: CustomEvent) {
27
85
  const { label, value } = e.detail;
28
86
 
29
87
  if (value) {
30
- this.filters.push(label);
31
- this._trials[this.activeTabIndex].categories = this._trials[
32
- this.activeTabIndex
33
- ].categories.filter((category) =>
34
- this.filters.includes(category.title)
35
- );
88
+ this.addLabelToFilter(label);
89
+ } else if (this.filteredTitles.length !== 1) {
90
+ this.removeLabelFromFilter(label);
36
91
  } else {
37
- this.filters = this.filters.filter((filter) => filter !== label);
38
- this._trials[this.activeTabIndex].categories = this._trials[
39
- this.activeTabIndex
40
- ].categories.filter(
41
- (category) => !this.filters.includes(category.title)
42
- );
92
+ this.resetFilters();
43
93
  }
44
94
  }
45
95
  }