@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
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryFn } from "@storybook/react";
|
|
2
|
-
import Text from "../Text/Text";
|
|
3
|
-
import Icon from ".";
|
|
4
|
-
import { IconTypes } from ".";
|
|
5
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
6
|
-
import {
|
|
7
|
-
faUser,
|
|
8
|
-
faCircleInfo,
|
|
9
|
-
faBell,
|
|
10
|
-
faCartShopping,
|
|
11
|
-
faCircleQuestion,
|
|
12
|
-
} from "@fortawesome/free-solid-svg-icons";
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
title: "Components/Icon",
|
|
16
|
-
component: Icon,
|
|
17
|
-
argTypes: {
|
|
18
|
-
iconColor: {
|
|
19
|
-
control: "select",
|
|
20
|
-
options: ["blue", "green", "black"],
|
|
21
|
-
description: "The icon color.",
|
|
22
|
-
},
|
|
23
|
-
backgroundColor: {
|
|
24
|
-
control: "select",
|
|
25
|
-
options: ["blue", "green", "grey", "none"],
|
|
26
|
-
description: "The background color.",
|
|
27
|
-
},
|
|
28
|
-
size: {
|
|
29
|
-
control: "select",
|
|
30
|
-
options: ["sm", "md", "lg"],
|
|
31
|
-
description: "The icon size.",
|
|
32
|
-
},
|
|
33
|
-
iconBorder: {
|
|
34
|
-
control: "select",
|
|
35
|
-
options: ["border", "none"],
|
|
36
|
-
description: "Whether there is a border around the icon.",
|
|
37
|
-
},
|
|
38
|
-
hoverColor: {
|
|
39
|
-
control: "select",
|
|
40
|
-
options: ["green", "blue", "black"],
|
|
41
|
-
description: "The icon and text color on hover.",
|
|
42
|
-
},
|
|
43
|
-
hoverBackground: {
|
|
44
|
-
control: "select",
|
|
45
|
-
options: ["blue", "green", "grey", "none"],
|
|
46
|
-
description: "The background color of the icon on hover.",
|
|
47
|
-
},
|
|
48
|
-
hoverBorder: {
|
|
49
|
-
control: "select",
|
|
50
|
-
options: ["border", "none"],
|
|
51
|
-
description: "Whether there is a border around the icon on hover.",
|
|
52
|
-
},
|
|
53
|
-
limitIndicator: {
|
|
54
|
-
control: "boolean",
|
|
55
|
-
description:
|
|
56
|
-
"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+'.",
|
|
57
|
-
},
|
|
58
|
-
indicatorNumber: {
|
|
59
|
-
control: "text",
|
|
60
|
-
description:
|
|
61
|
-
"The value of notifications that is shown in the indicator. Note: if the indicator number is '' or '0', the indicator will not be displayed.",
|
|
62
|
-
},
|
|
63
|
-
indicatorSize: {
|
|
64
|
-
control: "select",
|
|
65
|
-
options: ["sm", "md", "lg"],
|
|
66
|
-
description:
|
|
67
|
-
"The indicator size displaying notifications. Note: if the indicator size is 'lg', it is recommended that the icon size is also set to 'lg'.",
|
|
68
|
-
},
|
|
69
|
-
iconLabel: {
|
|
70
|
-
table: {
|
|
71
|
-
disable: true,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
onClick: {
|
|
75
|
-
table: {
|
|
76
|
-
disable: true,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
to: {
|
|
80
|
-
table: {
|
|
81
|
-
disable: true,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
text: {
|
|
85
|
-
control: "text",
|
|
86
|
-
description: "The text that is displayed below the icon.",
|
|
87
|
-
},
|
|
88
|
-
icon: {
|
|
89
|
-
table: {
|
|
90
|
-
disable: true,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
href: {
|
|
94
|
-
table: {
|
|
95
|
-
disable: true,
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
additionalContainerClasses: {
|
|
99
|
-
table: {
|
|
100
|
-
disable: true,
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
limitCharacters: {
|
|
104
|
-
table: {
|
|
105
|
-
disable: true,
|
|
106
|
-
},
|
|
107
|
-
description:
|
|
108
|
-
"Pass a function to limit the number of characters in the text.",
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
tags: ["autodocs"],
|
|
112
|
-
parameters: {
|
|
113
|
-
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
114
|
-
layout: "centered",
|
|
115
|
-
},
|
|
116
|
-
} as Meta;
|
|
117
|
-
|
|
118
|
-
const Template: StoryFn<IconTypes> = (args) => <Icon {...args} />;
|
|
119
|
-
|
|
120
|
-
export const Profile = Template.bind({});
|
|
121
|
-
Profile.args = {
|
|
122
|
-
iconColor: "green",
|
|
123
|
-
iconLabel: "Profile",
|
|
124
|
-
backgroundColor: "green",
|
|
125
|
-
size: "sm",
|
|
126
|
-
icon: <FontAwesomeIcon icon={faUser} />,
|
|
127
|
-
hoverBackground: "none",
|
|
128
|
-
hoverColor: "green",
|
|
129
|
-
indicatorNumber: "0",
|
|
130
|
-
text: (
|
|
131
|
-
<Text
|
|
132
|
-
size="text-md"
|
|
133
|
-
color="text-black"
|
|
134
|
-
fontFamily="font-serif"
|
|
135
|
-
text="Profile"
|
|
136
|
-
tag="h2"
|
|
137
|
-
additionalClasses="p-0"
|
|
138
|
-
/>
|
|
139
|
-
),
|
|
140
|
-
onClick: () => alert("Redirect to profile"),
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export const Support = Template.bind({});
|
|
144
|
-
Support.args = {
|
|
145
|
-
iconColor: "black",
|
|
146
|
-
iconLabel: "Support",
|
|
147
|
-
backgroundColor: "grey",
|
|
148
|
-
size: "sm",
|
|
149
|
-
icon: <FontAwesomeIcon icon={faCircleInfo} />,
|
|
150
|
-
hoverBackground: "none",
|
|
151
|
-
hoverColor: "blue",
|
|
152
|
-
indicatorNumber: "100",
|
|
153
|
-
limitIndicator: true,
|
|
154
|
-
indicatorSize: "lg",
|
|
155
|
-
text: (
|
|
156
|
-
<Text
|
|
157
|
-
size="text-md"
|
|
158
|
-
color="text-black"
|
|
159
|
-
fontFamily="font-serif"
|
|
160
|
-
text="Support"
|
|
161
|
-
tag="h2"
|
|
162
|
-
additionalClasses="p-0"
|
|
163
|
-
/>
|
|
164
|
-
),
|
|
165
|
-
onClick: () => alert("Redirect to support"),
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export const Messages = Template.bind({});
|
|
169
|
-
Messages.args = {
|
|
170
|
-
iconColor: "black",
|
|
171
|
-
iconLabel: "Messages",
|
|
172
|
-
backgroundColor: "grey",
|
|
173
|
-
size: "sm",
|
|
174
|
-
icon: <FontAwesomeIcon icon={faBell} />,
|
|
175
|
-
hoverBackground: "none",
|
|
176
|
-
hoverColor: "blue",
|
|
177
|
-
indicatorNumber: "12",
|
|
178
|
-
indicatorSize: "sm",
|
|
179
|
-
text: (
|
|
180
|
-
<Text
|
|
181
|
-
size="text-md"
|
|
182
|
-
color="text-black"
|
|
183
|
-
fontFamily="font-serif"
|
|
184
|
-
text="Messages"
|
|
185
|
-
tag="h2"
|
|
186
|
-
additionalClasses="p-0"
|
|
187
|
-
/>
|
|
188
|
-
),
|
|
189
|
-
onClick: () => alert("Redirect to messages"),
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export const Cart = Template.bind({});
|
|
193
|
-
Cart.args = {
|
|
194
|
-
iconColor: "blue",
|
|
195
|
-
iconLabel: "Cart",
|
|
196
|
-
size: "lg",
|
|
197
|
-
icon: <FontAwesomeIcon icon={faCartShopping} />,
|
|
198
|
-
hoverBackground: "blue",
|
|
199
|
-
hoverColor: "none",
|
|
200
|
-
indicatorNumber: "",
|
|
201
|
-
indicatorSize: "lg",
|
|
202
|
-
text: (
|
|
203
|
-
<Text
|
|
204
|
-
size="text-md"
|
|
205
|
-
color="text-black"
|
|
206
|
-
fontFamily="font-serif"
|
|
207
|
-
text="Cart"
|
|
208
|
-
tag="h2"
|
|
209
|
-
additionalClasses="p-0"
|
|
210
|
-
/>
|
|
211
|
-
),
|
|
212
|
-
onClick: () => alert("Redirect to cart"),
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
export const NoText = Template.bind({});
|
|
216
|
-
NoText.args = {
|
|
217
|
-
iconColor: "blue",
|
|
218
|
-
iconLabel: "Question",
|
|
219
|
-
backgroundColor: "grey",
|
|
220
|
-
size: "lg",
|
|
221
|
-
icon: <FontAwesomeIcon icon={faCircleQuestion} />,
|
|
222
|
-
hoverBackground: "grey",
|
|
223
|
-
hoverColor: "black",
|
|
224
|
-
iconBorder: "border",
|
|
225
|
-
indicatorNumber: "100",
|
|
226
|
-
onClick: () => alert("Redirect to question page"),
|
|
227
|
-
};
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Link } from "react-router-dom";
|
|
3
|
-
import { IconTypes } from "./Icon.types";
|
|
4
|
-
import {
|
|
5
|
-
getBorderClasses,
|
|
6
|
-
getColorClasses,
|
|
7
|
-
getHoverClasses,
|
|
8
|
-
getIndicatorSizeClasses,
|
|
9
|
-
getSizeClasses,
|
|
10
|
-
getIndicatorColorClasses,
|
|
11
|
-
getBackgroundColorClasses,
|
|
12
|
-
} from "./iconClassNames";
|
|
13
|
-
|
|
14
|
-
const containerSizeMap = {
|
|
15
|
-
xs: "size-8",
|
|
16
|
-
sm: "size-8",
|
|
17
|
-
md: "size-10",
|
|
18
|
-
lg: "size-10",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const Icon: React.FC<IconTypes> = ({
|
|
22
|
-
onClick,
|
|
23
|
-
text,
|
|
24
|
-
iconLabel,
|
|
25
|
-
iconColor = "black",
|
|
26
|
-
backgroundColor = "none",
|
|
27
|
-
size = "md",
|
|
28
|
-
icon,
|
|
29
|
-
iconBorder = "none",
|
|
30
|
-
additionalContainerClasses,
|
|
31
|
-
to,
|
|
32
|
-
href,
|
|
33
|
-
hoverBackground = "primary",
|
|
34
|
-
hoverColor = "blue",
|
|
35
|
-
hoverBorder,
|
|
36
|
-
indicatorSize = "md",
|
|
37
|
-
indicatorNumber,
|
|
38
|
-
limitIndicator = true,
|
|
39
|
-
limitCharacters = (text: string) => {
|
|
40
|
-
if (text.length > 12) {
|
|
41
|
-
window.confirm(
|
|
42
|
-
`Text length is ${text.length} characters, and should be less than or equal to 12.`
|
|
43
|
-
);
|
|
44
|
-
return text.slice(0, 12);
|
|
45
|
-
}
|
|
46
|
-
return text;
|
|
47
|
-
},
|
|
48
|
-
}) => {
|
|
49
|
-
let ariaLabel;
|
|
50
|
-
let ariaNotification = indicatorNumber;
|
|
51
|
-
let iconSizeClasses = getSizeClasses(size);
|
|
52
|
-
let iconColorClasses = getColorClasses(iconColor);
|
|
53
|
-
let containerSize = containerSizeMap[size as keyof typeof containerSizeMap];
|
|
54
|
-
let iconName = icon?.props.icon.iconName;
|
|
55
|
-
let iconClasses = ` flex flex-col justify-center
|
|
56
|
-
${iconSizeClasses}
|
|
57
|
-
`;
|
|
58
|
-
let backgroundColorClasses = getBackgroundColorClasses(backgroundColor);
|
|
59
|
-
let hoverClasses = getHoverClasses(
|
|
60
|
-
hoverBackground,
|
|
61
|
-
hoverColor,
|
|
62
|
-
hoverBorder
|
|
63
|
-
);
|
|
64
|
-
let indicatorSizeClasses = getIndicatorSizeClasses(indicatorSize);
|
|
65
|
-
let indicatorColorClasses = getIndicatorColorClasses(iconColor);
|
|
66
|
-
let borderClasses = getBorderClasses(iconColor, iconBorder as "none" | "border" | undefined);
|
|
67
|
-
|
|
68
|
-
let isIndicatorRedCircle = indicatorSize === "sm";
|
|
69
|
-
|
|
70
|
-
if (indicatorNumber && parseInt(indicatorNumber) > 99 && limitIndicator) {
|
|
71
|
-
indicatorNumber = "99+";
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (typeof text === "string" && limitCharacters) {
|
|
75
|
-
text = limitCharacters(text);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// if there is no text for the icon and no notifications, screen reader needs label to be announced for link
|
|
79
|
-
if (ariaNotification == "" && !text) {
|
|
80
|
-
ariaLabel = `${iconLabel}`;
|
|
81
|
-
|
|
82
|
-
// if there is no text for the icon and the icon has notifications, screen reader needs label to be announced type of link and number of notifications
|
|
83
|
-
// OR
|
|
84
|
-
// if there is text for the icon and the icon has notifications, screen reader needs label to be announced type of link and number of notifications because either
|
|
85
|
-
// way the ariaLabel will override the text
|
|
86
|
-
} else if (
|
|
87
|
-
(ariaNotification !== "" && !text) ||
|
|
88
|
-
(ariaNotification !== "" && text)
|
|
89
|
-
) {
|
|
90
|
-
ariaLabel = `${iconLabel} with ${ariaNotification} notifications`;
|
|
91
|
-
} else {
|
|
92
|
-
ariaLabel = "null";
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (to) {
|
|
96
|
-
return (
|
|
97
|
-
<div>
|
|
98
|
-
<Link
|
|
99
|
-
to={to}
|
|
100
|
-
onClick={onClick}
|
|
101
|
-
tabIndex={0}
|
|
102
|
-
className={`flex flex-col items-center justify-center`}
|
|
103
|
-
aria-label={ariaLabel}
|
|
104
|
-
>
|
|
105
|
-
<div
|
|
106
|
-
data-testid="icon"
|
|
107
|
-
className={`flex flex-col items-center justify-center ${containerSize} ${hoverClasses} ${borderClasses} ${iconColorClasses} ${backgroundColorClasses} ${additionalContainerClasses}`}
|
|
108
|
-
>
|
|
109
|
-
<div className="flex h-full">
|
|
110
|
-
<span
|
|
111
|
-
data-testid={iconName}
|
|
112
|
-
className={iconClasses}
|
|
113
|
-
>
|
|
114
|
-
{icon}
|
|
115
|
-
</span>
|
|
116
|
-
{indicatorNumber &&
|
|
117
|
-
parseInt(indicatorNumber) !== 0 &&
|
|
118
|
-
!isIndicatorRedCircle ? (
|
|
119
|
-
<div
|
|
120
|
-
className="indicator"
|
|
121
|
-
data-testid="indicator"
|
|
122
|
-
>
|
|
123
|
-
<span
|
|
124
|
-
className={` ${indicatorSizeClasses} ${indicatorColorClasses}`}
|
|
125
|
-
>
|
|
126
|
-
<p className="flex items-center justify-center h-full w-full">
|
|
127
|
-
{indicatorNumber}
|
|
128
|
-
</p>
|
|
129
|
-
</span>
|
|
130
|
-
</div>
|
|
131
|
-
) : null}
|
|
132
|
-
{isIndicatorRedCircle &&
|
|
133
|
-
indicatorNumber &&
|
|
134
|
-
parseInt(indicatorNumber) !== 0 ? (
|
|
135
|
-
<div
|
|
136
|
-
className="indicator"
|
|
137
|
-
data-testid="indicator"
|
|
138
|
-
>
|
|
139
|
-
<span
|
|
140
|
-
className={`${indicatorSizeClasses}`}
|
|
141
|
-
/>
|
|
142
|
-
</div>
|
|
143
|
-
) : null}
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
{text && <div className="">{text}</div>}
|
|
147
|
-
</Link>
|
|
148
|
-
</div>
|
|
149
|
-
);
|
|
150
|
-
} else {
|
|
151
|
-
return (
|
|
152
|
-
<div>
|
|
153
|
-
<a
|
|
154
|
-
href={href}
|
|
155
|
-
onClick={onClick}
|
|
156
|
-
tabIndex={0}
|
|
157
|
-
className={`flex flex-col items-center justify-center p-2 relative min-w-14`}
|
|
158
|
-
aria-label={ariaLabel}
|
|
159
|
-
>
|
|
160
|
-
<div
|
|
161
|
-
data-testid="icon"
|
|
162
|
-
className={`flex flex-col items-center justify-center ${containerSize} ${hoverClasses} ${borderClasses} ${iconColorClasses} ${backgroundColorClasses} ${additionalContainerClasses}`}
|
|
163
|
-
>
|
|
164
|
-
<div className="flex h-full">
|
|
165
|
-
<span
|
|
166
|
-
data-testid={iconName}
|
|
167
|
-
className={iconClasses}
|
|
168
|
-
>
|
|
169
|
-
{icon}
|
|
170
|
-
</span>
|
|
171
|
-
{indicatorNumber &&
|
|
172
|
-
parseInt(indicatorNumber) !== 0 &&
|
|
173
|
-
!isIndicatorRedCircle ? (
|
|
174
|
-
<div
|
|
175
|
-
className="indicator"
|
|
176
|
-
data-testid="indicator"
|
|
177
|
-
>
|
|
178
|
-
<span
|
|
179
|
-
className={` ${indicatorSizeClasses} ${indicatorColorClasses}`}
|
|
180
|
-
>
|
|
181
|
-
<p className="flex items-center justify-center h-full w-full">
|
|
182
|
-
{indicatorNumber}
|
|
183
|
-
</p>
|
|
184
|
-
</span>
|
|
185
|
-
</div>
|
|
186
|
-
) : null}
|
|
187
|
-
{isIndicatorRedCircle &&
|
|
188
|
-
indicatorNumber &&
|
|
189
|
-
parseInt(indicatorNumber) !== 0 ? (
|
|
190
|
-
<div
|
|
191
|
-
className="indicator"
|
|
192
|
-
data-testid="indicator"
|
|
193
|
-
>
|
|
194
|
-
<span
|
|
195
|
-
className={`${indicatorSizeClasses}`}
|
|
196
|
-
/>
|
|
197
|
-
</div>
|
|
198
|
-
) : null}
|
|
199
|
-
</div>
|
|
200
|
-
</div>
|
|
201
|
-
{text && <div className="absolute top-10 ">{text}</div>}
|
|
202
|
-
</a>
|
|
203
|
-
</div>
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export default Icon;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
export interface IconTypes {
|
|
4
|
-
onClick?: (
|
|
5
|
-
e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>
|
|
6
|
-
) => void;
|
|
7
|
-
text?: ReactNode;
|
|
8
|
-
iconColor?: string;
|
|
9
|
-
iconLabel: string;
|
|
10
|
-
backgroundColor?: string;
|
|
11
|
-
size?: "xs" | "sm" | "md" | "lg" | "xl" | string;
|
|
12
|
-
icon: JSX.Element | null;
|
|
13
|
-
iconBorder?: "border" | "none" | string;
|
|
14
|
-
to?: string;
|
|
15
|
-
href?: string;
|
|
16
|
-
additionalContainerClasses?: string;
|
|
17
|
-
hoverColor: "green" | "blue" | string;
|
|
18
|
-
hoverBackground: "blue" | "green" | "grey" | "none" | string;
|
|
19
|
-
hoverBorder?: "border" | "none" | string;
|
|
20
|
-
limitCharacters?: (text: string) => string;
|
|
21
|
-
indicatorSize?: "xs" | "sm" | "md" | "lg" | string;
|
|
22
|
-
indicatorNumber?: string;
|
|
23
|
-
limitIndicator?: boolean;
|
|
24
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import classNames from "classNames";
|
|
2
|
-
|
|
3
|
-
export const getSizeClasses = (size: string) => {
|
|
4
|
-
return classNames({
|
|
5
|
-
"text-md": size === "sm",
|
|
6
|
-
"text-lg": size === "md",
|
|
7
|
-
"text-xl": size === "lg",
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const getColorClasses = (iconColor: string) => {
|
|
12
|
-
return classNames({
|
|
13
|
-
"text-blue-800": iconColor === "blue",
|
|
14
|
-
"text-teal-800": iconColor === "green",
|
|
15
|
-
"text-slate-950": iconColor === "black",
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const getBackgroundColorClasses = (backgroundColor: string) => {
|
|
20
|
-
return classNames({
|
|
21
|
-
"bg-blue-100": backgroundColor === "blue",
|
|
22
|
-
"bg-teal-100": backgroundColor === "green",
|
|
23
|
-
"bg-slate-100": backgroundColor === "grey",
|
|
24
|
-
"bg-transparent": backgroundColor === "none",
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const getHoverClasses = (
|
|
29
|
-
hoverBackground: string | undefined,
|
|
30
|
-
hoverColor: string | undefined,
|
|
31
|
-
hoverBorder: string | undefined
|
|
32
|
-
) => {
|
|
33
|
-
return classNames(
|
|
34
|
-
"cursor-pointer",
|
|
35
|
-
{
|
|
36
|
-
"hover:bg-blue-100": hoverBackground === "blue",
|
|
37
|
-
"hover:bg-teal-50": hoverBackground === "green",
|
|
38
|
-
"hover:bg-gray-100": hoverBackground === "grey",
|
|
39
|
-
"hover:bg-transparent": hoverBackground === "none",
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"hover:text-teal-800 hover:border-teal-600": hoverColor === "green",
|
|
43
|
-
"hover:text-blue-800 hover:border-blue-800": hoverColor === "blue",
|
|
44
|
-
"hover:text-slate-950 hover:border-slate-950": hoverColor === "black",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"hover:border-transparent": hoverBorder === "none",
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const getIndicatorSizeClasses = (indicatorSize: string | undefined) => {
|
|
53
|
-
return classNames({
|
|
54
|
-
"size-[.5rem] rounded-full bg-red-500 absolute top-0":
|
|
55
|
-
indicatorSize === "sm",
|
|
56
|
-
"text-[.5rem] items-center justify-center h-4 w-4 rounded-full absolute top-[-4px] left-[-1px]":
|
|
57
|
-
indicatorSize === "md",
|
|
58
|
-
"text-[.65rem] items-center justify-center rounded-full h-5 w-5 absolute top-[-5px] left-[-1px]":
|
|
59
|
-
indicatorSize === "lg",
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const getIndicatorColorClasses = (color: string | undefined) => {
|
|
64
|
-
return classNames({
|
|
65
|
-
"bg-blue-800 text-white border-none": color === "blue",
|
|
66
|
-
"bg-teal-600 text-white border-none": color === "green",
|
|
67
|
-
"bg-black text-white border-none": color === "black",
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const getBorderClasses = (
|
|
72
|
-
color: string | undefined,
|
|
73
|
-
iconBorder: "border" | "none" | undefined
|
|
74
|
-
) => {
|
|
75
|
-
return classNames("cursor-pointer", "border-2", "rounded-full", {
|
|
76
|
-
[`border-${color}-500`]: iconBorder === "border",
|
|
77
|
-
"border-transparent": iconBorder === "none",
|
|
78
|
-
});
|
|
79
|
-
};
|