@agilant/toga-blox 1.0.8 → 1.0.10
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/Text/Text.stories.tsx +47 -10
- package/src/components/Text/Text.test.tsx +10 -17
- package/src/components/Toaster/Toaster.stories.tsx +69 -78
- package/src/components/Toaster/Toaster.test.tsx +49 -43
- package/src/components/Toaster/Toaster.tsx +43 -56
- package/src/components/Toaster/Toaster.types.ts +9 -8
- 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 +17 -2
- 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,122 +1,113 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
import Toaster, { ToasterTypes } from ".";
|
|
2
|
+
import Toaster from ".";
|
|
4
3
|
import { Meta, StoryFn } from "@storybook/react";
|
|
5
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
6
|
-
import { faCheck, faExclamation, faX } from "@fortawesome/free-solid-svg-icons";
|
|
7
4
|
|
|
8
5
|
export default {
|
|
9
6
|
title: "Components/Toaster",
|
|
10
7
|
component: Toaster,
|
|
11
8
|
argTypes: {
|
|
12
|
-
color: {
|
|
13
|
-
control: "select",
|
|
14
|
-
description: "The main color displayed on the toaster",
|
|
15
|
-
options: ["green-800", "red-800", "blue-800", "orange-800"],
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
icon: {
|
|
19
|
-
table: {
|
|
20
|
-
disable: true,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
title: {
|
|
24
|
-
table: {
|
|
25
|
-
disable: true,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
9
|
message: {
|
|
29
|
-
control: "
|
|
30
|
-
description:
|
|
10
|
+
control: "array",
|
|
11
|
+
description:
|
|
12
|
+
"The main messages displayed on the toaster, passed as an array.",
|
|
31
13
|
},
|
|
32
14
|
additionalClasses: {
|
|
33
|
-
table: {
|
|
34
|
-
disable: true,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
clearText: {
|
|
38
15
|
control: "text",
|
|
39
16
|
description:
|
|
40
|
-
"
|
|
41
|
-
},
|
|
42
|
-
hasClearText: {
|
|
43
|
-
control: "boolean",
|
|
44
|
-
description: "must be set to true to display the clear text button",
|
|
45
|
-
},
|
|
46
|
-
fullColor: {
|
|
47
|
-
control: "boolean",
|
|
48
|
-
description: "toggle the background color of toaster",
|
|
17
|
+
"Additional Tailwind CSS classes for the toaster container.",
|
|
49
18
|
},
|
|
50
|
-
|
|
19
|
+
hasClearButton: {
|
|
51
20
|
control: "boolean",
|
|
52
|
-
description: "
|
|
21
|
+
description: "Toggle to show or hide the clear message button.",
|
|
53
22
|
},
|
|
54
23
|
clearMessage: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
24
|
+
action: "Message Cleared!",
|
|
25
|
+
},
|
|
26
|
+
statusProps: {
|
|
27
|
+
control: "object",
|
|
28
|
+
description:
|
|
29
|
+
"Object containing colorClass and optional icon config.",
|
|
58
30
|
},
|
|
59
31
|
},
|
|
60
|
-
|
|
61
32
|
tags: ["autodocs"],
|
|
62
33
|
parameters: {
|
|
63
|
-
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
64
34
|
layout: "centered",
|
|
65
35
|
},
|
|
66
36
|
} as Meta;
|
|
67
37
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const Template: StoryFn<ToasterTypes> = (args) => (
|
|
71
|
-
<div className="">
|
|
72
|
-
<Toaster {...args} />
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
38
|
+
const Template: StoryFn = (args) => <Toaster message={[]} {...args} />;
|
|
75
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Default
|
|
42
|
+
*/
|
|
76
43
|
export const Default = Template.bind({});
|
|
77
44
|
Default.args = {
|
|
78
|
-
message: "Your action was successful!",
|
|
79
|
-
|
|
45
|
+
message: ["Your action was successful!"],
|
|
46
|
+
statusProps: {
|
|
47
|
+
// Pass the literal Tailwind classes instead of color: "green"
|
|
48
|
+
colorClass: "bg-green-100 border border-green-500 text-green-800",
|
|
49
|
+
},
|
|
50
|
+
additionalClasses: "p-5",
|
|
80
51
|
};
|
|
81
52
|
|
|
53
|
+
/**
|
|
54
|
+
* WithIconFail
|
|
55
|
+
*/
|
|
82
56
|
export const WithIconFail = Template.bind({});
|
|
83
57
|
WithIconFail.args = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
58
|
+
message: ["Your action failed!"],
|
|
59
|
+
statusProps: {
|
|
60
|
+
// Red variant
|
|
61
|
+
colorClass: "bg-red-100 border border-red-500 text-red-800",
|
|
62
|
+
icon: { icon: "x", type: "solid" },
|
|
63
|
+
},
|
|
64
|
+
additionalClasses: "p-5",
|
|
89
65
|
};
|
|
90
66
|
|
|
67
|
+
/**
|
|
68
|
+
* WithIconSuccess
|
|
69
|
+
*/
|
|
91
70
|
export const WithIconSuccess = Template.bind({});
|
|
92
71
|
WithIconSuccess.args = {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
72
|
+
message: ["Action completed successfully!"],
|
|
73
|
+
statusProps: {
|
|
74
|
+
// Green variant
|
|
75
|
+
colorClass: "bg-green-100 border border-green-600 text-green-800",
|
|
76
|
+
icon: { icon: "circleCheck", type: "solid" },
|
|
77
|
+
},
|
|
78
|
+
additionalClasses: "p-5",
|
|
97
79
|
};
|
|
98
80
|
|
|
81
|
+
/**
|
|
82
|
+
* WithIconAlert
|
|
83
|
+
*/
|
|
99
84
|
export const WithIconAlert = Template.bind({});
|
|
100
85
|
WithIconAlert.args = {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
message: ["Alert: Are you sure?"],
|
|
87
|
+
statusProps: {
|
|
88
|
+
// Gray variant
|
|
89
|
+
colorClass: "bg-yellow-100 border border-yellow-500 text-yellow-800",
|
|
90
|
+
icon: { icon: "triangleExclamation", type: "solid" },
|
|
91
|
+
},
|
|
92
|
+
additionalClasses: "p-5",
|
|
106
93
|
};
|
|
107
94
|
|
|
95
|
+
/**
|
|
96
|
+
* HasClearMessage
|
|
97
|
+
*/
|
|
108
98
|
export const HasClearMessage = Template.bind({});
|
|
109
99
|
HasClearMessage.args = {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
clearMessage: () =>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
100
|
+
message: [
|
|
101
|
+
"Message can be cleared and input has different padding from the additionalClasses prop",
|
|
102
|
+
],
|
|
103
|
+
hasClearButton: true,
|
|
104
|
+
clearMessage: () => {
|
|
105
|
+
alert("Message Cleared!");
|
|
106
|
+
},
|
|
107
|
+
statusProps: {
|
|
108
|
+
// Orange variant
|
|
109
|
+
colorClass: "bg-orange-100 border border-orange-500 text-orange-800",
|
|
110
|
+
icon: { icon: "circleCheck", type: "solid" },
|
|
111
|
+
},
|
|
112
|
+
additionalClasses: "py-2 px-5",
|
|
122
113
|
};
|
|
@@ -1,61 +1,67 @@
|
|
|
1
|
-
import { render, screen
|
|
2
|
-
import
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { describe, expect, test, vi } from "vitest";
|
|
3
4
|
import Toaster from "./Toaster";
|
|
4
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
5
|
-
import { faCoffee, faTimes } from "@fortawesome/free-solid-svg-icons";
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
render(<Toaster message="Test Message" color="green-500" />);
|
|
10
|
-
expect(screen.getByTestId("toaster")).toHaveTextContent("Test Message");
|
|
11
|
-
expect(screen.getByTestId("toaster")).toHaveClass("border-green-500");
|
|
12
|
-
});
|
|
6
|
+
const testId = "toaster-test-id";
|
|
7
|
+
const testMessage = "Test Message";
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/>
|
|
9
|
+
describe("Toaster Component Tests", () => {
|
|
10
|
+
test("renders the FA icon when passed in props", () => {
|
|
11
|
+
const customStatusProps = {
|
|
12
|
+
icon: { icon: "circleCheck", type: "solid" as "solid" },
|
|
13
|
+
};
|
|
14
|
+
const { container } = render(
|
|
15
|
+
<Toaster message={["Success!"]} statusProps={customStatusProps} />
|
|
21
16
|
);
|
|
22
|
-
|
|
17
|
+
const iconEl = container.querySelector(".fa-circle-check");
|
|
18
|
+
expect(iconEl).toBeInTheDocument();
|
|
23
19
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
render(
|
|
27
|
-
<Toaster
|
|
28
|
-
message="Test Message"
|
|
29
|
-
color="red-500"
|
|
30
|
-
title="Test Title"
|
|
31
|
-
/>
|
|
20
|
+
test("does not render an icon when icon is not in props", () => {
|
|
21
|
+
const customStatusProps = {};
|
|
22
|
+
const { container } = render(
|
|
23
|
+
<Toaster message={["Success!"]} statusProps={customStatusProps} />
|
|
32
24
|
);
|
|
33
|
-
|
|
25
|
+
const iconEl = container.querySelector(".fa-circle-check");
|
|
26
|
+
expect(iconEl).not.toBeInTheDocument();
|
|
34
27
|
});
|
|
35
28
|
|
|
36
|
-
test("renders
|
|
29
|
+
test("renders correct colors for status", () => {
|
|
30
|
+
const customStatusProps = {
|
|
31
|
+
colorClass: "bg-green-100 border border-green-500 text-green-800",
|
|
32
|
+
};
|
|
37
33
|
render(
|
|
38
|
-
<Toaster
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/>
|
|
34
|
+
<Toaster message={[testMessage]} statusProps={customStatusProps} />
|
|
35
|
+
);
|
|
36
|
+
expect(screen.getByTestId(testId)).toHaveTextContent(testMessage);
|
|
37
|
+
expect(screen.getByTestId(testId)).toHaveClass(
|
|
38
|
+
`${customStatusProps.colorClass}`
|
|
44
39
|
);
|
|
45
|
-
expect(screen.getByTestId("toaster")).toHaveClass("bg-blue-500");
|
|
46
40
|
});
|
|
41
|
+
test("calls clearMessage callback when the clear button is clicked", async () => {
|
|
42
|
+
// Arrange
|
|
43
|
+
const mockClearMessage = vi.fn();
|
|
44
|
+
const mockAlert = vi
|
|
45
|
+
.spyOn(window, "alert")
|
|
46
|
+
.mockImplementation(() => {});
|
|
47
47
|
|
|
48
|
-
test("clears the message on clear icon click", async () => {
|
|
49
|
-
const clearMessage = vi.fn();
|
|
50
48
|
render(
|
|
51
49
|
<Toaster
|
|
52
|
-
message=
|
|
53
|
-
|
|
54
|
-
clearMessage={
|
|
50
|
+
message={[testMessage]}
|
|
51
|
+
hasClearButton
|
|
52
|
+
clearMessage={mockClearMessage}
|
|
55
53
|
/>
|
|
56
54
|
);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
|
|
56
|
+
// Act - Click the clear button
|
|
57
|
+
const clearButton = screen.getByTestId("clear-button");
|
|
58
|
+
await userEvent.click(clearButton);
|
|
59
|
+
|
|
60
|
+
// Assert
|
|
61
|
+
expect(mockAlert).toHaveBeenCalledWith("Message Cleared!");
|
|
62
|
+
expect(mockClearMessage).toHaveBeenCalledWith(true);
|
|
63
|
+
|
|
64
|
+
// Cleanup
|
|
65
|
+
mockAlert.mockRestore();
|
|
60
66
|
});
|
|
61
67
|
});
|
|
@@ -1,78 +1,65 @@
|
|
|
1
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
2
1
|
import React from "react";
|
|
3
|
-
import Button from "../FormButton/FormButton";
|
|
4
|
-
import { faTimes } from "@fortawesome/free-solid-svg-icons";
|
|
5
2
|
import { ToasterTypes } from ".";
|
|
3
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
6
4
|
|
|
7
5
|
const Toaster: React.FC<ToasterTypes> = ({
|
|
8
6
|
message,
|
|
9
|
-
additionalClasses
|
|
7
|
+
additionalClasses,
|
|
10
8
|
clearMessage,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
clearText,
|
|
9
|
+
hasClearButton,
|
|
10
|
+
|
|
11
|
+
statusProps = {
|
|
12
|
+
colorClass: "bg-gray-100 border border-gray-500 text-gay-800",
|
|
13
|
+
icon: { icon: "circleCheck", type: "solid" },
|
|
14
|
+
},
|
|
18
15
|
}) => {
|
|
19
16
|
const handleClearMessage = () => {
|
|
20
17
|
if (clearMessage) {
|
|
18
|
+
alert("Message Cleared!");
|
|
21
19
|
clearMessage(true);
|
|
22
20
|
}
|
|
23
21
|
};
|
|
24
22
|
|
|
25
|
-
//
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"blue-800": "text-blue-800",
|
|
31
|
-
};
|
|
32
|
-
const iconClass = iconColorMap[color] || "";
|
|
33
|
-
// Improved CSS Class Composition
|
|
34
|
-
const borderClass = `border ${
|
|
35
|
-
hasBumper ? `border-l-4 border-${color}` : "border-l-1"
|
|
36
|
-
} `;
|
|
37
|
-
const backgroundColorClass = fullColor ? `bg-${color}` : "bg-white";
|
|
23
|
+
// Pull out colorClass and icon from statusProps
|
|
24
|
+
const { colorClass, icon: maybeIcon } = statusProps;
|
|
25
|
+
|
|
26
|
+
// We'll combine colorClass with other container styles
|
|
27
|
+
const containerClasses = colorClass ?? "";
|
|
38
28
|
|
|
39
|
-
|
|
29
|
+
// Your existing custom classes
|
|
30
|
+
const shadowClasses = `shadow-lg shadow-boxShadow rounded-lg`;
|
|
31
|
+
const closeButtonClasses = `cursor-pointer text-xs ml-4`;
|
|
40
32
|
|
|
41
33
|
return (
|
|
42
34
|
<div
|
|
43
|
-
data-testid="toaster"
|
|
44
|
-
|
|
35
|
+
data-testid="toaster-test-id"
|
|
36
|
+
role="alert"
|
|
37
|
+
aria-live="polite"
|
|
38
|
+
className={`${shadowClasses} ${containerClasses} ${additionalClasses}`}
|
|
45
39
|
>
|
|
46
|
-
{
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
{message.map((msg, index) => (
|
|
41
|
+
<div key={index} className="flex items-center">
|
|
42
|
+
{maybeIcon && (
|
|
43
|
+
<div className="mr-4">
|
|
44
|
+
{getFontAwesomeIcon(maybeIcon.icon, maybeIcon.type)}
|
|
45
|
+
</div>
|
|
46
|
+
)}
|
|
47
|
+
|
|
48
|
+
<p className={index === 0 ? "font-semibold ml-2" : "ml-2"}>
|
|
49
|
+
{msg}
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
{hasClearButton && (
|
|
53
|
+
<div
|
|
54
|
+
data-testid="clear-button"
|
|
55
|
+
className={`${closeButtonClasses}`}
|
|
58
56
|
onClick={handleClearMessage}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<Button
|
|
66
|
-
onClick={handleClearMessage}
|
|
67
|
-
text={clearText}
|
|
68
|
-
color="primary"
|
|
69
|
-
shape="outline"
|
|
70
|
-
type={"button"}
|
|
71
|
-
isDisabled={false}
|
|
72
|
-
additionalClasses="ml-2 px-4"
|
|
73
|
-
/>
|
|
74
|
-
)}
|
|
75
|
-
</div>
|
|
57
|
+
>
|
|
58
|
+
{getFontAwesomeIcon("x", "solid")}
|
|
59
|
+
</div>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
))}
|
|
76
63
|
</div>
|
|
77
64
|
);
|
|
78
65
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
interface StatusProps {
|
|
2
|
+
// color: string;
|
|
3
|
+
icon?: { icon: string; type: "solid" | "regular" };
|
|
4
|
+
colorClass?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
export interface ToasterTypes {
|
|
2
|
-
message: string;
|
|
8
|
+
message: string[];
|
|
3
9
|
additionalClasses?: string;
|
|
4
10
|
clearMessage?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
fullColor?: boolean;
|
|
8
|
-
hasBumper?: boolean;
|
|
9
|
-
title?: string;
|
|
10
|
-
hasClearText?: boolean;
|
|
11
|
-
clearText?: string;
|
|
11
|
+
hasClearButton?: boolean;
|
|
12
|
+
statusProps?: StatusProps;
|
|
12
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TagName } from "../components/Text/Text";
|
|
1
|
+
import { TagName } from "../components/Text/Text.types";
|
|
2
2
|
function assertTagName(tag: string): asserts tag is TagName {
|
|
3
3
|
if (!["span", "p", "h1", "h2", "h3", "h4", "h5"].includes(tag)) {
|
|
4
4
|
throw new Error(`Invalid tag name: ${tag}`);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { Fragment, useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { faChevronDown, faChevronUp } from "@fortawesome/free-solid-svg-icons";
|
|
2
|
+
import { getFontAwesomeIcon } from "./getFontAwesomeIcon";
|
|
4
3
|
|
|
5
4
|
type NavItem = {
|
|
6
5
|
title: string;
|
|
@@ -63,21 +62,16 @@ export const Accordion: React.FC<AccordionProps> = ({
|
|
|
63
62
|
<div className="px-6 text-left items-center h-10 select-none flex justify-between flex-row">
|
|
64
63
|
<div className="flex w-3/4">{item.title}</div>
|
|
65
64
|
<div className="flex w-1/2 justify-end">
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
: ""
|
|
71
|
-
}`}
|
|
72
|
-
icon={faChevronDown}
|
|
73
|
-
/>
|
|
65
|
+
{getFontAwesomeIcon(
|
|
66
|
+
"chevronDown",
|
|
67
|
+
`text-xs transition-transform duration-300 transform ${accordionExpanded[index] ? "rotate-180" : ""}`
|
|
68
|
+
)}
|
|
74
69
|
</div>
|
|
75
70
|
</div>
|
|
76
71
|
</div>
|
|
77
72
|
<div
|
|
78
|
-
className={`px-6 w-full overflow-hidden transition-[max-height] duration-500 ease-in-out ${
|
|
79
|
-
|
|
80
|
-
}`}
|
|
73
|
+
className={`px-6 w-full overflow-hidden transition-[max-height] duration-500 ease-in-out ${accordionExpanded[index] ? "max-h-96" : "max-h-0"
|
|
74
|
+
}`}
|
|
81
75
|
aria-hidden={!accordionExpanded[index]}
|
|
82
76
|
tabIndex={accordionExpanded[index] ? 0 : -1} // Set tabIndex dynamically
|
|
83
77
|
>
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Text from "../components/Text/Text";
|
|
3
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
4
|
-
import {
|
|
5
|
-
faEnvelope,
|
|
6
|
-
faLocationDot,
|
|
7
|
-
faPhone,
|
|
8
|
-
} from "@fortawesome/free-solid-svg-icons";
|
|
9
3
|
import { ContactInfoItem } from "../components/Footer/ContactInfoItem";
|
|
4
|
+
import { getFontAwesomeIcon } from "./getFontAwesomeIcon";
|
|
10
5
|
|
|
11
6
|
interface ContactProps {
|
|
12
7
|
contactDataList: {
|
|
@@ -24,11 +19,11 @@ export const FooterContacts: React.FC<ContactProps> = ({ contactDataList }) => {
|
|
|
24
19
|
return contactDataList.map((contact) => {
|
|
25
20
|
const contactDetails = [
|
|
26
21
|
{
|
|
27
|
-
icon:
|
|
22
|
+
icon: getFontAwesomeIcon("phone"),
|
|
28
23
|
text: contact.phone,
|
|
29
24
|
},
|
|
30
25
|
{
|
|
31
|
-
icon:
|
|
26
|
+
icon: getFontAwesomeIcon("envelope"),
|
|
32
27
|
text: contact.email,
|
|
33
28
|
},
|
|
34
29
|
];
|
|
@@ -39,7 +34,7 @@ export const FooterContacts: React.FC<ContactProps> = ({ contactDataList }) => {
|
|
|
39
34
|
data-testid="contact-info"
|
|
40
35
|
className="flex flex-col pt-2 w-60"
|
|
41
36
|
>
|
|
42
|
-
<ContactInfoItem icon={
|
|
37
|
+
<ContactInfoItem icon={getFontAwesomeIcon("location-dot")}>
|
|
43
38
|
<a
|
|
44
39
|
className="flex flex-col hover:underline"
|
|
45
40
|
href={contact.googleLink}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
3
|
+
import { IconDefinition } from "@fortawesome/free-solid-svg-icons";
|
|
3
4
|
import * as Icons from "@fortawesome/free-solid-svg-icons";
|
|
4
5
|
|
|
5
|
-
export const getFontAwesomeIcon = (
|
|
6
|
-
iconName: string
|
|
7
|
-
): React.ReactElement | null => {
|
|
6
|
+
export const getFontAwesomeIcon = (iconName: string, className = ""): React.ReactElement | null => {
|
|
8
7
|
try {
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
1
|
|
12
|
-
)}`;
|
|
13
|
-
const icon = (Icons as any)[iconKey];
|
|
8
|
+
const iconKey = `fa${iconName.charAt(0).toUpperCase()}${iconName.slice(1)}`;
|
|
9
|
+
const icon = Icons[iconKey as keyof typeof Icons] as IconDefinition;
|
|
14
10
|
|
|
15
|
-
if (
|
|
16
|
-
|
|
11
|
+
if (icon) {
|
|
12
|
+
return <FontAwesomeIcon icon={icon} className={className} />;
|
|
13
|
+
} else {
|
|
14
|
+
throw new Error(`Icon not found or invalid type: ${iconName}`);
|
|
17
15
|
}
|
|
18
|
-
|
|
19
|
-
// Render the FontAwesomeIcon with the selected icon
|
|
20
|
-
return <FontAwesomeIcon icon={icon} />;
|
|
21
16
|
} catch (error) {
|
|
22
17
|
console.error(`Error loading Font Awesome icon: ${iconName}`, error);
|
|
23
18
|
return null;
|
package/tailwind.config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @type {import('tailwindcss').Config} */
|
|
2
2
|
|
|
3
|
+
const colors = require("tailwindcss/colors");
|
|
3
4
|
|
|
4
5
|
module.exports = {
|
|
5
6
|
mode: "jit",
|
|
@@ -7,12 +8,23 @@ module.exports = {
|
|
|
7
8
|
|
|
8
9
|
theme: {
|
|
9
10
|
extend: {
|
|
11
|
+
width: {
|
|
12
|
+
"42px": "42px",
|
|
13
|
+
"26px": "26px",
|
|
14
|
+
"18px": "18px",
|
|
15
|
+
},
|
|
16
|
+
height: {
|
|
17
|
+
"42px": "42px",
|
|
18
|
+
"26px": "26px",
|
|
19
|
+
"18px": "18px",
|
|
20
|
+
},
|
|
10
21
|
maxHeight: {
|
|
11
22
|
"view-page": "1000px",
|
|
12
23
|
},
|
|
13
24
|
fontSize: {
|
|
14
25
|
"3xl": "2.25rem",
|
|
15
26
|
xxs: ".6rem",
|
|
27
|
+
"11px": "11px",
|
|
16
28
|
},
|
|
17
29
|
minWidth: {
|
|
18
30
|
navDropDown: "25em",
|
|
@@ -20,6 +32,11 @@ module.exports = {
|
|
|
20
32
|
maxWidth: {
|
|
21
33
|
pageSectionMaxWidth: "1500px",
|
|
22
34
|
},
|
|
35
|
+
colors: {
|
|
36
|
+
// Add any custom colors here or extend the default palette
|
|
37
|
+
yellow: colors.yellow,
|
|
38
|
+
orange: colors.orange,
|
|
39
|
+
},
|
|
23
40
|
},
|
|
24
41
|
fontFamily: {
|
|
25
42
|
sans: ["ui-sans-serif"],
|
|
@@ -27,6 +44,4 @@ module.exports = {
|
|
|
27
44
|
mono: ["ui-monospace"],
|
|
28
45
|
},
|
|
29
46
|
},
|
|
30
|
-
|
|
31
|
-
plugins: [require("daisyui")],
|
|
32
47
|
};
|