@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.
Files changed (138) hide show
  1. package/Dockerfile +9 -0
  2. package/README.md +69 -0
  3. package/assets/Logo.png +0 -0
  4. package/assets/compass-card-image-2.png +0 -0
  5. package/assets/compass-card-image-3.png +0 -0
  6. package/assets/compass-card-image-4.png +0 -0
  7. package/assets/compass-card-image.png +0 -0
  8. package/assets/compass-logo.png +0 -0
  9. package/assets/compass-tech-hero-bg.png +0 -0
  10. package/assets/contact-image.png +0 -0
  11. package/assets/green-laptop.png +0 -0
  12. package/assets/heroImage.png +0 -0
  13. package/assets/placeholder-no-image-available.png +0 -0
  14. package/assets/team.png +0 -0
  15. package/declarations.d.ts +4 -0
  16. package/docker-compose.yml +22 -0
  17. package/global.css +4 -0
  18. package/index.js +4 -0
  19. package/nodemon.json +5 -0
  20. package/package.json +70 -0
  21. package/postcss.config.js +6 -0
  22. package/src/components/Badge/Badge.stories.tsx +284 -0
  23. package/src/components/Badge/Badge.test.tsx +185 -0
  24. package/src/components/Badge/Badge.tsx +137 -0
  25. package/src/components/Badge/Badge.types.tsx +28 -0
  26. package/src/components/Badge/badgeClassNames.tsx +152 -0
  27. package/src/components/Badge/index.ts +2 -0
  28. package/src/components/Card/Card.stories.tsx +91 -0
  29. package/src/components/Card/Card.test.tsx +53 -0
  30. package/src/components/Card/Card.tsx +30 -0
  31. package/src/components/Card/Card.types.ts +11 -0
  32. package/src/components/Card/DUMMYPRODUCTDATA.json +670 -0
  33. package/src/components/Card/cardClassNames.ts +49 -0
  34. package/src/components/Card/index.ts +3 -0
  35. package/src/components/Card/templates/CompassCardTemplate.tsx +58 -0
  36. package/src/components/Card/templates/HorizontalCardTemplate.tsx +184 -0
  37. package/src/components/Card/templates/VerticalCardTemplate.tsx +154 -0
  38. package/src/components/Footer/ContactInfoItem.tsx +20 -0
  39. package/src/components/Footer/DUMMYFOOTERDATA.json +132 -0
  40. package/src/components/Footer/Footer.stories.tsx +292 -0
  41. package/src/components/Footer/Footer.test.tsx +90 -0
  42. package/src/components/Footer/Footer.tsx +159 -0
  43. package/src/components/Footer/Footer.types.tsx +61 -0
  44. package/src/components/Footer/footerClassNames.tsx +57 -0
  45. package/src/components/FormButton/FormButton.stories.tsx +199 -0
  46. package/src/components/FormButton/FormButton.test.tsx +73 -0
  47. package/src/components/FormButton/FormButton.tsx +116 -0
  48. package/src/components/FormButton/FormButton.types.ts +32 -0
  49. package/src/components/FormButton/formButtonClassNames.tsx +153 -0
  50. package/src/components/FormButton/index.ts +2 -0
  51. package/src/components/GenericList/DUMMYLISTDATA.json +560 -0
  52. package/src/components/GenericList/GenericList.stories.tsx +104 -0
  53. package/src/components/GenericList/GenericList.test.tsx +29 -0
  54. package/src/components/GenericList/GenericList.tsx +146 -0
  55. package/src/components/GenericList/genericListClassNames.tsx +8 -0
  56. package/src/components/GenericList/templates/DummyDataList.tsx +23 -0
  57. package/src/components/GenericList/templates/DynamicIconList.tsx +74 -0
  58. package/src/components/HamburgerButton/HamburgerButton.tsx +68 -0
  59. package/src/components/HamburgerButton/HamburgerButton.types.tsx +6 -0
  60. package/src/components/HamburgerButton/index.ts +2 -0
  61. package/src/components/Header/DUMMYICONDATA.json +136 -0
  62. package/src/components/Header/Header.stories.tsx +521 -0
  63. package/src/components/Header/Header.test.tsx +323 -0
  64. package/src/components/Header/Header.tsx +289 -0
  65. package/src/components/Header/Header.types.ts +52 -0
  66. package/src/components/Header/headerClassNames.tsx +50 -0
  67. package/src/components/Header/headerContext.tsx +125 -0
  68. package/src/components/Header/index.ts +2 -0
  69. package/src/components/Hero/Hero.stories.tsx +69 -0
  70. package/src/components/Hero/Hero.test.tsx +109 -0
  71. package/src/components/Hero/Hero.tsx +58 -0
  72. package/src/components/Hero/Hero.types.ts +9 -0
  73. package/src/components/Hero/index.ts +2 -0
  74. package/src/components/Icon/Icon.stories.tsx +227 -0
  75. package/src/components/Icon/Icon.test.tsx +53 -0
  76. package/src/components/Icon/Icon.tsx +208 -0
  77. package/src/components/Icon/Icon.types.ts +24 -0
  78. package/src/components/Icon/iconClassNames.ts +79 -0
  79. package/src/components/Icon/index.ts +2 -0
  80. package/src/components/Image/Image.stories.tsx +79 -0
  81. package/src/components/Image/Image.test.tsx +87 -0
  82. package/src/components/Image/Image.tsx +49 -0
  83. package/src/components/Image/Image.types.ts +11 -0
  84. package/src/components/Image/index.ts +2 -0
  85. package/src/components/Input/Input.stories.tsx +651 -0
  86. package/src/components/Input/Input.test.tsx +90 -0
  87. package/src/components/Input/Input.tsx +226 -0
  88. package/src/components/Input/Input.types.ts +52 -0
  89. package/src/components/Input/InputMemoTypes.tsx +32 -0
  90. package/src/components/Input/index.ts +2 -0
  91. package/src/components/Input/inputClassNames.tsx +169 -0
  92. package/src/components/MobileMenu/MobileMenu.tsx +41 -0
  93. package/src/components/MobileMenu/MobileMenu.types.tsx +30 -0
  94. package/src/components/MobileMenu/index.ts +2 -0
  95. package/src/components/Nav/DUMMYNAVDATA.json +234 -0
  96. package/src/components/Nav/Nav.stories.tsx +181 -0
  97. package/src/components/Nav/Nav.test.tsx +89 -0
  98. package/src/components/Nav/Nav.tsx +242 -0
  99. package/src/components/Nav/Nav.types.tsx +35 -0
  100. package/src/components/Nav/index.ts +2 -0
  101. package/src/components/Nav/navClassNames.tsx +192 -0
  102. package/src/components/Page/TableDataDummy.tsx +216 -0
  103. package/src/components/Page/ViewPageTemplate.stories.tsx +546 -0
  104. package/src/components/Page/ViewPageTemplate.test.tsx +361 -0
  105. package/src/components/Page/ViewPageTemplate.tsx +10 -0
  106. package/src/components/Page/ViewPageTemplate.types.ts +6 -0
  107. package/src/components/Page/index.ts +2 -0
  108. package/src/components/PageSection/PageSection.stories.tsx +114 -0
  109. package/src/components/PageSection/PageSection.tsx +12 -0
  110. package/src/components/PageSection/PageSection.types.ts +6 -0
  111. package/src/components/PageSection/PageSections.test.tsx +88 -0
  112. package/src/components/PageSection/index.ts +2 -0
  113. package/src/components/Text/Text.stories.tsx +60 -0
  114. package/src/components/Text/Text.test.tsx +52 -0
  115. package/src/components/Text/Text.tsx +80 -0
  116. package/src/components/Text/Text.types.ts +12 -0
  117. package/src/components/Text/index.ts +2 -0
  118. package/src/components/Toaster/Toaster.stories.tsx +122 -0
  119. package/src/components/Toaster/Toaster.test.tsx +61 -0
  120. package/src/components/Toaster/Toaster.tsx +80 -0
  121. package/src/components/Toaster/Toaster.types.ts +12 -0
  122. package/src/components/Toaster/index.ts +2 -0
  123. package/src/hoc/index.ts +2 -0
  124. package/src/hoc/styling/withStoryBook.tsx +19 -0
  125. package/src/main.css +3 -0
  126. package/src/setupTests.ts +1 -0
  127. package/src/userHoc/index.ts +1 -0
  128. package/src/userHoc/withMemo.tsx +20 -0
  129. package/src/utils/assertTagName.tsx +7 -0
  130. package/src/utils/generateAccordionItem.tsx +102 -0
  131. package/src/utils/generateFooterContacts.tsx +75 -0
  132. package/src/utils/generateNavMenu.tsx +54 -0
  133. package/src/utils/generateSocialList.tsx +34 -0
  134. package/src/utils/getFontAwesomeIcon.tsx +25 -0
  135. package/src/utils/inputValidation.tsx +26 -0
  136. package/tailwind.config.js +32 -0
  137. package/tsconfig.json +25 -0
  138. 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,10 @@
1
+ import { ViewPageTemplateTypes } from ".";
2
+
3
+ const ViewTemplatePage: React.FC<ViewPageTemplateTypes> = ({
4
+ children,
5
+ bgColor = "bg-gray-100",
6
+ }) => {
7
+ return <div className={`${bgColor}`}>{children}</div>;
8
+ };
9
+
10
+ export default ViewTemplatePage;
@@ -0,0 +1,6 @@
1
+ import React, { ReactNode } from "react";
2
+
3
+ export interface ViewPageTemplateTypes {
4
+ children: ReactNode;
5
+ bgColor?: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from "./ViewPageTemplate";
2
+ export * from "./ViewPageTemplate.types";
@@ -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,6 @@
1
+ import { ReactNode } from "react";
2
+
3
+ export interface PageSectionTypes {
4
+ children: ReactNode;
5
+ sectionContainerClasses?: string;
6
+ }
@@ -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,2 @@
1
+ export { default } from "./PageSection";
2
+ export * from "./PageSection.types";
@@ -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
+ };