@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,146 @@
1
+ import React, { useRef, useEffect, useState } from "react";
2
+ import { VirtualItem, useVirtualizer } from "@tanstack/react-virtual";
3
+ import { useCallback } from "react";
4
+ import { getListDirectionClasses } from "./genericListClassNames";
5
+
6
+ type GenericData = {
7
+ id: string;
8
+ [key: string]: any;
9
+ };
10
+
11
+ export type GenericListTypes<T> = {
12
+ data: T[];
13
+ renderItem: (item: T) => JSX.Element;
14
+ itemHeight?: number;
15
+ containerHeight?: number;
16
+ containerClasses?: string;
17
+ listDirection?: "horizontal" | "vertical";
18
+ hasVirtualization?: boolean;
19
+ listType: "ordered" | "unordered" | "none";
20
+ };
21
+
22
+ const GenericList = <T extends GenericData>({
23
+ data,
24
+ renderItem,
25
+ itemHeight,
26
+ containerHeight,
27
+ containerClasses,
28
+ listDirection,
29
+ hasVirtualization = false,
30
+ listType,
31
+ }: GenericListTypes<T>) => {
32
+ let listClasses = getListDirectionClasses(listDirection);
33
+ let parentRef = React.createRef<HTMLElement>();
34
+
35
+ const [virtualItems, setVirtualItems] = useState<VirtualItem[]>([]);
36
+ const [nonVirtualItems, setNonVirtualItems] = useState<T[]>([]);
37
+
38
+ const estimateSize = useCallback(
39
+ () => (itemHeight ? itemHeight : 0),
40
+ [itemHeight]
41
+ );
42
+
43
+ const count = data.length;
44
+
45
+ const virtualizer = useVirtualizer({
46
+ count,
47
+ estimateSize,
48
+ overscan: count,
49
+ getScrollElement: () => parentRef.current,
50
+ });
51
+
52
+ useEffect(() => {
53
+ if (hasVirtualization) {
54
+ setVirtualItems(virtualizer.getVirtualItems());
55
+ } else {
56
+ setNonVirtualItems(data);
57
+ }
58
+ }, [hasVirtualization, virtualizer, data]);
59
+
60
+ return (
61
+ <>
62
+ {(() => {
63
+ switch (listType) {
64
+ case "ordered":
65
+ return (
66
+ <ol
67
+ ref={parentRef as React.RefObject<HTMLOListElement>}
68
+ style={
69
+ hasVirtualization
70
+ ? { height: containerHeight, overflow: "scroll" }
71
+ : {}
72
+ }
73
+ className={`${listClasses} ${containerClasses}`}
74
+ >
75
+ {hasVirtualization
76
+ ? virtualItems.map((virtualItem) => (
77
+ <li
78
+ key={virtualItem.index}
79
+ style={{ height: itemHeight }}
80
+ >
81
+ {renderItem(data[virtualItem.index])}
82
+ </li>
83
+ ))
84
+ : nonVirtualItems.map((item) => (
85
+ <li key={item.id}>{renderItem(item)}</li>
86
+ ))}
87
+ </ol>
88
+ );
89
+ case "unordered":
90
+ return (
91
+ <ul
92
+ ref={parentRef as React.RefObject<HTMLUListElement>}
93
+ style={
94
+ hasVirtualization
95
+ ? { height: containerHeight, overflow: "scroll" }
96
+ : {}
97
+ }
98
+ className={`${listClasses} ${containerClasses}`}
99
+ >
100
+ {hasVirtualization
101
+ ? virtualItems.map((virtualItem) => (
102
+ <li
103
+ key={virtualItem.index}
104
+ style={{ height: itemHeight }}
105
+ >
106
+ {renderItem(data[virtualItem.index])}
107
+ </li>
108
+ ))
109
+ : nonVirtualItems.map((item) => (
110
+ <li key={item.id}>{renderItem(item)}</li>
111
+ ))}
112
+ </ul>
113
+ );
114
+ case "none":
115
+ default:
116
+ return (
117
+ <div
118
+ ref={parentRef as React.RefObject<HTMLDivElement>}
119
+ style={
120
+ hasVirtualization
121
+ ? { height: containerHeight, overflow: "scroll" }
122
+ : {}
123
+ }
124
+ className={`${listClasses} ${containerClasses}`}
125
+ >
126
+ {hasVirtualization
127
+ ? virtualItems.map((virtualItem) => (
128
+ <div
129
+ key={virtualItem.index}
130
+ style={{ height: itemHeight }}
131
+ >
132
+ {renderItem(data[virtualItem.index])}
133
+ </div>
134
+ ))
135
+ : nonVirtualItems.map((item) => (
136
+ <div key={item.id}>{renderItem(item)}</div>
137
+ ))}
138
+ </div>
139
+ );
140
+ }
141
+ })()}
142
+ </>
143
+ )
144
+ }
145
+
146
+ export default GenericList;
@@ -0,0 +1,8 @@
1
+ import classNames from "classNames";
2
+
3
+ export const getListDirectionClasses = (listDirection: string | undefined) => {
4
+ return classNames({
5
+ "flex": listDirection === "horizontal",
6
+ "flex flex-col": listDirection === "vertical",
7
+ });
8
+ };
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ import Text from "../../Text/index";
3
+
4
+ export type TreeListProps = {
5
+ item: string;
6
+ };
7
+
8
+ const TreeList: React.FC<TreeListProps> = ({ item }) => {
9
+ return (
10
+ <>
11
+ <Text
12
+ size="lg"
13
+ color="black"
14
+ text={item}
15
+ fontFamily="font-mono"
16
+ tag="p"
17
+ additionalClasses=""
18
+ />
19
+ </>
20
+ );
21
+ };
22
+
23
+ export default TreeList;
@@ -0,0 +1,74 @@
1
+ import React from "react";
2
+ import Icon from "../../Icon/index";
3
+ import { getFontAwesomeIcon } from "../../../utils/getFontAwesomeIcon";
4
+ import Text from "../../Text/index";
5
+ import { TagName } from "../../Text/index";
6
+
7
+ export type IconsListProps = {
8
+ item: {
9
+ iconColor?: string;
10
+ iconLabel: string;
11
+ backgroundColor?: string;
12
+ size?: "xs" | "sm" | "md" | "lg" | string;
13
+ icon: string;
14
+ hoverBorder?: "border" | "none" | string;
15
+ limitCharacters?: (text: string) => string;
16
+ indicatorSize?: "sm" | "md" | "lg" | string;
17
+ iconBorder?: "border" | "none" | string;
18
+ id: string;
19
+ hoverBackground: string;
20
+ hoverColor: string;
21
+ limitIndicator: boolean;
22
+ indicatorNumber: string;
23
+ additionalContainerClasses: string;
24
+ to?: string;
25
+ href?: string;
26
+ text: {
27
+ size: string;
28
+ color: string;
29
+ text: string;
30
+ fontFamily: string;
31
+ tag: TagName;
32
+ additionalClasses: string;
33
+ };
34
+ };
35
+ };
36
+ // TODO: create a genetic list comp with TanStack Virtual and move this into the template dir in the Generic list dir
37
+ // https://tanstack.com/virtual/latest/docs/introduction
38
+ const DynamicIconList: React.FC<IconsListProps> = ({ item }) => {
39
+ return (
40
+ <>
41
+ <Icon
42
+ key={item.id}
43
+ to={item.to}
44
+ href={item.href}
45
+ limitCharacters={item.limitCharacters}
46
+ backgroundColor={item.backgroundColor}
47
+ iconColor={item.iconColor}
48
+ iconLabel={item.iconLabel}
49
+ iconBorder={item.iconBorder}
50
+ size={item.size}
51
+ icon={getFontAwesomeIcon(item.icon)}
52
+ hoverBackground={item.hoverBackground}
53
+ hoverBorder={item.hoverBorder}
54
+ limitIndicator={item.limitIndicator}
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
+ </>
71
+ );
72
+ };
73
+
74
+ export default DynamicIconList;
@@ -0,0 +1,68 @@
1
+ import React from "react";
2
+ import { motion} from "framer-motion";
3
+
4
+ import { HamburgerButtonTypes } from "./HamburgerButton.types";
5
+
6
+
7
+ const HamburgerButton: React.FC<HamburgerButtonTypes> = ({
8
+ burgerAriaLabel,
9
+ burgerExpandedAlert,
10
+ animateBoolean,
11
+ handleNav,
12
+ }) => {
13
+ return (
14
+ <div className="flex min-h-20">
15
+ <div className="pl-2 mx-auto my-auto hidden max-xl:flex">
16
+ {
17
+ <motion.button
18
+ aria-label={burgerAriaLabel}
19
+ aria-expanded={burgerExpandedAlert === "True"}
20
+ data-testid="hamburger-button"
21
+ initial="hide"
22
+ animate={animateBoolean ? "show" : "hide"}
23
+ onClick={handleNav}
24
+ className="flex flex-col space-y-1 relative z-10 p-2"
25
+ >
26
+ <motion.span
27
+ variants={{
28
+ hide: {
29
+ rotate: 0,
30
+ },
31
+ show: {
32
+ rotate: 45,
33
+ y: 5,
34
+ },
35
+ }}
36
+ className="w-6 bg-black h-px block"
37
+ ></motion.span>
38
+ <motion.span
39
+ variants={{
40
+ hide: {
41
+ opacity: 1,
42
+ },
43
+ show: {
44
+ opacity: 0,
45
+ },
46
+ }}
47
+ className="w-6 bg-black h-px block"
48
+ ></motion.span>
49
+ <motion.span
50
+ variants={{
51
+ hide: {
52
+ rotate: 0,
53
+ },
54
+ show: {
55
+ rotate: -45,
56
+ y: -5,
57
+ },
58
+ }}
59
+ className="w-6 bg-black h-px block"
60
+ ></motion.span>
61
+ </motion.button>
62
+ }
63
+ </div>
64
+ </div>
65
+ );
66
+ };
67
+
68
+ export default HamburgerButton;
@@ -0,0 +1,6 @@
1
+ export interface HamburgerButtonTypes {
2
+ burgerAriaLabel: string;
3
+ burgerExpandedAlert: string;
4
+ animateBoolean: boolean;
5
+ handleNav: () => void;
6
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from "./HamburgerButton";
2
+ export * from "./HamburgerButton.types";
@@ -0,0 +1,136 @@
1
+ {
2
+ "DUMMYICONCOMPASSDATA": [
3
+ {
4
+ "id": "1",
5
+ "icon": "user",
6
+ "href": "#",
7
+ "to": "",
8
+ "iconColor": "black",
9
+ "iconLabel": "account",
10
+ "iconBorder": "none",
11
+ "backgroundColor": "green",
12
+ "hoverBackground": "green",
13
+ "hoverBorder": "green",
14
+ "hoverColor": "green",
15
+ "size": "xs",
16
+ "additionalContainerClasses": "",
17
+ "indicatorNumber": "",
18
+ "limitIndicator": true,
19
+ "indicatorSize": "sm",
20
+ "text": {
21
+ "size": "xs",
22
+ "color": "primary",
23
+ "text": "Account",
24
+ "fontFamily": "serif",
25
+ "tag": "span",
26
+ "additionalClasses": "m-0 p-0"
27
+ }
28
+ },
29
+ {
30
+ "id": "2",
31
+ "icon": "infoCircle",
32
+ "href": "#",
33
+ "to": "",
34
+ "iconColor": "black",
35
+ "iconLabel": "information",
36
+ "iconBorder": "none",
37
+ "backgroundColor": "green",
38
+ "hoverBackground": "green",
39
+ "hoverBorder": "green",
40
+ "hoverColor": "green",
41
+ "size": "xs",
42
+ "additionalContainerClasses": "",
43
+ "indicatorNumber": "",
44
+ "limitIndicator": true,
45
+ "indicatorSize": "sm",
46
+ "text": {
47
+ "size": "xs",
48
+ "color": "primary",
49
+ "text": "Info",
50
+ "fontFamily": "serif",
51
+ "tag": "span",
52
+ "additionalClasses": "m-0 p-0"
53
+ }
54
+ },
55
+ {
56
+ "id": "3",
57
+ "icon": "bell",
58
+ "href": "#",
59
+ "to": "",
60
+ "iconColor": "black",
61
+ "iconLabel": "notifications",
62
+ "iconBorder": "none",
63
+ "backgroundColor": "green",
64
+ "hoverBackground": "green",
65
+ "hoverBorder": "green",
66
+ "hoverColor": "green",
67
+ "size": "xs",
68
+ "additionalContainerClasses": "",
69
+ "indicatorNumber": "100",
70
+ "limitIndicator": true,
71
+ "indicatorSize": "sm",
72
+ "text": {
73
+ "size": "xs",
74
+ "color": "primary",
75
+ "text": "Notifications",
76
+ "fontFamily": "serif",
77
+ "tag": "span",
78
+ "additionalClasses": "m-0 p-0"
79
+ }
80
+ },
81
+ {
82
+ "id": "4",
83
+ "icon": "shoppingCart",
84
+ "href": "#",
85
+ "to": "",
86
+ "iconColor": "black",
87
+ "iconLabel": "shopping cart",
88
+ "iconBorder": "none",
89
+ "backgroundColor": "green",
90
+ "hoverBackground": "green",
91
+ "hoverBorder": "green",
92
+ "hoverColor": "green",
93
+ "size": "xs",
94
+ "additionalContainerClasses": "",
95
+ "indicatorNumber": "",
96
+ "limitIndicator": true,
97
+ "indicatorSize": "sm",
98
+ "text": {
99
+ "size": "xs",
100
+ "color": "primary",
101
+ "text": "Cart",
102
+ "fontFamily": "serif",
103
+ "tag": "span",
104
+ "additionalClasses": "m-0 p-0"
105
+ }
106
+ }
107
+ ],
108
+ "DUMMYICONTOGADATA": [
109
+ {
110
+ "id": "1",
111
+ "icon": "user",
112
+ "href": "#",
113
+ "to": "",
114
+ "iconColor": "black",
115
+ "iconLabel": "account",
116
+ "iconBorder": "none",
117
+ "backgroundColor": "blue",
118
+ "hoverBackground": "blue",
119
+ "hoverBorder": "none",
120
+ "hoverColor": "blue",
121
+ "size": "xs",
122
+ "additionalContainerClasses": "",
123
+ "indicatorNumber": "",
124
+ "limitIndicator": true,
125
+ "indicatorSize": "sm",
126
+ "text": {
127
+ "size": "xs",
128
+ "color": "primary",
129
+ "text": "Account",
130
+ "fontFamily": "serif",
131
+ "tag": "span",
132
+ "additionalClasses": "m-0 p-0"
133
+ }
134
+ }
135
+ ]
136
+ }