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

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.4",
3
+ "version": "1.1.2-alpha.6",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -27,10 +27,22 @@ dx-tab-panel-list {
27
27
  --dx-c-tab-panel-list-horizontal-padding: 0;
28
28
  }
29
29
 
30
- .category-title {
30
+ dx-card-trial {
31
+ width: 400px;
32
+ max-width: 100%;
33
+ min-width: 240px;
34
+ }
35
+
36
+ .category-text-container {
31
37
  width: 100%;
32
38
  }
33
39
 
40
+ .category-subtitle {
41
+ color: var(--dx-g-font-sans);
42
+ margin-top: var(--dx-g-spacing-smd);
43
+ max-width: 560px;
44
+ }
45
+
34
46
  .button-toggle-container {
35
47
  display: flex;
36
48
  gap: var(--dx-g-spacing-md);
@@ -10,21 +10,33 @@
10
10
  if:false={trial.hideFilters}
11
11
  >
12
12
  <template
13
- for:each={buttonLabelsForActiveTab}
14
- for:item="buttonLabel"
13
+ for:each={buttonToggleStates}
14
+ for:item="buttonToggleState"
15
15
  >
16
16
  <dx-button-toggle
17
- label={buttonLabel}
18
- key={buttonLabel}
17
+ label={buttonToggleState.label}
18
+ key={buttonToggleState.label}
19
+ value={buttonToggleState.value}
19
20
  ontoggle={handleFilters}
20
21
  ></dx-button-toggle>
21
22
  </template>
22
23
  </div>
23
24
  <template for:each={filteredCategories} for:item="category">
24
25
  <div key={category.title} class="category-container">
25
- <h2 class="dx-text-heading-4 category-title">
26
- {category.title}
27
- </h2>
26
+ <div
27
+ if:true={category.title}
28
+ class="category-text-container"
29
+ >
30
+ <h2 class="dx-text-heading-4 category-title">
31
+ {category.title}
32
+ </h2>
33
+ <p
34
+ if:true={category.subtitle}
35
+ class="category-subtitle"
36
+ >
37
+ {category.subtitle}
38
+ </p>
39
+ </div>
28
40
  <template for:each={category.cards} for:item="card">
29
41
  <template if:true={card.hasModal}>
30
42
  <dx-card-trial
@@ -14,17 +14,26 @@ export default class BrowseTrials extends LightningElement {
14
14
  this._trials = toJson(value);
15
15
  this.tabLabels = this._trials.map((trial) => ({ label: trial.label }));
16
16
  this.buttonLabels = this._trials.map((trial) =>
17
- trial.hideFilters ? [] : trial.buttonLabels
17
+ !trial.hideFilters ? trial.buttonLabels : []
18
18
  );
19
+ this._filteredTitles = this._trials.map(() => []);
19
20
  this._filteredCategories = this._trials.map(
20
21
  (trial) => trial.categories
21
22
  );
23
+ }
22
24
 
23
- console.log(this._filteredCategories);
25
+ get buttonToggleStates() {
26
+ return this.buttonLabels[this.activeTabIndex].map((label) => ({
27
+ label,
28
+ value: this.activeFilteredTitles.includes(label)
29
+ }));
24
30
  }
25
31
 
26
- get buttonLabelsForActiveTab() {
27
- return this.buttonLabels[this.activeTabIndex];
32
+ get activeFilteredTitles() {
33
+ return this._filteredTitles[this.activeTabIndex];
34
+ }
35
+ set activeFilteredTitles(value: string[]) {
36
+ this._filteredTitles[this.activeTabIndex] = value;
28
37
  }
29
38
 
30
39
  get activeCategories() {
@@ -43,7 +52,7 @@ export default class BrowseTrials extends LightningElement {
43
52
 
44
53
  private activeTabIndex = 0;
45
54
  private buttonLabels!: string[][];
46
- private filteredTitles: string[] = [];
55
+ private _filteredTitles!: string[][];
47
56
  private tabLabels!: Array<{ label: string }>;
48
57
  private _trials!: [
49
58
  {
@@ -60,24 +69,24 @@ export default class BrowseTrials extends LightningElement {
60
69
 
61
70
  filterCategories() {
62
71
  this.filteredCategories = this.activeCategories.filter((category) =>
63
- this.filteredTitles.includes(category.title)
72
+ this.activeFilteredTitles.includes(category.title)
64
73
  );
65
74
  }
66
75
 
67
76
  addLabelToFilter(label: string) {
68
- this.filteredTitles.push(label);
77
+ this.activeFilteredTitles.push(label);
69
78
  this.filterCategories();
70
79
  }
71
80
 
72
81
  removeLabelFromFilter(label: string) {
73
- this.filteredTitles = this.filteredTitles.filter(
82
+ this.activeFilteredTitles = this.activeFilteredTitles.filter(
74
83
  (filterTitle) => filterTitle !== label
75
84
  );
76
85
  this.filterCategories();
77
86
  }
78
87
 
79
88
  resetFilters() {
80
- this.filteredTitles = [];
89
+ this.activeFilteredTitles = [];
81
90
  this.filteredCategories = this.activeCategories;
82
91
  }
83
92
 
@@ -86,7 +95,7 @@ export default class BrowseTrials extends LightningElement {
86
95
 
87
96
  if (value) {
88
97
  this.addLabelToFilter(label);
89
- } else if (this.filteredTitles.length !== 1) {
98
+ } else if (this.activeFilteredTitles.length !== 1) {
90
99
  this.removeLabelFromFilter(label);
91
100
  } else {
92
101
  this.resetFilters();