@agilant/toga-blox 1.0.8 → 1.0.9

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 (215) hide show
  1. package/assets/cable.jpg +0 -0
  2. package/assets/card-1.jpg +0 -0
  3. package/assets/cat-logo.png +0 -0
  4. package/assets/item.jpg +0 -0
  5. package/assets/map.png +0 -0
  6. package/coverage/base.css +224 -0
  7. package/coverage/block-navigation.js +87 -0
  8. package/coverage/clover.xml +953 -0
  9. package/coverage/coverage-final.json +74 -0
  10. package/coverage/favicon.png +0 -0
  11. package/coverage/index.html +551 -0
  12. package/coverage/prettify.css +1 -0
  13. package/coverage/prettify.js +2 -0
  14. package/coverage/sort-arrow-sprite.png +0 -0
  15. package/coverage/sorter.js +196 -0
  16. package/coverage/toga-blox-npm/index.html +131 -0
  17. package/coverage/toga-blox-npm/postcss.config.js.html +103 -0
  18. package/coverage/toga-blox-npm/src/components/Badge/Badge.stories.tsx.html +793 -0
  19. package/coverage/toga-blox-npm/src/components/Badge/Badge.tsx.html +247 -0
  20. package/coverage/toga-blox-npm/src/components/Badge/index.html +131 -0
  21. package/coverage/toga-blox-npm/src/components/Card/Card.stories.tsx.html +787 -0
  22. package/coverage/toga-blox-npm/src/components/Card/Card.tsx.html +163 -0
  23. package/coverage/toga-blox-npm/src/components/Card/index.html +131 -0
  24. package/coverage/toga-blox-npm/src/components/Card/templates/CategoryCardTemplate.tsx.html +343 -0
  25. package/coverage/toga-blox-npm/src/components/Card/templates/CompassCardTemplate.tsx.html +259 -0
  26. package/coverage/toga-blox-npm/src/components/Card/templates/CounterContentCardTemplate.tsx.html +685 -0
  27. package/coverage/toga-blox-npm/src/components/Card/templates/HorizontalCardTemplate.tsx.html +637 -0
  28. package/coverage/toga-blox-npm/src/components/Card/templates/ItemCardTemplate.tsx.html +550 -0
  29. package/coverage/toga-blox-npm/src/components/Card/templates/KitContentCardTemplate.tsx.html +469 -0
  30. package/coverage/toga-blox-npm/src/components/Card/templates/ShippingAddressCardTemplate.tsx.html +418 -0
  31. package/coverage/toga-blox-npm/src/components/Card/templates/VerticalCardTemplate.tsx.html +592 -0
  32. package/coverage/toga-blox-npm/src/components/Card/templates/index.html +221 -0
  33. package/coverage/toga-blox-npm/src/components/CounterButton/CounterButton.stories.tsx.html +358 -0
  34. package/coverage/toga-blox-npm/src/components/CounterButton/CounterButton.tsx.html +385 -0
  35. package/coverage/toga-blox-npm/src/components/CounterButton/index.html +131 -0
  36. package/coverage/toga-blox-npm/src/components/Description/Description.stories.tsx.html +286 -0
  37. package/coverage/toga-blox-npm/src/components/Description/Description.tsx.html +124 -0
  38. package/coverage/toga-blox-npm/src/components/Description/index.html +131 -0
  39. package/coverage/toga-blox-npm/src/components/DropDownIconButton/DropDownIconButton.stories.tsx.html +676 -0
  40. package/coverage/toga-blox-npm/src/components/DropDownIconButton/DropDownIconButton.tsx.html +346 -0
  41. package/coverage/toga-blox-npm/src/components/DropDownIconButton/index.html +131 -0
  42. package/coverage/toga-blox-npm/src/components/Footer/ContactInfoItem.tsx.html +139 -0
  43. package/coverage/toga-blox-npm/src/components/Footer/Footer.stories.tsx.html +934 -0
  44. package/coverage/toga-blox-npm/src/components/Footer/Footer.tsx.html +373 -0
  45. package/coverage/toga-blox-npm/src/components/Footer/index.html +146 -0
  46. package/coverage/toga-blox-npm/src/components/FormButton/FormButton.stories.tsx.html +952 -0
  47. package/coverage/toga-blox-npm/src/components/FormButton/FormButton.tsx.html +343 -0
  48. package/coverage/toga-blox-npm/src/components/FormButton/index.html +131 -0
  49. package/coverage/toga-blox-npm/src/components/GenericList/GenericList.stories.tsx.html +376 -0
  50. package/coverage/toga-blox-npm/src/components/GenericList/GenericList.tsx.html +520 -0
  51. package/coverage/toga-blox-npm/src/components/GenericList/index.html +131 -0
  52. package/coverage/toga-blox-npm/src/components/GenericList/templates/DummyDataList.tsx.html +154 -0
  53. package/coverage/toga-blox-npm/src/components/GenericList/templates/DynamicIconList.tsx.html +250 -0
  54. package/coverage/toga-blox-npm/src/components/GenericList/templates/index.html +131 -0
  55. package/coverage/toga-blox-npm/src/components/GetSupport/GetSupport.stories.tsx.html +325 -0
  56. package/coverage/toga-blox-npm/src/components/GetSupport/GetSupport.tsx.html +262 -0
  57. package/coverage/toga-blox-npm/src/components/GetSupport/index.html +131 -0
  58. package/coverage/toga-blox-npm/src/components/HamburgerButton/Hamburger.stories.tsx.html +760 -0
  59. package/coverage/toga-blox-npm/src/components/HamburgerButton/HamburgerButton.tsx.html +232 -0
  60. package/coverage/toga-blox-npm/src/components/HamburgerButton/index.html +131 -0
  61. package/coverage/toga-blox-npm/src/components/Header/Header.stories.tsx.html +1633 -0
  62. package/coverage/toga-blox-npm/src/components/Header/Header.tsx.html +814 -0
  63. package/coverage/toga-blox-npm/src/components/Header/headerContext.tsx.html +460 -0
  64. package/coverage/toga-blox-npm/src/components/Header/index.html +146 -0
  65. package/coverage/toga-blox-npm/src/components/Hero/Hero.stories.tsx.html +289 -0
  66. package/coverage/toga-blox-npm/src/components/Hero/Hero.tsx.html +259 -0
  67. package/coverage/toga-blox-npm/src/components/Hero/index.html +131 -0
  68. package/coverage/toga-blox-npm/src/components/IconButton/IconButton.stories.tsx.html +673 -0
  69. package/coverage/toga-blox-npm/src/components/IconButton/IconButton.tsx.html +313 -0
  70. package/coverage/toga-blox-npm/src/components/IconButton/index.html +131 -0
  71. package/coverage/toga-blox-npm/src/components/Image/Image.stories.tsx.html +322 -0
  72. package/coverage/toga-blox-npm/src/components/Image/Image.tsx.html +226 -0
  73. package/coverage/toga-blox-npm/src/components/Image/index.html +131 -0
  74. package/coverage/toga-blox-npm/src/components/Input/Input.stories.tsx.html +1621 -0
  75. package/coverage/toga-blox-npm/src/components/Input/Input.tsx.html +568 -0
  76. package/coverage/toga-blox-npm/src/components/Input/InputMemoTypes.tsx.html +181 -0
  77. package/coverage/toga-blox-npm/src/components/Input/index.html +146 -0
  78. package/coverage/toga-blox-npm/src/components/MobileMenu/MobileMenu.tsx.html +208 -0
  79. package/coverage/toga-blox-npm/src/components/MobileMenu/index.html +116 -0
  80. package/coverage/toga-blox-npm/src/components/Nav/Nav.stories.tsx.html +628 -0
  81. package/coverage/toga-blox-npm/src/components/Nav/Nav.tsx.html +622 -0
  82. package/coverage/toga-blox-npm/src/components/Nav/index.html +131 -0
  83. package/coverage/toga-blox-npm/src/components/Page/TableDataDummy.tsx.html +733 -0
  84. package/coverage/toga-blox-npm/src/components/Page/ViewPageTemplate.stories.tsx.html +1714 -0
  85. package/coverage/toga-blox-npm/src/components/Page/ViewPageTemplate.tsx.html +115 -0
  86. package/coverage/toga-blox-npm/src/components/Page/index.html +146 -0
  87. package/coverage/toga-blox-npm/src/components/PageSection/PageSection.stories.tsx.html +433 -0
  88. package/coverage/toga-blox-npm/src/components/PageSection/PageSection.tsx.html +121 -0
  89. package/coverage/toga-blox-npm/src/components/PageSection/index.html +131 -0
  90. package/coverage/toga-blox-npm/src/components/SearchInput/SearchInput.stories.tsx.html +517 -0
  91. package/coverage/toga-blox-npm/src/components/SearchInput/SearchInput.tsx.html +325 -0
  92. package/coverage/toga-blox-npm/src/components/SearchInput/index.html +131 -0
  93. package/coverage/toga-blox-npm/src/components/Slider/Slider.stories.tsx.html +349 -0
  94. package/coverage/toga-blox-npm/src/components/Slider/Slider.tsx.html +502 -0
  95. package/coverage/toga-blox-npm/src/components/Slider/index.html +131 -0
  96. package/coverage/toga-blox-npm/src/components/Submenus/AdminSubmenu.tsx.html +136 -0
  97. package/coverage/toga-blox-npm/src/components/Submenus/AlertSubmenu.tsx.html +253 -0
  98. package/coverage/toga-blox-npm/src/components/Submenus/AlertSubmenuItem.tsx.html +202 -0
  99. package/coverage/toga-blox-npm/src/components/Submenus/index.html +146 -0
  100. package/coverage/toga-blox-npm/src/components/Text/Text.stories.tsx.html +235 -0
  101. package/coverage/toga-blox-npm/src/components/Text/Text.tsx.html +172 -0
  102. package/coverage/toga-blox-npm/src/components/Text/index.html +131 -0
  103. package/coverage/toga-blox-npm/src/components/Toaster/Toaster.stories.tsx.html +445 -0
  104. package/coverage/toga-blox-npm/src/components/Toaster/Toaster.tsx.html +301 -0
  105. package/coverage/toga-blox-npm/src/components/Toaster/index.html +131 -0
  106. package/coverage/toga-blox-npm/src/hoc/styling/index.html +116 -0
  107. package/coverage/toga-blox-npm/src/hoc/styling/withStoryBook.tsx.html +142 -0
  108. package/coverage/toga-blox-npm/src/userHoc/index.html +116 -0
  109. package/coverage/toga-blox-npm/src/userHoc/withMemo.tsx.html +145 -0
  110. package/coverage/toga-blox-npm/src/utils/assertTagName.tsx.html +106 -0
  111. package/coverage/toga-blox-npm/src/utils/generateAccordionItem.tsx.html +373 -0
  112. package/coverage/toga-blox-npm/src/utils/generateFooterContacts.tsx.html +295 -0
  113. package/coverage/toga-blox-npm/src/utils/generateNavMenu.tsx.html +247 -0
  114. package/coverage/toga-blox-npm/src/utils/generateSocialList.tsx.html +187 -0
  115. package/coverage/toga-blox-npm/src/utils/getFontAwesomeIcon.tsx.html +145 -0
  116. package/coverage/toga-blox-npm/src/utils/index.html +206 -0
  117. package/coverage/toga-blox-npm/src/utils/inputValidation.tsx.html +163 -0
  118. package/coverage/toga-blox-npm/tailwind.config.js.html +205 -0
  119. package/declarations.d.ts +1 -1
  120. package/package.json +5 -6
  121. package/src/components/Badge/Badge.stories.tsx +110 -207
  122. package/src/components/Badge/Badge.test.tsx +40 -41
  123. package/src/components/Badge/Badge.tsx +29 -99
  124. package/src/components/Badge/Badge.types.tsx +12 -23
  125. package/src/components/Card/Card.stories.tsx +166 -22
  126. package/src/components/Card/Card.test.tsx +3 -3
  127. package/src/components/Card/Card.tsx +12 -16
  128. package/src/components/Card/DUMMYPRODUCTDATA.json +381 -225
  129. package/src/components/Card/templates/CategoryCardTemplate.tsx +86 -0
  130. package/src/components/Card/templates/CompassCardTemplate.tsx +1 -1
  131. package/src/components/Card/templates/CounterContentCardTemplate.tsx +200 -0
  132. package/src/components/Card/templates/ItemCardTemplate.tsx +155 -0
  133. package/src/components/Card/templates/KitContentCardTemplate.tsx +128 -0
  134. package/src/components/Card/templates/ShippingAddressCardTemplate.tsx +111 -0
  135. package/src/components/Card/templates/VerticalCardTemplate.tsx +100 -85
  136. package/src/components/CounterButton/CounterButton.tsx +1 -1
  137. package/src/components/Description/Description.stories.tsx +67 -0
  138. package/src/components/Description/Description.tsx +13 -0
  139. package/src/components/Description/Description.types.ts +9 -0
  140. package/src/components/DropDownIconButton/DropDownIconButton.stories.tsx +197 -0
  141. package/src/components/DropDownIconButton/DropDownIconButton.test.tsx +90 -0
  142. package/src/components/DropDownIconButton/DropDownIconButton.tsx +87 -0
  143. package/src/components/DropDownIconButton/DropDownIconButton.types.ts +21 -0
  144. package/src/components/DropDownIconButton/index.ts +2 -0
  145. package/src/components/Footer/ContactInfoItem.tsx +8 -10
  146. package/src/components/Footer/Footer.stories.tsx +13 -22
  147. package/src/components/Footer/Footer.tsx +25 -88
  148. package/src/components/Footer/Footer.types.tsx +2 -2
  149. package/src/components/FormButton/FormButton.stories.tsx +101 -226
  150. package/src/components/FormButton/FormButton.test.tsx +1 -1
  151. package/src/components/FormButton/FormButton.tsx +34 -42
  152. package/src/components/FormButton/FormButton.types.ts +7 -13
  153. package/src/components/GenericList/GenericList.stories.tsx +5 -12
  154. package/src/components/GenericList/GenericList.tsx +91 -92
  155. package/src/components/GenericList/templates/DynamicIconList.tsx +45 -64
  156. package/src/components/GetSupport/GetSupport.stories.tsx +80 -0
  157. package/src/components/GetSupport/GetSupport.test.tsx +62 -0
  158. package/src/components/GetSupport/GetSupport.tsx +59 -0
  159. package/src/components/GetSupport/GetSupport.types.ts +11 -0
  160. package/src/components/HamburgerButton/Hamburger.stories.tsx +225 -0
  161. package/src/components/HamburgerButton/HamburgerButton.tsx +37 -56
  162. package/src/components/HamburgerButton/HamburgerButton.types.tsx +2 -1
  163. package/src/components/Header/Header.stories.tsx +3 -5
  164. package/src/components/Header/Header.tsx +37 -83
  165. package/src/components/Hero/Hero.stories.tsx +1 -2
  166. package/src/components/IconButton/IconButton.stories.tsx +196 -0
  167. package/src/components/{Icon/Icon.test.tsx → IconButton/IconButton.test.tsx} +3 -4
  168. package/src/components/IconButton/IconButton.tsx +76 -0
  169. package/src/components/IconButton/IconButton.types.ts +28 -0
  170. package/src/components/IconButton/index.ts +2 -0
  171. package/src/components/Image/Image.tsx +1 -1
  172. package/src/components/Input/Input.stories.tsx +10 -12
  173. package/src/components/Input/Input.test.tsx +2 -3
  174. package/src/components/Input/Input.tsx +41 -104
  175. package/src/components/MobileMenu/MobileMenu.types.tsx +0 -2
  176. package/src/components/Nav/DUMMYNAVDATA.json +4 -4
  177. package/src/components/Nav/Nav.tsx +49 -112
  178. package/src/components/Nav/Nav.types.tsx +14 -2
  179. package/src/components/Page/ViewPageTemplate.stories.tsx +2 -2
  180. package/src/components/Page/ViewPageTemplate.test.tsx +1 -1
  181. package/src/components/Page/ViewPageTemplate.types.ts +1 -1
  182. package/src/components/PageSection/PageSection.stories.tsx +3 -1
  183. package/src/components/PageSection/PageSections.test.tsx +2 -1
  184. package/src/components/SearchInput/SearchInput.stories.tsx +144 -0
  185. package/src/components/SearchInput/SearchInput.tsx +81 -0
  186. package/src/components/SearchInput/SearchInput.types.ts +28 -0
  187. package/src/components/Slider/Slider.stories.tsx +88 -0
  188. package/src/components/Slider/Slider.tsx +139 -0
  189. package/src/components/Slider/Slider.types.ts +21 -0
  190. package/src/components/Submenus/AdminSubmenu.tsx +17 -0
  191. package/src/components/Submenus/AlertSubmenu.tsx +56 -0
  192. package/src/components/Submenus/AlertSubmenuItem.tsx +39 -0
  193. package/src/components/Submenus/types.tsx +32 -0
  194. package/src/components/Toaster/Toaster.stories.tsx +4 -6
  195. package/src/components/Toaster/Toaster.test.tsx +3 -4
  196. package/src/components/Toaster/Toaster.tsx +9 -17
  197. package/src/components/Toaster/Toaster.types.ts +2 -2
  198. package/src/utils/assertTagName.tsx +1 -1
  199. package/src/utils/generateAccordionItem.tsx +7 -13
  200. package/src/utils/generateFooterContacts.tsx +4 -9
  201. package/src/utils/getFontAwesomeIcon.tsx +8 -13
  202. package/tailwind.config.js +11 -3
  203. package/src/components/Badge/badgeClassNames.tsx +0 -173
  204. package/src/components/Card/cardClassNames.ts +0 -49
  205. package/src/components/Footer/footerClassNames.tsx +0 -57
  206. package/src/components/FormButton/formButtonClassNames.tsx +0 -153
  207. package/src/components/GenericList/genericListClassNames.tsx +0 -8
  208. package/src/components/Header/headerClassNames.tsx +0 -50
  209. package/src/components/Icon/Icon.stories.tsx +0 -227
  210. package/src/components/Icon/Icon.tsx +0 -208
  211. package/src/components/Icon/Icon.types.ts +0 -24
  212. package/src/components/Icon/iconClassNames.ts +0 -79
  213. package/src/components/Icon/index.ts +0 -2
  214. package/src/components/Input/inputClassNames.tsx +0 -169
  215. package/src/components/Nav/navClassNames.tsx +0 -192
