@agilant/toga-blox 1.0.8 → 1.0.10

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 (217) 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/Text/Text.stories.tsx +47 -10
  195. package/src/components/Text/Text.test.tsx +10 -17
  196. package/src/components/Toaster/Toaster.stories.tsx +69 -78
  197. package/src/components/Toaster/Toaster.test.tsx +49 -43
  198. package/src/components/Toaster/Toaster.tsx +43 -56
  199. package/src/components/Toaster/Toaster.types.ts +9 -8
  200. package/src/utils/assertTagName.tsx +1 -1
  201. package/src/utils/generateAccordionItem.tsx +7 -13
  202. package/src/utils/generateFooterContacts.tsx +4 -9
  203. package/src/utils/getFontAwesomeIcon.tsx +8 -13
  204. package/tailwind.config.js +17 -2
  205. package/src/components/Badge/badgeClassNames.tsx +0 -173
  206. package/src/components/Card/cardClassNames.ts +0 -49
  207. package/src/components/Footer/footerClassNames.tsx +0 -57
  208. package/src/components/FormButton/formButtonClassNames.tsx +0 -153
  209. package/src/components/GenericList/genericListClassNames.tsx +0 -8
  210. package/src/components/Header/headerClassNames.tsx +0 -50
  211. package/src/components/Icon/Icon.stories.tsx +0 -227
  212. package/src/components/Icon/Icon.tsx +0 -208
  213. package/src/components/Icon/Icon.types.ts +0 -24
  214. package/src/components/Icon/iconClassNames.ts +0 -79
  215. package/src/components/Icon/index.ts +0 -2
  216. package/src/components/Input/inputClassNames.tsx +0 -169
  217. package/src/components/Nav/navClassNames.tsx +0 -192
@@ -1,122 +1,113 @@
1
1
  import React from "react";
2
-
3
- import Toaster, { ToasterTypes } from ".";
2
+ import Toaster from ".";
4
3
  import { Meta, StoryFn } from "@storybook/react";
5
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
- import { faCheck, faExclamation, faX } from "@fortawesome/free-solid-svg-icons";
7
4
 
