@agilant/toga-blox 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/cable.jpg +0 -0
- package/assets/card-1.jpg +0 -0
- package/assets/cat-logo.png +0 -0
- package/assets/item.jpg +0 -0
- package/assets/map.png +0 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +953 -0
- package/coverage/coverage-final.json +74 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +551 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/toga-blox-npm/index.html +131 -0
- package/coverage/toga-blox-npm/postcss.config.js.html +103 -0
- package/coverage/toga-blox-npm/src/components/Badge/Badge.stories.tsx.html +793 -0
- package/coverage/toga-blox-npm/src/components/Badge/Badge.tsx.html +247 -0
- package/coverage/toga-blox-npm/src/components/Badge/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Card/Card.stories.tsx.html +787 -0
- package/coverage/toga-blox-npm/src/components/Card/Card.tsx.html +163 -0
- package/coverage/toga-blox-npm/src/components/Card/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/CategoryCardTemplate.tsx.html +343 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/CompassCardTemplate.tsx.html +259 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/CounterContentCardTemplate.tsx.html +685 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/HorizontalCardTemplate.tsx.html +637 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/ItemCardTemplate.tsx.html +550 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/KitContentCardTemplate.tsx.html +469 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/ShippingAddressCardTemplate.tsx.html +418 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/VerticalCardTemplate.tsx.html +592 -0
- package/coverage/toga-blox-npm/src/components/Card/templates/index.html +221 -0
- package/coverage/toga-blox-npm/src/components/CounterButton/CounterButton.stories.tsx.html +358 -0
- package/coverage/toga-blox-npm/src/components/CounterButton/CounterButton.tsx.html +385 -0
- package/coverage/toga-blox-npm/src/components/CounterButton/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Description/Description.stories.tsx.html +286 -0
- package/coverage/toga-blox-npm/src/components/Description/Description.tsx.html +124 -0
- package/coverage/toga-blox-npm/src/components/Description/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/DropDownIconButton/DropDownIconButton.stories.tsx.html +676 -0
- package/coverage/toga-blox-npm/src/components/DropDownIconButton/DropDownIconButton.tsx.html +346 -0
- package/coverage/toga-blox-npm/src/components/DropDownIconButton/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Footer/ContactInfoItem.tsx.html +139 -0
- package/coverage/toga-blox-npm/src/components/Footer/Footer.stories.tsx.html +934 -0
- package/coverage/toga-blox-npm/src/components/Footer/Footer.tsx.html +373 -0
- package/coverage/toga-blox-npm/src/components/Footer/index.html +146 -0
- package/coverage/toga-blox-npm/src/components/FormButton/FormButton.stories.tsx.html +952 -0
- package/coverage/toga-blox-npm/src/components/FormButton/FormButton.tsx.html +343 -0
- package/coverage/toga-blox-npm/src/components/FormButton/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/GenericList/GenericList.stories.tsx.html +376 -0
- package/coverage/toga-blox-npm/src/components/GenericList/GenericList.tsx.html +520 -0
- package/coverage/toga-blox-npm/src/components/GenericList/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/GenericList/templates/DummyDataList.tsx.html +154 -0
- package/coverage/toga-blox-npm/src/components/GenericList/templates/DynamicIconList.tsx.html +250 -0
- package/coverage/toga-blox-npm/src/components/GenericList/templates/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/GetSupport/GetSupport.stories.tsx.html +325 -0
- package/coverage/toga-blox-npm/src/components/GetSupport/GetSupport.tsx.html +262 -0
- package/coverage/toga-blox-npm/src/components/GetSupport/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/HamburgerButton/Hamburger.stories.tsx.html +760 -0
- package/coverage/toga-blox-npm/src/components/HamburgerButton/HamburgerButton.tsx.html +232 -0
- package/coverage/toga-blox-npm/src/components/HamburgerButton/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Header/Header.stories.tsx.html +1633 -0
- package/coverage/toga-blox-npm/src/components/Header/Header.tsx.html +814 -0
- package/coverage/toga-blox-npm/src/components/Header/headerContext.tsx.html +460 -0
- package/coverage/toga-blox-npm/src/components/Header/index.html +146 -0
- package/coverage/toga-blox-npm/src/components/Hero/Hero.stories.tsx.html +289 -0
- package/coverage/toga-blox-npm/src/components/Hero/Hero.tsx.html +259 -0
- package/coverage/toga-blox-npm/src/components/Hero/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/IconButton/IconButton.stories.tsx.html +673 -0
- package/coverage/toga-blox-npm/src/components/IconButton/IconButton.tsx.html +313 -0
- package/coverage/toga-blox-npm/src/components/IconButton/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Image/Image.stories.tsx.html +322 -0
- package/coverage/toga-blox-npm/src/components/Image/Image.tsx.html +226 -0
- package/coverage/toga-blox-npm/src/components/Image/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Input/Input.stories.tsx.html +1621 -0
- package/coverage/toga-blox-npm/src/components/Input/Input.tsx.html +568 -0
- package/coverage/toga-blox-npm/src/components/Input/InputMemoTypes.tsx.html +181 -0
- package/coverage/toga-blox-npm/src/components/Input/index.html +146 -0
- package/coverage/toga-blox-npm/src/components/MobileMenu/MobileMenu.tsx.html +208 -0
- package/coverage/toga-blox-npm/src/components/MobileMenu/index.html +116 -0
- package/coverage/toga-blox-npm/src/components/Nav/Nav.stories.tsx.html +628 -0
- package/coverage/toga-blox-npm/src/components/Nav/Nav.tsx.html +622 -0
- package/coverage/toga-blox-npm/src/components/Nav/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Page/TableDataDummy.tsx.html +733 -0
- package/coverage/toga-blox-npm/src/components/Page/ViewPageTemplate.stories.tsx.html +1714 -0
- package/coverage/toga-blox-npm/src/components/Page/ViewPageTemplate.tsx.html +115 -0
- package/coverage/toga-blox-npm/src/components/Page/index.html +146 -0
- package/coverage/toga-blox-npm/src/components/PageSection/PageSection.stories.tsx.html +433 -0
- package/coverage/toga-blox-npm/src/components/PageSection/PageSection.tsx.html +121 -0
- package/coverage/toga-blox-npm/src/components/PageSection/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/SearchInput/SearchInput.stories.tsx.html +517 -0
- package/coverage/toga-blox-npm/src/components/SearchInput/SearchInput.tsx.html +325 -0
- package/coverage/toga-blox-npm/src/components/SearchInput/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Slider/Slider.stories.tsx.html +349 -0
- package/coverage/toga-blox-npm/src/components/Slider/Slider.tsx.html +502 -0
- package/coverage/toga-blox-npm/src/components/Slider/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Submenus/AdminSubmenu.tsx.html +136 -0
- package/coverage/toga-blox-npm/src/components/Submenus/AlertSubmenu.tsx.html +253 -0
- package/coverage/toga-blox-npm/src/components/Submenus/AlertSubmenuItem.tsx.html +202 -0
- package/coverage/toga-blox-npm/src/components/Submenus/index.html +146 -0
- package/coverage/toga-blox-npm/src/components/Text/Text.stories.tsx.html +235 -0
- package/coverage/toga-blox-npm/src/components/Text/Text.tsx.html +172 -0
- package/coverage/toga-blox-npm/src/components/Text/index.html +131 -0
- package/coverage/toga-blox-npm/src/components/Toaster/Toaster.stories.tsx.html +445 -0
- package/coverage/toga-blox-npm/src/components/Toaster/Toaster.tsx.html +301 -0
- package/coverage/toga-blox-npm/src/components/Toaster/index.html +131 -0
- package/coverage/toga-blox-npm/src/hoc/styling/index.html +116 -0
- package/coverage/toga-blox-npm/src/hoc/styling/withStoryBook.tsx.html +142 -0
- package/coverage/toga-blox-npm/src/userHoc/index.html +116 -0
- package/coverage/toga-blox-npm/src/userHoc/withMemo.tsx.html +145 -0
- package/coverage/toga-blox-npm/src/utils/assertTagName.tsx.html +106 -0
- package/coverage/toga-blox-npm/src/utils/generateAccordionItem.tsx.html +373 -0
- package/coverage/toga-blox-npm/src/utils/generateFooterContacts.tsx.html +295 -0
- package/coverage/toga-blox-npm/src/utils/generateNavMenu.tsx.html +247 -0
- package/coverage/toga-blox-npm/src/utils/generateSocialList.tsx.html +187 -0
- package/coverage/toga-blox-npm/src/utils/getFontAwesomeIcon.tsx.html +145 -0
- package/coverage/toga-blox-npm/src/utils/index.html +206 -0
- package/coverage/toga-blox-npm/src/utils/inputValidation.tsx.html +163 -0
- package/coverage/toga-blox-npm/tailwind.config.js.html +205 -0
- package/declarations.d.ts +1 -1
- package/package.json +5 -6
- package/src/components/Badge/Badge.stories.tsx +110 -207
- package/src/components/Badge/Badge.test.tsx +40 -41
- package/src/components/Badge/Badge.tsx +29 -99
- package/src/components/Badge/Badge.types.tsx +12 -23
- package/src/components/Card/Card.stories.tsx +166 -22
- package/src/components/Card/Card.test.tsx +3 -3
- package/src/components/Card/Card.tsx +12 -16
- package/src/components/Card/DUMMYPRODUCTDATA.json +381 -225
- package/src/components/Card/templates/CategoryCardTemplate.tsx +86 -0
- package/src/components/Card/templates/CompassCardTemplate.tsx +1 -1
- package/src/components/Card/templates/CounterContentCardTemplate.tsx +200 -0
- package/src/components/Card/templates/ItemCardTemplate.tsx +155 -0
- package/src/components/Card/templates/KitContentCardTemplate.tsx +128 -0
- package/src/components/Card/templates/ShippingAddressCardTemplate.tsx +111 -0
- package/src/components/Card/templates/VerticalCardTemplate.tsx +100 -85
- package/src/components/CounterButton/CounterButton.tsx +1 -1
- package/src/components/Description/Description.stories.tsx +67 -0
- package/src/components/Description/Description.tsx +13 -0
- package/src/components/Description/Description.types.ts +9 -0
- package/src/components/DropDownIconButton/DropDownIconButton.stories.tsx +197 -0
- package/src/components/DropDownIconButton/DropDownIconButton.test.tsx +90 -0
- package/src/components/DropDownIconButton/DropDownIconButton.tsx +87 -0
- package/src/components/DropDownIconButton/DropDownIconButton.types.ts +21 -0
- package/src/components/DropDownIconButton/index.ts +2 -0
- package/src/components/Footer/ContactInfoItem.tsx +8 -10
- package/src/components/Footer/Footer.stories.tsx +13 -22
- package/src/components/Footer/Footer.tsx +25 -88
- package/src/components/Footer/Footer.types.tsx +2 -2
- package/src/components/FormButton/FormButton.stories.tsx +101 -226
- package/src/components/FormButton/FormButton.test.tsx +1 -1
- package/src/components/FormButton/FormButton.tsx +34 -42
- package/src/components/FormButton/FormButton.types.ts +7 -13
- package/src/components/GenericList/GenericList.stories.tsx +5 -12
- package/src/components/GenericList/GenericList.tsx +91 -92
- package/src/components/GenericList/templates/DynamicIconList.tsx +45 -64
- package/src/components/GetSupport/GetSupport.stories.tsx +80 -0
- package/src/components/GetSupport/GetSupport.test.tsx +62 -0
- package/src/components/GetSupport/GetSupport.tsx +59 -0
- package/src/components/GetSupport/GetSupport.types.ts +11 -0
- package/src/components/HamburgerButton/Hamburger.stories.tsx +225 -0
- package/src/components/HamburgerButton/HamburgerButton.tsx +37 -56
- package/src/components/HamburgerButton/HamburgerButton.types.tsx +2 -1
- package/src/components/Header/Header.stories.tsx +3 -5
- package/src/components/Header/Header.tsx +37 -83
- package/src/components/Hero/Hero.stories.tsx +1 -2
- package/src/components/IconButton/IconButton.stories.tsx +196 -0
- package/src/components/{Icon/Icon.test.tsx → IconButton/IconButton.test.tsx} +3 -4
- package/src/components/IconButton/IconButton.tsx +76 -0
- package/src/components/IconButton/IconButton.types.ts +28 -0
- package/src/components/IconButton/index.ts +2 -0
- package/src/components/Image/Image.tsx +1 -1
- package/src/components/Input/Input.stories.tsx +10 -12
- package/src/components/Input/Input.test.tsx +2 -3
- package/src/components/Input/Input.tsx +41 -104
- package/src/components/MobileMenu/MobileMenu.types.tsx +0 -2
- package/src/components/Nav/DUMMYNAVDATA.json +4 -4
- package/src/components/Nav/Nav.tsx +49 -112
- package/src/components/Nav/Nav.types.tsx +14 -2
- package/src/components/Page/ViewPageTemplate.stories.tsx +2 -2
- package/src/components/Page/ViewPageTemplate.test.tsx +1 -1
- package/src/components/Page/ViewPageTemplate.types.ts +1 -1
- package/src/components/PageSection/PageSection.stories.tsx +3 -1
- package/src/components/PageSection/PageSections.test.tsx +2 -1
- package/src/components/SearchInput/SearchInput.stories.tsx +144 -0
- package/src/components/SearchInput/SearchInput.tsx +81 -0
- package/src/components/SearchInput/SearchInput.types.ts +28 -0
- package/src/components/Slider/Slider.stories.tsx +88 -0
- package/src/components/Slider/Slider.tsx +139 -0
- package/src/components/Slider/Slider.types.ts +21 -0
- package/src/components/Submenus/AdminSubmenu.tsx +17 -0
- package/src/components/Submenus/AlertSubmenu.tsx +56 -0
- package/src/components/Submenus/AlertSubmenuItem.tsx +39 -0
- package/src/components/Submenus/types.tsx +32 -0
- package/src/components/Toaster/Toaster.stories.tsx +4 -6
- package/src/components/Toaster/Toaster.test.tsx +3 -4
- package/src/components/Toaster/Toaster.tsx +9 -17
- package/src/components/Toaster/Toaster.types.ts +2 -2
- package/src/utils/assertTagName.tsx +1 -1
- package/src/utils/generateAccordionItem.tsx +7 -13
- package/src/utils/generateFooterContacts.tsx +4 -9
- package/src/utils/getFontAwesomeIcon.tsx +8 -13
- package/tailwind.config.js +11 -3
- package/src/components/Badge/badgeClassNames.tsx +0 -173
- package/src/components/Card/cardClassNames.ts +0 -49
- package/src/components/Footer/footerClassNames.tsx +0 -57
- package/src/components/FormButton/formButtonClassNames.tsx +0 -153
- package/src/components/GenericList/genericListClassNames.tsx +0 -8
- package/src/components/Header/headerClassNames.tsx +0 -50
- package/src/components/Icon/Icon.stories.tsx +0 -227
- package/src/components/Icon/Icon.tsx +0 -208
- package/src/components/Icon/Icon.types.ts +0 -24
- package/src/components/Icon/iconClassNames.ts +0 -79
- package/src/components/Icon/index.ts +0 -2
- package/src/components/Input/inputClassNames.tsx +0 -169
- package/src/components/Nav/navClassNames.tsx +0 -192
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// src/components/HamburgerButton.stories.tsx
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
4
|
+
import { motion, AnimatePresence } from 'framer-motion';
|
|
5
|
+
import HamburgerButton from './HamburgerButton';
|
|
6
|
+
import { HamburgerButtonProps } from './HamburgerButton.types';
|
|
7
|
+
import GetSupport from '../GetSupport/GetSupport';
|
|
8
|
+
import { getFontAwesomeIcon } from '../../utils/getFontAwesomeIcon';
|
|
9
|
+
import IconButton from '../IconButton';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'Components/HamburgerButton',
|
|
13
|
+
component: HamburgerButton,
|
|
14
|
+
parameters: {
|
|
15
|
+
docs: {
|
|
16
|
+
description: {
|
|
17
|
+
component: `
|
|
18
|
+
The **HamburgerButton** component toggles between a hamburger icon and an "X" icon with smooth animations using Framer Motion.
|
|
19
|
+
It overlays on top of everything, and a gray background appears on toggle.
|
|
20
|
+
`,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
argTypes: {
|
|
25
|
+
containerClasses: {
|
|
26
|
+
control: 'none',
|
|
27
|
+
description: 'CSS classes for styling the container of the button.',
|
|
28
|
+
defaultValue: 'bg-gray-200',
|
|
29
|
+
table: {
|
|
30
|
+
type: { summary: 'string' },
|
|
31
|
+
defaultValue: { summary: 'bg-gray-200' },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
burgerAriaLabel: {
|
|
35
|
+
control: 'none',
|
|
36
|
+
description: 'Aria-label for accessibility to describe the button.',
|
|
37
|
+
defaultValue: 'Toggle navigation',
|
|
38
|
+
table: {
|
|
39
|
+
type: { summary: 'string' },
|
|
40
|
+
defaultValue: { summary: 'Toggle navigation' },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
burgerExpandedAlert: {
|
|
44
|
+
control: 'none',
|
|
45
|
+
description: 'Indicates whether the burger is in the expanded state.',
|
|
46
|
+
defaultValue: false,
|
|
47
|
+
table: {
|
|
48
|
+
type: { summary: 'boolean' },
|
|
49
|
+
defaultValue: { summary: false },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
animateBoolean: {
|
|
53
|
+
control: 'none',
|
|
54
|
+
description: 'Determines whether the burger animations should play.',
|
|
55
|
+
defaultValue: false,
|
|
56
|
+
table: {
|
|
57
|
+
type: { summary: 'boolean' },
|
|
58
|
+
defaultValue: { summary: false },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
handleNav: {
|
|
62
|
+
action: 'clicked',
|
|
63
|
+
description: 'Action triggered when the button is clicked.',
|
|
64
|
+
table: {
|
|
65
|
+
type: { summary: 'function' },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
tags: ['autodocs'],
|
|
70
|
+
} as Meta<typeof HamburgerButton>;
|
|
71
|
+
|
|
72
|
+
const Template: StoryFn<HamburgerButtonProps> = (args) => {
|
|
73
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
74
|
+
|
|
75
|
+
const toggleIcon = () => {
|
|
76
|
+
setIsOpen(!isOpen);
|
|
77
|
+
args.handleNav();
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className="relative h-screen bg-gray-50 overflow-hidden flex items-start justify-end p-4">
|
|
82
|
+
<AnimatePresence>
|
|
83
|
+
{isOpen && (
|
|
84
|
+
<motion.div
|
|
85
|
+
className="fixed inset-0 bg-white z-30 flex flex-col items-start p-6 space-y-8"
|
|
86
|
+
initial={{ x: '-100%' }}
|
|
87
|
+
animate={{ x: '0%' }}
|
|
88
|
+
exit={{ x: '-100%' }}
|
|
89
|
+
transition={{ duration: 0.3 }}
|
|
90
|
+
>
|
|
91
|
+
<div className="flex items-center space-x-3">
|
|
92
|
+
<img
|
|
93
|
+
src="../../../assets/compass-logo.png"
|
|
94
|
+
alt="Compass Technology"
|
|
95
|
+
className="h-10"
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div className="flex items-center w-full bg-gray-100 p-1 rounded-full shadow-inner">
|
|
100
|
+
<input
|
|
101
|
+
type="text"
|
|
102
|
+
placeholder="Search for product..."
|
|
103
|
+
className="flex-grow bg-transparent outline-none px-1 text-gray-700 placeholder-gray-400"
|
|
104
|
+
/>
|
|
105
|
+
<button className="bg-teal-600 flex justify-center items-center rounded-full p-3 w-10 h-10 text-white">
|
|
106
|
+
{getFontAwesomeIcon('search')}
|
|
107
|
+
</button>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div className="flex flex-row justify-start items-center gap-6">
|
|
111
|
+
<IconButton
|
|
112
|
+
iconColor="text-black"
|
|
113
|
+
text="Admin"
|
|
114
|
+
backgroundColor="bg-gray-200 hover:bg-slate-300"
|
|
115
|
+
iconSize="h-8 w-8"
|
|
116
|
+
icon={getFontAwesomeIcon("cog")}
|
|
117
|
+
notificationCount={0}
|
|
118
|
+
textClasses="text-black font-serif text-md"
|
|
119
|
+
onClick={() => alert("Redirect to admin")}
|
|
120
|
+
/>
|
|
121
|
+
<IconButton
|
|
122
|
+
iconColor="text-black"
|
|
123
|
+
text="Profile"
|
|
124
|
+
backgroundColor="bg-gray-200 hover:bg-slate-300"
|
|
125
|
+
iconSize="h-8 w-8"
|
|
126
|
+
icon={getFontAwesomeIcon("user")}
|
|
127
|
+
hoverBackgroundColor="hover:bg-gray-300"
|
|
128
|
+
hoverBorderColor="hover:border-black"
|
|
129
|
+
notificationCount={34}
|
|
130
|
+
textClasses="text-black font-serif text-md"
|
|
131
|
+
onClick={() => alert("Redirect to user")}
|
|
132
|
+
/>
|
|
133
|
+
<IconButton
|
|
134
|
+
iconColor="text-black"
|
|
135
|
+
text="Notifications"
|
|
136
|
+
backgroundColor="bg-gray-200 hover:bg-slate-300"
|
|
137
|
+
iconSize="h-8 w-8"
|
|
138
|
+
icon={getFontAwesomeIcon("bell")}
|
|
139
|
+
hoverBackgroundColor="hover:bg-gray-300"
|
|
140
|
+
hoverBorderColor="hover:border-black"
|
|
141
|
+
notificationCount={6}
|
|
142
|
+
textClasses="text-black font-serif text-md"
|
|
143
|
+
onClick={() => alert("Redirect to notifications")}
|
|
144
|
+
/>
|
|
145
|
+
<IconButton
|
|
146
|
+
iconColor="text-black"
|
|
147
|
+
text="Cart"
|
|
148
|
+
backgroundColor="bg-gray-200 hover:bg-slate-300"
|
|
149
|
+
iconSize="h-8 w-8"
|
|
150
|
+
icon={getFontAwesomeIcon("shoppingCart")}
|
|
151
|
+
hoverBackgroundColor="hover:bg-gray-300"
|
|
152
|
+
hoverBorderColor="hover:border-black"
|
|
153
|
+
notificationCount={124}
|
|
154
|
+
textClasses="text-black font-serif text-md"
|
|
155
|
+
onClick={() => alert("Redirect to cart")}
|
|
156
|
+
/>
|
|
157
|
+
</div>
|
|
158
|
+
<GetSupport
|
|
159
|
+
icon={getFontAwesomeIcon("phone")}
|
|
160
|
+
as="a"
|
|
161
|
+
to="/support"
|
|
162
|
+
title="Get Support"
|
|
163
|
+
iconClasses="p-4 bg-gray-200 rounded-full group-hover:bg-slate-300"
|
|
164
|
+
titleClasses="text-xl font-bold"
|
|
165
|
+
subTitle="1-800-123-4567"
|
|
166
|
+
subTitleClasses="text-md text-gray-500"
|
|
167
|
+
containerClasses="flex items-center gap-4 p-2 bg-white rounded-lg hover:cursor-pointer group"
|
|
168
|
+
/>
|
|
169
|
+
</motion.div>
|
|
170
|
+
)}
|
|
171
|
+
</AnimatePresence>
|
|
172
|
+
|
|
173
|
+
{/* Hamburger Button */}
|
|
174
|
+
<motion.button
|
|
175
|
+
onClick={toggleIcon}
|
|
176
|
+
className="p-2 z-40 relative"
|
|
177
|
+
aria-label={args.burgerAriaLabel}
|
|
178
|
+
aria-expanded={isOpen}
|
|
179
|
+
initial={false}
|
|
180
|
+
animate={isOpen ? 'open' : 'closed'}
|
|
181
|
+
>
|
|
182
|
+
<motion.div className="relative flex items-center justify-center w-8 h-8">
|
|
183
|
+
<motion.span
|
|
184
|
+
className="absolute w-full h-0.5 bg-black"
|
|
185
|
+
variants={{
|
|
186
|
+
closed: { rotate: 0, y: -8 },
|
|
187
|
+
open: { rotate: 45, y: 0 },
|
|
188
|
+
}}
|
|
189
|
+
transition={{ duration: 0.3 }}
|
|
190
|
+
/>
|
|
191
|
+
<motion.span
|
|
192
|
+
className="absolute w-full h-0.5 bg-black"
|
|
193
|
+
variants={{
|
|
194
|
+
closed: { opacity: 1 },
|
|
195
|
+
open: { opacity: 0 },
|
|
196
|
+
}}
|
|
197
|
+
transition={{ duration: 0.2 }}
|
|
198
|
+
/>
|
|
199
|
+
<motion.span
|
|
200
|
+
className="absolute w-full h-0.5 bg-black"
|
|
201
|
+
variants={{
|
|
202
|
+
closed: { rotate: 0, y: 8 },
|
|
203
|
+
open: { rotate: -45, y: 0 },
|
|
204
|
+
}}
|
|
205
|
+
transition={{ duration: 0.3 }}
|
|
206
|
+
/>
|
|
207
|
+
</motion.div>
|
|
208
|
+
</motion.button>
|
|
209
|
+
</div>
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export const ToggleMenu = Template.bind({});
|
|
214
|
+
ToggleMenu.args = {
|
|
215
|
+
containerClasses: 'bg-gray-100',
|
|
216
|
+
burgerAriaLabel: 'Toggle navigation',
|
|
217
|
+
};
|
|
218
|
+
ToggleMenu.parameters = {
|
|
219
|
+
docs: {
|
|
220
|
+
description: {
|
|
221
|
+
story:
|
|
222
|
+
'This story demonstrates the toggle functionality of the HamburgerButton, transitioning between the hamburger and "X" icons on click, with a gray background appearing on toggle.',
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
};
|
|
@@ -1,66 +1,47 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { motion} from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { motion } from 'framer-motion';
|
|
3
|
+
import { HamburgerButtonProps } from './HamburgerButton.types';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const HamburgerButton: React.FC<HamburgerButtonTypes> = ({
|
|
5
|
+
const HamburgerButton: React.FC<HamburgerButtonProps> = ({
|
|
6
|
+
containerClasses,
|
|
8
7
|
burgerAriaLabel,
|
|
9
8
|
burgerExpandedAlert,
|
|
10
9
|
animateBoolean,
|
|
11
10
|
handleNav,
|
|
12
11
|
}) => {
|
|
13
12
|
return (
|
|
14
|
-
<div className=
|
|
15
|
-
<
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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>
|
|
13
|
+
<div className={`relative ${containerClasses}`}>
|
|
14
|
+
<motion.button
|
|
15
|
+
aria-label={burgerAriaLabel}
|
|
16
|
+
aria-expanded={burgerExpandedAlert === 'True'}
|
|
17
|
+
initial="hide"
|
|
18
|
+
animate={animateBoolean ? 'show' : 'hide'}
|
|
19
|
+
onClick={handleNav}
|
|
20
|
+
className={`flex flex-col space-y-1 p-2 ${burgerExpandedAlert === 'True' ? 'fixed' : ''}`}
|
|
21
|
+
tabIndex={0}
|
|
22
|
+
>
|
|
23
|
+
<motion.span
|
|
24
|
+
variants={{
|
|
25
|
+
hide: { rotate: 0 },
|
|
26
|
+
show: { rotate: 45, y: 5 },
|
|
27
|
+
}}
|
|
28
|
+
className="w-6 bg-black h-px block"
|
|
29
|
+
/>
|
|
30
|
+
<motion.span
|
|
31
|
+
variants={{
|
|
32
|
+
hide: { opacity: 1 },
|
|
33
|
+
show: { opacity: 0 },
|
|
34
|
+
}}
|
|
35
|
+
className="w-6 bg-black h-px block"
|
|
36
|
+
/>
|
|
37
|
+
<motion.span
|
|
38
|
+
variants={{
|
|
39
|
+
hide: { rotate: 0 },
|
|
40
|
+
show: { rotate: -45, y: -5 },
|
|
41
|
+
}}
|
|
42
|
+
className="w-6 bg-black h-px block"
|
|
43
|
+
/>
|
|
44
|
+
</motion.button>
|
|
64
45
|
</div>
|
|
65
46
|
);
|
|
66
47
|
};
|
|
@@ -6,8 +6,6 @@ import Badge from "../Badge/Badge";
|
|
|
6
6
|
import Text from "../Text/Text";
|
|
7
7
|
import Input from "../Input/Input";
|
|
8
8
|
import FormButton from "../FormButton/FormButton";
|
|
9
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
10
|
-
import { faSquarePhone } from "@fortawesome/free-solid-svg-icons";
|
|
11
9
|
import DUMMYICONDATA from "./DUMMYICONDATA.json";
|
|
12
10
|
import { DUMMYCOMPASSNAVDATA, DUMMYNAVDATA } from "../Nav/DUMMYNAVDATA.json";
|
|
13
11
|
import { HeaderTypes } from "./Header.types";
|
|
@@ -156,7 +154,7 @@ Default.args = {
|
|
|
156
154
|
to="#"
|
|
157
155
|
hoverColor="blue"
|
|
158
156
|
borderColor="none"
|
|
159
|
-
mobileIcon={
|
|
157
|
+
mobileIcon={getFontAwesomeIcon("square-phone")}
|
|
160
158
|
mobileIconLabel="Contact Us"
|
|
161
159
|
onClick={() => alert("Redirect to Contact Us page")}
|
|
162
160
|
image={
|
|
@@ -320,7 +318,7 @@ Compass.args = {
|
|
|
320
318
|
color="green"
|
|
321
319
|
hoverColor="green"
|
|
322
320
|
borderColor="none"
|
|
323
|
-
mobileIcon={
|
|
321
|
+
mobileIcon={getFontAwesomeIcon("square-phone")}
|
|
324
322
|
mobileIconLabel="Contact Us"
|
|
325
323
|
onClick={() => alert("Redirect to Contact Us page")}
|
|
326
324
|
image={
|
|
@@ -451,7 +449,7 @@ NoSearchOrBadge.args = {
|
|
|
451
449
|
color="green"
|
|
452
450
|
hoverColor="green"
|
|
453
451
|
borderColor="none"
|
|
454
|
-
mobileIcon={
|
|
452
|
+
mobileIcon={getFontAwesomeIcon("square-phone")}
|
|
455
453
|
mobileIconLabel="Contact Us"
|
|
456
454
|
onClick={() => alert("Redirect to Contact Us page")}
|
|
457
455
|
image={
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { motion, AnimatePresence, MotionConfig } from "framer-motion";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
getLogoClasses,
|
|
6
|
-
getHeaderClasses,
|
|
7
|
-
getMobileMenuClasses,
|
|
8
|
-
} from "./headerClassNames";
|
|
9
3
|
import { HeaderTypes } from "./Header.types";
|
|
10
4
|
import MobileMenu from "../MobileMenu/MobileMenu";
|
|
11
5
|
import { HeaderProvider } from "./headerContext";
|
|
12
6
|
import HamburgerButton from "../HamburgerButton/HamburgerButton";
|
|
13
7
|
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
8
|
+
|
|
14
9
|
const justifyMap = {
|
|
15
10
|
start: "justify-start",
|
|
16
11
|
center: "justify-center",
|
|
@@ -26,18 +21,18 @@ const Header: React.FC<HeaderTypes> = ({
|
|
|
26
21
|
input,
|
|
27
22
|
icons,
|
|
28
23
|
|
|
29
|
-
backgroundColor,
|
|
30
|
-
bottomBorderColor,
|
|
24
|
+
backgroundColor = "bg-white",
|
|
25
|
+
bottomBorderColor = "border-b-2",
|
|
31
26
|
hasGlass = false,
|
|
32
27
|
|
|
33
|
-
logoBorderRadius,
|
|
34
|
-
logoHoverColor,
|
|
28
|
+
logoBorderRadius = "rounded-md",
|
|
29
|
+
logoHoverColor = "hover:bg-gray-200",
|
|
35
30
|
|
|
36
31
|
hasAnimatedHamburgerButton = false,
|
|
37
32
|
hasMobileMenu,
|
|
38
33
|
mobileLeft = true,
|
|
39
34
|
mobileRight = false,
|
|
40
|
-
mobileMenuBackground,
|
|
35
|
+
mobileMenuBackground = "bg-white",
|
|
41
36
|
|
|
42
37
|
iconsData,
|
|
43
38
|
|
|
@@ -56,14 +51,13 @@ const Header: React.FC<HeaderTypes> = ({
|
|
|
56
51
|
justifyBadge = "center",
|
|
57
52
|
justifyIcons = "center",
|
|
58
53
|
|
|
59
|
-
logoOrder,
|
|
60
|
-
navOrder,
|
|
61
|
-
inputOrder,
|
|
62
|
-
badgeOrder,
|
|
63
|
-
iconsOrder,
|
|
54
|
+
logoOrder = 1,
|
|
55
|
+
navOrder = 2,
|
|
56
|
+
inputOrder = 3,
|
|
57
|
+
badgeOrder = 4,
|
|
58
|
+
iconsOrder = 5,
|
|
64
59
|
}) => {
|
|
65
|
-
const [navSideMenuVisibility, setNavSideMenuVisibility] =
|
|
66
|
-
useState<boolean>(false);
|
|
60
|
+
const [navSideMenuVisibility, setNavSideMenuVisibility] = useState(false);
|
|
67
61
|
|
|
68
62
|
const handleNav = () => {
|
|
69
63
|
setNavSideMenuVisibility(!navSideMenuVisibility);
|
|
@@ -74,20 +68,14 @@ const Header: React.FC<HeaderTypes> = ({
|
|
|
74
68
|
: "Select to open menu";
|
|
75
69
|
const burgerExpandedAlert = navSideMenuVisibility ? "True" : "False";
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
mobileRight = false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let logoClasses = getLogoClasses(logoBorderRadius, logoHoverColor);
|
|
84
|
-
let headerClasses = getHeaderClasses(backgroundColor, bottomBorderColor);
|
|
85
|
-
let mobileMenuClasses = getMobileMenuClasses(mobileMenuBackground);
|
|
71
|
+
const logoClasses = `${logoBorderRadius} ${logoHoverColor}`;
|
|
72
|
+
const headerClasses = `${backgroundColor} ${bottomBorderColor}`;
|
|
73
|
+
const mobileMenuClasses = mobileMenuBackground;
|
|
86
74
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
const justifyNavClass = justifyMap[justifyNav as keyof typeof justifyMap];
|
|
76
|
+
const justifyInputClass = justifyMap[justifyInput as keyof typeof justifyMap];
|
|
77
|
+
const justifyBadgeClass = justifyMap[justifyBadge as keyof typeof justifyMap];
|
|
78
|
+
const justifyIconsClass = justifyMap[justifyIcons as keyof typeof justifyMap];
|
|
91
79
|
|
|
92
80
|
return (
|
|
93
81
|
<HeaderProvider
|
|
@@ -96,17 +84,15 @@ const Header: React.FC<HeaderTypes> = ({
|
|
|
96
84
|
hasMobileBadge={hasMobileBadge}
|
|
97
85
|
hasMobileSearchBar={hasMobileSearchBar}
|
|
98
86
|
iconsData={iconsData}
|
|
99
|
-
hasIcons={
|
|
100
|
-
hasNavItems={
|
|
101
|
-
hasBadge={
|
|
102
|
-
hasSearchBar={
|
|
103
|
-
mobileCloseIcon={
|
|
87
|
+
hasIcons={hasIcons}
|
|
88
|
+
hasNavItems={hasNavItems}
|
|
89
|
+
hasBadge={hasBadge}
|
|
90
|
+
hasSearchBar={hasSearchBar}
|
|
91
|
+
mobileCloseIcon={getFontAwesomeIcon("X")}
|
|
104
92
|
>
|
|
105
93
|
<header
|
|
106
94
|
data-testid="header"
|
|
107
|
-
className={
|
|
108
|
-
hasGlass ? "glass" : "bg-white"
|
|
109
|
-
}`}
|
|
95
|
+
className={`border-b-2 h-20 z-[1000] top-0 w-full px-2 ${headerClasses} ${hasGlass ? "glass" : ""}`}
|
|
110
96
|
>
|
|
111
97
|
<div className="flex min-h-20">
|
|
112
98
|
{/* LEFT MOBILE OPEN ICON */}
|
|
@@ -125,11 +111,7 @@ const Header: React.FC<HeaderTypes> = ({
|
|
|
125
111
|
) : (
|
|
126
112
|
<button
|
|
127
113
|
aria-label={burgerAriaLabel}
|
|
128
|
-
aria-expanded={
|
|
129
|
-
burgerExpandedAlert === "True"
|
|
130
|
-
? true
|
|
131
|
-
: false
|
|
132
|
-
}
|
|
114
|
+
aria-expanded={burgerExpandedAlert === "True" ? true : false}
|
|
133
115
|
data-testid="hamburger-button"
|
|
134
116
|
onClick={handleNav}
|
|
135
117
|
className="flex flex-col space-y-1 relative z-10 p-2"
|
|
@@ -143,29 +125,21 @@ const Header: React.FC<HeaderTypes> = ({
|
|
|
143
125
|
)}
|
|
144
126
|
|
|
145
127
|
{/* LOGO */}
|
|
146
|
-
<div
|
|
147
|
-
className={
|
|
148
|
-
>
|
|
149
|
-
<a
|
|
150
|
-
className={logoClasses}
|
|
151
|
-
href=""
|
|
152
|
-
data-testid="header-logo"
|
|
153
|
-
>
|
|
128
|
+
<div className={`flex flex-auto items-center pl-1 order-${logoOrder}`}>
|
|
129
|
+
<a className={logoClasses} href="" data-testid="header-logo">
|
|
154
130
|
{logo}
|
|
155
131
|
</a>
|
|
156
132
|
</div>
|
|
157
133
|
|
|
158
134
|
{/* NAV MENUS */}
|
|
159
|
-
<div
|
|
160
|
-
className={`flex flex-auto ${justifyNav} max-xl:hidden order-${navOrder}`}
|
|
161
|
-
>
|
|
135
|
+
<div className={`flex flex-auto ${justifyNavClass} max-xl:hidden order-${navOrder}`}>
|
|
162
136
|
{hasNavItems && nav}
|
|
163
137
|
</div>
|
|
164
138
|
|
|
165
139
|
{/* INPUT */}
|
|
166
140
|
{hasSearchBar && (
|
|
167
141
|
<div
|
|
168
|
-
className={`flex flex-auto items-center ${
|
|
142
|
+
className={`flex flex-auto items-center ${justifyInputClass} max-xl:hidden order-${inputOrder}`}
|
|
169
143
|
data-testid="header-placeholder-input"
|
|
170
144
|
>
|
|
171
145
|
<div className="2xl:flex w-full [&:has(:focus-visible)]:ring-2">
|
|
@@ -176,20 +150,12 @@ const Header: React.FC<HeaderTypes> = ({
|
|
|
176
150
|
|
|
177
151
|
{/* BADGE AND ICONS */}
|
|
178
152
|
{hasBadge && (
|
|
179
|
-
<div
|
|
180
|
-
className={`flex flex-auto items-center ${justifyBadge} max-xl:justify-end order-${badgeOrder}`}
|
|
181
|
-
data-testid="header-badge"
|
|
182
|
-
>
|
|
153
|
+
<div className={`flex flex-auto items-center ${justifyBadgeClass} max-xl:justify-end order-${badgeOrder}`} data-testid="header-badge">
|
|
183
154
|
<div className="w-fit">{badge}</div>
|
|
184
155
|
</div>
|
|
185
156
|
)}
|
|
186
157
|
{hasIcons && (
|
|
187
|
-
<div
|
|
188
|
-
className={`flex flex-auto items-center ${justifyIcons} max-xl:hidden order-${iconsOrder}`}
|
|
189
|
-
data-testid="header-icons"
|
|
190
|
-
>
|
|
191
|
-
{/* FIXME: we need to find a way to keep the type tight for this and still deal with the error */}
|
|
192
|
-
{/* @ts-ignore */}
|
|
158
|
+
<div className={`flex flex-auto items-center ${justifyIconsClass} max-xl:hidden order-${iconsOrder}`} data-testid="header-icons">
|
|
193
159
|
{icons}
|
|
194
160
|
</div>
|
|
195
161
|
)}
|
|
@@ -210,11 +176,7 @@ const Header: React.FC<HeaderTypes> = ({
|
|
|
210
176
|
) : (
|
|
211
177
|
<button
|
|
212
178
|
aria-label={burgerAriaLabel}
|
|
213
|
-
aria-expanded={
|
|
214
|
-
burgerExpandedAlert === "True"
|
|
215
|
-
? true
|
|
216
|
-
: false
|
|
217
|
-
}
|
|
179
|
+
aria-expanded={burgerExpandedAlert === "True" ? true : false}
|
|
218
180
|
data-testid="hamburger-button"
|
|
219
181
|
onClick={handleNav}
|
|
220
182
|
className="flex flex-col space-y-1 relative z-10 p-2"
|
|
@@ -226,23 +188,17 @@ const Header: React.FC<HeaderTypes> = ({
|
|
|
226
188
|
)}
|
|
227
189
|
</div>
|
|
228
190
|
)}
|
|
191
|
+
|
|
229
192
|
{/* MOBILE MENU */}
|
|
230
193
|
<AnimatePresence>
|
|
231
194
|
{hasMobileMenu && navSideMenuVisibility && (
|
|
232
195
|
<div>
|
|
233
|
-
<MotionConfig
|
|
234
|
-
transition={{
|
|
235
|
-
type: "spring",
|
|
236
|
-
bounce: 0.1,
|
|
237
|
-
}}
|
|
238
|
-
>
|
|
196
|
+
<MotionConfig transition={{ type: "spring", bounce: 0.1 }}>
|
|
239
197
|
<motion.div
|
|
240
198
|
key="mobile-nav"
|
|
241
199
|
variants={{
|
|
242
200
|
hide: {
|
|
243
|
-
x: mobileRight
|
|
244
|
-
? "100%"
|
|
245
|
-
: "-100%",
|
|
201
|
+
x: mobileRight ? "100%" : "-100%",
|
|
246
202
|
transition: {
|
|
247
203
|
type: "spring",
|
|
248
204
|
bounce: 0.1,
|
|
@@ -271,9 +227,7 @@ const Header: React.FC<HeaderTypes> = ({
|
|
|
271
227
|
nav={nav}
|
|
272
228
|
input={input}
|
|
273
229
|
icons={icons}
|
|
274
|
-
mobileMenuClasses={
|
|
275
|
-
mobileMenuClasses
|
|
276
|
-
}
|
|
230
|
+
mobileMenuClasses={mobileMenuClasses}
|
|
277
231
|
/>
|
|
278
232
|
</motion.div>
|
|
279
233
|
</MotionConfig>
|
|
@@ -39,9 +39,8 @@ export default {
|
|
|
39
39
|
tags: ["autodocs"],
|
|
40
40
|
} as Meta<HeroStoryTypes>;
|
|
41
41
|
|
|
42
|
-
// const Template: StoryFn<HeroStoryProps> = (args) => <Hero {...args} />;
|
|
43
42
|
|
|
44
|
-
const Template: StoryFn<
|
|
43
|
+
const Template: StoryFn<HeroStoryTypes> = (args) => (
|
|
45
44
|
<StorybookHero
|
|
46
45
|
{...args}
|
|
47
46
|
storybookStyle={{
|