@agilant/toga-blox 1.0.5
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/Dockerfile +9 -0
- package/README.md +69 -0
- package/assets/Logo.png +0 -0
- package/assets/compass-card-image-2.png +0 -0
- package/assets/compass-card-image-3.png +0 -0
- package/assets/compass-card-image-4.png +0 -0
- package/assets/compass-card-image.png +0 -0
- package/assets/compass-logo.png +0 -0
- package/assets/compass-tech-hero-bg.png +0 -0
- package/assets/contact-image.png +0 -0
- package/assets/green-laptop.png +0 -0
- package/assets/heroImage.png +0 -0
- package/assets/placeholder-no-image-available.png +0 -0
- package/assets/team.png +0 -0
- package/declarations.d.ts +4 -0
- package/docker-compose.yml +22 -0
- package/global.css +4 -0
- package/index.js +4 -0
- package/nodemon.json +5 -0
- package/package.json +70 -0
- package/postcss.config.js +6 -0
- package/src/components/Badge/Badge.stories.tsx +284 -0
- package/src/components/Badge/Badge.test.tsx +185 -0
- package/src/components/Badge/Badge.tsx +137 -0
- package/src/components/Badge/Badge.types.tsx +28 -0
- package/src/components/Badge/badgeClassNames.tsx +152 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/Card/Card.stories.tsx +91 -0
- package/src/components/Card/Card.test.tsx +53 -0
- package/src/components/Card/Card.tsx +30 -0
- package/src/components/Card/Card.types.ts +11 -0
- package/src/components/Card/DUMMYPRODUCTDATA.json +670 -0
- package/src/components/Card/cardClassNames.ts +49 -0
- package/src/components/Card/index.ts +3 -0
- package/src/components/Card/templates/CompassCardTemplate.tsx +58 -0
- package/src/components/Card/templates/HorizontalCardTemplate.tsx +184 -0
- package/src/components/Card/templates/VerticalCardTemplate.tsx +154 -0
- package/src/components/Footer/ContactInfoItem.tsx +20 -0
- package/src/components/Footer/DUMMYFOOTERDATA.json +132 -0
- package/src/components/Footer/Footer.stories.tsx +292 -0
- package/src/components/Footer/Footer.test.tsx +90 -0
- package/src/components/Footer/Footer.tsx +159 -0
- package/src/components/Footer/Footer.types.tsx +61 -0
- package/src/components/Footer/footerClassNames.tsx +57 -0
- package/src/components/FormButton/FormButton.stories.tsx +199 -0
- package/src/components/FormButton/FormButton.test.tsx +73 -0
- package/src/components/FormButton/FormButton.tsx +116 -0
- package/src/components/FormButton/FormButton.types.ts +32 -0
- package/src/components/FormButton/formButtonClassNames.tsx +153 -0
- package/src/components/FormButton/index.ts +2 -0
- package/src/components/GenericList/DUMMYLISTDATA.json +560 -0
- package/src/components/GenericList/GenericList.stories.tsx +104 -0
- package/src/components/GenericList/GenericList.test.tsx +29 -0
- package/src/components/GenericList/GenericList.tsx +146 -0
- package/src/components/GenericList/genericListClassNames.tsx +8 -0
- package/src/components/GenericList/templates/DummyDataList.tsx +23 -0
- package/src/components/GenericList/templates/DynamicIconList.tsx +74 -0
- package/src/components/HamburgerButton/HamburgerButton.tsx +68 -0
- package/src/components/HamburgerButton/HamburgerButton.types.tsx +6 -0
- package/src/components/HamburgerButton/index.ts +2 -0
- package/src/components/Header/DUMMYICONDATA.json +136 -0
- package/src/components/Header/Header.stories.tsx +521 -0
- package/src/components/Header/Header.test.tsx +323 -0
- package/src/components/Header/Header.tsx +289 -0
- package/src/components/Header/Header.types.ts +52 -0
- package/src/components/Header/headerClassNames.tsx +50 -0
- package/src/components/Header/headerContext.tsx +125 -0
- package/src/components/Header/index.ts +2 -0
- package/src/components/Hero/Hero.stories.tsx +69 -0
- package/src/components/Hero/Hero.test.tsx +109 -0
- package/src/components/Hero/Hero.tsx +58 -0
- package/src/components/Hero/Hero.types.ts +9 -0
- package/src/components/Hero/index.ts +2 -0
- package/src/components/Icon/Icon.stories.tsx +227 -0
- package/src/components/Icon/Icon.test.tsx +53 -0
- package/src/components/Icon/Icon.tsx +208 -0
- package/src/components/Icon/Icon.types.ts +24 -0
- package/src/components/Icon/iconClassNames.ts +79 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Image/Image.stories.tsx +79 -0
- package/src/components/Image/Image.test.tsx +87 -0
- package/src/components/Image/Image.tsx +49 -0
- package/src/components/Image/Image.types.ts +11 -0
- package/src/components/Image/index.ts +2 -0
- package/src/components/Input/Input.stories.tsx +651 -0
- package/src/components/Input/Input.test.tsx +90 -0
- package/src/components/Input/Input.tsx +226 -0
- package/src/components/Input/Input.types.ts +52 -0
- package/src/components/Input/InputMemoTypes.tsx +32 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/Input/inputClassNames.tsx +169 -0
- package/src/components/MobileMenu/MobileMenu.tsx +41 -0
- package/src/components/MobileMenu/MobileMenu.types.tsx +30 -0
- package/src/components/MobileMenu/index.ts +2 -0
- package/src/components/Nav/DUMMYNAVDATA.json +234 -0
- package/src/components/Nav/Nav.stories.tsx +181 -0
- package/src/components/Nav/Nav.test.tsx +89 -0
- package/src/components/Nav/Nav.tsx +242 -0
- package/src/components/Nav/Nav.types.tsx +35 -0
- package/src/components/Nav/index.ts +2 -0
- package/src/components/Nav/navClassNames.tsx +192 -0
- package/src/components/Page/TableDataDummy.tsx +216 -0
- package/src/components/Page/ViewPageTemplate.stories.tsx +546 -0
- package/src/components/Page/ViewPageTemplate.test.tsx +361 -0
- package/src/components/Page/ViewPageTemplate.tsx +10 -0
- package/src/components/Page/ViewPageTemplate.types.ts +6 -0
- package/src/components/Page/index.ts +2 -0
- package/src/components/PageSection/PageSection.stories.tsx +114 -0
- package/src/components/PageSection/PageSection.tsx +12 -0
- package/src/components/PageSection/PageSection.types.ts +6 -0
- package/src/components/PageSection/PageSections.test.tsx +88 -0
- package/src/components/PageSection/index.ts +2 -0
- package/src/components/Text/Text.stories.tsx +60 -0
- package/src/components/Text/Text.test.tsx +52 -0
- package/src/components/Text/Text.tsx +80 -0
- package/src/components/Text/Text.types.ts +12 -0
- package/src/components/Text/index.ts +2 -0
- package/src/components/Toaster/Toaster.stories.tsx +122 -0
- package/src/components/Toaster/Toaster.test.tsx +61 -0
- package/src/components/Toaster/Toaster.tsx +80 -0
- package/src/components/Toaster/Toaster.types.ts +12 -0
- package/src/components/Toaster/index.ts +2 -0
- package/src/hoc/index.ts +2 -0
- package/src/hoc/styling/withStoryBook.tsx +19 -0
- package/src/main.css +3 -0
- package/src/setupTests.ts +1 -0
- package/src/userHoc/index.ts +1 -0
- package/src/userHoc/withMemo.tsx +20 -0
- package/src/utils/assertTagName.tsx +7 -0
- package/src/utils/generateAccordionItem.tsx +102 -0
- package/src/utils/generateFooterContacts.tsx +75 -0
- package/src/utils/generateNavMenu.tsx +54 -0
- package/src/utils/generateSocialList.tsx +34 -0
- package/src/utils/getFontAwesomeIcon.tsx +25 -0
- package/src/utils/inputValidation.tsx +26 -0
- package/tailwind.config.js +32 -0
- package/tsconfig.json +25 -0
- package/vite.config.ts +33 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import { describe, expect, beforeEach, test, it } from "vitest";
|
|
3
|
+
import ViewTemplatePage from "./ViewPageTemplate";
|
|
4
|
+
import Hero from "../Hero/Hero";
|
|
5
|
+
import PageSection from "../PageSection/PageSection";
|
|
6
|
+
import Badge from "../Badge/Badge";
|
|
7
|
+
import Text from "../Text/Text";
|
|
8
|
+
import Image from "../Image/Image";
|
|
9
|
+
import Nav from "../Nav/Nav";
|
|
10
|
+
import Card from "../Card/Card";
|
|
11
|
+
import FormButton from "../FormButton";
|
|
12
|
+
import CompassCardTemplate from "../Card/templates/CompassCardTemplate";
|
|
13
|
+
import Footer from "../Footer/Footer";
|
|
14
|
+
import { DUMMYICONCOMPASSDATA } from "../Header/DUMMYICONDATA.json";
|
|
15
|
+
import { DUMMYCOMPASSNAVDATA } from "../Nav/DUMMYNAVDATA.json";
|
|
16
|
+
import { DUMMYCOMPASSPRODUCTDATA } from "../Card/DUMMYPRODUCTDATA.json";
|
|
17
|
+
import Header from "../Header/Header";
|
|
18
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
19
|
+
import GenericList from "../GenericList/GenericList";
|
|
20
|
+
|
|
21
|
+
describe("<ViewTemplatePage />", () => {
|
|
22
|
+
it("renders with default background color", () => {
|
|
23
|
+
const { container } = render(
|
|
24
|
+
<ViewTemplatePage>
|
|
25
|
+
<p>Content goes here</p>
|
|
26
|
+
</ViewTemplatePage>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// Check if the default background color is applied
|
|
30
|
+
expect(container.firstChild).toHaveClass("bg-gray-100");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("renders with custom background color", () => {
|
|
34
|
+
const customBgColor = "bg-red-500";
|
|
35
|
+
const { container } = render(
|
|
36
|
+
<ViewTemplatePage bgColor={customBgColor}>
|
|
37
|
+
<p>Content goes here</p>
|
|
38
|
+
</ViewTemplatePage>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// Check if the custom background color is applied
|
|
42
|
+
expect(container.firstChild).toHaveClass(customBgColor);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("renders children correctly", () => {
|
|
46
|
+
const { getByText } = render(
|
|
47
|
+
<ViewTemplatePage>
|
|
48
|
+
<p>Test child content</p>
|
|
49
|
+
</ViewTemplatePage>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
// Check if the child content is rendered
|
|
53
|
+
expect(getByText("Test child content")).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("<ViewTemplatePage />", () => {
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
render(
|
|
60
|
+
<ViewTemplatePage>
|
|
61
|
+
children: [ <div className="h-16"></div>,
|
|
62
|
+
<div className="fixed top-0 w-full z-[1000]">
|
|
63
|
+
<Header
|
|
64
|
+
hasIcons={true}
|
|
65
|
+
iconsData={DUMMYICONCOMPASSDATA}
|
|
66
|
+
logoBorderRadius={true}
|
|
67
|
+
hasSearchBar={true}
|
|
68
|
+
hasBadge={true}
|
|
69
|
+
hasNavItems={true}
|
|
70
|
+
logoHoverColor="green"
|
|
71
|
+
backgroundColor="gray"
|
|
72
|
+
bottomBorderColor="green"
|
|
73
|
+
badge={
|
|
74
|
+
<Badge
|
|
75
|
+
type="href"
|
|
76
|
+
to="#"
|
|
77
|
+
color="green"
|
|
78
|
+
hoverColor="green"
|
|
79
|
+
borderColor="none"
|
|
80
|
+
tagStyle={false}
|
|
81
|
+
mobileIcon={getFontAwesomeIcon("phone")}
|
|
82
|
+
mobileIconLabel="Contact Us"
|
|
83
|
+
onClick={() =>
|
|
84
|
+
alert("Redirect to Contact Us page")
|
|
85
|
+
}
|
|
86
|
+
image={
|
|
87
|
+
<Image
|
|
88
|
+
src="../../../assets/contact-image.png"
|
|
89
|
+
alt=""
|
|
90
|
+
background={false}
|
|
91
|
+
additionalClasses="flex justify-center w-8 h-8 max-md:hidden"
|
|
92
|
+
/>
|
|
93
|
+
}
|
|
94
|
+
text={
|
|
95
|
+
<>
|
|
96
|
+
<Text
|
|
97
|
+
size="sm"
|
|
98
|
+
color="primary"
|
|
99
|
+
fontFamily="serif"
|
|
100
|
+
text="Contact Us"
|
|
101
|
+
tag="h2"
|
|
102
|
+
additionalClasses="pl-2 pb-0 font-bold"
|
|
103
|
+
/>
|
|
104
|
+
<Text
|
|
105
|
+
size="xs"
|
|
106
|
+
color="primary"
|
|
107
|
+
fontFamily="serif"
|
|
108
|
+
text="1-800-800-8000"
|
|
109
|
+
tag="p"
|
|
110
|
+
additionalClasses="pl-2 pt-0"
|
|
111
|
+
/>
|
|
112
|
+
</>
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
115
|
+
}
|
|
116
|
+
logo={
|
|
117
|
+
<Image
|
|
118
|
+
src="../../../assets/compass-logo.png"
|
|
119
|
+
alt="Generic Company Logo."
|
|
120
|
+
background={false}
|
|
121
|
+
additionalClasses=" w-40 p-2"
|
|
122
|
+
/>
|
|
123
|
+
}
|
|
124
|
+
nav={
|
|
125
|
+
<Nav
|
|
126
|
+
navData={DUMMYCOMPASSNAVDATA}
|
|
127
|
+
navBackgroundColor={"#FFFFF"}
|
|
128
|
+
parentHoverBackground={"none"}
|
|
129
|
+
parentHoverFontColor={"black"}
|
|
130
|
+
parentHoverUnderline={true}
|
|
131
|
+
parentHoverBorderColor={"none"}
|
|
132
|
+
parentShape={"cornered"}
|
|
133
|
+
parentBackground={"none"}
|
|
134
|
+
parentBorderColor={"none"}
|
|
135
|
+
submenuBackgroundColor={"white"}
|
|
136
|
+
submenuHoverBackground={"green"}
|
|
137
|
+
submenuHoverBorderStyle={"top-bottom"}
|
|
138
|
+
submenuHoverBorderColor={"green"}
|
|
139
|
+
includeSubmenuImages={true}
|
|
140
|
+
mobileBreakpoint={"extraLarge"}
|
|
141
|
+
accordionParentStyle={
|
|
142
|
+
"cornered p-2 w-full border-b-2 border-b-teal-700 text-black"
|
|
143
|
+
}
|
|
144
|
+
accordionExpandedStyle={"pl-2 py-3"}
|
|
145
|
+
/>
|
|
146
|
+
}
|
|
147
|
+
/>
|
|
148
|
+
</div>
|
|
149
|
+
,
|
|
150
|
+
<Hero
|
|
151
|
+
key="hero"
|
|
152
|
+
textAlignment={"right"}
|
|
153
|
+
background="image"
|
|
154
|
+
src="../../../assets/compass-tech-hero-bg.png"
|
|
155
|
+
text={
|
|
156
|
+
<Text
|
|
157
|
+
size="xxxl"
|
|
158
|
+
color="white"
|
|
159
|
+
fontFamily="serif"
|
|
160
|
+
text="Equip your team with exactly what they need"
|
|
161
|
+
tag="h1"
|
|
162
|
+
additionalClasses="text-left w-3/4 max-xl:text-xl max-lg:text-xl max-md:hidden"
|
|
163
|
+
/>
|
|
164
|
+
}
|
|
165
|
+
/>
|
|
166
|
+
,
|
|
167
|
+
<div data-testid="kits-header-section">
|
|
168
|
+
<PageSection
|
|
169
|
+
key="pageSection"
|
|
170
|
+
sectionContainerClasses="w-full bg-slate-100 flex flex-col p-6
|
|
171
|
+
justify-center items-center h-[100%]"
|
|
172
|
+
>
|
|
173
|
+
<Text
|
|
174
|
+
size="xxxl"
|
|
175
|
+
color="black"
|
|
176
|
+
fontFamily="serif"
|
|
177
|
+
text="Kits"
|
|
178
|
+
tag="h2"
|
|
179
|
+
additionalClasses="my-8"
|
|
180
|
+
/>
|
|
181
|
+
</PageSection>
|
|
182
|
+
</div>
|
|
183
|
+
,
|
|
184
|
+
<div data-testid="kits-cards-section">
|
|
185
|
+
<PageSection
|
|
186
|
+
key="pageSection"
|
|
187
|
+
sectionContainerClasses="w-full bg-slate-100 flex flex-col p-6
|
|
188
|
+
justify-center items-center h-[100%]"
|
|
189
|
+
>
|
|
190
|
+
<>
|
|
191
|
+
<div className="w-3/4 grid grid-cols-4 gap-8 h-[100%] max-xl:gap-1 max-lg:grid-cols-2 max-lg:gap-y-24 max-lg:justify-items-center">
|
|
192
|
+
<GenericList
|
|
193
|
+
data={DUMMYCOMPASSPRODUCTDATA}
|
|
194
|
+
renderItem={(item) => (
|
|
195
|
+
<Card
|
|
196
|
+
containerClasses={"w-3/4"}
|
|
197
|
+
cardBackgroundColor={
|
|
198
|
+
item.cardBackgroundColor
|
|
199
|
+
}
|
|
200
|
+
cardBorderRadius={
|
|
201
|
+
item.cardBorderRadius
|
|
202
|
+
}
|
|
203
|
+
cardBorderColor={
|
|
204
|
+
item.cardBorderColor
|
|
205
|
+
}
|
|
206
|
+
cardBoxShadow={item.cardBoxShadow}
|
|
207
|
+
key={item.id}
|
|
208
|
+
>
|
|
209
|
+
<CompassCardTemplate data={item} />
|
|
210
|
+
</Card>
|
|
211
|
+
)}
|
|
212
|
+
/>
|
|
213
|
+
</div>
|
|
214
|
+
</>
|
|
215
|
+
</PageSection>
|
|
216
|
+
</div>
|
|
217
|
+
,
|
|
218
|
+
<div data-testid="survey-section">
|
|
219
|
+
<PageSection
|
|
220
|
+
sectionContainerClasses="w-full bg-yellow-400 flex p-6
|
|
221
|
+
justify-center items-center h-[100%] mt-6"
|
|
222
|
+
>
|
|
223
|
+
<Text
|
|
224
|
+
size="xl"
|
|
225
|
+
color="black"
|
|
226
|
+
fontFamily="serif"
|
|
227
|
+
text="Equip your team with exactly what they need"
|
|
228
|
+
tag="h1"
|
|
229
|
+
additionalClasses="mr-8"
|
|
230
|
+
/>
|
|
231
|
+
<FormButton
|
|
232
|
+
text={
|
|
233
|
+
<Text
|
|
234
|
+
size={""}
|
|
235
|
+
color={""}
|
|
236
|
+
text={"Take the Survey!"}
|
|
237
|
+
fontFamily={""}
|
|
238
|
+
/>
|
|
239
|
+
}
|
|
240
|
+
color="green"
|
|
241
|
+
fontColor="white"
|
|
242
|
+
size="md"
|
|
243
|
+
shape="semiRounded"
|
|
244
|
+
borderColor="none"
|
|
245
|
+
hoverBackground="green"
|
|
246
|
+
hoverFontColor="green"
|
|
247
|
+
hoverBorderColor="green"
|
|
248
|
+
hoverUnderline={true}
|
|
249
|
+
onClick={() => alert("Button clicked!")}
|
|
250
|
+
as="a"
|
|
251
|
+
/>
|
|
252
|
+
</PageSection>
|
|
253
|
+
</div>
|
|
254
|
+
,
|
|
255
|
+
<Footer
|
|
256
|
+
logo={
|
|
257
|
+
<Image
|
|
258
|
+
src="../../../assets/compass-logo.png"
|
|
259
|
+
alt="Generic Compass Logo."
|
|
260
|
+
background={false}
|
|
261
|
+
additionalClasses=" w-40 p-2"
|
|
262
|
+
/>
|
|
263
|
+
}
|
|
264
|
+
title={
|
|
265
|
+
<Text
|
|
266
|
+
size={"xl"}
|
|
267
|
+
color={""}
|
|
268
|
+
text={"Compass Website"}
|
|
269
|
+
fontFamily={""}
|
|
270
|
+
tag={"h2"}
|
|
271
|
+
additionalClasses="font-bold uppercase pl-2 mt-2 max-md:text-sm"
|
|
272
|
+
/>
|
|
273
|
+
}
|
|
274
|
+
slogan={
|
|
275
|
+
<Text
|
|
276
|
+
size={"md"}
|
|
277
|
+
color={""}
|
|
278
|
+
text={"Great slogan goes here."}
|
|
279
|
+
fontFamily={""}
|
|
280
|
+
tag={"p"}
|
|
281
|
+
additionalClasses="pl-2"
|
|
282
|
+
/>
|
|
283
|
+
}
|
|
284
|
+
copyRightText={
|
|
285
|
+
<Text
|
|
286
|
+
size={"md"}
|
|
287
|
+
color={"black"}
|
|
288
|
+
text="Copyright © 2024 - All right reserved by Generic Company"
|
|
289
|
+
fontFamily={""}
|
|
290
|
+
additionalClasses="text-center"
|
|
291
|
+
/>
|
|
292
|
+
}
|
|
293
|
+
socialTitle={
|
|
294
|
+
<Text
|
|
295
|
+
size={"md"}
|
|
296
|
+
color={"black"}
|
|
297
|
+
text="Connect"
|
|
298
|
+
fontFamily={""}
|
|
299
|
+
additionalClasses="font-bold uppercase w-full"
|
|
300
|
+
/>
|
|
301
|
+
}
|
|
302
|
+
contactTitle={
|
|
303
|
+
<Text
|
|
304
|
+
size={"md"}
|
|
305
|
+
color={"black"}
|
|
306
|
+
text="Contact Us:"
|
|
307
|
+
fontFamily={""}
|
|
308
|
+
additionalClasses="font-bold uppercase"
|
|
309
|
+
/>
|
|
310
|
+
}
|
|
311
|
+
logoBorderRadius={true}
|
|
312
|
+
hasNavItems={true}
|
|
313
|
+
hasSocial={true}
|
|
314
|
+
logoHoverColor="green"
|
|
315
|
+
backgroundColor="green"
|
|
316
|
+
accordionGap="gap-1"
|
|
317
|
+
copyRightTextPlacement="center"
|
|
318
|
+
socialPlacement="center"
|
|
319
|
+
accordionParentStyle="border-b border-black p-2 w-full"
|
|
320
|
+
accordionExpandedStyle="pl-3 py-3"
|
|
321
|
+
/>
|
|
322
|
+
, ]
|
|
323
|
+
</ViewTemplatePage>
|
|
324
|
+
);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test("renders header on page", () => {
|
|
328
|
+
const header = screen.getByTestId("header");
|
|
329
|
+
expect(header).toBeInTheDocument();
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
test("renders hero on page", () => {
|
|
333
|
+
const hero = screen.getByTestId("image-background-hero");
|
|
334
|
+
expect(hero).toBeInTheDocument();
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
test("renders hero on page", () => {
|
|
338
|
+
const hero = screen.getByTestId("image-background-hero");
|
|
339
|
+
expect(hero).toBeInTheDocument();
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
test("renders kits header on page", () => {
|
|
343
|
+
const kitsHeading = screen.getByTestId("kits-header-section");
|
|
344
|
+
expect(kitsHeading).toBeInTheDocument();
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test("renders cards section on page", () => {
|
|
348
|
+
const kitsCards = screen.getByTestId("kits-cards-section");
|
|
349
|
+
expect(kitsCards).toBeInTheDocument();
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test("renders survey section on page", () => {
|
|
353
|
+
const surveySection = screen.getByTestId("survey-section");
|
|
354
|
+
expect(surveySection).toBeInTheDocument();
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
test("renders footer on page", () => {
|
|
358
|
+
const footer = screen.getByTestId("footer");
|
|
359
|
+
expect(footer).toBeInTheDocument();
|
|
360
|
+
});
|
|
361
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
2
|
+
import Section, { PageSectionTypes } from ".";
|
|
3
|
+
import Card from "../Card/Card";
|
|
4
|
+
import Text from "../Text/Text";
|
|
5
|
+
import GenericList from "../GenericList/GenericList";
|
|
6
|
+
import {
|
|
7
|
+
DUMMYPRODUCTDATA,
|
|
8
|
+
DUMMYCOMPASSPRODUCTDATA,
|
|
9
|
+
} from "../../components/Card/DUMMYPRODUCTDATA.json";
|
|
10
|
+
import HorizontalCardTemplate from "../Card/templates/HorizontalCardTemplate";
|
|
11
|
+
import CompassCardTemplate from "../Card/templates/CompassCardTemplate";
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: "Components/Section",
|
|
15
|
+
component: Section,
|
|
16
|
+
argTypes: {
|
|
17
|
+
children: {
|
|
18
|
+
control: {
|
|
19
|
+
type: "none",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
sectionContainerClasses: {
|
|
23
|
+
control: {
|
|
24
|
+
type: "none",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
} as Meta;
|
|
29
|
+
|
|
30
|
+
const Template: StoryFn<PageSectionTypes> = (args) => <Section {...args} />;
|
|
31
|
+
|
|
32
|
+
export const Default = Template.bind({});
|
|
33
|
+
Default.args = {
|
|
34
|
+
sectionContainerClasses:
|
|
35
|
+
" flex flex-row justify-center items-center flex-wrap lg:gap-10 gap-4 my-20 lg:max-h-view-page max-h-fit min-h-fit overflow-scroll px-4",
|
|
36
|
+
children: (
|
|
37
|
+
<>
|
|
38
|
+
<div className="bg-red-400 p-4">Content 1</div>
|
|
39
|
+
<div className="bg-green-400 p-4">Content 2</div>
|
|
40
|
+
<div className="bg-blue-400 p-4">Content 3</div>
|
|
41
|
+
</>
|
|
42
|
+
),
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const HorizontalCardsSection = Template.bind({});
|
|
46
|
+
HorizontalCardsSection.args = {
|
|
47
|
+
sectionContainerClasses:
|
|
48
|
+
"w-full bg-slate-100 flex flex-col p-6 justify-center items-center",
|
|
49
|
+
children: (
|
|
50
|
+
<>
|
|
51
|
+
<Text
|
|
52
|
+
tag={"h1"}
|
|
53
|
+
size={"lg"}
|
|
54
|
+
text={"Example of a section with horizontal cards:"}
|
|
55
|
+
color={"black"}
|
|
56
|
+
fontFamily={""}
|
|
57
|
+
additionalClasses={"pb-12"}
|
|
58
|
+
/>
|
|
59
|
+
<GenericList
|
|
60
|
+
data={DUMMYPRODUCTDATA}
|
|
61
|
+
renderItem={(item) => (
|
|
62
|
+
<Card
|
|
63
|
+
containerClasses={
|
|
64
|
+
"flex mb-6 max-sm:w-1/2 max-sm:flex-col overflow-hidden"
|
|
65
|
+
}
|
|
66
|
+
cardBackgroundColor={item.cardBackgroundColor}
|
|
67
|
+
cardBorderRadius={item.cardBorderRadius}
|
|
68
|
+
cardBorderColor={item.cardBorderColor}
|
|
69
|
+
cardBoxShadow={item.cardBoxShadow}
|
|
70
|
+
key={item.id}
|
|
71
|
+
>
|
|
72
|
+
<HorizontalCardTemplate data={item} />
|
|
73
|
+
</Card>
|
|
74
|
+
)}
|
|
75
|
+
/>
|
|
76
|
+
</>
|
|
77
|
+
),
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const CompassCardsSection = Template.bind({});
|
|
81
|
+
CompassCardsSection.args = {
|
|
82
|
+
sectionContainerClasses:
|
|
83
|
+
"w-full bg-slate-100 flex flex-col p-6 justify-center items-center h-[100%]",
|
|
84
|
+
children: (
|
|
85
|
+
<>
|
|
86
|
+
<Text
|
|
87
|
+
tag={"h1"}
|
|
88
|
+
size={"lg"}
|
|
89
|
+
text={"Example of a section with horizontal cards:"}
|
|
90
|
+
color={"black"}
|
|
91
|
+
fontFamily={""}
|
|
92
|
+
additionalClasses={"pb-12"}
|
|
93
|
+
/>
|
|
94
|
+
<GenericList
|
|
95
|
+
data={DUMMYCOMPASSPRODUCTDATA}
|
|
96
|
+
containerClasses="w-full grid grid-cols-4 gap-y-12 gap-x-8 h-full max-lg:grid-cols-2 max-lg:gap-y-12 max-lg:gap-x-2 max-md:gap-12 max-sm:w-[90%] max-sm:gap-8 justify-items-center"
|
|
97
|
+
renderItem={(item) => (
|
|
98
|
+
<Card
|
|
99
|
+
containerClasses={
|
|
100
|
+
"w-full h-full shadow-md overflow-hidden rounded-md transition ease-in-out delay-150 hover:-translate-y-1 hover:scale-110 duration-300 max-lg:transition-none max-lg:hover:transform-none max-w-72"
|
|
101
|
+
}
|
|
102
|
+
cardBackgroundColor={item.cardBackgroundColor}
|
|
103
|
+
cardBorderRadius={item.cardBorderRadius}
|
|
104
|
+
cardBorderColor={item.cardBorderColor}
|
|
105
|
+
cardBoxShadow={item.cardBoxShadow}
|
|
106
|
+
key={item.id}
|
|
107
|
+
>
|
|
108
|
+
<CompassCardTemplate data={item} />
|
|
109
|
+
</Card>
|
|
110
|
+
)}
|
|
111
|
+
/>
|
|
112
|
+
</>
|
|
113
|
+
),
|
|
114
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PageSectionTypes } from ".";
|
|
3
|
+
|
|
4
|
+
const Section: React.FC<PageSectionTypes> = ({ children, sectionContainerClasses, }) => {
|
|
5
|
+
return (
|
|
6
|
+
<section className={`${sectionContainerClasses}`} data-testid="section">
|
|
7
|
+
{children}
|
|
8
|
+
</section>
|
|
9
|
+
);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default Section;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, test } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import Section from "./PageSection";
|
|
4
|
+
import Text from "../Text/Text";
|
|
5
|
+
import Card from "../Card/Card";
|
|
6
|
+
import GenericList from "../GenericList/GenericList";
|
|
7
|
+
import CompassCardTemplate from "../Card/templates/CompassCardTemplate";
|
|
8
|
+
import { DUMMYCOMPASSPRODUCTDATA } from "../../components/Card/DUMMYPRODUCTDATA.json";
|
|
9
|
+
|
|
10
|
+
describe("<Section />", () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
render(
|
|
13
|
+
<Section
|
|
14
|
+
sectionContainerClasses="flex flex-row justify-center items-center flex-wrap lg:gap-10 gap-4 my-20 lg:max-h-view-page max-h-fit min-h-fit overflow-scroll px-4"
|
|
15
|
+
children={
|
|
16
|
+
<>
|
|
17
|
+
<div className="bg-red-400 p-4">Content 1</div>
|
|
18
|
+
<div className="bg-green-400 p-4">Content 2</div>
|
|
19
|
+
<div className="bg-blue-400 p-4">Content 3</div>
|
|
20
|
+
</>
|
|
21
|
+
}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("renders children content", () => {
|
|
27
|
+
const { getByText } = render(
|
|
28
|
+
<Section>
|
|
29
|
+
<div>Test Child</div>
|
|
30
|
+
</Section>
|
|
31
|
+
);
|
|
32
|
+
expect(getByText("Test Child")).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("displays children in a horizontal row", () => {
|
|
36
|
+
const section = screen.getByTestId("section");
|
|
37
|
+
expect(section).toHaveClass("flex-row");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("<Section /> with compass cards", () => {
|
|
42
|
+
it("displays correct cards", () => {
|
|
43
|
+
render(
|
|
44
|
+
<Section
|
|
45
|
+
sectionContainerClasses="flex flex-row justify-center items-center flex-wrap lg:gap-10 gap-4 my-20 lg:max-h-view-page max-h-fit min-h-fit overflow-scroll px-4"
|
|
46
|
+
children={
|
|
47
|
+
<>
|
|
48
|
+
<Text
|
|
49
|
+
tag={"h1"}
|
|
50
|
+
size={"lg"}
|
|
51
|
+
text={"Example of a section with horizontal cards:"}
|
|
52
|
+
color={"black"}
|
|
53
|
+
fontFamily={""}
|
|
54
|
+
additionalClasses={"pb-12"}
|
|
55
|
+
/>
|
|
56
|
+
<div className="grid grid-cols-4 gap-8 h-[100%] max-xl:gap-1 max-lg:grid-cols-2 max-lg:gap-y-24 max-lg:justify-items-center">
|
|
57
|
+
<GenericList
|
|
58
|
+
data={DUMMYCOMPASSPRODUCTDATA}
|
|
59
|
+
renderItem={(item) => (
|
|
60
|
+
<Card
|
|
61
|
+
containerClasses={"w-3/4"}
|
|
62
|
+
cardBackgroundColor={
|
|
63
|
+
item.cardBackgroundColor
|
|
64
|
+
}
|
|
65
|
+
cardBorderRadius={item.cardBorderRadius}
|
|
66
|
+
cardBorderColor={item.cardBorderColor}
|
|
67
|
+
cardBoxShadow={item.cardBoxShadow}
|
|
68
|
+
>
|
|
69
|
+
<CompassCardTemplate data={item} />
|
|
70
|
+
</Card>
|
|
71
|
+
)}
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
</>
|
|
75
|
+
}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const cards = screen.queryAllByTestId("card");
|
|
80
|
+
expect(cards.length).toBe(16);
|
|
81
|
+
|
|
82
|
+
expect(cards[0]).toHaveTextContent(
|
|
83
|
+
"Compass Sales Lenovo TP X13 Yoga G3 Laptop"
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(cards[3]).toHaveTextContent("Exec RoadWarrior");
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
3
|
+
import Text, { TextTypes } from ".";
|
|
4
|
+
|
|
5
|
+
interface TextStoryProps extends TextTypes {
|
|
6
|
+
size: "xs" | "sm" | "md" | "lg" | "xl";
|
|
7
|
+
color: "red" | "blue" | "green" | "primary" | "slate";
|
|
8
|
+
as: "h1" | "h2" | "h3" | "h4" | "h5" | "p";
|
|
9
|
+
fontFamily: "sans" | "mono" | "serif";
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: "Components/Text",
|
|
15
|
+
component: Text,
|
|
16
|
+
argTypes: {
|
|
17
|
+
size: {
|
|
18
|
+
control: "select",
|
|
19
|
+
options: ["xs", "sm", "md", "lg", "xl"],
|
|
20
|
+
description: "The font size for the text.",
|
|
21
|
+
},
|
|
22
|
+
color: {
|
|
23
|
+
control: "select",
|
|
24
|
+
options: ["red", "blue", "green", "slate"],
|
|
25
|
+
description: "The color of the text.",
|
|
26
|
+
},
|
|
27
|
+
tag: {
|
|
28
|
+
control: "select",
|
|
29
|
+
options: ["h1", "h2", "h3", "h4", "h5", "p"],
|
|
30
|
+
description: "The type of HTML element the text should be.",
|
|
31
|
+
},
|
|
32
|
+
fontFamily: {
|
|
33
|
+
control: "select",
|
|
34
|
+
options: ["sans", "mono", "serif"],
|
|
35
|
+
description: "The type of font family.",
|
|
36
|
+
},
|
|
37
|
+
text: {
|
|
38
|
+
control: "text",
|
|
39
|
+
description: "The main text displayed on the toaster.",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
43
|
+
tags: ["autodocs"],
|
|
44
|
+
parameters: {
|
|
45
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
46
|
+
layout: "centered",
|
|
47
|
+
},
|
|
48
|
+
} as Meta<TextStoryProps>;
|
|
49
|
+
|
|
50
|
+
const Template: StoryFn<TextStoryProps> = (args) => <Text {...args} />;
|
|
51
|
+
|
|
52
|
+
export const Primary = Template.bind({});
|
|
53
|
+
Primary.args = {
|
|
54
|
+
size: "xl",
|
|
55
|
+
color: "slate",
|
|
56
|
+
tag: "h2",
|
|
57
|
+
fontFamily: "sans",
|
|
58
|
+
text: "Testing",
|
|
59
|
+
additionalClasses: "p-5",
|
|
60
|
+
};
|