8
5
  export default {
9
6
  title: "Components/Toaster",
10
7
  component: Toaster,
11
8
  argTypes: {
12
- color: {
13
- control: "select",
14
- description: "The main color displayed on the toaster",
15
- options: ["green-800", "red-800", "blue-800", "orange-800"],
16
- },
17
-
18
- icon: {
19
- table: {
20
- disable: true,
21
- },
22
- },
23
- title: {
24
- table: {
25
- disable: true,
26
- },
27
- },
28
9
  message: {
29
- control: "text",
30
- description: "The main text displayed on the toaster",
10
+ control: "array",
11
+ description:
12
+ "The main messages displayed on the toaster, passed as an array.",
31
13
  },
32
14
  additionalClasses: {
33
- table: {
34
- disable: true,
35
- },
36
- },
37
- clearText: {
38
15
  control: "text",
39
16
  description:
40
- "The text displayed on the clear message button if set to true",
41
- },
42
- hasClearText: {
43
- control: "boolean",
44
- description: "must be set to true to display the clear text button",
45
- },
46
- fullColor: {
47
- control: "boolean",
48
- description: "toggle the background color of toaster",
17
+ "Additional Tailwind CSS classes for the toaster container.",
49
18
  },
50
- hasBumper: {
19
+ hasClearButton: {
51
20
  control: "boolean",
52
- description: "toggle the left bumper toaster",
21
+ description: "Toggle to show or hide the clear message button.",
53
22
  },
54
23
  clearMessage: {
55
- table: {
56
- disable: true,
57
- },
24
+ action: "Message Cleared!",
25
+ },
26
+ statusProps: {
27
+ control: "object",
28
+ description:
29
+ "Object containing colorClass and optional icon config.",
58
30
  },
59
31
  },
60
-
61
32
  tags: ["autodocs"],
62
33
  parameters: {
63
- // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
64
34
  layout: "centered",
65
35
  },
66
36
  } as Meta;
67
37
 
68
- const minWidth = "min-w-[200px]";
69
-
70
- const Template: StoryFn<ToasterTypes> = (args) => (
71
- <div className="">
72
- <Toaster {...args} />
73
- </div>
74
- );
38
+ const Template: StoryFn = (args) => <Toaster message={[]} {...args} />;
75
39
 
40
+ /**
41
+ * Default
42
+ */
76
43
  export const Default = Template.bind({});
77
44
  Default.args = {
78
- message: "Your action was successful!",
79
- additionalClasses: `border-blue-500 ${minWidth}`,
45
+ message: ["Your action was successful!"],
46
+ statusProps: {
47
+ // Pass the literal Tailwind classes instead of color: "green"
48
+ colorClass: "bg-green-100 border border-green-500 text-green-800",
49
+ },
50
+ additionalClasses: "p-5",
80
51
  };
81
52
 
53
+ /**
54
+ * WithIconFail
55
+ */
82
56
  export const WithIconFail = Template.bind({});
83
57
  WithIconFail.args = {
84
- ...Default.args,
85
- message: "Your action failed!",
86
- color: "red-800",
87
- icon: <FontAwesomeIcon icon={faX} />,
88
- additionalClasses: `border-red-500 ${minWidth}`,
58
+ message: ["Your action failed!"],
59
+ statusProps: {
60
+ // Red variant
61
+ colorClass: "bg-red-100 border border-red-500 text-red-800",
62
+ icon: { icon: "x", type: "solid" },
63
+ },
64
+ additionalClasses: "p-5",
89
65
  };
90
66
 
67
+ /**
68
+ * WithIconSuccess
69
+ */
91
70
  export const WithIconSuccess = Template.bind({});
92
71
  WithIconSuccess.args = {
93
- ...Default.args,
94
- color: "green-800",
95
- icon: <FontAwesomeIcon icon={faCheck} />,
96
- additionalClasses: `border-green-500 ${minWidth}`,
72
+ message: ["Action completed successfully!"],
73
+ statusProps: {
74
+ // Green variant
75
+ colorClass: "bg-green-100 border border-green-600 text-green-800",
76
+ icon: { icon: "circleCheck", type: "solid" },
77
+ },
78
+ additionalClasses: "p-5",
97
79
  };
98
80
 
81
+ /**
82
+ * WithIconAlert
83
+ */
99
84
  export const WithIconAlert = Template.bind({});
100
85
  WithIconAlert.args = {
101
- ...Default.args,
102
- message: "Alert, are you sure!",
103
- color: "orange-800",
104
- icon: <FontAwesomeIcon icon={faExclamation} />,
105
- additionalClasses: `border-orange-500 ${minWidth}`,
86
+ message: ["Alert: Are you sure?"],
87
+ statusProps: {
88
+ // Gray variant
89
+ colorClass: "bg-yellow-100 border border-yellow-500 text-yellow-800",
90
+ icon: { icon: "triangleExclamation", type: "solid" },
91
+ },
92
+ additionalClasses: "p-5",
106
93
  };
107
94
 
95
+ /**
96
+ * HasClearMessage
97
+ */
108
98
  export const HasClearMessage = Template.bind({});
109
99
  HasClearMessage.args = {
110
- ...Default.args,
111
- clearText: "Clear Message",
112
- color: "blue-800",
113
- hasClearText: true,
114
- clearMessage: () => alert("Message Cleared!"),
115
- };
116
-
117
- export const FullColor = Template.bind({});
118
- FullColor.args = {
119
- ...Default.args,
120
- fullColor: true,
121
- color: "blue-800",
100
+ message: [
101
+ "Message can be cleared and input has different padding from the additionalClasses prop",
102
+ ],
103
+ hasClearButton: true,
104
+ clearMessage: () => {
105
+ alert("Message Cleared!");
106
+ },
107
+ statusProps: {
108
+ // Orange variant
109
+ colorClass: "bg-orange-100 border border-orange-500 text-orange-800",
110
+ icon: { icon: "circleCheck", type: "solid" },
111
+ },
112
+ additionalClasses: "py-2 px-5",
122
113
  };
@@ -1,61 +1,67 @@
1
- import { render, screen, fireEvent } from "@testing-library/react";
2
- import { describe, expect, beforeEach, test, vi } from "vitest";
1
+ import { render, screen } from "@testing-library/react";
2
+ import userEvent from "@testing-library/user-event";
3
+ import { describe, expect, test, vi } from "vitest";
3
4
  import Toaster from "./Toaster";
4
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
- import { faCoffee, faTimes } from "@fortawesome/free-solid-svg-icons";
6
5
 
7
- describe("Toaster Component Tests", () => {
8
- test("renders correctly with minimal props", () => {
9
- render(<Toaster message="Test Message" color="green-500" />);
10
- expect(screen.getByTestId("toaster")).toHaveTextContent("Test Message");
11
- expect(screen.getByTestId("toaster")).toHaveClass("border-green-500");
12
- });
6
+ const testId = "toaster-test-id";
7
+ const testMessage = "Test Message";
13
8
 
14
- test("renders with an icon when provided", () => {
15
- render(
16
- <Toaster
17
- message="Test Message"
18
- color="blue-500"
19
- icon={<FontAwesomeIcon icon={faCoffee} />}
20
- />
9
+ describe("Toaster Component Tests", () => {
10
+ test("renders the FA icon when passed in props", () => {
11
+ const customStatusProps = {
12
+ icon: { icon: "circleCheck", type: "solid" as "solid" },
13
+ };
14
+ const { container } = render(
15
+ <Toaster message={["Success!"]} statusProps={customStatusProps} />
21
16
  );
22
- expect(screen.getByTestId("toaster")).toBeInTheDocument();
17
+ const iconEl = container.querySelector(".fa-circle-check");
18
+ expect(iconEl).toBeInTheDocument();
23
19
  });
24
-
25
- test("renders the title when provided", () => {
26
- render(
27
- <Toaster
28
- message="Test Message"
29
- color="red-500"
30
- title="Test Title"
31
- />
20
+ test("does not render an icon when icon is not in props", () => {
21
+ const customStatusProps = {};
22
+ const { container } = render(
23
+ <Toaster message={["Success!"]} statusProps={customStatusProps} />
32
24
  );
33
- expect(screen.getByTestId("toaster")).toHaveTextContent("Test Title");
25
+ const iconEl = container.querySelector(".fa-circle-check");
26
+ expect(iconEl).not.toBeInTheDocument();
34
27
  });
35
28
 
36
- test("renders with full color background", () => {
29
+ test("renders correct colors for status", () => {
30
+ const customStatusProps = {
31
+ colorClass: "bg-green-100 border border-green-500 text-green-800",
32
+ };
37
33
  render(
38
- <Toaster
39
- message="Test Message"
40
- color="blue-500"
41
- title="Test Title"
42
- fullColor
43
- />
34
+ <Toaster message={[testMessage]} statusProps={customStatusProps} />
35
+ );
36
+ expect(screen.getByTestId(testId)).toHaveTextContent(testMessage);
37
+ expect(screen.getByTestId(testId)).toHaveClass(
38
+ `${customStatusProps.colorClass}`
44
39
  );
45
- expect(screen.getByTestId("toaster")).toHaveClass("bg-blue-500");
46
40
  });
41
+ test("calls clearMessage callback when the clear button is clicked", async () => {
42
+ // Arrange
43
+ const mockClearMessage = vi.fn();
44
+ const mockAlert = vi
45
+ .spyOn(window, "alert")
46
+ .mockImplementation(() => {});
47
47
 
48
- test("clears the message on clear icon click", async () => {
49
- const clearMessage = vi.fn();
50
48
  render(
51
49
  <Toaster
52
- message="Test Message"
53
- color="orange-500"
54
- clearMessage={clearMessage}
50
+ message={[testMessage]}
51
+ hasClearButton
52
+ clearMessage={mockClearMessage}
55
53
  />
56
54
  );
57
- const clearButton = screen.getByTestId("clearMessage");
58
- fireEvent.click(clearButton);
59
- expect(clearMessage).toHaveBeenCalled();
55
+
56
+ // Act - Click the clear button
57
+ const clearButton = screen.getByTestId("clear-button");
58
+ await userEvent.click(clearButton);
59
+
60
+ // Assert
61
+ expect(mockAlert).toHaveBeenCalledWith("Message Cleared!");
62
+ expect(mockClearMessage).toHaveBeenCalledWith(true);
63
+
64
+ // Cleanup
65
+ mockAlert.mockRestore();
60
66
  });
61
67
  });
@@ -1,78 +1,65 @@
1
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
2
1
  import React from "react";
3
- import Button from "../FormButton/FormButton";
4
- import { faTimes } from "@fortawesome/free-solid-svg-icons";
5
2
  import { ToasterTypes } from ".";
3
+ import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
6
4
 
7
5
  const Toaster: React.FC<ToasterTypes> = ({
8
6
  message,
9
- additionalClasses = "",
7
+ additionalClasses,
10
8
  clearMessage,
11
- color,
12
- icon,
13
- fullColor = false,
14
- hasBumper = true,
15
- title = "",
16
- hasClearText,
17
- clearText,
9
+ hasClearButton,
10
+
11
+ statusProps = {
12
+ colorClass: "bg-gray-100 border border-gray-500 text-gay-800",
13
+ icon: { icon: "circleCheck", type: "solid" },
14
+ },
18
15
  }) => {
19
16
  const handleClearMessage = () => {
20
17
  if (clearMessage) {
18
+ alert("Message Cleared!");
21
19
  clearMessage(true);
22
20
  }
23
21
  };
24
22
 
25
- // Simplified Color Handling
26
- const iconColorMap: { [key: string]: string } = {
27
- "green-800": "text-green-800",
28
- "red-800": "text-red-800",
29
- "orange-800": "text-orange-800",
30
- "blue-800": "text-blue-800",
31
- };
32
- const iconClass = iconColorMap[color] || "";
33
- // Improved CSS Class Composition
34
- const borderClass = `border ${
35
- hasBumper ? `border-l-4 border-${color}` : "border-l-1"
36
- } `;
37
- const backgroundColorClass = fullColor ? `bg-${color}` : "bg-white";
23
+ // Pull out colorClass and icon from statusProps
24
+ const { colorClass, icon: maybeIcon } = statusProps;
25
+
26
+ // We'll combine colorClass with other container styles
27
+ const containerClasses = colorClass ?? "";
38
28
 
39
- const textColorClass = fullColor ? "text-white" : "text-black";
29
+ // Your existing custom classes
30
+ const shadowClasses = `shadow-lg shadow-boxShadow rounded-lg`;
31
+ const closeButtonClasses = `cursor-pointer text-xs ml-4`;
40
32
 
41
33
  return (
42
34
  <div
43
- data-testid="toaster"
44
- className={`${borderClass} border-${color} p-4 shadow-lg shadow-boxShadow text-sm ${backgroundColorClass} rounded ${additionalClasses}`}
35
+ data-testid="toaster-test-id"
36
+ role="alert"
37
+ aria-live="polite"
38
+ className={`${shadowClasses} ${containerClasses} ${additionalClasses}`}
45
39
  >
46
- {title ? (
47
- <h3 className="ml-8 font-bold text-xl text-left">{title}</h3>
48
- ) : (
49
- <></>
50
- )}
51
- <div className="flex items-center justify-between">
52
- <span className={`mr-2 ${iconClass}`}>{icon}</span>
53
- <span className={textColorClass}>{message}</span>
54
- {clearMessage && !hasClearText && (
55
- <span className="cursor-pointer hover:bg-gray-200 py-1 px-2 rounded-md">
56
- <FontAwesomeIcon
57
- data-testid="clearMessage"
40
+ {message.map((msg, index) => (
41
+ <div key={index} className="flex items-center">
42
+ {maybeIcon && (
43
+ <div className="mr-4">
44
+ {getFontAwesomeIcon(maybeIcon.icon, maybeIcon.type)}
45
+ </div>
46
+ )}
47
+
48
+ <p className={index === 0 ? "font-semibold ml-2" : "ml-2"}>
49
+ {msg}
50
+ </p>
51
+
52
+ {hasClearButton && (
53
+ <div
54
+ data-testid="clear-button"
55
+ className={`${closeButtonClasses}`}
58
56
  onClick={handleClearMessage}
59
- className={`cursor-pointer ${textColorClass}`}
60
- icon={faTimes}
61
- />
62
- </span>
63
- )}
64
- {hasClearText && clearText && (
65
- <Button
66
- onClick={handleClearMessage}
67
- text={clearText}
68
- color="primary"
69
- shape="outline"
70
- type={"button"}
71
- isDisabled={false}
72
- additionalClasses="ml-2 px-4"
73
- />
74
- )}
75
- </div>
57
+ >
58
+ {getFontAwesomeIcon("x", "solid")}
59
+ </div>
60
+ )}
61
+ </div>
62
+ ))}
76
63
  </div>
77
64
  );
78
65
  };
@@ -1,12 +1,13 @@
1
+ interface StatusProps {
2
+ // color: string;
3
+ icon?: { icon: string; type: "solid" | "regular" };
4
+ colorClass?: string;
5
+ }
6
+
1
7
  export interface ToasterTypes {
2
- message: string;
8
+ message: string[];
3
9
  additionalClasses?: string;
4
10
  clearMessage?: React.Dispatch<React.SetStateAction<boolean>>;
5
- color: "green-800" | "red-800" | "yellow-800" | "blue-800" | "orange-800";
6
- icon?: JSX.Element;
7
- fullColor?: boolean;
8
- hasBumper?: boolean;
9
- title?: string;
10
- hasClearText?: boolean;
11
- clearText?: string;
11
+ hasClearButton?: boolean;
12
+ statusProps?: StatusProps;
12
13
  }
@@ -1,4 +1,4 @@
1
- import { TagName } from "../components/Text/Text";
1
+ import { TagName } from "../components/Text/Text.types";
2
2
  function assertTagName(tag: string): asserts tag is TagName {
3
3
  if (!["span", "p", "h1", "h2", "h3", "h4", "h5"].includes(tag)) {
4
4
  throw new Error(`Invalid tag name: ${tag}`);
@@ -1,6 +1,5 @@
1
1
  import React, { Fragment, useState } from "react";
2
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
3
- import { faChevronDown, faChevronUp } from "@fortawesome/free-solid-svg-icons";
2
+ import { getFontAwesomeIcon } from "./getFontAwesomeIcon";
4
3
 
5
4
  type NavItem = {
6
5
  title: string;
@@ -63,21 +62,16 @@ export const Accordion: React.FC<AccordionProps> = ({
63
62
  <div className="px-6 text-left items-center h-10 select-none flex justify-between flex-row">
64
63
  <div className="flex w-3/4">{item.title}</div>
65
64
  <div className="flex w-1/2 justify-end">
66
- <FontAwesomeIcon
67
- className={`text-xs transition-transform duration-300 transform ${
68
- accordionExpanded[index]
69
- ? "rotate-180"
70
- : ""
71
- }`}
72
- icon={faChevronDown}
73
- />
65
+ {getFontAwesomeIcon(
66
+ "chevronDown",
67
+ `text-xs transition-transform duration-300 transform ${accordionExpanded[index] ? "rotate-180" : ""}`
68
+ )}
74
69
  </div>
75
70
  </div>
76
71
  </div>
77
72
  <div
78
- className={`px-6 w-full overflow-hidden transition-[max-height] duration-500 ease-in-out ${
79
- accordionExpanded[index] ? "max-h-96" : "max-h-0"
80
- }`}
73
+ className={`px-6 w-full overflow-hidden transition-[max-height] duration-500 ease-in-out ${accordionExpanded[index] ? "max-h-96" : "max-h-0"
74
+ }`}
81
75
  aria-hidden={!accordionExpanded[index]}
82
76
  tabIndex={accordionExpanded[index] ? 0 : -1} // Set tabIndex dynamically
83
77
  >
@@ -1,12 +1,7 @@
1
1
  import React from "react";
2
2
  import Text from "../components/Text/Text";
3
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4
- import {
5
- faEnvelope,
6
- faLocationDot,
7
- faPhone,
8
- } from "@fortawesome/free-solid-svg-icons";
9
3
  import { ContactInfoItem } from "../components/Footer/ContactInfoItem";
4
+ import { getFontAwesomeIcon } from "./getFontAwesomeIcon";
10
5
 
11
6
  interface ContactProps {
12
7
  contactDataList: {
@@ -24,11 +19,11 @@ export const FooterContacts: React.FC<ContactProps> = ({ contactDataList }) => {
24
19
  return contactDataList.map((contact) => {
25
20
  const contactDetails = [
26
21
  {
27
- icon: faPhone,
22
+ icon: getFontAwesomeIcon("phone"),
28
23
  text: contact.phone,
29
24
  },
30
25
  {
31
- icon: faEnvelope,
26
+ icon: getFontAwesomeIcon("envelope"),
32
27
  text: contact.email,
33
28
  },
34
29
  ];
@@ -39,7 +34,7 @@ export const FooterContacts: React.FC<ContactProps> = ({ contactDataList }) => {
39
34
  data-testid="contact-info"
40
35
  className="flex flex-col pt-2 w-60"
41
36
  >
42
- <ContactInfoItem icon={faLocationDot}>
37
+ <ContactInfoItem icon={getFontAwesomeIcon("location-dot")}>
43
38
  <a
44
39
  className="flex flex-col hover:underline"
45
40
  href={contact.googleLink}
@@ -1,23 +1,18 @@
1
1
  import React from "react";
2
2
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
3
+ import { IconDefinition } from "@fortawesome/free-solid-svg-icons";
3
4
  import * as Icons from "@fortawesome/free-solid-svg-icons";
4
5
 
5
- export const getFontAwesomeIcon = (
6
- iconName: string
7
- ): React.ReactElement | null => {
6
+ export const getFontAwesomeIcon = (iconName: string, className = ""): React.ReactElement | null => {
8
7
  try {
9
- // Extract the required icon using bracket notation
10
- const iconKey = `fa${iconName.charAt(0).toUpperCase()}${iconName.slice(
11
- 1
12
- )}`;
13
- const icon = (Icons as any)[iconKey];
8
+ const iconKey = `fa${iconName.charAt(0).toUpperCase()}${iconName.slice(1)}`;
9
+ const icon = Icons[iconKey as keyof typeof Icons] as IconDefinition;
14
10
 
15
- if (!icon) {
16
- throw new Error(`Icon not found: ${iconName}`);
11
+ if (icon) {
12
+ return <FontAwesomeIcon icon={icon} className={className} />;
13
+ } else {
14
+ throw new Error(`Icon not found or invalid type: ${iconName}`);
17
15
  }
18
-
19
- // Render the FontAwesomeIcon with the selected icon
20
- return <FontAwesomeIcon icon={icon} />;
21
16
  } catch (error) {
22
17
  console.error(`Error loading Font Awesome icon: ${iconName}`, error);
23
18
  return null;
@@ -1,5 +1,6 @@
1
1
  /** @type {import('tailwindcss').Config} */
2
2
 
3
+ const colors = require("tailwindcss/colors");
3
4
 
4
5
  module.exports = {
5
6
  mode: "jit",
@@ -7,12 +8,23 @@ module.exports = {
7
8
 
8
9
  theme: {
9
10
  extend: {
11
+ width: {
12
+ "42px": "42px",
13
+ "26px": "26px",
14
+ "18px": "18px",
15
+ },
16
+ height: {
17
+ "42px": "42px",
18
+ "26px": "26px",
19
+ "18px": "18px",
20
+ },
10
21
  maxHeight: {
11
22
  "view-page": "1000px",
12
23
  },
13
24
  fontSize: {
14
25
  "3xl": "2.25rem",
15
26
  xxs: ".6rem",
27
+ "11px": "11px",
16
28
  },
17
29
  minWidth: {
18
30
  navDropDown: "25em",
@@ -20,6 +32,11 @@ module.exports = {
20
32
  maxWidth: {
21
33
  pageSectionMaxWidth: "1500px",
22
34
  },
35
+ colors: {
36
+ // Add any custom colors here or extend the default palette
37
+ yellow: colors.yellow,
38
+ orange: colors.orange,
39
+ },
23
40
  },
24
41
  fontFamily: {
25
42
  sans: ["ui-sans-serif"],
@@ -27,6 +44,4 @@ module.exports = {
27
44
  mono: ["ui-monospace"],
28
45
  },
29
46
  },
30
-
31
- plugins: [require("daisyui")],
32
47
  };