@@ -1,6 +1,5 @@
1
- import { Meta } from "@storybook/react";
2
- import GenericList from "./GenericList";
3
- import GenericListTypes from "./GenericList";
1
+ import { Meta, StoryFn } from "@storybook/react";
2
+ import GenericList, { GenericListTypes } from "./GenericList";
4
3
  import DynamicIconList from "./templates/DynamicIconList";
5
4
  import DUMMYICONDATA from "../Header/DUMMYICONDATA.json";
6
5
  import DUMMYLISTDATA from "./DUMMYLISTDATA.json";
@@ -59,9 +58,7 @@ export default {
59
58
  },
60
59
  } as Meta;
61
60
 
62
- const Template: typeof GenericListTypes & { args?: any } = (args) => (
63
- <GenericList {...args} />
64
- );
61
+ const Template: StoryFn<GenericListTypes<any>> = (args) => <GenericList {...args} />;
65
62
 
66
63
  export const Default = Template.bind({});
67
64
  Default.args = {
@@ -70,9 +67,7 @@ Default.args = {
70
67
  itemHeight: 20,
71
68
  containerHeight: 72,
72
69
  hasVirtualization: true,
73
- renderItem: (item: IconsListProps["item"]) => (
74
- <DynamicIconList item={item} />
75
- ),
70
+ renderItem: (item: IconsListProps["item"]) => <DynamicIconList item={item} />,
76
71
  listDirection: "horizontal",
77
72
  listType: "none",
78
73
  };
@@ -84,9 +79,7 @@ VerticalList.args = {
84
79
  itemHeight: 150,
85
80
  containerHeight: 300,
86
81
  hasVirtualization: true,
87
- renderItem: (item: IconsListProps["item"]) => (
88
- <DynamicIconList item={item} />
89
- ),
82
+ renderItem: (item: IconsListProps["item"]) => <DynamicIconList item={item} />,
90
83
  listDirection: "vertical",
91
84
  listType: "none",
92
85
  };
@@ -1,7 +1,6 @@
1
- import React, { useRef, useEffect, useState } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import { VirtualItem, useVirtualizer } from "@tanstack/react-virtual";
3
3
  import { useCallback } from "react";
4
- import { getListDirectionClasses } from "./genericListClassNames";
5
4
 
6
5
  type GenericData = {
7
6
  id: string;
@@ -24,15 +23,15 @@ const GenericList = <T extends GenericData>({
24
23
  renderItem,
25
24
  itemHeight,
26
25
  containerHeight,
27
- containerClasses,
28
- listDirection,
26
+ containerClasses = "",
27
+ listDirection = "vertical",
29
28
  hasVirtualization = false,
30
- listType,
29
+ listType = "none",
31
30
  }: GenericListTypes<T>) => {
32
- let listClasses = getListDirectionClasses(listDirection);
33
- let parentRef = React.createRef<HTMLElement>();
31
+ const listClasses = listDirection === "horizontal" ? "flex flex-row" : "flex flex-col";
32
+ const parentRef = React.createRef<HTMLElement>();
34
33
 
35
- const [virtualItems, setVirtualItems] = useState<VirtualItem[]>([]);
34
+ const [virtualItems, setVirtualItems] = useState<VirtualItem<Element>[]>([]);
36
35
  const [nonVirtualItems, setNonVirtualItems] = useState<T[]>([]);
37
36
 
38
37
  const estimateSize = useCallback(
@@ -58,89 +57,89 @@ const GenericList = <T extends GenericData>({
58
57
  }, [hasVirtualization, virtualizer, data]);
59
58
 
60
59
  return (
61
- <>
62
- {(() => {
63
- switch (listType) {
64
- case "ordered":
65
- return (
66
- <ol
67
- ref={parentRef as React.RefObject<HTMLOListElement>}
68
- style={
69
- hasVirtualization
70
- ? { height: containerHeight, overflow: "scroll" }
71
- : {}
72
- }
73
- className={`${listClasses} ${containerClasses}`}
74
- >
75
- {hasVirtualization
76
- ? virtualItems.map((virtualItem) => (
77
- <li
78
- key={virtualItem.index}
79
- style={{ height: itemHeight }}
80
- >
81
- {renderItem(data[virtualItem.index])}
82
- </li>
83
- ))
84
- : nonVirtualItems.map((item) => (
85
- <li key={item.id}>{renderItem(item)}</li>
86
- ))}
87
- </ol>
88
- );
89
- case "unordered":
90
- return (
91
- <ul
92
- ref={parentRef as React.RefObject<HTMLUListElement>}
93
- style={
94
- hasVirtualization
95
- ? { height: containerHeight, overflow: "scroll" }
96
- : {}
97
- }
98
- className={`${listClasses} ${containerClasses}`}
99
- >
100
- {hasVirtualization
101
- ? virtualItems.map((virtualItem) => (
102
- <li
103
- key={virtualItem.index}
104
- style={{ height: itemHeight }}
105
- >
106
- {renderItem(data[virtualItem.index])}
107
- </li>
108
- ))
109
- : nonVirtualItems.map((item) => (
110
- <li key={item.id}>{renderItem(item)}</li>
111
- ))}
112
- </ul>
113
- );
114
- case "none":
115
- default:
116
- return (
117
- <div
118
- ref={parentRef as React.RefObject<HTMLDivElement>}
119
- style={
120
- hasVirtualization
121
- ? { height: containerHeight, overflow: "scroll" }
122
- : {}
123
- }
124
- className={`${listClasses} ${containerClasses}`}
125
- >
126
- {hasVirtualization
127
- ? virtualItems.map((virtualItem) => (
128
- <div
129
- key={virtualItem.index}
130
- style={{ height: itemHeight }}
131
- >
132
- {renderItem(data[virtualItem.index])}
133
- </div>
134
- ))
135
- : nonVirtualItems.map((item) => (
136
- <div key={item.id}>{renderItem(item)}</div>
137
- ))}
138
- </div>
139
- );
140
- }
141
- })()}
142
- </>
143
- )
144
- }
60
+ <>
61
+ {(() => {
62
+ switch (listType) {
63
+ case "ordered":
64
+ return (
65
+ <ol
66
+ ref={parentRef as React.RefObject<HTMLOListElement>}
67
+ style={
68
+ hasVirtualization
69
+ ? { height: containerHeight, overflow: "scroll" }
70
+ : {}
71
+ }
72
+ className={`${listClasses} ${containerClasses}`}
73
+ >
74
+ {hasVirtualization
75
+ ? virtualItems.map((virtualItem) => (
76
+ <li
77
+ key={virtualItem.index}
78
+ style={{ height: itemHeight }}
79
+ >
80
+ {renderItem(data[virtualItem.index])}
81
+ </li>
82
+ ))
83
+ : nonVirtualItems.map((item) => (
84
+ <li key={item.id}>{renderItem(item)}</li>
85
+ ))}
86
+ </ol>
87
+ );
88
+ case "unordered":
89
+ return (
90
+ <ul
91
+ ref={parentRef as React.RefObject<HTMLUListElement>}
92
+ style={
93
+ hasVirtualization
94
+ ? { height: containerHeight, overflow: "scroll" }
95
+ : {}
96
+ }
97
+ className={`${listClasses} ${containerClasses}`}
98
+ >
99
+ {hasVirtualization
100
+ ? virtualItems.map((virtualItem) => (
101
+ <li
102
+ key={virtualItem.index}
103
+ style={{ height: itemHeight }}
104
+ >
105
+ {renderItem(data[virtualItem.index])}
106
+ </li>
107
+ ))
108
+ : nonVirtualItems.map((item) => (
109
+ <li key={item.id}>{renderItem(item)}</li>
110
+ ))}
111
+ </ul>
112
+ );
113
+ case "none":
114
+ default:
115
+ return (
116
+ <div
117
+ ref={parentRef as React.RefObject<HTMLDivElement>}
118
+ style={
119
+ hasVirtualization
120
+ ? { height: containerHeight, overflow: "scroll" }
121
+ : {}
122
+ }
123
+ className={`${listClasses} ${containerClasses}`}
124
+ >
125
+ {hasVirtualization
126
+ ? virtualItems.map((virtualItem) => (
127
+ <div
128
+ key={virtualItem.index}
129
+ style={{ height: itemHeight }}
130
+ >
131
+ {renderItem(data[virtualItem.index])}
132
+ </div>
133
+ ))
134
+ : nonVirtualItems.map((item) => (
135
+ <div key={item.id}>{renderItem(item)}</div>
136
+ ))}
137
+ </div>
138
+ );
139
+ }
140
+ })()}
141
+ </>
142
+ );
143
+ };
145
144
 
146
145
  export default GenericList;
@@ -1,74 +1,55 @@
1
1
  import React from "react";
2
- import Icon from "../../Icon/index";
2
+ import IconButton from "../../IconButton/index";
3
3
  import { getFontAwesomeIcon } from "../../../utils/getFontAwesomeIcon";
4
- import Text from "../../Text/index";
5
4
  import { TagName } from "../../Text/index";
6
5
 
7
- export type IconsListProps = {
8
- item: {
9
- iconColor?: string;
10
- iconLabel: string;
11
- backgroundColor?: string;
12
- size?: "xs" | "sm" | "md" | "lg" | string;
13
- icon: string;
14
- hoverBorder?: "border" | "none" | string;
15
- limitCharacters?: (text: string) => string;
16
- indicatorSize?: "sm" | "md" | "lg" | string;
17
- iconBorder?: "border" | "none" | string;
18
- id: string;
19
- hoverBackground: string;
20
- hoverColor: string;
21
- limitIndicator: boolean;
22
- indicatorNumber: string;
23
- additionalContainerClasses: string;
24
- to?: string;
25
- href?: string;
26
- text: {
27
- size: string;
28
- color: string;
29
- text: string;
30
- fontFamily: string;
31
- tag: TagName;
32
- additionalClasses: string;
33
- };
6
+ export type IconButtonsListProps = {
7
+ id: string;
8
+ iconColor?: string;
9
+ iconLabel?: string; // Ensure this matches IconButtonTypes if necessary
10
+ backgroundColor?: string;
11
+ size?: "xs" | "sm" | "md" | "lg" | string;
12
+ icon: string;
13
+ hoverBorder?: "border" | "none" | string;
14
+ limitCharacters?: (text: string) => string;
15
+ indicatorSize?: "sm" | "md" | "lg" | string;
16
+ iconBorder?: "border" | "none" | string;
17
+ hoverBackground: string;
18
+ hoverColor: string;
19
+ limitIndicator: boolean;
20
+ indicatorNumber: string;
21
+ additionalContainerClasses: string;
22
+ onClick?: () => void;
23
+ text: {
24
+ size: string;
25
+ color: string;
26
+ text: string;
27
+ fontFamily: string;
28
+ tag: TagName;
29
+ additionalClasses: string;
34
30
  };
31
+ to?: string;
32
+ href?: string;
35
33
  };
36
- // TODO: create a genetic list comp with TanStack Virtual and move this into the template dir in the Generic list dir
37
- // https://tanstack.com/virtual/latest/docs/introduction
38
- const DynamicIconList: React.FC<IconsListProps> = ({ item }) => {
34
+
35
+ const DynamicIconButtonList: React.FC<IconButtonsListProps> = (props) => {
39
36
  return (
40
- <>
41
- <Icon
42
- key={item.id}
43
- to={item.to}
44
- href={item.href}
45
- limitCharacters={item.limitCharacters}
46
- backgroundColor={item.backgroundColor}
47
- iconColor={item.iconColor}
48
- iconLabel={item.iconLabel}
49
- iconBorder={item.iconBorder}
50
- size={item.size}
51
- icon={getFontAwesomeIcon(item.icon)}
52
- hoverBackground={item.hoverBackground}
53
- hoverBorder={item.hoverBorder}
54
- limitIndicator={item.limitIndicator}
55
- indicatorNumber={item.indicatorNumber}
56
- indicatorSize={item.indicatorSize}
57
- hoverColor={item.hoverColor}
58
- additionalContainerClasses={item.additionalContainerClasses}
59
- text={
60
- <Text
61
- size={item.text.size}
62
- color={item.text.color}
63
- text={item.text.text}
64
- fontFamily={item.text.fontFamily}
65
- tag={item.text.tag}
66
- additionalClasses={item.text.additionalClasses}
67
- />
68
- }
69
- />
70
- </>
37
+ <IconButton
38
+ key={props.id}
39
+ onClick={props.onClick}
40
+ backgroundColor={props.backgroundColor}
41
+ iconColor={props.iconColor}
42
+ iconLabel={props.iconLabel}
43
+ iconBorder={props.iconBorder}
44
+ icon={getFontAwesomeIcon(props.icon)}
45
+ hoverBackgroundColor={props.hoverBackground}
46
+ hoverBorderColor={props.hoverBorder}
47
+ indicatorNumber={props.indicatorNumber}
48
+ indicatorSize={props.indicatorSize}
49
+ additionalContainerClasses={props.additionalContainerClasses}
50
+ text={props.text.text}
51
+ />
71
52
  );
72
53
  };
73
54
 
74
- export default DynamicIconList;
55
+ export default DynamicIconButtonList;
@@ -0,0 +1,80 @@
1
+ import { Meta, StoryFn } from "@storybook/react";
2
+ import GetSupport from "./GetSupport";
3
+ import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
4
+
5
+ export default {
6
+ title: "Components/GetSupport",
7
+ component: GetSupport,
8
+ argTypes: {
9
+ to: {
10
+ control: "none",
11
+ description: "URL to navigate to when the button is clicked.",
12
+ },
13
+ icon: {
14
+ control: "none",
15
+ description: "FontAwesome icon to be displayed.",
16
+ },
17
+ iconClasses: {
18
+ control: "none",
19
+ description: "Tailwind CSS classes for icon styling.",
20
+ },
21
+ title: {
22
+ control: "none",
23
+ description: "The main title text.",
24
+ },
25
+ titleClasses: {
26
+ control: "none",
27
+ description: "Tailwind CSS classes for title styling.",
28
+ },
29
+ subTitle: {
30
+ control: "none",
31
+ description: "Optional subtitle text.",
32
+ },
33
+ subTitleClasses: {
34
+ control: "none",
35
+ description: "Tailwind CSS classes for subtitle styling.",
36
+ },
37
+ containerClasses: {
38
+ control: "none",
39
+ description: "Tailwind CSS classes for container styling.",
40
+ },
41
+ as: {
42
+ control: "none",
43
+ description: "The element type to use for the button.",
44
+ },
45
+ },
46
+ tags: ["autodocs"],
47
+ } as Meta;
48
+
49
+ const Template: StoryFn = (args) => (
50
+ <GetSupport to={""} icon={null} title={""} {...args} />
51
+ );
52
+
53
+ export const Default = Template.bind({});
54
+ Default.args = {
55
+ icon: getFontAwesomeIcon("phone"),
56
+ as: "a",
57
+ to: "/support",
58
+ title: "Get Support",
59
+ iconClasses:
60
+ "p-4 bg-slate-600 text-white group-hover:text-slate-600 rounded-full group-hover:bg-slate-200",
61
+ titleClasses: "text-xl font-bold",
62
+ subTitle: "1-800-123-4567",
63
+ subTitleClasses: "text-md text-gray-500",
64
+ containerClasses:
65
+ "flex items-center gap-4 p-2 bg-white rounded-lg hover:cursor-pointer group",
66
+ };
67
+
68
+ export const WithoutPhoneNumber = Template.bind({});
69
+ WithoutPhoneNumber.args = {
70
+ icon: getFontAwesomeIcon("phone"),
71
+ as: "a",
72
+ to: "/support",
73
+ title: "Get Support",
74
+ iconClasses:
75
+ "p-4 bg-slate-600 text-white group-hover:text-slate-600 rounded-full group-hover:bg-slate-200",
76
+ titleClasses: "text-xl font-bold",
77
+ subTitleClasses: "text-md text-gray-500",
78
+ containerClasses:
79
+ "flex items-center gap-4 p-2 bg-white rounded-lg hover:cursor-pointer group",
80
+ };
@@ -0,0 +1,62 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import GetSupport from './GetSupport';
3
+ import { MemoryRouter } from 'react-router-dom';
4
+ import { describe, expect, it } from 'vitest';
5
+
6
+ describe('GetSupport Component', () => {
7
+ const defaultProps = {
8
+ as: 'link',
9
+ to: '/support',
10
+ icon: <div>Icon</div>,
11
+ iconClasses: 'p-2 w-12 h-12 bg-gray-200 rounded-full',
12
+ title: 'Get Support',
13
+ titleClasses: 'text-xl font-bold',
14
+ subTitle: '1-800-123-4567',
15
+ subTitleClasses: 'text-md text-gray-500',
16
+ containerClasses: 'flex items-center gap-4 p-2 bg-white rounded-lg',
17
+ };
18
+
19
+ it('renders without crashing', () => {
20
+ render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
21
+ expect(screen.getByText('Get Support')).toBeInTheDocument();
22
+ });
23
+
24
+ it('renders the title', () => {
25
+ render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
26
+ expect(screen.getByText('Get Support')).toBeInTheDocument();
27
+ });
28
+
29
+ it('renders the subtitle', () => {
30
+ render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
31
+ expect(screen.getByText('1-800-123-4567')).toBeInTheDocument();
32
+ });
33
+
34
+ it('applies container classes', () => {
35
+ render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
36
+ const container = screen.getByRole('link').firstChild;
37
+ expect(container).toHaveClass('flex items-center gap-4 p-2 bg-white rounded-lg');
38
+ });
39
+
40
+ it('applies title classes', () => {
41
+ render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
42
+ const title = screen.getByText('Get Support');
43
+ expect(title).toHaveClass('text-xl font-bold');
44
+ });
45
+
46
+ it('applies subtitle classes', () => {
47
+ render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
48
+ const subTitle = screen.getByText('1-800-123-4567');
49
+ expect(subTitle).toHaveClass('text-md text-gray-500');
50
+ });
51
+
52
+ it('renders without subtitle', () => {
53
+ const { container } = render(
54
+ <GetSupport
55
+ {...defaultProps}
56
+ subTitle={undefined}
57
+ />,
58
+ { wrapper: MemoryRouter }
59
+ );
60
+ expect(container.querySelector('.text-md.text-gray-500')).toBeNull();
61
+ });
62
+ });
@@ -0,0 +1,59 @@
1
+ import React from "react";
2
+ import FormButton from "../FormButton/FormButton";
3
+ import Text from "../Text/Text";
4
+ import { GetSupportTypes } from "./GetSupport.types";
5
+
6
+ const GetSupport: React.FC<GetSupportTypes> = ({
7
+ as,
8
+ to,
9
+ icon,
10
+ iconClasses,
11
+ title,
12
+ titleClasses,
13
+ subTitle,
14
+ subTitleClasses,
15
+ containerClasses,
16
+ }) => {
17
+ return (
18
+ <FormButton
19
+ as={as}
20
+ to={to}
21
+ text={
22
+ <div className={`flex items-center gap-4 ${containerClasses}`}>
23
+ <div
24
+ className={`flex items-center justify-center ${iconClasses}`}
25
+ >
26
+ {icon}
27
+ </div>
28
+ <div className="flex flex-col">
29
+ <Text
30
+ size="text-md"
31
+ color="text-black"
32
+ text={title}
33
+ fontFamily="font-serif"
34
+ tag="p"
35
+ additionalClasses={titleClasses}
36
+ />
37
+ {subTitle && (
38
+ <Text
39
+ size="text-md"
40
+ color="text-black"
41
+ text={subTitle}
42
+ fontFamily="font-serif"
43
+ tag="p"
44
+ additionalClasses={subTitleClasses}
45
+ />
46
+ )}
47
+ </div>
48
+ </div>
49
+ }
50
+ backgroundColor="bg-transparent"
51
+ fontColor="text-black"
52
+ borderColor="border-none"
53
+ shape="rounded-md"
54
+ additionalClasses={containerClasses}
55
+ />
56
+ );
57
+ };
58
+
59
+ export default GetSupport;
@@ -0,0 +1,11 @@
1
+ export type GetSupportTypes = {
2
+ as?: string;
3
+ to: string;
4
+ icon: JSX.Element | null;
5
+ iconClasses?: string;
6
+ title: string;
7
+ titleClasses?: string;
8
+ subTitle?: string;
9
+ subTitleClasses?: string;
10
+ containerClasses?: string;
11
+ };