@agilant/toga-blox 1.0.7 → 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.
- package/assets/cable.jpg +0 -0
- package/assets/card-1.jpg +0 -0
- package/assets/cat-logo.png +0 -0
- package/assets/item.jpg +0 -0
- package/assets/map.png +0 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +953 -0
- package/coverage/coverage-final.json +74 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +551 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/toga-blox-npm/index.html +131 -0
- package/coverage/toga-blox-npm/postcss.config.js.html +103 -0
- package/coverage/toga-blox-npm/src/components/Badge/Badge.stories.tsx.html +793 -0
- package/coverage/toga-blox-npm/src/components/Badge/Badge.tsx.html +247 -0
- package/coverage/toga-blox-npm/src/components/Badge/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Card/Card.stories.tsx.html +787 -0
- package/coverage/toga-blox-npm/src/components/Card/Card.tsx.html +163 -0
- package/coverage/toga-blox-npm/src/components/Card/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/CategoryCardTemplate.tsx.html +343 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/CompassCardTemplate.tsx.html +259 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/CounterContentCardTemplate.tsx.html +685 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/HorizontalCardTemplate.tsx.html +637 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/ItemCardTemplate.tsx.html +550 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/KitContentCardTemplate.tsx.html +469 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/ShippingAddressCardTemplate.tsx.html +418 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/VerticalCardTemplate.tsx.html +592 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/index.html +221 -0
- package/coverage/toga-blox-npm/src/components/CounterButton/CounterButton.stories.tsx.html +358 -0
- package/coverage/toga-blox-npm/src/components/CounterButton/CounterButton.tsx.html +385 -0
- package/coverage/toga-blox-npm/src/components/CounterButton/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Description/Description.stories.tsx.html +286 -0
- package/coverage/toga-blox-npm/src/components/Description/Description.tsx.html +124 -0
- package/coverage/toga-blox-npm/src/components/Description/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/DropDownIconButton/DropDownIconButton.stories.tsx.html +676 -0
- package/coverage/toga-blox-npm/src/components/DropDownIconButton/DropDownIconButton.tsx.html +346 -0
- package/coverage/toga-blox-npm/src/components/DropDownIconButton/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Footer/ContactInfoItem.tsx.html +139 -0
- package/coverage/toga-blox-npm/src/components/Footer/Footer.stories.tsx.html +934 -0
- package/coverage/toga-blox-npm/src/components/Footer/Footer.tsx.html +373 -0
- package/coverage/toga-blox-npm/src/components/Footer/index.html +146 -0
- package/coverage/toga-blox-npm/src/components/FormButton/FormButton.stories.tsx.html +952 -0
- package/coverage/toga-blox-npm/src/components/FormButton/FormButton.tsx.html +343 -0
- package/coverage/toga-blox-npm/src/components/FormButton/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/GenericList/GenericList.stories.tsx.html +376 -0
- package/coverage/toga-blox-npm/src/components/GenericList/GenericList.tsx.html +520 -0
- package/coverage/toga-blox-npm/src/components/GenericList/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/GenericList/templates/DummyDataList.tsx.html +154 -0
- package/coverage/toga-blox-npm/src/components/GenericList/templates/DynamicIconList.tsx.html +250 -0
- package/coverage/toga-blox-npm/src/components/GenericList/templates/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/GetSupport/GetSupport.stories.tsx.html +325 -0
- package/coverage/toga-blox-npm/src/components/GetSupport/GetSupport.tsx.html +262 -0
- package/coverage/toga-blox-npm/src/components/GetSupport/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/HamburgerButton/Hamburger.stories.tsx.html +760 -0
- package/coverage/toga-blox-npm/src/components/HamburgerButton/HamburgerButton.tsx.html +232 -0
- package/coverage/toga-blox-npm/src/components/HamburgerButton/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Header/Header.stories.tsx.html +1633 -0
- package/coverage/toga-blox-npm/src/components/Header/Header.tsx.html +814 -0
- package/coverage/toga-blox-npm/src/components/Header/headerContext.tsx.html +460 -0
- package/coverage/toga-blox-npm/src/components/Header/index.html +146 -0
- package/coverage/toga-blox-npm/src/components/Hero/Hero.stories.tsx.html +289 -0
- package/coverage/toga-blox-npm/src/components/Hero/Hero.tsx.html +259 -0
- package/coverage/toga-blox-npm/src/components/Hero/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/IconButton/IconButton.stories.tsx.html +673 -0
- package/coverage/toga-blox-npm/src/components/IconButton/IconButton.tsx.html +313 -0
- package/coverage/toga-blox-npm/src/components/IconButton/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Image/Image.stories.tsx.html +322 -0
- package/coverage/toga-blox-npm/src/components/Image/Image.tsx.html +226 -0
- package/coverage/toga-blox-npm/src/components/Image/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Input/Input.stories.tsx.html +1621 -0
- package/coverage/toga-blox-npm/src/components/Input/Input.tsx.html +568 -0
- package/coverage/toga-blox-npm/src/components/Input/InputMemoTypes.tsx.html +181 -0
- package/coverage/toga-blox-npm/src/components/Input/index.html +146 -0
- package/coverage/toga-blox-npm/src/components/MobileMenu/MobileMenu.tsx.html +208 -0
- package/coverage/toga-blox-npm/src/components/MobileMenu/index.html +116 -0
- package/coverage/toga-blox-npm/src/components/Nav/Nav.stories.tsx.html +628 -0
- package/coverage/toga-blox-npm/src/components/Nav/Nav.tsx.html +622 -0
- package/coverage/toga-blox-npm/src/components/Nav/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Page/TableDataDummy.tsx.html +733 -0
- package/coverage/toga-blox-npm/src/components/Page/ViewPageTemplate.stories.tsx.html +1714 -0
- package/coverage/toga-blox-npm/src/components/Page/ViewPageTemplate.tsx.html +115 -0
- package/coverage/toga-blox-npm/src/components/Page/index.html +146 -0
- package/coverage/toga-blox-npm/src/components/PageSection/PageSection.stories.tsx.html +433 -0
- package/coverage/toga-blox-npm/src/components/PageSection/PageSection.tsx.html +121 -0
- package/coverage/toga-blox-npm/src/components/PageSection/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/SearchInput/SearchInput.stories.tsx.html +517 -0
- package/coverage/toga-blox-npm/src/components/SearchInput/SearchInput.tsx.html +325 -0
- package/coverage/toga-blox-npm/src/components/SearchInput/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Slider/Slider.stories.tsx.html +349 -0
- package/coverage/toga-blox-npm/src/components/Slider/Slider.tsx.html +502 -0
- package/coverage/toga-blox-npm/src/components/Slider/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Submenus/AdminSubmenu.tsx.html +136 -0
- package/coverage/toga-blox-npm/src/components/Submenus/AlertSubmenu.tsx.html +253 -0
- package/coverage/toga-blox-npm/src/components/Submenus/AlertSubmenuItem.tsx.html +202 -0
- package/coverage/toga-blox-npm/src/components/Submenus/index.html +146 -0
- package/coverage/toga-blox-npm/src/components/Text/Text.stories.tsx.html +235 -0
- package/coverage/toga-blox-npm/src/components/Text/Text.tsx.html +172 -0
- package/coverage/toga-blox-npm/src/components/Text/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Toaster/Toaster.stories.tsx.html +445 -0
- package/coverage/toga-blox-npm/src/components/Toaster/Toaster.tsx.html +301 -0
- package/coverage/toga-blox-npm/src/components/Toaster/index.html +131 -0
- package/coverage/toga-blox-npm/src/hoc/styling/index.html +116 -0
- package/coverage/toga-blox-npm/src/hoc/styling/withStoryBook.tsx.html +142 -0
- package/coverage/toga-blox-npm/src/userHoc/index.html +116 -0
- package/coverage/toga-blox-npm/src/userHoc/withMemo.tsx.html +145 -0
- package/coverage/toga-blox-npm/src/utils/assertTagName.tsx.html +106 -0
- package/coverage/toga-blox-npm/src/utils/generateAccordionItem.tsx.html +373 -0
- package/coverage/toga-blox-npm/src/utils/generateFooterContacts.tsx.html +295 -0
- package/coverage/toga-blox-npm/src/utils/generateNavMenu.tsx.html +247 -0
- package/coverage/toga-blox-npm/src/utils/generateSocialList.tsx.html +187 -0
- package/coverage/toga-blox-npm/src/utils/getFontAwesomeIcon.tsx.html +145 -0
- package/coverage/toga-blox-npm/src/utils/index.html +206 -0
- package/coverage/toga-blox-npm/src/utils/inputValidation.tsx.html +163 -0
- package/coverage/toga-blox-npm/tailwind.config.js.html +205 -0
- package/declarations.d.ts +1 -1
- package/package.json +7 -7
- package/src/components/Badge/Badge.stories.tsx +110 -207
- package/src/components/Badge/Badge.test.tsx +40 -41
- package/src/components/Badge/Badge.tsx +29 -99
- package/src/components/Badge/Badge.types.tsx +12 -23
- package/src/components/Card/Card.stories.tsx +166 -22
- package/src/components/Card/Card.test.tsx +3 -3
- package/src/components/Card/Card.tsx +12 -16
- package/src/components/Card/DUMMYPRODUCTDATA.json +381 -225
- package/src/components/Card/templates/CategoryCardTemplate.tsx +86 -0
- package/src/components/Card/templates/CompassCardTemplate.tsx +1 -1
- package/src/components/Card/templates/CounterContentCardTemplate.tsx +200 -0
- package/src/components/Card/templates/ItemCardTemplate.tsx +155 -0
- package/src/components/Card/templates/KitContentCardTemplate.tsx +128 -0
- package/src/components/Card/templates/ShippingAddressCardTemplate.tsx +111 -0
- package/src/components/Card/templates/VerticalCardTemplate.tsx +100 -85
- package/src/components/CounterButton/CounterButton.tsx +1 -1
- package/src/components/Description/Description.stories.tsx +67 -0
- package/src/components/Description/Description.tsx +13 -0
- package/src/components/Description/Description.types.ts +9 -0
- package/src/components/DropDownIconButton/DropDownIconButton.stories.tsx +197 -0
- package/src/components/DropDownIconButton/DropDownIconButton.test.tsx +90 -0
- package/src/components/DropDownIconButton/DropDownIconButton.tsx +87 -0
- package/src/components/DropDownIconButton/DropDownIconButton.types.ts +21 -0
- package/src/components/DropDownIconButton/index.ts +2 -0
- package/src/components/Footer/ContactInfoItem.tsx +8 -10
- package/src/components/Footer/Footer.stories.tsx +13 -22
- package/src/components/Footer/Footer.tsx +25 -88
- package/src/components/Footer/Footer.types.tsx +2 -2
- package/src/components/FormButton/FormButton.stories.tsx +101 -226
- package/src/components/FormButton/FormButton.test.tsx +1 -1
- package/src/components/FormButton/FormButton.tsx +34 -42
- package/src/components/FormButton/FormButton.types.ts +7 -13
- package/src/components/GenericList/GenericList.stories.tsx +5 -12
- package/src/components/GenericList/GenericList.tsx +91 -92
- package/src/components/GenericList/templates/DynamicIconList.tsx +45 -64
- package/src/components/GetSupport/GetSupport.stories.tsx +80 -0
- package/src/components/GetSupport/GetSupport.test.tsx +62 -0
- package/src/components/GetSupport/GetSupport.tsx +59 -0
- package/src/components/GetSupport/GetSupport.types.ts +11 -0
- package/src/components/HamburgerButton/Hamburger.stories.tsx +225 -0
- package/src/components/HamburgerButton/HamburgerButton.tsx +37 -56
- package/src/components/HamburgerButton/HamburgerButton.types.tsx +2 -1
- package/src/components/Header/Header.stories.tsx +3 -5
- package/src/components/Header/Header.tsx +37 -83
- package/src/components/Hero/Hero.stories.tsx +1 -2
- package/src/components/IconButton/IconButton.stories.tsx +196 -0
- package/src/components/{Icon/Icon.test.tsx → IconButton/IconButton.test.tsx} +3 -4
- package/src/components/IconButton/IconButton.tsx +76 -0
- package/src/components/IconButton/IconButton.types.ts +28 -0
- package/src/components/IconButton/index.ts +2 -0
- package/src/components/Image/Image.tsx +1 -1
- package/src/components/Input/Input.stories.tsx +10 -12
- package/src/components/Input/Input.test.tsx +2 -3
- package/src/components/Input/Input.tsx +41 -104
- package/src/components/MobileMenu/MobileMenu.types.tsx +0 -2
- package/src/components/Nav/DUMMYNAVDATA.json +4 -4
- package/src/components/Nav/Nav.tsx +49 -112
- package/src/components/Nav/Nav.types.tsx +14 -2
- package/src/components/Page/ViewPageTemplate.stories.tsx +2 -2
- package/src/components/Page/ViewPageTemplate.test.tsx +1 -1
- package/src/components/Page/ViewPageTemplate.types.ts +1 -1
- package/src/components/PageSection/PageSection.stories.tsx +3 -1
- package/src/components/PageSection/PageSections.test.tsx +2 -1
- package/src/components/SearchInput/SearchInput.stories.tsx +144 -0
- package/src/components/SearchInput/SearchInput.tsx +81 -0
- package/src/components/SearchInput/SearchInput.types.ts +28 -0
- package/src/components/Slider/Slider.stories.tsx +88 -0
- package/src/components/Slider/Slider.tsx +139 -0
- package/src/components/Slider/Slider.types.ts +21 -0
- package/src/components/Submenus/AdminSubmenu.tsx +17 -0
- package/src/components/Submenus/AlertSubmenu.tsx +56 -0
- package/src/components/Submenus/AlertSubmenuItem.tsx +39 -0
- package/src/components/Submenus/types.tsx +32 -0
- package/src/components/Toaster/Toaster.stories.tsx +4 -6
- package/src/components/Toaster/Toaster.test.tsx +3 -4
- package/src/components/Toaster/Toaster.tsx +9 -17
- package/src/components/Toaster/Toaster.types.ts +2 -2
- package/src/utils/assertTagName.tsx +1 -1
- package/src/utils/generateAccordionItem.tsx +7 -13
- package/src/utils/generateFooterContacts.tsx +4 -9
- package/src/utils/getFontAwesomeIcon.tsx +8 -13
- package/tailwind.config.js +11 -3
- package/src/components/Badge/badgeClassNames.tsx +0 -173
- package/src/components/Card/cardClassNames.ts +0 -49
- package/src/components/Footer/footerClassNames.tsx +0 -57
- package/src/components/FormButton/formButtonClassNames.tsx +0 -153
- package/src/components/GenericList/genericListClassNames.tsx +0 -8
- package/src/components/Header/headerClassNames.tsx +0 -50
- package/src/components/Icon/Icon.stories.tsx +0 -227
- package/src/components/Icon/Icon.tsx +0 -208
- package/src/components/Icon/Icon.types.ts +0 -24
- package/src/components/Icon/iconClassNames.ts +0 -79
- package/src/components/Icon/index.ts +0 -2
- package/src/components/Input/inputClassNames.tsx +0 -169
- package/src/components/Nav/navClassNames.tsx +0 -192
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
2
|
+
import IconButton from "./IconButton";
|
|
3
|
+
import { IconButtonTypes } from "./IconButton.types";
|
|
4
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
5
|
+
import { JSX } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Components/IconButton",
|
|
9
|
+
component: IconButton,
|
|
10
|
+
argTypes: {
|
|
11
|
+
iconSize: {
|
|
12
|
+
control: "none",
|
|
13
|
+
description: "Tailwind classes for the icon size. Example: `h-6 w-6`",
|
|
14
|
+
},
|
|
15
|
+
iconColor: {
|
|
16
|
+
control: "none",
|
|
17
|
+
description: "Tailwind classes for the icon color. Example: `text-blue-500`",
|
|
18
|
+
},
|
|
19
|
+
backgroundColor: {
|
|
20
|
+
control: "none",
|
|
21
|
+
description: "Tailwind classes for the background color. Example: `bg-gray-200`",
|
|
22
|
+
},
|
|
23
|
+
borderColor: {
|
|
24
|
+
control: "none",
|
|
25
|
+
description: "Tailwind classes for the border color. Example: `border-gray-300`",
|
|
26
|
+
},
|
|
27
|
+
iconLabel: {
|
|
28
|
+
control: "none",
|
|
29
|
+
description: "The label for the icon. Example: `Profile`",
|
|
30
|
+
},
|
|
31
|
+
icon: {
|
|
32
|
+
control: "none",
|
|
33
|
+
description: "The icon to be displayed. Example: `user-cog`",
|
|
34
|
+
},
|
|
35
|
+
size: {
|
|
36
|
+
control: "none",
|
|
37
|
+
description: "The size of the icon. Example: `xl`",
|
|
38
|
+
},
|
|
39
|
+
iconBorder: {
|
|
40
|
+
control: "none",
|
|
41
|
+
description: "Tailwind classes for the icon border. Example: `border-2`",
|
|
42
|
+
},
|
|
43
|
+
to: {
|
|
44
|
+
control: "none",
|
|
45
|
+
description: "The URL to redirect to when the icon is clicked. Example: `/admin`",
|
|
46
|
+
},
|
|
47
|
+
href: {
|
|
48
|
+
control: "none",
|
|
49
|
+
description: "The URL to redirect to when the icon is clicked. Example: `/admin`",
|
|
50
|
+
},
|
|
51
|
+
hoverBorderColor: {
|
|
52
|
+
control: "none",
|
|
53
|
+
description: "Tailwind classes for the border color on hover. Example: `hover:border-blue-500`",
|
|
54
|
+
},
|
|
55
|
+
hoverColor: {
|
|
56
|
+
control: "none",
|
|
57
|
+
description: "Tailwind classes for the color on hover. Example: `hover:text-blue-500`",
|
|
58
|
+
},
|
|
59
|
+
indicatorSize: {
|
|
60
|
+
control: "none",
|
|
61
|
+
description: "Tailwind classes for the indicator size. Example: `h-4 w-4`",
|
|
62
|
+
},
|
|
63
|
+
indicatorNumber: {
|
|
64
|
+
control: "none",
|
|
65
|
+
description: "The number to be displayed inside the indicator. Example: `12`",
|
|
66
|
+
},
|
|
67
|
+
hoverBorder: {
|
|
68
|
+
control: "none",
|
|
69
|
+
description: "Tailwind classes for the border on hover. Example: `hover:border-2`",
|
|
70
|
+
},
|
|
71
|
+
limitCharacters: {
|
|
72
|
+
control: "none",
|
|
73
|
+
description: "Flag to indicate if the text should be limited to 2 characters. If set to true and the text is greater than 99, the text will display '99+'.",
|
|
74
|
+
},
|
|
75
|
+
hoverBackgroundColor: {
|
|
76
|
+
control: "none",
|
|
77
|
+
description: "Tailwind classes for the background on hover. Example: `hover:bg-gray-300`",
|
|
78
|
+
},
|
|
79
|
+
hoverBackground: {
|
|
80
|
+
control: "none",
|
|
81
|
+
description: "Tailwind classes for the background color on hover. Example: `hover:bg-gray-300`",
|
|
82
|
+
},
|
|
83
|
+
hasNotification: {
|
|
84
|
+
control: "none",
|
|
85
|
+
description: "Flag to indicate if the button has a notification badge.",
|
|
86
|
+
},
|
|
87
|
+
notificationTextColor: {
|
|
88
|
+
control: "none",
|
|
89
|
+
description: "Tailwind classes for the notification text color. Example: `text-white`",
|
|
90
|
+
},
|
|
91
|
+
notificationBgColor: {
|
|
92
|
+
control: "none",
|
|
93
|
+
description: "Tailwind classes for the notification background color. Example: `bg-red-500`",
|
|
94
|
+
},
|
|
95
|
+
notificationCount: {
|
|
96
|
+
control: "none",
|
|
97
|
+
description: "The number to be displayed inside the notification badge. Example: `12`",
|
|
98
|
+
},
|
|
99
|
+
text: {
|
|
100
|
+
control: "none",
|
|
101
|
+
description: "The text to be displayed below the button. Example: `Profile`",
|
|
102
|
+
},
|
|
103
|
+
textClasses: {
|
|
104
|
+
control: "none",
|
|
105
|
+
description: "Tailwind classes to style the text. Example: `text-sm text-black`",
|
|
106
|
+
},
|
|
107
|
+
onClick: {
|
|
108
|
+
table: {
|
|
109
|
+
disable: true,
|
|
110
|
+
},
|
|
111
|
+
control: "none",
|
|
112
|
+
description: "Callback function to handle click events. Example: `() => alert('Clicked!')`",
|
|
113
|
+
},
|
|
114
|
+
role: {
|
|
115
|
+
control: "none",
|
|
116
|
+
description: "ARIA role for accessibility. Example: `button`",
|
|
117
|
+
},
|
|
118
|
+
additionalContainerClasses: {
|
|
119
|
+
control: "none",
|
|
120
|
+
description: "Additional Tailwind classes for the container. Example: `p-4`",
|
|
121
|
+
},
|
|
122
|
+
limitIndicator: {
|
|
123
|
+
control: "none",
|
|
124
|
+
description:
|
|
125
|
+
"Whether the indicator number should be limited to 2 characters. If set to true and the number is greater than 99, the indicator will display '99+'.",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
tags: ["autodocs"],
|
|
129
|
+
parameters: {
|
|
130
|
+
layout: "centered",
|
|
131
|
+
},
|
|
132
|
+
} as Meta;
|
|
133
|
+
|
|
134
|
+
const Template: StoryFn<IconButtonTypes> = (args) => <IconButton {...args} />;
|
|
135
|
+
|
|
136
|
+
export const AdminButton = Template.bind({});
|
|
137
|
+
AdminButton.args = {
|
|
138
|
+
iconColor: "text-black",
|
|
139
|
+
text: "Admin",
|
|
140
|
+
backgroundColor: "bg-gray-200",
|
|
141
|
+
iconSize: "h-8 w-8",
|
|
142
|
+
icon: getFontAwesomeIcon("cog"),
|
|
143
|
+
hoverBackgroundColor: "hover:bg-gray-300",
|
|
144
|
+
hoverBorderColor: "hover:border-black",
|
|
145
|
+
notificationCount: 0,
|
|
146
|
+
textClasses: "text-black font-serif text-md",
|
|
147
|
+
onClick: () => alert("Redirect to admin"),
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const AccountButton = Template.bind({});
|
|
151
|
+
AccountButton.args = {
|
|
152
|
+
iconColor: "text-black",
|
|
153
|
+
text: "Account",
|
|
154
|
+
backgroundColor: "bg-gray-200",
|
|
155
|
+
iconSize: "h-8 w-8",
|
|
156
|
+
icon: getFontAwesomeIcon("user"),
|
|
157
|
+
hoverBackgroundColor: "hover:bg-gray-300",
|
|
158
|
+
hoverBorderColor: "hover:border-black",
|
|
159
|
+
notificationCount: 0,
|
|
160
|
+
textClasses: "text-black font-serif text-md",
|
|
161
|
+
onClick: () => alert("Redirect to account"),
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const AlertsButton = Template.bind({});
|
|
165
|
+
AlertsButton.args = {
|
|
166
|
+
iconColor: "text-black",
|
|
167
|
+
text: "Alerts",
|
|
168
|
+
backgroundColor: "bg-gray-200",
|
|
169
|
+
iconSize: "h-8 w-8",
|
|
170
|
+
icon: getFontAwesomeIcon("bell"),
|
|
171
|
+
hoverBackgroundColor: "hover:bg-gray-300",
|
|
172
|
+
hoverBorderColor: "hover:border-black",
|
|
173
|
+
hasNotification: true,
|
|
174
|
+
notificationTextClasses: "text-white",
|
|
175
|
+
notificationBgColor: "bg-green-600",
|
|
176
|
+
notificationCount: 123,
|
|
177
|
+
textClasses: "text-black font-serif text-md",
|
|
178
|
+
onClick: () => alert("Redirect to alerts"),
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export const CartButton = Template.bind({});
|
|
182
|
+
CartButton.args = {
|
|
183
|
+
iconColor: "text-black",
|
|
184
|
+
text: "Cart",
|
|
185
|
+
backgroundColor: "bg-gray-200",
|
|
186
|
+
iconSize: "h-8 w-8",
|
|
187
|
+
icon: getFontAwesomeIcon("shop"),
|
|
188
|
+
hoverBackgroundColor: "hover:bg-gray-300",
|
|
189
|
+
hoverBorderColor: "hover:border-black",
|
|
190
|
+
hasNotification: true,
|
|
191
|
+
notificationTextClasses: "text-white",
|
|
192
|
+
notificationBgColor: "bg-green-600",
|
|
193
|
+
notificationCount: 3,
|
|
194
|
+
textClasses: "text-black font-serif text-md",
|
|
195
|
+
onClick: () => alert("Redirect to cart"),
|
|
196
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { render, screen } from "@testing-library/react";
|
|
2
2
|
import { describe, expect, beforeEach, test } from "vitest";
|
|
3
|
-
import Icon from "./
|
|
3
|
+
import Icon from "./IconButton";
|
|
4
4
|
import Text from "../Text/Text";
|
|
5
|
-
import {
|
|
6
|
-
import { faUser } from "@fortawesome/free-solid-svg-icons";
|
|
5
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
7
6
|
|
|
8
7
|
describe("<Icon /> Profile", () => {
|
|
9
8
|
beforeEach(() => {
|
|
@@ -12,7 +11,7 @@ describe("<Icon /> Profile", () => {
|
|
|
12
11
|
iconLabel="Profile"
|
|
13
12
|
iconColor="green"
|
|
14
13
|
size="sm"
|
|
15
|
-
icon={
|
|
14
|
+
icon={getFontAwesomeIcon("user")}
|
|
16
15
|
hoverBackground="none"
|
|
17
16
|
hoverColor="green"
|
|
18
17
|
text={
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IconButtonTypes } from "./IconButton.types";
|
|
3
|
+
import Text from "../Text/Text";
|
|
4
|
+
|
|
5
|
+
const Icon: React.FC<IconButtonTypes> = ({
|
|
6
|
+
onClick = () => { },
|
|
7
|
+
role,
|
|
8
|
+
icon,
|
|
9
|
+
iconSize,
|
|
10
|
+
iconColor,
|
|
11
|
+
hasNotification,
|
|
12
|
+
notificationTextClasses,
|
|
13
|
+
notificationBgColor,
|
|
14
|
+
notificationCount,
|
|
15
|
+
text,
|
|
16
|
+
textSize,
|
|
17
|
+
textColor,
|
|
18
|
+
textFontFamily,
|
|
19
|
+
textClasses,
|
|
20
|
+
textContainerClasses,
|
|
21
|
+
hoverBorderColor,
|
|
22
|
+
hoverBackgroundColor,
|
|
23
|
+
backgroundColor,
|
|
24
|
+
borderColor,
|
|
25
|
+
additionalContainerClasses,
|
|
26
|
+
}) => {
|
|
27
|
+
const displayNotificationCount = notificationCount && notificationCount > 99 ? "99+" : notificationCount;
|
|
28
|
+
|
|
29
|
+
const notificationClasses = `absolute -top-1 h-18px rounded-full text-11px font-semibold leading-[18px] flex items-center justify-center ${notificationTextClasses} ${notificationBgColor} ${notificationCount && notificationCount > 99
|
|
30
|
+
? "w-26px -right-4 "
|
|
31
|
+
: "w-18px -right-2 "
|
|
32
|
+
}`;
|
|
33
|
+
|
|
34
|
+
const iconClasses = `flex items-center justify-center ${iconSize} ${iconColor}`;
|
|
35
|
+
const iconContainerClasses = `relative flex items-center justify-center h-42px w-42px rounded-full border-1 ${borderColor} ${backgroundColor} group-hover:${hoverBorderColor} group-hover:${hoverBackgroundColor}`;
|
|
36
|
+
|
|
37
|
+
const ariaLabel = `${text} ${hasNotification ? `with ${notificationCount} notifications` : ""}`;
|
|
38
|
+
|
|
39
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
40
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
41
|
+
onClick(e as unknown as React.MouseEvent<HTMLDivElement>);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
className={`flex flex-col items-center justify-center group ${additionalContainerClasses}`}
|
|
48
|
+
onClick={(e) => onClick(e as React.MouseEvent<HTMLDivElement>)}
|
|
49
|
+
role={role}
|
|
50
|
+
tabIndex={0}
|
|
51
|
+
onKeyDown={(e) => handleKeyDown(e)}
|
|
52
|
+
aria-label={ariaLabel}
|
|
53
|
+
>
|
|
54
|
+
<div className={iconContainerClasses}>
|
|
55
|
+
<div className={iconClasses}>{icon}</div>
|
|
56
|
+
{hasNotification && notificationCount && (
|
|
57
|
+
<span className={notificationClasses}>
|
|
58
|
+
{displayNotificationCount}
|
|
59
|
+
</span>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
<div aria-hidden={true} className={textContainerClasses}>
|
|
63
|
+
<Text
|
|
64
|
+
size={textSize}
|
|
65
|
+
color={textColor}
|
|
66
|
+
fontFamily={textFontFamily}
|
|
67
|
+
text={text}
|
|
68
|
+
tag="p"
|
|
69
|
+
additionalClasses={textClasses}
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default Icon;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export interface IconButtonTypes {
|
|
4
|
+
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
5
|
+
role?: string;
|
|
6
|
+
icon: ReactNode;
|
|
7
|
+
iconSize?: string;
|
|
8
|
+
iconColor?: string;
|
|
9
|
+
hasNotification?: boolean;
|
|
10
|
+
notificationTextClasses?: string;
|
|
11
|
+
notificationBgColor?: string;
|
|
12
|
+
notificationCount?: number;
|
|
13
|
+
text?: string;
|
|
14
|
+
textSize?: string;
|
|
15
|
+
textColor?: string;
|
|
16
|
+
textFontFamily?: string;
|
|
17
|
+
textClasses?: string;
|
|
18
|
+
hoverBorderColor?: string;
|
|
19
|
+
hoverBackgroundColor?: string;
|
|
20
|
+
backgroundColor?: string;
|
|
21
|
+
borderColor?: string;
|
|
22
|
+
additionalContainerClasses?: string;
|
|
23
|
+
textContainerClasses?: string;
|
|
24
|
+
iconLabel?: string;
|
|
25
|
+
iconBorder?: string;
|
|
26
|
+
indicatorNumber?: string;
|
|
27
|
+
indicatorSize?: string;
|
|
28
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Children,
|
|
1
|
+
import React, { Children, CSSProperties } from "react";
|
|
2
2
|
import heroImage from "../../../assets/heroImage.png";
|
|
3
3
|
import imageNotFound from "../../../assets/placeholder-no-image-available.png";
|
|
4
4
|
import { ImageTypes } from "./Image.types";
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Meta, StoryFn } from "@storybook/react";
|
|
2
2
|
import { Input, InputTypes } from ".";
|
|
3
3
|
import Text from "../Text/Text";
|
|
4
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
5
|
-
import { faMagnifyingGlass, faCircleArrowRight, faEnvelope } from "@fortawesome/free-solid-svg-icons";
|
|
6
4
|
import { minCharactersRegex } from "../../utils/inputValidation";
|
|
7
5
|
import { withMemo } from "../../userHoc";
|
|
8
6
|
import { arePropsEqual } from "./InputMemoTypes";
|
|
@@ -203,8 +201,8 @@ NoIcons.args = {
|
|
|
203
201
|
),
|
|
204
202
|
hasLeftIcon: false,
|
|
205
203
|
hasRightIcon: false,
|
|
206
|
-
leftIcon:
|
|
207
|
-
rightIcon:
|
|
204
|
+
leftIcon: getFontAwesomeIcon("search"),
|
|
205
|
+
rightIcon: getFontAwesomeIcon("arrow-right"),
|
|
208
206
|
hasButton: true,
|
|
209
207
|
button: (
|
|
210
208
|
<FormButton
|
|
@@ -252,7 +250,7 @@ LeftIcon.args = {
|
|
|
252
250
|
/>
|
|
253
251
|
),
|
|
254
252
|
hasLeftIcon: true,
|
|
255
|
-
leftIcon:
|
|
253
|
+
leftIcon: getFontAwesomeIcon("search"),
|
|
256
254
|
iconBackgroundColor: "none",
|
|
257
255
|
hasRightIcon: false,
|
|
258
256
|
iconColor: "text-green-500",
|
|
@@ -283,7 +281,7 @@ RightIcon.args = {
|
|
|
283
281
|
),
|
|
284
282
|
hasLeftIcon: false,
|
|
285
283
|
hasRightIcon: true,
|
|
286
|
-
rightIcon:
|
|
284
|
+
rightIcon: getFontAwesomeIcon("arrow-right"),
|
|
287
285
|
iconBackgroundColor: "none",
|
|
288
286
|
hasButton: false,
|
|
289
287
|
};
|
|
@@ -312,8 +310,8 @@ DualIcons.args = {
|
|
|
312
310
|
),
|
|
313
311
|
hasRightIcon: true,
|
|
314
312
|
hasLeftIcon: true,
|
|
315
|
-
rightIcon:
|
|
316
|
-
leftIcon:
|
|
313
|
+
rightIcon: getFontAwesomeIcon("arrow-right"),
|
|
314
|
+
leftIcon: getFontAwesomeIcon("search"),
|
|
317
315
|
iconBackgroundColor: "none",
|
|
318
316
|
};
|
|
319
317
|
|
|
@@ -352,7 +350,7 @@ ButtonWithValidation.args = {
|
|
|
352
350
|
as="button"
|
|
353
351
|
hoverBackground="hover:bg-green-500"
|
|
354
352
|
backgroundColor="bg-green-500"
|
|
355
|
-
icon={
|
|
353
|
+
icon={getFontAwesomeIcon("search")}
|
|
356
354
|
fontColor="text-white"
|
|
357
355
|
additionalClasses="items-center px-2 h-full"
|
|
358
356
|
borderColor="border-none"
|
|
@@ -386,7 +384,7 @@ ButtonWithLeftIcon.args = {
|
|
|
386
384
|
),
|
|
387
385
|
hasRightIcon: false,
|
|
388
386
|
hasLeftIcon: true,
|
|
389
|
-
leftIcon:
|
|
387
|
+
leftIcon: getFontAwesomeIcon("search"),
|
|
390
388
|
iconBackgroundColor: "none",
|
|
391
389
|
hasButton: true,
|
|
392
390
|
button: (
|
|
@@ -396,7 +394,7 @@ ButtonWithLeftIcon.args = {
|
|
|
396
394
|
as="button"
|
|
397
395
|
hoverBackground="hover:bg-green-500"
|
|
398
396
|
backgroundColor="bg-green-500"
|
|
399
|
-
icon={
|
|
397
|
+
icon={getFontAwesomeIcon("search")}
|
|
400
398
|
fontColor="text-white"
|
|
401
399
|
additionalClasses="items-center px-2 h-full"
|
|
402
400
|
borderColor="border-none"
|
|
@@ -456,7 +454,7 @@ EmailInput.args = {
|
|
|
456
454
|
),
|
|
457
455
|
hasRightIcon: false,
|
|
458
456
|
hasLeftIcon: true,
|
|
459
|
-
leftIcon:
|
|
457
|
+
leftIcon: getFontAwesomeIcon("envelope"),
|
|
460
458
|
hasButton: false,
|
|
461
459
|
};
|
|
462
460
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import "../../../dist/main.css";
|
|
2
2
|
import { render, screen } from "@testing-library/react";
|
|
3
3
|
import { describe, test, expect, beforeEach } from "vitest";
|
|
4
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
5
|
-
import { faCircleArrowRight } from "@fortawesome/free-solid-svg-icons";
|
|
6
4
|
import Input from "./Input";
|
|
7
5
|
import Text from "../Text/Text";
|
|
8
6
|
import FormButton from "../FormButton/FormButton";
|
|
7
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
9
8
|
|
|
10
9
|
describe("<Input /> with all props", () => {
|
|
11
10
|
beforeEach(() => {
|
|
@@ -49,7 +48,7 @@ describe("<Input /> with all props", () => {
|
|
|
49
48
|
as="button"
|
|
50
49
|
hoverBackground="green"
|
|
51
50
|
backgroundColor="green"
|
|
52
|
-
icon={
|
|
51
|
+
icon={getFontAwesomeIcon("arrow-right")}
|
|
53
52
|
fontColor="white"
|
|
54
53
|
additionalClasses="items-center px-4"
|
|
55
54
|
borderColor="green"
|
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
3
|
-
import { faCircleArrowRight } from "@fortawesome/free-solid-svg-icons";
|
|
4
2
|
import FormButton from "../FormButton/FormButton";
|
|
5
3
|
import { InputTypes } from ".";
|
|
6
4
|
import { validateInput } from "../../utils/inputValidation";
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
getInputBorderClassNames,
|
|
10
|
-
getInputPaddingClassNames,
|
|
11
|
-
getInputBackgroundClassNames,
|
|
12
|
-
getInputTextClasses,
|
|
13
|
-
getInputShape,
|
|
14
|
-
getLabelPlacement,
|
|
15
|
-
getLabelVisibility,
|
|
16
|
-
getSuccessColorClasses,
|
|
17
|
-
getErrorColorClasses,
|
|
18
|
-
getIconClasses,
|
|
19
|
-
inputButtonWithClasses,
|
|
20
|
-
} from "./inputClassNames";
|
|
5
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
21
6
|
|
|
22
7
|
const Input: React.FC<InputTypes> = ({
|
|
23
8
|
// FUNCTIONALITY
|
|
@@ -29,46 +14,41 @@ const Input: React.FC<InputTypes> = ({
|
|
|
29
14
|
// LABEL
|
|
30
15
|
label,
|
|
31
16
|
labelVisible = true,
|
|
32
|
-
labelPlacement,
|
|
33
|
-
|
|
17
|
+
labelPlacement = "block",
|
|
34
18
|
// INPUT DETAILS
|
|
35
19
|
inputName,
|
|
36
20
|
inputType,
|
|
37
|
-
|
|
38
21
|
// PLACEHOLDER
|
|
39
22
|
hasPlaceholder = true,
|
|
40
23
|
placeholder,
|
|
41
|
-
|
|
42
24
|
// ICONS
|
|
43
25
|
hasLeftIcon,
|
|
44
26
|
hasRightIcon,
|
|
45
27
|
leftIcon,
|
|
46
28
|
rightIcon,
|
|
47
|
-
iconColor,
|
|
48
|
-
iconBackgroundColor,
|
|
49
|
-
|
|
29
|
+
iconColor = "text-gray-500",
|
|
30
|
+
iconBackgroundColor = "bg-transparent",
|
|
50
31
|
// INPUT STYLES
|
|
51
|
-
inputTextSize,
|
|
52
|
-
inputShape,
|
|
53
|
-
borderColor = "
|
|
54
|
-
backgroundColor,
|
|
55
|
-
inputWidth,
|
|
56
|
-
errorBorder,
|
|
57
|
-
successBorder,
|
|
58
|
-
|
|
32
|
+
inputTextSize = "text-base",
|
|
33
|
+
inputShape = "rounded-md",
|
|
34
|
+
borderColor = "border-gray-300",
|
|
35
|
+
backgroundColor = "bg-white",
|
|
36
|
+
inputWidth = "w-full",
|
|
37
|
+
errorBorder = "border-red-500",
|
|
38
|
+
successBorder = "border-green-500",
|
|
59
39
|
// BUTTON
|
|
60
40
|
hasButton,
|
|
61
41
|
button = (
|
|
62
42
|
<FormButton
|
|
63
43
|
text="Submit"
|
|
64
44
|
as="button"
|
|
65
|
-
hoverBackground="green"
|
|
66
|
-
backgroundColor="red"
|
|
67
|
-
icon={
|
|
68
|
-
fontColor="white"
|
|
69
|
-
borderColor="green"
|
|
70
|
-
hoverFontColor="black"
|
|
71
|
-
shape="
|
|
45
|
+
hoverBackground="hover:bg-green-500"
|
|
46
|
+
backgroundColor="bg-red-500"
|
|
47
|
+
icon={getFontAwesomeIcon("arrow-right")}
|
|
48
|
+
fontColor="text-white"
|
|
49
|
+
borderColor="border-green-500"
|
|
50
|
+
hoverFontColor="hover:text-black"
|
|
51
|
+
shape="rounded-none"
|
|
72
52
|
additionalClasses="h-full"
|
|
73
53
|
/>
|
|
74
54
|
),
|
|
@@ -76,39 +56,19 @@ const Input: React.FC<InputTypes> = ({
|
|
|
76
56
|
const [isValid, setIsValid] = useState<string>("");
|
|
77
57
|
const [termInternal, setTermInternal] = useState<string>("");
|
|
78
58
|
const [inputBorderClasses, setInputBorderClasses] = useState<string>(
|
|
79
|
-
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
let iconClasses = getIconClasses(
|
|
83
|
-
iconColor,
|
|
84
|
-
iconBackgroundColor,
|
|
85
|
-
inputShape
|
|
59
|
+
borderColor
|
|
86
60
|
);
|
|
87
61
|
|
|
88
|
-
let errorColor = getErrorColorClasses(errorBorder);
|
|
89
|
-
let successColor = getSuccessColorClasses(successBorder);
|
|
90
|
-
let inputPaddingClasses = getInputPaddingClassNames(
|
|
91
|
-
hasButton,
|
|
92
|
-
hasLeftIcon,
|
|
93
|
-
hasRightIcon
|
|
94
|
-
);
|
|
95
|
-
let inputBackgroundClasses = getInputBackgroundClassNames(backgroundColor);
|
|
96
|
-
let inputShapeClasses = getInputShape(inputShape);
|
|
97
|
-
let inputWithButtonClasses = inputButtonWithClasses(inputShape);
|
|
98
|
-
let labelVisibility = getLabelVisibility(labelVisible);
|
|
99
|
-
let labelPlacementClasses = getLabelPlacement(labelPlacement);
|
|
100
|
-
let inputTextClasses = getInputTextClasses(inputTextSize);
|
|
101
|
-
let inputBorderColor = getInputBorderClassNames(borderColor);
|
|
102
62
|
const inputValue = termInternal || controlledState || "";
|
|
103
63
|
const setTerm = setControlledState || setTermInternal;
|
|
104
64
|
|
|
105
65
|
const handleBorderStyles = () => {
|
|
106
66
|
if (isValid !== "Success" && isValid !== "") {
|
|
107
|
-
setInputBorderClasses(
|
|
67
|
+
setInputBorderClasses(errorBorder);
|
|
108
68
|
} else if (isValid === "Success") {
|
|
109
|
-
setInputBorderClasses(
|
|
69
|
+
setInputBorderClasses(successBorder);
|
|
110
70
|
} else if (isValid === "") {
|
|
111
|
-
setInputBorderClasses(
|
|
71
|
+
setInputBorderClasses(borderColor);
|
|
112
72
|
}
|
|
113
73
|
};
|
|
114
74
|
|
|
@@ -127,62 +87,49 @@ const Input: React.FC<InputTypes> = ({
|
|
|
127
87
|
};
|
|
128
88
|
|
|
129
89
|
return (
|
|
130
|
-
<div
|
|
131
|
-
className={`${labelPlacementClasses} w-full`}
|
|
132
|
-
data-testid="input-container"
|
|
133
|
-
>
|
|
90
|
+
<div className={`${labelPlacement} w-full`} data-testid="input-container">
|
|
134
91
|
<label
|
|
135
|
-
htmlFor={
|
|
136
|
-
className={`${
|
|
92
|
+
htmlFor={inputName}
|
|
93
|
+
className={`${labelVisible ? "block" : "hidden"} pb-1 pl-1`}
|
|
137
94
|
data-testid="input-label"
|
|
138
95
|
>
|
|
139
96
|
{label}
|
|
140
97
|
</label>
|
|
141
98
|
{hasButton ? (
|
|
142
99
|
<div className={`relative ${inputWidth} flex`}>
|
|
143
|
-
<div className="flex-1">
|
|
100
|
+
<div className="flex-1 relative">
|
|
144
101
|
{hasLeftIcon && (
|
|
145
102
|
<div
|
|
146
|
-
className={`absolute bottom-1
|
|
103
|
+
className={`absolute bottom-1 left-1 flex items-center justify-center ${iconColor} ${iconBackgroundColor} h-8 w-8`}
|
|
147
104
|
>
|
|
148
105
|
{leftIcon}
|
|
149
106
|
</div>
|
|
150
107
|
)}
|
|
151
108
|
<input
|
|
152
109
|
type={inputType}
|
|
153
|
-
placeholder={
|
|
154
|
-
hasPlaceholder ? placeholder : undefined
|
|
155
|
-
}
|
|
110
|
+
placeholder={hasPlaceholder ? placeholder : undefined}
|
|
156
111
|
name={inputName}
|
|
157
112
|
id={inputName}
|
|
158
113
|
onChange={handleChange}
|
|
159
114
|
value={inputValue}
|
|
160
115
|
data-testid="input-element"
|
|
161
|
-
className={`block w-full border-2 p-2 ${
|
|
162
|
-
? inputBorderColor
|
|
163
|
-
: inputBorderClasses
|
|
164
|
-
}`}
|
|
116
|
+
className={`block w-full border-2 p-2 ${inputTextSize} ${inputShape} ${backgroundColor} ${inputBorderClasses} ${hasLeftIcon ? "pl-10" : ""} ${hasRightIcon ? "pr-10" : ""}`}
|
|
165
117
|
/>
|
|
166
118
|
</div>
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
{button}
|
|
176
|
-
</div>
|
|
177
|
-
</div>
|
|
178
|
-
)}
|
|
179
|
-
</div>
|
|
119
|
+
{hasButton && (
|
|
120
|
+
<div
|
|
121
|
+
className={`flex items-center justify-center ${inputShape} h-full`}
|
|
122
|
+
data-testid="submit-button"
|
|
123
|
+
>
|
|
124
|
+
{button}
|
|
125
|
+
</div>
|
|
126
|
+
)}
|
|
180
127
|
</div>
|
|
181
128
|
) : (
|
|
182
129
|
<div className={`relative ${inputWidth} flex`}>
|
|
183
130
|
{hasLeftIcon && (
|
|
184
131
|
<div
|
|
185
|
-
className={`absolute top-
|
|
132
|
+
className={`absolute top-1 left-1 flex items-center justify-center ${iconColor} ${iconBackgroundColor} h-8 w-8`}
|
|
186
133
|
>
|
|
187
134
|
{leftIcon}
|
|
188
135
|
</div>
|
|
@@ -195,30 +142,20 @@ const Input: React.FC<InputTypes> = ({
|
|
|
195
142
|
onChange={handleChange}
|
|
196
143
|
value={inputValue}
|
|
197
144
|
data-testid="input-element"
|
|
198
|
-
className={`block w-full border-2 ${
|
|
199
|
-
? inputBorderColor
|
|
200
|
-
: inputBorderClasses
|
|
201
|
-
}`}
|
|
145
|
+
className={`block w-full border-2 ${inputTextSize} ${inputShape} ${backgroundColor} ${inputBorderClasses} ${hasLeftIcon ? "pl-10" : ""} ${hasRightIcon ? "pr-10" : ""}`}
|
|
202
146
|
/>
|
|
203
147
|
{hasRightIcon && (
|
|
204
148
|
<div
|
|
205
|
-
className={`absolute
|
|
149
|
+
className={`absolute top-1 right-1 flex items-center justify-center ${iconColor} ${iconBackgroundColor} h-8 w-8`}
|
|
206
150
|
>
|
|
207
151
|
{rightIcon}
|
|
208
152
|
</div>
|
|
209
153
|
)}
|
|
210
|
-
{hasButton && (
|
|
211
|
-
<div
|
|
212
|
-
className={`${inputShape} flex items-center inset-y-0 end-1.5`}
|
|
213
|
-
data-testid="submit-button"
|
|
214
|
-
>
|
|
215
|
-
{button}
|
|
216
|
-
</div>
|
|
217
|
-
)}
|
|
218
154
|
</div>
|
|
219
155
|
)}
|
|
220
156
|
</div>
|
|
221
157
|
);
|
|
222
158
|
};
|
|
159
|
+
|
|
223
160
|
Input.displayName = "Memo(Input)";
|
|
224
161
|
export default Input;
|