@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,6 +1,5 @@
|
|
|
1
|
-
import { Meta } from "@storybook/react";
|
|
2
|
-
import GenericList from "./GenericList";
|
|
3
|
-
import GenericListTypes from "./GenericList";
|
|
1
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
2
|
+
import GenericList, { GenericListTypes } from "./GenericList";
|
|
4
3
|
import DynamicIconList from "./templates/DynamicIconList";
|
|
5
4
|
import DUMMYICONDATA from "../Header/DUMMYICONDATA.json";
|
|
6
5
|
import DUMMYLISTDATA from "./DUMMYLISTDATA.json";
|
|
@@ -59,9 +58,7 @@ export default {
|
|
|
59
58
|
},
|
|
60
59
|
} as Meta;
|
|
61
60
|
|
|
62
|
-
const Template:
|
|
63
|
-
<GenericList {...args} />
|
|
64
|
-
);
|
|
61
|
+
const Template: StoryFn<GenericListTypes<any>> = (args) => <GenericList {...args} />;
|
|
65
62
|
|
|
66
63
|
export const Default = Template.bind({});
|
|
67
64
|
Default.args = {
|
|
@@ -70,9 +67,7 @@ Default.args = {
|
|
|
70
67
|
itemHeight: 20,
|
|
71
68
|
containerHeight: 72,
|
|
72
69
|
hasVirtualization: true,
|
|
73
|
-
renderItem: (item: IconsListProps["item"]) =>
|
|
74
|
-
<DynamicIconList item={item} />
|
|
75
|
-
),
|
|
70
|
+
renderItem: (item: IconsListProps["item"]) => <DynamicIconList item={item} />,
|
|
76
71
|
listDirection: "horizontal",
|
|
77
72
|
listType: "none",
|
|
78
73
|
};
|
|
@@ -84,9 +79,7 @@ VerticalList.args = {
|
|
|
84
79
|
itemHeight: 150,
|
|
85
80
|
containerHeight: 300,
|
|
86
81
|
hasVirtualization: true,
|
|
87
|
-
renderItem: (item: IconsListProps["item"]) =>
|
|
88
|
-
<DynamicIconList item={item} />
|
|
89
|
-
),
|
|
82
|
+
renderItem: (item: IconsListProps["item"]) => <DynamicIconList item={item} />,
|
|
90
83
|
listDirection: "vertical",
|
|
91
84
|
listType: "none",
|
|
92
85
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { VirtualItem, useVirtualizer } from "@tanstack/react-virtual";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
|
-
import { getListDirectionClasses } from "./genericListClassNames";
|
|
5
4
|
|
|
6
5
|
type GenericData = {
|
|
7
6
|
id: string;
|
|
@@ -24,15 +23,15 @@ const GenericList = <T extends GenericData>({
|
|
|
24
23
|
renderItem,
|
|
25
24
|
itemHeight,
|
|
26
25
|
containerHeight,
|
|
27
|
-
containerClasses,
|
|
28
|
-
listDirection,
|
|
26
|
+
containerClasses = "",
|
|
27
|
+
listDirection = "vertical",
|
|
29
28
|
hasVirtualization = false,
|
|
30
|
-
listType,
|
|
29
|
+
listType = "none",
|
|
31
30
|
}: GenericListTypes<T>) => {
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const listClasses = listDirection === "horizontal" ? "flex flex-row" : "flex flex-col";
|
|
32
|
+
const parentRef = React.createRef<HTMLElement>();
|
|
34
33
|
|
|
35
|
-
const [virtualItems, setVirtualItems] = useState<VirtualItem[]>([]);
|
|
34
|
+
const [virtualItems, setVirtualItems] = useState<VirtualItem<Element>[]>([]);
|
|
36
35
|
const [nonVirtualItems, setNonVirtualItems] = useState<T[]>([]);
|
|
37
36
|
|
|
38
37
|
const estimateSize = useCallback(
|
|
@@ -58,89 +57,89 @@ const GenericList = <T extends GenericData>({
|
|
|
58
57
|
}, [hasVirtualization, virtualizer, data]);
|
|
59
58
|
|
|
60
59
|
return (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
)
|
|
144
|
-
}
|
|
60
|
+
<>
|
|
61
|
+
{(() => {
|
|
62
|
+
switch (listType) {
|
|
63
|
+
case "ordered":
|
|
64
|
+
return (
|
|
65
|
+
<ol
|
|
66
|
+
ref={parentRef as React.RefObject<HTMLOListElement>}
|
|
67
|
+
style={
|
|
68
|
+
hasVirtualization
|
|
69
|
+
? { height: containerHeight, overflow: "scroll" }
|
|
70
|
+
: {}
|
|
71
|
+
}
|
|
72
|
+
className={`${listClasses} ${containerClasses}`}
|
|
73
|
+
>
|
|
74
|
+
{hasVirtualization
|
|
75
|
+
? virtualItems.map((virtualItem) => (
|
|
76
|
+
<li
|
|
77
|
+
key={virtualItem.index}
|
|
78
|
+
style={{ height: itemHeight }}
|
|
79
|
+
>
|
|
80
|
+
{renderItem(data[virtualItem.index])}
|
|
81
|
+
</li>
|
|
82
|
+
))
|
|
83
|
+
: nonVirtualItems.map((item) => (
|
|
84
|
+
<li key={item.id}>{renderItem(item)}</li>
|
|
85
|
+
))}
|
|
86
|
+
</ol>
|
|
87
|
+
);
|
|
88
|
+
case "unordered":
|
|
89
|
+
return (
|
|
90
|
+
<ul
|
|
91
|
+
ref={parentRef as React.RefObject<HTMLUListElement>}
|
|
92
|
+
style={
|
|
93
|
+
hasVirtualization
|
|
94
|
+
? { height: containerHeight, overflow: "scroll" }
|
|
95
|
+
: {}
|
|
96
|
+
}
|
|
97
|
+
className={`${listClasses} ${containerClasses}`}
|
|
98
|
+
>
|
|
99
|
+
{hasVirtualization
|
|
100
|
+
? virtualItems.map((virtualItem) => (
|
|
101
|
+
<li
|
|
102
|
+
key={virtualItem.index}
|
|
103
|
+
style={{ height: itemHeight }}
|
|
104
|
+
>
|
|
105
|
+
{renderItem(data[virtualItem.index])}
|
|
106
|
+
</li>
|
|
107
|
+
))
|
|
108
|
+
: nonVirtualItems.map((item) => (
|
|
109
|
+
<li key={item.id}>{renderItem(item)}</li>
|
|
110
|
+
))}
|
|
111
|
+
</ul>
|
|
112
|
+
);
|
|
113
|
+
case "none":
|
|
114
|
+
default:
|
|
115
|
+
return (
|
|
116
|
+
<div
|
|
117
|
+
ref={parentRef as React.RefObject<HTMLDivElement>}
|
|
118
|
+
style={
|
|
119
|
+
hasVirtualization
|
|
120
|
+
? { height: containerHeight, overflow: "scroll" }
|
|
121
|
+
: {}
|
|
122
|
+
}
|
|
123
|
+
className={`${listClasses} ${containerClasses}`}
|
|
124
|
+
>
|
|
125
|
+
{hasVirtualization
|
|
126
|
+
? virtualItems.map((virtualItem) => (
|
|
127
|
+
<div
|
|
128
|
+
key={virtualItem.index}
|
|
129
|
+
style={{ height: itemHeight }}
|
|
130
|
+
>
|
|
131
|
+
{renderItem(data[virtualItem.index])}
|
|
132
|
+
</div>
|
|
133
|
+
))
|
|
134
|
+
: nonVirtualItems.map((item) => (
|
|
135
|
+
<div key={item.id}>{renderItem(item)}</div>
|
|
136
|
+
))}
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
})()}
|
|
141
|
+
</>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
145
144
|
|
|
146
145
|
export default GenericList;
|
|
@@ -1,74 +1,55 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import IconButton from "../../IconButton/index";
|
|
3
3
|
import { getFontAwesomeIcon } from "../../../utils/getFontAwesomeIcon";
|
|
4
|
-
import Text from "../../Text/index";
|
|
5
4
|
import { TagName } from "../../Text/index";
|
|
6
5
|
|
|
7
|
-
export type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
tag: TagName;
|
|
32
|
-
additionalClasses: string;
|
|
33
|
-
};
|
|
6
|
+
export type IconButtonsListProps = {
|
|
7
|
+
id: string;
|
|
8
|
+
iconColor?: string;
|
|
9
|
+
iconLabel?: string; // Ensure this matches IconButtonTypes if necessary
|
|
10
|
+
backgroundColor?: string;
|
|
11
|
+
size?: "xs" | "sm" | "md" | "lg" | string;
|
|
12
|
+
icon: string;
|
|
13
|
+
hoverBorder?: "border" | "none" | string;
|
|
14
|
+
limitCharacters?: (text: string) => string;
|
|
15
|
+
indicatorSize?: "sm" | "md" | "lg" | string;
|
|
16
|
+
iconBorder?: "border" | "none" | string;
|
|
17
|
+
hoverBackground: string;
|
|
18
|
+
hoverColor: string;
|
|
19
|
+
limitIndicator: boolean;
|
|
20
|
+
indicatorNumber: string;
|
|
21
|
+
additionalContainerClasses: string;
|
|
22
|
+
onClick?: () => void;
|
|
23
|
+
text: {
|
|
24
|
+
size: string;
|
|
25
|
+
color: string;
|
|
26
|
+
text: string;
|
|
27
|
+
fontFamily: string;
|
|
28
|
+
tag: TagName;
|
|
29
|
+
additionalClasses: string;
|
|
34
30
|
};
|
|
31
|
+
to?: string;
|
|
32
|
+
href?: string;
|
|
35
33
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const DynamicIconList: React.FC<IconsListProps> = ({ item }) => {
|
|
34
|
+
|
|
35
|
+
const DynamicIconButtonList: React.FC<IconButtonsListProps> = (props) => {
|
|
39
36
|
return (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
indicatorNumber={item.indicatorNumber}
|
|
56
|
-
indicatorSize={item.indicatorSize}
|
|
57
|
-
hoverColor={item.hoverColor}
|
|
58
|
-
additionalContainerClasses={item.additionalContainerClasses}
|
|
59
|
-
text={
|
|
60
|
-
<Text
|
|
61
|
-
size={item.text.size}
|
|
62
|
-
color={item.text.color}
|
|
63
|
-
text={item.text.text}
|
|
64
|
-
fontFamily={item.text.fontFamily}
|
|
65
|
-
tag={item.text.tag}
|
|
66
|
-
additionalClasses={item.text.additionalClasses}
|
|
67
|
-
/>
|
|
68
|
-
}
|
|
69
|
-
/>
|
|
70
|
-
</>
|
|
37
|
+
<IconButton
|
|
38
|
+
key={props.id}
|
|
39
|
+
onClick={props.onClick}
|
|
40
|
+
backgroundColor={props.backgroundColor}
|
|
41
|
+
iconColor={props.iconColor}
|
|
42
|
+
iconLabel={props.iconLabel}
|
|
43
|
+
iconBorder={props.iconBorder}
|
|
44
|
+
icon={getFontAwesomeIcon(props.icon)}
|
|
45
|
+
hoverBackgroundColor={props.hoverBackground}
|
|
46
|
+
hoverBorderColor={props.hoverBorder}
|
|
47
|
+
indicatorNumber={props.indicatorNumber}
|
|
48
|
+
indicatorSize={props.indicatorSize}
|
|
49
|
+
additionalContainerClasses={props.additionalContainerClasses}
|
|
50
|
+
text={props.text.text}
|
|
51
|
+
/>
|
|
71
52
|
);
|
|
72
53
|
};
|
|
73
54
|
|
|
74
|
-
export default
|
|
55
|
+
export default DynamicIconButtonList;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
2
|
+
import GetSupport from "./GetSupport";
|
|
3
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Components/GetSupport",
|
|
7
|
+
component: GetSupport,
|
|
8
|
+
argTypes: {
|
|
9
|
+
to: {
|
|
10
|
+
control: "none",
|
|
11
|
+
description: "URL to navigate to when the button is clicked.",
|
|
12
|
+
},
|
|
13
|
+
icon: {
|
|
14
|
+
control: "none",
|
|
15
|
+
description: "FontAwesome icon to be displayed.",
|
|
16
|
+
},
|
|
17
|
+
iconClasses: {
|
|
18
|
+
control: "none",
|
|
19
|
+
description: "Tailwind CSS classes for icon styling.",
|
|
20
|
+
},
|
|
21
|
+
title: {
|
|
22
|
+
control: "none",
|
|
23
|
+
description: "The main title text.",
|
|
24
|
+
},
|
|
25
|
+
titleClasses: {
|
|
26
|
+
control: "none",
|
|
27
|
+
description: "Tailwind CSS classes for title styling.",
|
|
28
|
+
},
|
|
29
|
+
subTitle: {
|
|
30
|
+
control: "none",
|
|
31
|
+
description: "Optional subtitle text.",
|
|
32
|
+
},
|
|
33
|
+
subTitleClasses: {
|
|
34
|
+
control: "none",
|
|
35
|
+
description: "Tailwind CSS classes for subtitle styling.",
|
|
36
|
+
},
|
|
37
|
+
containerClasses: {
|
|
38
|
+
control: "none",
|
|
39
|
+
description: "Tailwind CSS classes for container styling.",
|
|
40
|
+
},
|
|
41
|
+
as: {
|
|
42
|
+
control: "none",
|
|
43
|
+
description: "The element type to use for the button.",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
tags: ["autodocs"],
|
|
47
|
+
} as Meta;
|
|
48
|
+
|
|
49
|
+
const Template: StoryFn = (args) => (
|
|
50
|
+
<GetSupport to={""} icon={null} title={""} {...args} />
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
export const Default = Template.bind({});
|
|
54
|
+
Default.args = {
|
|
55
|
+
icon: getFontAwesomeIcon("phone"),
|
|
56
|
+
as: "a",
|
|
57
|
+
to: "/support",
|
|
58
|
+
title: "Get Support",
|
|
59
|
+
iconClasses:
|
|
60
|
+
"p-4 bg-slate-600 text-white group-hover:text-slate-600 rounded-full group-hover:bg-slate-200",
|
|
61
|
+
titleClasses: "text-xl font-bold",
|
|
62
|
+
subTitle: "1-800-123-4567",
|
|
63
|
+
subTitleClasses: "text-md text-gray-500",
|
|
64
|
+
containerClasses:
|
|
65
|
+
"flex items-center gap-4 p-2 bg-white rounded-lg hover:cursor-pointer group",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const WithoutPhoneNumber = Template.bind({});
|
|
69
|
+
WithoutPhoneNumber.args = {
|
|
70
|
+
icon: getFontAwesomeIcon("phone"),
|
|
71
|
+
as: "a",
|
|
72
|
+
to: "/support",
|
|
73
|
+
title: "Get Support",
|
|
74
|
+
iconClasses:
|
|
75
|
+
"p-4 bg-slate-600 text-white group-hover:text-slate-600 rounded-full group-hover:bg-slate-200",
|
|
76
|
+
titleClasses: "text-xl font-bold",
|
|
77
|
+
subTitleClasses: "text-md text-gray-500",
|
|
78
|
+
containerClasses:
|
|
79
|
+
"flex items-center gap-4 p-2 bg-white rounded-lg hover:cursor-pointer group",
|
|
80
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import GetSupport from './GetSupport';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
|
|
6
|
+
describe('GetSupport Component', () => {
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
as: 'link',
|
|
9
|
+
to: '/support',
|
|
10
|
+
icon: <div>Icon</div>,
|
|
11
|
+
iconClasses: 'p-2 w-12 h-12 bg-gray-200 rounded-full',
|
|
12
|
+
title: 'Get Support',
|
|
13
|
+
titleClasses: 'text-xl font-bold',
|
|
14
|
+
subTitle: '1-800-123-4567',
|
|
15
|
+
subTitleClasses: 'text-md text-gray-500',
|
|
16
|
+
containerClasses: 'flex items-center gap-4 p-2 bg-white rounded-lg',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
it('renders without crashing', () => {
|
|
20
|
+
render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
|
|
21
|
+
expect(screen.getByText('Get Support')).toBeInTheDocument();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('renders the title', () => {
|
|
25
|
+
render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
|
|
26
|
+
expect(screen.getByText('Get Support')).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('renders the subtitle', () => {
|
|
30
|
+
render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
|
|
31
|
+
expect(screen.getByText('1-800-123-4567')).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('applies container classes', () => {
|
|
35
|
+
render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
|
|
36
|
+
const container = screen.getByRole('link').firstChild;
|
|
37
|
+
expect(container).toHaveClass('flex items-center gap-4 p-2 bg-white rounded-lg');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('applies title classes', () => {
|
|
41
|
+
render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
|
|
42
|
+
const title = screen.getByText('Get Support');
|
|
43
|
+
expect(title).toHaveClass('text-xl font-bold');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('applies subtitle classes', () => {
|
|
47
|
+
render(<GetSupport {...defaultProps} />, { wrapper: MemoryRouter });
|
|
48
|
+
const subTitle = screen.getByText('1-800-123-4567');
|
|
49
|
+
expect(subTitle).toHaveClass('text-md text-gray-500');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('renders without subtitle', () => {
|
|
53
|
+
const { container } = render(
|
|
54
|
+
<GetSupport
|
|
55
|
+
{...defaultProps}
|
|
56
|
+
subTitle={undefined}
|
|
57
|
+
/>,
|
|
58
|
+
{ wrapper: MemoryRouter }
|
|
59
|
+
);
|
|
60
|
+
expect(container.querySelector('.text-md.text-gray-500')).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import FormButton from "../FormButton/FormButton";
|
|
3
|
+
import Text from "../Text/Text";
|
|
4
|
+
import { GetSupportTypes } from "./GetSupport.types";
|
|
5
|
+
|
|
6
|
+
const GetSupport: React.FC<GetSupportTypes> = ({
|
|
7
|
+
as,
|
|
8
|
+
to,
|
|
9
|
+
icon,
|
|
10
|
+
iconClasses,
|
|
11
|
+
title,
|
|
12
|
+
titleClasses,
|
|
13
|
+
subTitle,
|
|
14
|
+
subTitleClasses,
|
|
15
|
+
containerClasses,
|
|
16
|
+
}) => {
|
|
17
|
+
return (
|
|
18
|
+
<FormButton
|
|
19
|
+
as={as}
|
|
20
|
+
to={to}
|
|
21
|
+
text={
|
|
22
|
+
<div className={`flex items-center gap-4 ${containerClasses}`}>
|
|
23
|
+
<div
|
|
24
|
+
className={`flex items-center justify-center ${iconClasses}`}
|
|
25
|
+
>
|
|
26
|
+
{icon}
|
|
27
|
+
</div>
|
|
28
|
+
<div className="flex flex-col">
|
|
29
|
+
<Text
|
|
30
|
+
size="text-md"
|
|
31
|
+
color="text-black"
|
|
32
|
+
text={title}
|
|
33
|
+
fontFamily="font-serif"
|
|
34
|
+
tag="p"
|
|
35
|
+
additionalClasses={titleClasses}
|
|
36
|
+
/>
|
|
37
|
+
{subTitle && (
|
|
38
|
+
<Text
|
|
39
|
+
size="text-md"
|
|
40
|
+
color="text-black"
|
|
41
|
+
text={subTitle}
|
|
42
|
+
fontFamily="font-serif"
|
|
43
|
+
tag="p"
|
|
44
|
+
additionalClasses={subTitleClasses}
|
|
45
|
+
/>
|
|
46
|
+
)}
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
}
|
|
50
|
+
backgroundColor="bg-transparent"
|
|
51
|
+
fontColor="text-black"
|
|
52
|
+
borderColor="border-none"
|
|
53
|
+
shape="rounded-md"
|
|
54
|
+
additionalClasses={containerClasses}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default GetSupport;
|