@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,9 +1,8 @@
1
1
  import { Meta, StoryFn } from "@storybook/react";
2
2
  import FormButton from "./FormButton";
3
- import type { ButtonTypes } from "./FormButton.types";
4
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
- import { faBoxes, faClipboardList, faTags, faPlusSquare, faCoffee, faTrash, faArrowRight } from "@fortawesome/free-solid-svg-icons";
3
+ import type { FormButtonProps } from "./FormButton.types";
6
4
  import Text from "../Text/Text";
5
+ import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
7
6
 
8
7
  export default {
9
8
  title: "Components/FormButton",
@@ -13,239 +12,132 @@ export default {
13
12
  table: {
14
13
  disable: true,
15
14
  },
16
- },
17
- text: {
18
15
  control: "none",
19
- description:
20
- "The main text displayed on the button. Passed through the Text component. Text component controls styles of text",
21
16
  },
22
- textStyle: {
17
+ text: {
23
18
  control: "none",
24
- options: ["font-normal", "font-bold"],
25
- table: {
26
- disable: true,
27
- },
28
- description:
29
- "The font weight of the button text. *Storybook prop only.",
19
+ description: "The main text displayed on the button.",
30
20
  },
31
21
  fontFamily: {
32
22
  control: "none",
33
- options: ["font-sans", "font-serif", "font-mono"],
34
- table: {
35
- disable: true,
36
- },
37
- description:
38
- "The font family of the button text. *Storybook prop only.",
23
+ description: "The font family of the button text.",
39
24
  },
40
25
  backgroundColor: {
41
26
  control: "none",
42
- options: [
43
- "bg-blue-600",
44
- "bg-green-600",
45
- "bg-gray-600",
46
- "bg-transparent",
47
- ],
48
- description:
49
- "The background color of the button. Use Tailwind CSS color classes.",
50
- },
51
- fontColor: {
52
- control: "none",
53
- options: ["text-white", "text-black"],
54
- table: {
55
- disable: true,
56
- },
57
- description:
58
- "The text color of the button. Use Tailwind CSS color classes. *Storybook prop only.",
59
- },
60
- size: {
61
- control: "none",
62
- options: ["text-xs", "text-sm", "text-md", "text-lg", "text-xl"],
63
- table: {
64
- disable: true,
65
- },
66
- description:
67
- "The size of the text on the button. Use Tailwind CSS text size classes. *Storybook prop only.",
27
+ description: "The background color of the button. Use Tailwind CSS color classes.",
68
28
  },
69
29
  borderColor: {
70
30
  control: "none",
71
- options: [
72
- "border-blue-600",
73
- "border-green-600",
74
- "border-gray-600",
75
- "border-none",
76
- ],
77
- description:
78
- "The color of the border of the button. Use Tailwind CSS border color classes.",
31
+ description: "The color of the border of the button. Use Tailwind CSS border color classes.",
79
32
  },
80
33
  shape: {
81
34
  control: "none",
82
- options: [
83
- "rounded-none",
84
- "rounded-md",
85
- "rounded-full",
86
- "border-b-6 border-b-black",
87
- ],
88
- description:
89
- "The shape of the button. Use Tailwind CSS border radius classes.",
35
+ description: "The shape of the button. Use Tailwind CSS border radius classes.",
90
36
  },
91
37
  hoverBackground: {
92
38
  control: "none",
93
- options: [
94
- "hover:bg-blue-700",
95
- "hover:bg-green-700",
96
- "hover:bg-gray-700",
97
- "hover:bg-transparent",
98
- ],
99
- description:
100
- "The background color of the button on hover. Use Tailwind CSS color classes.",
101
- },
102
- hoverBorderColor: {
103
- control: "none",
104
- options: [
105
- "hover:border-blue-700",
106
- "hover:border-green-700",
107
- "hover:border-gray-700",
108
- "hover:border-transparent",
109
- ],
110
- description:
111
- "The border color of the button on hover. Use Tailwind CSS border color classes.",
39
+ description: "The background color of the button on hover. Use Tailwind CSS color classes.",
112
40
  },
113
41
  hoverFontColor: {
114
42
  control: "none",
115
- options: [
116
- "hover:text-blue-700",
117
- "hover:text-green-700",
118
- "hover:text-gray-700",
119
- "hover:text-black",
120
- ],
121
- description:
122
- "The text color of the button on hover. Use Tailwind CSS color classes.",
43
+ description: "The text color of the button on hover. Use Tailwind CSS color classes.",
123
44
  },
124
45
  hoverUnderline: {
125
46
  control: "none",
126
47
  description: "Whether the text is underlined on hover.",
127
48
  },
128
- hoverBorder: {
49
+ hoverBorderColor: {
129
50
  control: "none",
130
- description: "Whether there is a border on hover.",
51
+ description: "The border color of the button on hover. Use Tailwind CSS border color classes.",
131
52
  },
132
- icon: {
133
- table: {
134
- disable: true,
135
- },
136
- },
137
- color: {
138
- table: {
139
- disable: true,
140
- },
141
- },
142
- as: {
143
- table: {
144
- disable: true,
145
- },
146
- },
147
- buttonWide: {
148
- table: {
149
- disable: true,
150
- },
151
- },
152
- iconOrder: {
53
+ isDisabled: {
153
54
  control: "none",
154
- options: ["first", "last"],
155
- table: {
156
- disable: true,
157
- },
158
- description:
159
- "The order of the icon in the button. *Storybook prop only.",
160
- },
161
- type: {
162
- table: {
163
- disable: true,
164
- },
55
+ description: "Whether the button is disabled and cannot be clicked.",
165
56
  },
166
- to: {
167
- table: {
168
- disable: true,
169
- },
57
+ hasShadow: {
58
+ control: "none",
59
+ description: "Tailwind CSS class to add a shadow to the button.",
170
60
  },
171
- href: {
172
- table: {
173
- disable: true,
174
- },
61
+ customWidth: {
62
+ control: "none",
63
+ description: "Custom width for the button. Can be a Tailwind CSS class.",
175
64
  },
176
- tooltip: {
177
- table: {
178
- disable: true,
179
- },
65
+ customHeight: {
66
+ control: "none",
67
+ description: "Custom height for the button. Can be a Tailwind CSS class.",
180
68
  },
181
69
  additionalClasses: {
182
- table: {
183
- disable: true,
184
- },
70
+ control: "none",
71
+ description: "Additional Tailwind CSS classes to apply to the button.",
185
72
  },
186
- isDisabled: {
73
+ icon: {
187
74
  control: "none",
188
- description:
189
- "Whether the button is disabled and cannot be clicked.",
75
+ description: "An optional icon element to display inside the button.",
190
76
  },
191
- hasShadow: {
77
+ iconClasses: {
192
78
  control: "none",
193
- description: "Whether the button has a shadow.",
79
+ description: "Classes for styling the icon inside the button.",
194
80
  },
195
- customWidth: {
81
+ as: {
196
82
  control: "none",
197
- description: "The custom width of the button.",
83
+ description: "Defines the type of element to render, such as a 'button', 'a', or a React Router 'Link'.",
198
84
  },
199
- customHeight: {
85
+ href: {
86
+ control: "none",
87
+ description: "If 'as' is 'a', this specifies the 'href' for an anchor element.",
88
+ },
89
+ to: {
200
90
  control: "none",
201
- description: "The custom height of the button.",
91
+ description: "If 'as' is 'Link', this specifies the 'to' prop for React Router 'Link'.",
202
92
  },
203
93
  },
204
- tags: ["autodocs"],
94
+ tags: ['autodocs'],
205
95
  parameters: {
96
+ docs: {
97
+ description: {
98
+ component: "The `FormButton` component is a versatile button component that supports different types of elements like `button`, `a`, and `Link` from React Router. It's highly customizable with Tailwind CSS classes."
99
+ },
100
+ },
206
101
  layout: "centered",
207
102
  },
208
103
  } as Meta;
209
104
 
210
- const Template: StoryFn<ButtonTypes> = (args) => <FormButton {...args} />;
105
+ const Template: StoryFn<FormButtonProps> = (args) => <FormButton {...args} />;
211
106
 
212
107
  export const Default = Template.bind({});
213
108
  Default.args = {
214
109
  text: "Default Button",
215
110
  backgroundColor: "bg-blue-600",
216
- fontColor: "text-white",
111
+ fontFamily: "font-sans",
217
112
  borderColor: "border-none",
218
113
  shape: "rounded-md",
219
- hoverBackground: "bg-blue-700",
220
- hoverFontColor: "text-black",
221
- hoverBorderColor: "border-blue-700",
222
- hoverUnderline: false,
114
+ hoverBackground: "hover:bg-blue-700",
115
+ hoverFontColor: "hover:text-black",
223
116
  onClick: () => alert("Button clicked!"),
224
117
  additionalClasses: "p-2",
225
118
  };
226
119
 
227
120
  export const Compass = Template.bind({});
228
121
  Compass.args = {
229
- text: <Text size={""} color={""} text={"Compass Button"} fontFamily={""} />,
122
+ text: <Text size="" color="" text="Compass Button" fontFamily="" />,
230
123
  backgroundColor: "bg-green-400",
231
- fontColor: "text-black",
124
+ fontFamily: "font-sans",
232
125
  shape: "rounded-md",
233
126
  borderColor: "border-none",
234
- hoverBackground: "bg-green-700",
235
- hoverFontColor: "text-white",
236
- hoverBorderColor: "border-green-900",
127
+ hoverBackground: "hover:bg-green-700",
128
+ hoverFontColor: "hover:text-white",
129
+ hoverBorderColor: "hover:border-green-900",
237
130
  hoverUnderline: false,
238
131
  onClick: () => alert("Button clicked!"),
239
132
  as: "a",
133
+ href: "#",
240
134
  additionalClasses: "p-2",
241
135
  };
242
136
 
243
137
  export const Disabled = Template.bind({});
244
138
  Disabled.args = {
245
139
  ...Default.args,
246
- text: (
247
- <Text size={""} color={""} text={"Disabled Button"} fontFamily={""} />
248
- ),
140
+ text: <Text size="" color="" text="Disabled Button" fontFamily="" />,
249
141
  isDisabled: true,
250
142
  };
251
143
 
@@ -254,74 +146,67 @@ WithIcon.args = {
254
146
  ...Default.args,
255
147
  text: (
256
148
  <Text
257
- size={""}
258
- color={""}
259
- text={"Button with icon"}
260
- fontFamily={""}
149
+ size=""
150
+ color=""
151
+ text="Button with icon"
152
+ fontFamily=""
261
153
  additionalClasses="pl-2"
262
154
  />
263
155
  ),
264
- icon: <FontAwesomeIcon icon={faCoffee} />,
156
+ icon: getFontAwesomeIcon("coffee"),
265
157
  shape: "rounded-none",
266
158
  hoverUnderline: false,
267
159
  onClick: () => alert("Button clicked!"),
160
+ iconClasses: "pl-2",
268
161
  };
269
162
 
270
163
  export const IconOnly = Template.bind({});
271
164
  IconOnly.args = {
272
- fontColor: "text-red-600",
165
+ fontFamily: "font-sans",
273
166
  shape: "rounded",
274
- hoverBackground: "bg-blue-700",
275
- hoverFontColor: "text-white",
276
- hoverBorderColor: "border-blue-700",
167
+ hoverBackground: "hover:bg-gray-100",
277
168
  hoverUnderline: false,
278
- icon: <FontAwesomeIcon icon={faTrash} />,
279
- additionalClasses: "px-4 py-3 bg-gray-50",
169
+ icon: getFontAwesomeIcon("trash"),
170
+ additionalClasses: "flex justify-center items-center px-4 py-3 bg-gray-50",
280
171
  onClick: () => alert("Icon button clicked!"),
281
172
  };
282
173
 
283
174
  export const ClearCartButton = Template.bind({});
284
175
  ClearCartButton.args = {
285
- text: <Text size={""} color={""} text={"Clear Cart"} fontFamily={""} />,
286
- fontColor: "text-red-600",
287
- size: "text-md",
176
+ text: <Text size="" color="" text="Clear Cart" fontFamily="" />,
177
+ fontFamily: "font-sans",
288
178
  shape: "rounded-md",
289
- hoverBackground: "bg-blue-700",
290
- hoverFontColor: "text-white",
291
- hoverBorderColor: "border-red-700",
179
+ hoverBackground: "hover:bg-gray-100",
180
+ hoverFontColor: "hover:text-black",
181
+ hoverBorderColor: "hover:border-red-700",
292
182
  hoverUnderline: false,
293
- icon: <FontAwesomeIcon icon={faTrash} />,
294
- iconOrder: "first",
295
- additionalClasses:
296
- "px-5 py-6 bg-gray-50 border-red-500 gap-2",
183
+ icon: getFontAwesomeIcon("trash"),
184
+ iconClasses: "order-first",
185
+ additionalClasses: "px-5 py-6 bg-gray-50 border-red-500 gap-2",
297
186
  onClick: () => alert("Cart Cleared!"),
298
187
  };
299
188
 
300
189
  export const RightIconButton = Template.bind({});
301
190
  RightIconButton.args = {
302
- text: (
303
- <Text size={""} color={"text-blue-600"} text={"Next"} fontFamily={""} />
304
- ),
305
- backgroundColor: "bg-gray-700",
191
+ text: <Text size="" color="text-white" text="Next" fontFamily="" />,
192
+ backgroundColor: "bg-gray-500",
306
193
  shape: "rounded-md",
307
- hoverBackground: "bg-blue-700",
308
- hoverFontColor: "text-white",
309
- hoverBorderColor: "border-blue-700",
194
+ hoverBackground: "hover:bg-gray-700",
195
+ hoverFontColor: "hover:text-white",
196
+ hoverBorderColor: "hover:border-blue-700",
310
197
  hoverUnderline: false,
311
- icon: <FontAwesomeIcon icon={faArrowRight} />,
312
- additionalClasses:
313
- "px-6 py-3 bg-gray-50 border-red-500 gap-2 flex-row-reverse",
314
- onClick: () => alert("Cart Cleared!"),
198
+ icon: getFontAwesomeIcon("arrow-right"),
199
+ additionalClasses: "px-6 py-3 flex-row-reverse",
200
+ iconClasses: "ml-2",
201
+ onClick: () => alert("Next clicked!"),
315
202
  };
316
203
 
204
+
317
205
  export const ConfirmRequestButton = Template.bind({});
318
206
  ConfirmRequestButton.args = {
319
- text: (
320
- <Text size={""} color={""} text={"CONFIRM REQUEST"} fontFamily={""} />
321
- ),
207
+ text: <Text size="" color="" text="CONFIRM REQUEST" fontFamily="" />,
322
208
  backgroundColor: "bg-[#9ca3af]",
323
- fontColor: "text-white",
324
- size: "text-md",
209
+ fontFamily: "font-sans",
325
210
  borderColor: "border-none",
326
211
  shape: "rounded-md",
327
212
  hoverUnderline: false,
@@ -337,33 +222,28 @@ FourButtonsRow.decorators = [
337
222
  <FormButton
338
223
  text="All"
339
224
  backgroundColor="bg-teal-600"
340
- fontColor="text-white"
341
- size="text-md"
225
+ fontFamily="font-sans"
342
226
  borderColor="border-gray-200"
343
227
  shape="rounded-none"
344
- hoverBackground="bg-teal-600"
345
- hoverFontColor="text-black"
346
- hoverBorderColor="border-none"
347
228
  hoverUnderline={false}
348
- additionalClasses="py-2 px-4"
229
+ additionalClasses="py-2 px-4 text-white"
349
230
  onClick={() => alert("All clicked!")}
350
231
  />
351
232
 
352
233
  <FormButton
353
234
  text={
354
235
  <>
355
- <FontAwesomeIcon icon={faBoxes} className="mr-2" />{" "}
236
+ {getFontAwesomeIcon("boxes", "mr-2")}
356
237
  Bundles
357
238
  </>
358
239
  }
359
240
  backgroundColor="bg-white"
360
- fontColor="text-teal-600"
361
- size="text-md"
241
+ fontFamily="font-sans"
362
242
  borderColor="border-gray-200"
363
243
  shape="rounded-none"
364
- hoverBackground="bg-teal-600"
365
- hoverFontColor="text-black"
366
- hoverBorderColor="border-none"
244
+ hoverBackground="hover:bg-teal-600"
245
+ hoverFontColor="hover:text-white"
246
+ hoverBorderColor="hover:border-none"
367
247
  hoverUnderline={false}
368
248
  additionalClasses="py-2 px-4"
369
249
  onClick={() => alert("Bundles clicked!")}
@@ -371,21 +251,17 @@ FourButtonsRow.decorators = [
371
251
  <FormButton
372
252
  text={
373
253
  <>
374
- <FontAwesomeIcon
375
- icon={faClipboardList}
376
- className="mr-2"
377
- />{" "}
254
+ {getFontAwesomeIcon("clipboard", "mr-2")}
378
255
  Categories
379
256
  </>
380
257
  }
381
258
  backgroundColor="bg-white"
382
- fontColor="text-teal-600"
383
- size="text-md"
259
+ fontFamily="font-sans"
384
260
  borderColor="border-gray-200"
385
261
  shape="rounded-none"
386
- hoverBackground="bg-teal-600"
387
- hoverFontColor="text-black"
388
- hoverBorderColor="border-none"
262
+ hoverBackground="hover:bg-teal-600"
263
+ hoverFontColor="hover:text-white"
264
+ hoverBorderColor="hover:border-none"
389
265
  hoverUnderline={false}
390
266
  additionalClasses="py-2 px-4"
391
267
  onClick={() => alert("Categories clicked!")}
@@ -393,18 +269,17 @@ FourButtonsRow.decorators = [
393
269
  <FormButton
394
270
  text={
395
271
  <>
396
- <FontAwesomeIcon icon={faPlusSquare} className="mr-2" />{" "}
272
+ {getFontAwesomeIcon("plus", "mr-2")}
397
273
  Custom Categories
398
274
  </>
399
275
  }
400
276
  backgroundColor="bg-white"
401
- fontColor="text-teal-600"
402
- size="text-md"
277
+ fontFamily="font-sans"
403
278
  borderColor="border-gray-200"
404
279
  shape="rounded-none"
405
- hoverBackground="bg-teal-600"
406
- hoverFontColor="text-black"
407
- hoverBorderColor="border-none"
280
+ hoverBackground="hover:bg-teal-600"
281
+ hoverFontColor="hover:text-white"
282
+ hoverBorderColor="hover:border-none"
408
283
  hoverUnderline={false}
409
284
  additionalClasses="py-2 px-4"
410
285
  onClick={() => alert("Custom Categories clicked!")}
@@ -1,5 +1,5 @@
1
1
  import { render, screen, fireEvent } from "@testing-library/react";
2
- import { describe, expect, beforeEach, test, vi } from "vitest";
2
+ import { describe, expect, test, vi } from "vitest";
3
3
  import Button from "./FormButton";
4
4
  import { MemoryRouter } from "react-router-dom";
5
5
 
@@ -1,61 +1,53 @@
1
- import React, { ElementType } from "react";
2
- import { Link } from "react-router-dom";
3
- import type { ButtonTypes } from "./FormButton.types";
1
+ import React from "react";
2
+ import type { FormButtonProps } from "./FormButton.types";
4
3
 
5
- const FormButton: React.FC<ButtonTypes> = ({
4
+ const FormButton: React.FC<FormButtonProps> = ({
6
5
  onClick,
7
6
  text,
8
- textStyle = "font-normal",
9
- fontFamily = "font-sans",
10
- backgroundColor = "bg-blue-600",
11
- fontColor = "text-white",
12
- size = "text-md",
7
+ fontFamily,
8
+ backgroundColor,
13
9
  customWidth,
14
10
  customHeight,
15
- shape = "rounded-md",
16
- borderColor = "border-transparent",
11
+ shape,
12
+ borderColor,
17
13
  icon,
18
- iconOrder = "first",
19
- additionalClasses = "",
14
+ additionalClasses,
20
15
  type = "button",
21
16
  to,
22
17
  href,
23
- tooltip,
24
18
  isDisabled = false,
25
19
  hasShadow,
26
20
  as: Element = "button",
27
- hoverBackground = "",
28
- hoverFontColor = "",
21
+ hoverBackground,
22
+ hoverFontColor,
29
23
  hoverUnderline = false,
30
- hoverBorderColor = "",
24
+ hoverBorderColor,
25
+ iconClasses,
31
26
  ...props
32
27
  }) => {
33
28
  const baseFormButtonClasses = "flex items-center justify-center";
34
29
  const hoverClasses = !isDisabled
35
- ? `hover:${hoverBackground} hover:${hoverFontColor} ${hoverUnderline ? "hover:underline hover:underline-offset-4" : ""
36
- } hover:${hoverBorderColor}`
30
+ ? `${hoverBackground} ${hoverFontColor} ${hoverUnderline ? "underline underline-offset-4" : ""} ${hoverBorderColor}`
37
31
  : "";
38
- const buttonColorClasses = `${backgroundColor} ${fontColor} ${borderColor}`;
32
+ const buttonColorClasses = `${backgroundColor} ${borderColor}`;
39
33
  const cursorClasses = isDisabled
40
34
  ? "cursor-not-allowed opacity-50"
41
35
  : "cursor-pointer";
42
- const textStyleClasses = `${textStyle} ${fontFamily}`;
36
+ const textStyleClasses = `${fontFamily}`;
43
37
  const buttonShapeClasses = shape;
44
- const iconClasses =
45
- iconOrder === "first" ? "order-first" : "order-last pl-2";
46
38
 
47
39
  const buttonClasses = `
48
- ${baseFormButtonClasses}
49
- ${buttonColorClasses}
50
- ${buttonShapeClasses}
51
- ${textStyleClasses}
52
- ${hoverClasses}
53
- ${cursorClasses}
54
- ${hasShadow ? hasShadow : ""}
55
- ${customWidth}
56
- ${customHeight}
57
- ${additionalClasses}
58
- `.trim();
40
+ ${baseFormButtonClasses}
41
+ ${buttonColorClasses}
42
+ ${buttonShapeClasses}
43
+ ${textStyleClasses}
44
+ ${hoverClasses}
45
+ ${cursorClasses}
46
+ ${hasShadow ? "shadow-md" : ""}
47
+ ${customWidth}
48
+ ${customHeight}
49
+ ${additionalClasses}
50
+ `.trim();
59
51
 
60
52
  const handleClick = (
61
53
  e: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>
@@ -70,21 +62,21 @@ const FormButton: React.FC<ButtonTypes> = ({
70
62
  const baseProps = {
71
63
  className: buttonClasses,
72
64
  onClick: handleClick,
73
- type: type,
74
65
  "aria-disabled": isDisabled ? "true" : "false",
75
- "data-tooltip": tooltip,
76
66
  };
77
67
 
78
- if (Element === "a") {
79
- props = { ...baseProps, href: href };
80
- } else if (Element === "link") {
81
- props = { ...baseProps, to: to };
68
+ let ElementProps: React.ComponentProps<any> = { ...baseProps };
69
+
70
+ if (Element === "a" && href) {
71
+ ElementProps = { ...baseProps, href };
82
72
  } else if (Element === "button") {
83
- props = { ...baseProps };
73
+ ElementProps = { ...baseProps, type };
74
+ } else {
75
+ ElementProps = { ...baseProps };
84
76
  }
85
77
 
86
78
  return (
87
- <Element {...props}>
79
+ <Element {...ElementProps} {...props}>
88
80
  {icon && <span className={iconClasses}>{icon}</span>}
89
81
  {text}
90
82
  </Element>
@@ -1,33 +1,27 @@
1
1
  import React, { ElementType } from "react";
2
2
 
3
- export interface ButtonTypes {
3
+ export interface FormButtonProps {
4
4
  onClick?: (
5
5
  e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>
6
6
  ) => void;
7
7
  text?: string | JSX.Element;
8
+ fontFamily?: string;
8
9
  backgroundColor?: string;
9
10
  borderColor?: string;
10
- fontFamily?: "sans" | "mono" | "serif" | string;
11
11
  customWidth?: string;
12
12
  customHeight?: string;
13
- shape?: "cornered" | "semiRounded" | "rounded" | "underline" | string;
13
+ shape?: string;
14
14
  icon?: JSX.Element | null;
15
- type?: "submit" | "reset" | "button";
15
+ additionalClasses?: string;
16
+ type?: "button" | "submit" | "reset";
16
17
  to?: string;
17
18
  href?: string;
18
- tooltip?: string;
19
- additionalClasses?: string;
20
19
  isDisabled?: boolean;
21
20
  hasShadow?: string;
22
- as?: ElementType;
21
+ as?: ElementType | string;
23
22
  hoverBackground?: string;
24
23
  hoverFontColor?: string;
25
24
  hoverUnderline?: boolean;
26
25
  hoverBorderColor?: string;
27
-
28
- // STORYBOOK PROPS
29
- size?: "xs" | "sm" | "md" | "lg" | "xl" | string;
30
- textStyle?: "thin" | "light" | "normal" | "semibold" | "bold";
31
- iconOrder?: "first" | "last";
32
- fontColor?: string;
26
+ iconClasses?: string;
33
27
  }