@salesforcedevs/dx-components 0.20.2 → 0.23.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.
Files changed (37) hide show
  1. package/lwc.config.json +2 -0
  2. package/package.json +2 -2
  3. package/src/modules/dx/cardExpanded/__tests__/cardExpanded.test.ts +193 -0
  4. package/src/modules/dx/cardExpanded/__tests__/mockProps.ts +21 -0
  5. package/src/modules/dx/cardExpanded/cardExpanded.css +49 -0
  6. package/src/modules/dx/cardExpanded/cardExpanded.html +37 -0
  7. package/src/modules/dx/cardExpanded/cardExpanded.stories.ts +59 -0
  8. package/src/modules/dx/cardExpanded/cardExpanded.ts +45 -0
  9. package/src/modules/dx/cardMinimal/__tests__/cardMinimal.test.ts +87 -0
  10. package/src/modules/dx/cardMinimal/__tests__/mockProps.ts +10 -0
  11. package/src/modules/dx/cardMinimal/cardMinimal.css +31 -0
  12. package/src/modules/dx/cardMinimal/cardMinimal.html +13 -0
  13. package/src/modules/dx/cardMinimal/cardMinimal.stories.ts +32 -0
  14. package/src/modules/dx/cardMinimal/cardMinimal.ts +3 -0
  15. package/src/modules/dx/codeBlock/__tests__/codeBlock.test.ts +0 -4
  16. package/src/modules/dx/grid/__tests__/grid.test.ts +2 -7
  17. package/src/modules/dx/headerSearch/__tests__/headerSearch.test.ts +0 -1
  18. package/src/modules/dx/imageAndLabel/imageAndLabel.html +14 -2
  19. package/src/modules/dx/popover/__tests__/popover.test.ts +26 -37
  20. package/src/modules/dx/sidebar/__tests__/sidebar.test.ts +0 -4
  21. package/src/modules/dx/sidebarOld/__tests__/sidebarOld.test.ts +0 -4
  22. package/src/modules/dx/sidebarSearch/__tests__/mockPreloadedState.ts +938 -930
  23. package/src/modules/dx/sidebarSearch/__tests__/sidebarSearch.test.ts +74 -15
  24. package/src/modules/dx/sidebarSearch/sidebarSearch.html +2 -2
  25. package/src/modules/dx/sidebarSearch/sidebarSearch.ts +4 -0
  26. package/src/modules/dx/socials/__tests__/socials.test.ts +12 -22
  27. package/src/modules/dx/topics/__tests__/mockProps.ts +3 -0
  28. package/src/modules/dx/topics/__tests__/topics.test.ts +31 -0
  29. package/src/modules/dx/topics/topics.css +25 -0
  30. package/src/modules/dx/topics/topics.html +12 -0
  31. package/src/modules/dx/topics/topics.ts +25 -0
  32. package/src/modules/dx/tree/__tests__/tree.test.ts +17 -28
  33. package/src/modules/dx/treeItem/__tests__/treeItem.test.ts +36 -59
  34. package/src/modules/dx/typeBadge/typeBadge.css +1 -1
  35. package/src/modules/helpers/text/text.css +7 -0
  36. package/src/modules/utils/archiveCard/archiveCard.ts +35 -0
  37. package/src/modules/utils/normalizers/normalizers.ts +2 -2
@@ -0,0 +1,35 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import { LinkTarget, Color } from "typings/custom";
3
+
4
+ const MOBILE_QUERY = "(max-width: 640px)";
5
+
6
+ export abstract class ArchiveCard extends LightningElement {
7
+ @api contentType: "Blog" | "Podcast" = "Blog";
8
+ @api href!: string;
9
+ @api title!: string;
10
+ @api target: LinkTarget = "_self";
11
+
12
+ private matchMedia!: MediaQueryList;
13
+ protected mobile = false;
14
+
15
+ protected get badgeColor(): Color {
16
+ return this.contentType === "Blog" ? "teal" : "blue";
17
+ }
18
+
19
+ connectedCallback(): void {
20
+ this.matchMedia = window.matchMedia(MOBILE_QUERY);
21
+ this.onMediaChange(this.matchMedia);
22
+ this.matchMedia.addEventListener("change", this.onMediaChange);
23
+ }
24
+
25
+ disconnectedCallback(): void {
26
+ this.matchMedia.removeEventListener("change", this.onMediaChange);
27
+ }
28
+
29
+ private onMediaChange = (e: MediaQueryListEvent | MediaQueryList) =>
30
+ (this.mobile = e.matches);
31
+
32
+ protected get badgeSize(): string {
33
+ return (this.mobile && "small") || "default";
34
+ }
35
+ }
@@ -6,7 +6,7 @@ export const toJson = (value: string | object | null) =>
6
6
  export const normalizeToArray = (
7
7
  value: string[] | string | null,
8
8
  splitKey: string = ","
9
- ) => {
9
+ ): Array<string> => {
10
10
  if (!value) {
11
11
  return [];
12
12
  }
@@ -19,7 +19,7 @@ export const normalizeToArray = (
19
19
  }
20
20
  }
21
21
 
22
- return Array.isArray(value) ? value : [value];
22
+ return (Array.isArray(value) ? value : [value]) as Array<string>;
23
23
  };
24
24
 
25
25
  type WordpressPodcastEpisode = {