@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.
- 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 +5 -6
- 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
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Link } from "react-router-dom";
|
|
3
2
|
import { BadgeTypes } from "./Badge.types";
|
|
4
3
|
|
|
5
4
|
const Badge: React.FC<BadgeTypes> = ({
|
|
6
|
-
onClick,
|
|
7
|
-
cursorPointer = true,
|
|
8
|
-
type = "span",
|
|
9
|
-
to,
|
|
10
|
-
href,
|
|
11
|
-
testId,
|
|
12
|
-
hoverColor,
|
|
13
5
|
borderColor,
|
|
14
|
-
borderHoverColor,
|
|
15
6
|
borderWidth,
|
|
16
7
|
borderRadius,
|
|
17
8
|
backgroundColor,
|
|
@@ -26,99 +17,38 @@ const Badge: React.FC<BadgeTypes> = ({
|
|
|
26
17
|
text,
|
|
27
18
|
badgeContainerClasses,
|
|
28
19
|
}) => {
|
|
29
|
-
const baseBadgeContainerClasses = "flex items-center justify-center px-[10px] py-[3px] rounded gap-[4px]";
|
|
30
20
|
const iconClasses = `${iconSize}`;
|
|
31
|
-
const badgeBackgroundClasses = `${backgroundColor}
|
|
32
|
-
const badgeBorderClasses = `${borderWidth} ${borderColor} ${borderRadius}
|
|
33
|
-
const
|
|
34
|
-
const badgeClasses = `${cursorClasses} ${baseBadgeContainerClasses} ${badgeBorderClasses} ${badgeContainerClasses} ${badgeBackgroundClasses}`;
|
|
21
|
+
const badgeBackgroundClasses = `${backgroundColor}`;
|
|
22
|
+
const badgeBorderClasses = `${borderWidth} ${borderColor} ${borderRadius}`;
|
|
23
|
+
const badgeClasses = `inline-flex items-center ${badgeBorderClasses} ${badgeBackgroundClasses} ${badgeContainerClasses}`;
|
|
35
24
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
switch (type) {
|
|
50
|
-
case "href":
|
|
51
|
-
return (
|
|
52
|
-
<>
|
|
53
|
-
<a {...baseProps} href={href} className={badgeClasses}>
|
|
54
|
-
{renderContent()}
|
|
55
|
-
</a>
|
|
56
|
-
</>
|
|
57
|
-
);
|
|
58
|
-
case "to":
|
|
59
|
-
if (to) {
|
|
60
|
-
return (
|
|
61
|
-
<>
|
|
62
|
-
<Link
|
|
63
|
-
{...baseProps}
|
|
64
|
-
to={to}
|
|
65
|
-
className={badgeClasses}
|
|
66
|
-
>
|
|
67
|
-
{renderContent()}
|
|
68
|
-
</Link>
|
|
69
|
-
</>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
break;
|
|
73
|
-
case "span":
|
|
74
|
-
return (
|
|
75
|
-
<>
|
|
76
|
-
<span className={badgeClasses}>{renderContent()}</span>
|
|
77
|
-
</>
|
|
78
|
-
);
|
|
79
|
-
default:
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function renderContent() {
|
|
84
|
-
return (
|
|
85
|
-
<>
|
|
86
|
-
{image && <span>{image}</span>}
|
|
87
|
-
{icon && hasLeftIcon && (
|
|
88
|
-
<span
|
|
89
|
-
className={`${iconClasses} max-md:hidden`}
|
|
90
|
-
data-testid="badge-icon"
|
|
91
|
-
>
|
|
92
|
-
<>{icon}</>
|
|
93
|
-
</span>
|
|
94
|
-
)}
|
|
95
|
-
{mobileIcon && hasMobileStyle && (
|
|
96
|
-
<span
|
|
97
|
-
className={`${iconClasses} hidden max-md:flex max-md:p-0`}
|
|
98
|
-
data-testid="mobile-badge-icon"
|
|
99
|
-
aria-hidden="false"
|
|
100
|
-
aria-label={mobileIconLabel}
|
|
101
|
-
>
|
|
102
|
-
<>{mobileIcon}</>
|
|
103
|
-
</span>
|
|
104
|
-
)}
|
|
105
|
-
<div
|
|
106
|
-
className={` ${hasMobileStyle ? "max-md:hidden" : ""} `}
|
|
107
|
-
data-testid="badge-text"
|
|
25
|
+
return (
|
|
26
|
+
<span className={badgeClasses}>
|
|
27
|
+
{image && <span className="mr-2">{image}</span>}
|
|
28
|
+
{icon && hasLeftIcon && (
|
|
29
|
+
<span className={`${iconClasses} max-md:hidden mr-2`}>
|
|
30
|
+
{icon}
|
|
31
|
+
</span>
|
|
32
|
+
)}
|
|
33
|
+
{mobileIcon && hasMobileStyle && (
|
|
34
|
+
<span
|
|
35
|
+
className={`${iconClasses} hidden max-md:flex max-md:p-0 mr-2`}
|
|
36
|
+
aria-hidden="false"
|
|
37
|
+
aria-label={mobileIconLabel}
|
|
108
38
|
>
|
|
109
|
-
{
|
|
110
|
-
</
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
39
|
+
{mobileIcon}
|
|
40
|
+
</span>
|
|
41
|
+
)}
|
|
42
|
+
<div className={`${hasMobileStyle ? "max-md:hidden" : ""}`}>
|
|
43
|
+
{text}
|
|
44
|
+
</div>
|
|
45
|
+
{icon && hasRightIcon && (
|
|
46
|
+
<span className={`${iconClasses} max-md:hidden ml-2`}>
|
|
47
|
+
{icon}
|
|
48
|
+
</span>
|
|
49
|
+
)}
|
|
50
|
+
</span>
|
|
51
|
+
);
|
|
122
52
|
};
|
|
123
53
|
|
|
124
54
|
export default Badge;
|
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
|
|
3
3
|
export interface BadgeTypes {
|
|
4
|
-
onClick?: (
|
|
5
|
-
|
|
6
|
-
) => void;
|
|
7
|
-
text?: React.ReactNode;
|
|
4
|
+
onClick?: (e: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void;
|
|
5
|
+
text?: ReactNode;
|
|
8
6
|
cursorPointer?: boolean;
|
|
9
7
|
type: "href" | "to" | "span";
|
|
10
|
-
image?:
|
|
11
|
-
borderColor?: string
|
|
12
|
-
backgroundColor?: string
|
|
13
|
-
borderWidth?: string
|
|
14
|
-
borderRadius?: string
|
|
15
|
-
borderHoverColor?: string
|
|
8
|
+
image?: ReactNode;
|
|
9
|
+
borderColor?: string;
|
|
10
|
+
backgroundColor?: string;
|
|
11
|
+
borderWidth?: string;
|
|
12
|
+
borderRadius?: string;
|
|
13
|
+
borderHoverColor?: string;
|
|
16
14
|
hoverColor?: string;
|
|
17
15
|
to?: string;
|
|
18
16
|
href?: string;
|
|
19
17
|
hasMobileStyle?: boolean;
|
|
20
|
-
mobileIcon?:
|
|
18
|
+
mobileIcon?: ReactNode;
|
|
21
19
|
mobileIconLabel?: string;
|
|
22
|
-
icon?:
|
|
20
|
+
icon?: ReactNode;
|
|
23
21
|
hasLeftIcon?: boolean;
|
|
24
22
|
hasRightIcon?: boolean;
|
|
25
23
|
badgeContainerClasses?: string;
|
|
26
|
-
iconSize?: string
|
|
27
|
-
|
|
28
|
-
// STORYBOOK PROP TYPES
|
|
29
|
-
color?: string | undefined;
|
|
30
|
-
badgeSize?: string | undefined;
|
|
31
|
-
iconOrder?: "first" | "last";
|
|
32
|
-
children?: React.ReactNode;
|
|
24
|
+
iconSize?: string;
|
|
33
25
|
testId?: string;
|
|
34
|
-
textSize?: string;
|
|
35
|
-
fontColor?: string | undefined;
|
|
36
|
-
additionalClasses?: string;
|
|
37
26
|
}
|
|
@@ -1,35 +1,41 @@
|
|
|
1
1
|
import { Meta, StoryFn } from "@storybook/react";
|
|
2
2
|
import Card from "./Card";
|
|
3
|
-
import type { CardTypes } from ".";
|
|
3
|
+
import type { CardTypes } from "./Card.types";
|
|
4
4
|
import {
|
|
5
5
|
DUMMYPRODUCTDATA,
|
|
6
6
|
DUMMYCOMPASSPRODUCTDATA,
|
|
7
|
+
DUMMYCATEGORYCARDDATA,
|
|
7
8
|
} from "./DUMMYPRODUCTDATA.json";
|
|
8
9
|
import HorizontalCardTemplate from "./templates/HorizontalCardTemplate";
|
|
9
10
|
import VerticalCardTemplate from "./templates/VerticalCardTemplate";
|
|
10
11
|
import CompassCardTemplate from "./templates/CompassCardTemplate";
|
|
12
|
+
import CategoryCardTemplate from "./templates/CategoryCardTemplate";
|
|
13
|
+
import ItemCardTemplate from "./templates/ItemCardTemplate";
|
|
14
|
+
import KitContentCardTemplate from "./templates/KitContentCardTemplate";
|
|
15
|
+
import ShippingAddressCardTemplate from "./templates/ShippingAddressCardTemplate";
|
|
16
|
+
import CounterContentCardTemplate from "./templates/CounterContentCardTemplate";
|
|
11
17
|
|
|
12
18
|
export default {
|
|
13
19
|
title: "Components/Card",
|
|
14
20
|
component: Card,
|
|
15
21
|
argTypes: {
|
|
16
22
|
cardBorderRadius: {
|
|
17
|
-
control: "
|
|
18
|
-
options: ["
|
|
23
|
+
control: "none",
|
|
24
|
+
options: ["rounded-none", "rounded-sm", "rounded-md", "rounded-lg", "rounded-full"],
|
|
19
25
|
description: "The border radius of the card.",
|
|
20
26
|
},
|
|
21
27
|
cardBackgroundColor: {
|
|
22
|
-
control: "
|
|
23
|
-
options: ["
|
|
28
|
+
control: "none",
|
|
29
|
+
options: ["bg-blue-100", "bg-teal-100", "bg-slate-50", "bg-white"],
|
|
24
30
|
description: "The background color of the card.",
|
|
25
31
|
},
|
|
26
32
|
cardBorderColor: {
|
|
27
|
-
control: "
|
|
28
|
-
options: ["blue", "
|
|
33
|
+
control: "none",
|
|
34
|
+
options: ["border-blue-500", "border-teal-500", "border-slate-50", "border-none"],
|
|
29
35
|
description: "The color of the card border.",
|
|
30
36
|
},
|
|
31
37
|
cardBoxShadow: {
|
|
32
|
-
control: "
|
|
38
|
+
control: "none",
|
|
33
39
|
description: "Whether the card has box shadow or not.",
|
|
34
40
|
},
|
|
35
41
|
children: {
|
|
@@ -52,7 +58,7 @@ export default {
|
|
|
52
58
|
parameters: {
|
|
53
59
|
layout: "centered",
|
|
54
60
|
},
|
|
55
|
-
} as Meta
|
|
61
|
+
} as Meta<CardTypes>;
|
|
56
62
|
|
|
57
63
|
const Template: StoryFn<CardTypes> = (args) => <Card {...args} />;
|
|
58
64
|
|
|
@@ -60,22 +66,38 @@ export const Default = Template.bind({});
|
|
|
60
66
|
Default.args = {
|
|
61
67
|
containerClasses: "flex w-full max-sm:w-1/2 max-sm:flex-col",
|
|
62
68
|
key: DUMMYPRODUCTDATA[0].id,
|
|
63
|
-
cardBorderRadius: "
|
|
64
|
-
cardBorderColor: "blue",
|
|
65
|
-
cardBackgroundColor: "
|
|
69
|
+
cardBorderRadius: "rounded-md",
|
|
70
|
+
cardBorderColor: "border-blue-500",
|
|
71
|
+
cardBackgroundColor: "bg-blue-100",
|
|
66
72
|
cardBoxShadow: false,
|
|
67
73
|
children: <HorizontalCardTemplate data={DUMMYPRODUCTDATA[0]} />,
|
|
68
74
|
};
|
|
69
75
|
|
|
70
76
|
export const VerticalCard = Template.bind({});
|
|
71
77
|
VerticalCard.args = {
|
|
72
|
-
containerClasses: "w-1/2 max-sm:w-1/2overflow-hidden rounded-md",
|
|
73
78
|
key: DUMMYPRODUCTDATA[0].id,
|
|
74
|
-
cardBorderRadius: "
|
|
75
|
-
cardBorderColor: "
|
|
76
|
-
cardBackgroundColor: "
|
|
77
|
-
cardBoxShadow:
|
|
78
|
-
children:
|
|
79
|
+
cardBorderRadius: "rounded-lg",
|
|
80
|
+
cardBorderColor: "border-none",
|
|
81
|
+
cardBackgroundColor: "bg-none",
|
|
82
|
+
cardBoxShadow: false,
|
|
83
|
+
children: (
|
|
84
|
+
<VerticalCardTemplate
|
|
85
|
+
data={{
|
|
86
|
+
...DUMMYPRODUCTDATA[4],
|
|
87
|
+
badgeText: "Kit",
|
|
88
|
+
description: "2 included items, 2 required add-ons",
|
|
89
|
+
imageUrl: "../../../assets/card-1.jpg",
|
|
90
|
+
altText: "Product Image",
|
|
91
|
+
}}
|
|
92
|
+
containerClasses="flex flex-col items-center w-full max-w-[320px] sm:max-w-[408px] h-auto sm:h-[500px] border border-[#DFE4EA] bg-white rounded-lg relative hover:border-1 hover:border-teal-600 hover:shadow-inner"
|
|
93
|
+
imageContainerClasses="flex justify-center items-center w-2/3 h-64 sm:h-20 gap-2 flex-1 p-5"
|
|
94
|
+
titleContainerClasses="flex flex-col items-start gap-1 m-2 sm:m-5 text-sm sm:text-base"
|
|
95
|
+
descriptionContainerClasses="flex items-center mb-2 sm:mb-5 text-xs sm:text-xs"
|
|
96
|
+
priceContainerClasses="flex items-end justify-between w-full text-sm sm:text-base"
|
|
97
|
+
buttonContainerClasses="w-16 sm:w-24 px-2 sm:px-3 py-1 sm:py-2 text-xs sm:text-sm sm:p-3 hover:bg-teal-800"
|
|
98
|
+
badgeContainerClasses="absolute top-2 sm:top-5 left-2 sm:left-5 text-xs sm:text-sm"
|
|
99
|
+
/>
|
|
100
|
+
),
|
|
79
101
|
};
|
|
80
102
|
|
|
81
103
|
export const CompassCard = Template.bind({});
|
|
@@ -83,9 +105,131 @@ CompassCard.args = {
|
|
|
83
105
|
containerClasses:
|
|
84
106
|
"w-1/2 max-sm:w-1/2 overflow-hidden rounded-md transition ease-in-out delay-150 hover:-translate-y-1 hover:scale-110 duration-300",
|
|
85
107
|
key: DUMMYCOMPASSPRODUCTDATA[0].id,
|
|
86
|
-
cardBorderRadius: "
|
|
87
|
-
cardBorderColor: "
|
|
88
|
-
cardBackgroundColor: "
|
|
108
|
+
cardBorderRadius: "rounded-none",
|
|
109
|
+
cardBorderColor: "border-teal-500",
|
|
110
|
+
cardBackgroundColor: "bg-teal-500",
|
|
89
111
|
cardBoxShadow: true,
|
|
90
|
-
children:
|
|
112
|
+
children: (
|
|
113
|
+
<CompassCardTemplate
|
|
114
|
+
data={{
|
|
115
|
+
title: "Card Title",
|
|
116
|
+
...DUMMYCOMPASSPRODUCTDATA[0],
|
|
117
|
+
imageBackgroundColor: "",
|
|
118
|
+
textBackgroundColor: "",
|
|
119
|
+
}}
|
|
120
|
+
/>
|
|
121
|
+
),
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const CategoryCard = Template.bind({});
|
|
125
|
+
CategoryCard.args = {
|
|
126
|
+
key: DUMMYCATEGORYCARDDATA[0].id,
|
|
127
|
+
cardBorderRadius: "rounded-md",
|
|
128
|
+
cardBorderColor: "border-none",
|
|
129
|
+
cardBackgroundColor: "bg-white",
|
|
130
|
+
cardBoxShadow: false,
|
|
131
|
+
children: (
|
|
132
|
+
<CategoryCardTemplate
|
|
133
|
+
data={{
|
|
134
|
+
...DUMMYCATEGORYCARDDATA[0],
|
|
135
|
+
productCount: DUMMYCATEGORYCARDDATA[0].productCount,
|
|
136
|
+
imageBackgroundColor: "bg-white",
|
|
137
|
+
textBackgroundColor: "text-black",
|
|
138
|
+
titleProps: {
|
|
139
|
+
tag: "h3",
|
|
140
|
+
size: "text-lg",
|
|
141
|
+
fontColor: "text-black",
|
|
142
|
+
fontFamily: "font-sans",
|
|
143
|
+
additionalClasses: "font-bold",
|
|
144
|
+
},
|
|
145
|
+
}}
|
|
146
|
+
containerClasses="flex flex-col items-center w-full max-w-[320px] sm:max-w-[408px] h-auto border border-gray-300 bg-white rounded-lg hover:border-teal-600 hover:shadow-inner"
|
|
147
|
+
imageContainerClasses="flex items-center justify-center w-full h-full object-contain sm:h-[300px] p-4"
|
|
148
|
+
titleClasses="text-center mt-2 sm:mt-4"
|
|
149
|
+
productCountClasses="text-gray-500 text-sm mt-2"
|
|
150
|
+
/>
|
|
151
|
+
),
|
|
91
152
|
};
|
|
153
|
+
|
|
154
|
+
export const ItemCard = Template.bind({});
|
|
155
|
+
ItemCard.args = {
|
|
156
|
+
key: DUMMYPRODUCTDATA[1].id,
|
|
157
|
+
cardBorderRadius: "rounded-lg",
|
|
158
|
+
cardBorderColor: "border-none",
|
|
159
|
+
cardBackgroundColor: "bg-white",
|
|
160
|
+
cardBoxShadow: false,
|
|
161
|
+
children: (
|
|
162
|
+
<ItemCardTemplate
|
|
163
|
+
data={{
|
|
164
|
+
...DUMMYPRODUCTDATA[1],
|
|
165
|
+
badgeText: "In Stock",
|
|
166
|
+
description: "USB - Microphone - Battery - Black, Silver",
|
|
167
|
+
}}
|
|
168
|
+
containerClasses="flex flex-col items-center w-full max-w-[408px] sm:max-w-full border border-[#DFE4EA] bg-white rounded-lg relative hover:border-teal-600 hover:shadow-inner"
|
|
169
|
+
imageContainerClasses="flex justify-center items-center w-full h-36 sm:h-64 p-2 sm:p-4"
|
|
170
|
+
titleContainerClasses="flex flex-col items-start gap-1 px-2 sm:px-5 pb-2 sm:pb-5"
|
|
171
|
+
descriptionContainerClasses="flex flex-col"
|
|
172
|
+
priceContainerClasses="flex items-center justify-between w-full"
|
|
173
|
+
buttonContainerClasses="px-3 py-1 sm:px-5 sm:py-2"
|
|
174
|
+
badgeContainerClasses="absolute top-3 left-3 sm:top-5 sm:left-5"
|
|
175
|
+
/>
|
|
176
|
+
),
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const KitContentCard = Template.bind({});
|
|
180
|
+
KitContentCard.args = {
|
|
181
|
+
key: DUMMYPRODUCTDATA[0].id,
|
|
182
|
+
cardBorderRadius: "rounded-lg",
|
|
183
|
+
cardBorderColor: "border-none",
|
|
184
|
+
cardBackgroundColor: "bg-none",
|
|
185
|
+
cardBoxShadow: false,
|
|
186
|
+
children: (
|
|
187
|
+
<KitContentCardTemplate
|
|
188
|
+
data={{
|
|
189
|
+
...DUMMYPRODUCTDATA[2],
|
|
190
|
+
badgeText: "In Stock",
|
|
191
|
+
description: "",
|
|
192
|
+
}}
|
|
193
|
+
/>
|
|
194
|
+
),
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export const ShippingAddressCard = Template.bind({});
|
|
198
|
+
ShippingAddressCard.args = {
|
|
199
|
+
key: DUMMYPRODUCTDATA[0].id,
|
|
200
|
+
cardBorderRadius: "rounded-lg",
|
|
201
|
+
cardBorderColor: "border-none",
|
|
202
|
+
cardBackgroundColor: "bg-none",
|
|
203
|
+
cardBoxShadow: false,
|
|
204
|
+
children: (
|
|
205
|
+
<ShippingAddressCardTemplate
|
|
206
|
+
data={{
|
|
207
|
+
...DUMMYPRODUCTDATA[2],
|
|
208
|
+
imageUrl: "../../../assets/map.png",
|
|
209
|
+
badgeText: "Primary",
|
|
210
|
+
title: "Tech Solutions Inc.",
|
|
211
|
+
addressLine1: "789 Oak Avenue",
|
|
212
|
+
addressLine2: "Suite 300",
|
|
213
|
+
addressLine3: "Springfield, IL 62701, US",
|
|
214
|
+
}}
|
|
215
|
+
/>
|
|
216
|
+
),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export const CounterContentCard = Template.bind({});
|
|
220
|
+
CounterContentCard.args = {
|
|
221
|
+
key: DUMMYPRODUCTDATA[0].id,
|
|
222
|
+
cardBorderRadius: "rounded-lg",
|
|
223
|
+
cardBorderColor: "border-none",
|
|
224
|
+
cardBackgroundColor: "bg-none",
|
|
225
|
+
cardBoxShadow: false,
|
|
226
|
+
children: (
|
|
227
|
+
<CounterContentCardTemplate
|
|
228
|
+
data={{
|
|
229
|
+
...DUMMYPRODUCTDATA[5],
|
|
230
|
+
badgeText: "In Stock",
|
|
231
|
+
description: "3.28 ft USB Data Transfer Cable for iPad Pro, Power Adapter - First End: 1 x USB 3.1 Type C - Male - Second End: 1 x USB 3.1 Type C - Male - 10 Gbit/s - White",
|
|
232
|
+
}}
|
|
233
|
+
/>
|
|
234
|
+
),
|
|
235
|
+
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { render, screen } from "@testing-library/react";
|
|
2
2
|
import { describe, expect, beforeEach, test } from "vitest";
|
|
3
3
|
import Card from "./Card";
|
|
4
|
-
import {
|
|
4
|
+
import { DUMMYPRODUCTDATA } from "./DUMMYPRODUCTDATA.json";
|
|
5
5
|
import CompassCardTemplate from "./templates/CompassCardTemplate";
|
|
6
6
|
|
|
7
7
|
describe("<Card />", () => {
|
|
8
8
|
beforeEach(() => {
|
|
9
9
|
render(
|
|
10
10
|
<Card
|
|
11
|
-
key={
|
|
11
|
+
key={DUMMYPRODUCTDATA[0].id}
|
|
12
12
|
cardBorderRadius="cornered"
|
|
13
13
|
cardBorderColor="green"
|
|
14
14
|
cardBackgroundColor="none"
|
|
15
15
|
cardBoxShadow={true}
|
|
16
16
|
containerClasses="w-1/2 max-sm:w-1/2"
|
|
17
|
-
children={<CompassCardTemplate data={
|
|
17
|
+
children={<CompassCardTemplate data={{ ...DUMMYPRODUCTDATA[0], imageBackgroundColor: "", textBackgroundColor: "" }} />}
|
|
18
18
|
/>
|
|
19
19
|
);
|
|
20
20
|
});
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { CardTypes } from "./Card.types";
|
|
3
|
-
import { getCardStyleClasses } from "./cardClassNames";
|
|
4
3
|
|
|
5
4
|
const Card: React.FC<CardTypes> = ({
|
|
6
5
|
children,
|
|
7
|
-
containerClasses,
|
|
8
|
-
cardBackgroundColor,
|
|
9
|
-
cardBorderColor,
|
|
10
|
-
cardBorderRadius,
|
|
11
|
-
cardBoxShadow,
|
|
6
|
+
containerClasses = "",
|
|
7
|
+
cardBackgroundColor = "bg-white",
|
|
8
|
+
cardBorderColor = "border-gray-300",
|
|
9
|
+
cardBorderRadius = "rounded-lg",
|
|
10
|
+
cardBoxShadow = true,
|
|
12
11
|
}) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
cardBorderColor
|
|
16
|
-
|
|
17
|
-
cardBoxShadow
|
|
18
|
-
|
|
12
|
+
const cardStyleClasses = `
|
|
13
|
+
${cardBackgroundColor}
|
|
14
|
+
${cardBorderColor !== "none" ? `border ${cardBorderColor}` : ""}
|
|
15
|
+
${cardBorderRadius}
|
|
16
|
+
${cardBoxShadow ? true : ""}
|
|
17
|
+
`;
|
|
19
18
|
|
|
20
19
|
return (
|
|
21
|
-
<div
|
|
22
|
-
className={`${containerClasses} ${cardStyleClasses}`}
|
|
23
|
-
data-testid="card-container"
|
|
24
|
-
>
|
|
20
|
+
<div className={`${containerClasses} ${cardStyleClasses}`} data-testid="card-container">
|
|
25
21
|
{children}
|
|
26
22
|
</div>
|
|
27
23
|
);
|