Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(header): L3-376 Added Header component #168

Merged
merged 32 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0d0d052
feat(header): initial commit of header component
adietrich3074 May 31, 2024
8e0f714
feat(navigationitem): add navigation item
adietrich3074 Jun 3, 2024
914ae87
feat(header): moved child components to story. context added to manag…
adietrich3074 Jun 4, 2024
1200d71
Merge branch 'main' into feature/L3-376_Header_Component
adietrich3074 Jun 4, 2024
d977820
chore(header): reverted package.lock to version on main
adietrich3074 Jun 4, 2024
88be6b5
chore(header): removed incorrect logo file
adietrich3074 Jun 4, 2024
8daf953
feat(header): added user management component. style fixes
adietrich3074 Jun 7, 2024
f8be323
Merge branch 'main' into feature/L3-376_Header_Component
adietrich3074 Jun 7, 2024
70eef77
feat(header): updated unit tests
adietrich3074 Jun 10, 2024
3144415
chore(header): fixed search component show hide logic
adietrich3074 Jun 10, 2024
c2502fe
chore(header): reverted package.lock to version on main
adietrich3074 Jun 10, 2024
ed3b92a
Merge branch 'main' into feature/L3-376_Header_Component
adietrich3074 Jun 12, 2024
b639e98
feat(header): updates to header unit tests and minor css style updates
adietrich3074 Jun 18, 2024
69c9c23
chore(header): resolved merge conflicts
adietrich3074 Jun 18, 2024
7b11f30
chore(header): L3-376 updated unit tests to get full coverage on comp…
adietrich3074 Jun 20, 2024
6bee3e0
chore(header): css updates for breakpoint mixins, address pr comments
adietrich3074 Jun 20, 2024
0e624f6
Merge branch 'main' into feature/L3-376_Header_Component
adietrich3074 Jun 24, 2024
bd23dec
chore(header): L3-376 updates to tests, laguage selection, mobile sty…
adietrich3074 Jun 24, 2024
644229d
chore(header): L3-376 style fixes for clicks in open areas triggering…
adietrich3074 Jun 25, 2024
ffb0b6d
chore(header): L3-376 updated language selection logic
adietrich3074 Jun 25, 2024
017c3ea
chore(header): L3-376 added userManagement component to index.ts
adietrich3074 Jun 25, 2024
a51ca30
build(scss): fix aliases on export to handle nested components
scottdickerson Jun 25, 2024
2841b8f
Merge branch 'feature/L3-376_Header_Component' of https://github.com/…
scottdickerson Jun 25, 2024
638936d
chore(header): L3-376 updated label props to strings
adietrich3074 Jun 25, 2024
3fed3e1
chore(header): removed most transitions, updated styles in header to …
adietrich3074 Jun 26, 2024
2bd5a98
fix(usermanagement): export callback properties
scottdickerson Jun 27, 2024
36c7f6b
Merge branch 'feature/L3-376_Header_Component' of https://github.com/…
scottdickerson Jun 27, 2024
79eb0f0
chore(header): L3-376 update header styles to resolve issues in remix
adietrich3074 Jun 27, 2024
94a0033
fix(header): L3-376 fixed tag syntax and style issue when consumed by…
adietrich3074 Jun 27, 2024
9d9d2d0
Merge branch 'main' into feature/L3-376_Header_Component
adietrich3074 Jun 27, 2024
d0bb341
chore(header): L3-376 resolved issue with tests for UserManagement co…
adietrich3074 Jul 8, 2024
d7ee00c
Merge branch 'main' into feature/L3-376_Header_Component
adietrich3074 Jul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const config: StorybookConfig = {
options: {},
},
docs: {
defaultName: "Overview"
defaultName: "Overview",
},
viteFinal: (config) => {
if (config && config.resolve) {
Expand Down
2 changes: 2 additions & 0 deletions .template/Component/ComponentName.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meta } from '@storybook/react';
import ComponentName, { ComponentNameProps } from './ComponentName';

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta = {
title: 'Components/ComponentName',
component: ComponentName,
Expand All @@ -9,6 +10,7 @@ const meta = {
export default meta;
export const Playground = (props: ComponentNameProps) => <ComponentName {...props} />;

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
Playground.args = {
children: 'Hi There',
};
Expand Down
10 changes: 10 additions & 0 deletions src/assets/PhillipsLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/account_circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 0 additions & 26 deletions src/components/Header/Header.stories.ts

This file was deleted.

200 changes: 200 additions & 0 deletions src/components/Header/Header.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import type { Meta } from '@storybook/react';
import Header, { HeaderProps } from './Header';
import Logo from '../../assets/PhillipsLogo.svg?react';
import Navigation from '../Navigation/Navigation';
import NavigationList from '../Navigation/NavigationList/NavigationList';
import NavigationItemTrigger from '../Navigation/NavigationItemTrigger/NavigationItemTrigger';
import NavigationItem from '../Navigation/NavigationItem/NavigationItem';
import { LinkVariants } from '../Link/utils';
import { px } from '../../utils';
import UserManagement from '../UserManagement/UserManagement';

const meta = {
title: 'Components/Header',
component: Header,
parameters: {
docs: {
story: {
height: '700px',
},
},
layout: 'fullscreen',
},
} satisfies Meta<typeof Header>;

export default meta;

export const Playground = (props: HeaderProps) => (
<Header {...props}>
<Navigation id={`${px}-main-nav`} backBtnLabel="← Back">
<NavigationList id={`${px}-main-nav-list`}>
<NavigationItemTrigger id="auctions" label="Auctions">
<NavigationList id={`${px}-auctions-nav-list`}>
<NavigationItem
badge="New York"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="Editions & Works on Paper"
/>
<NavigationItem
badge="London"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="Casa Fornaroli"
/>
<NavigationItem
badge="Geneva"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="The Geneva Watch Auction: XVII"
/>
<NavigationItem
badge="New York"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="Modern & Contemporary Art Day Sale—Morning Session"
/>
<NavigationItem
badge="New York"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="Modern & Contemporary Art Day Sale—Afternoon Session"
/>
<NavigationItem
badge="New York"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="Modern & Contemporary Art Evening Sale"
/>
<NavigationItem
badge="London"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="Wired: Online Auction"
/>
<NavigationItem
badge="Hong Kong "
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="The Imperial Patek Philippe Sale"
/>
<NavigationItem
badge="Hong Kong"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="Disruptors: Evening Sale of Modern & Contemporary Art, Design and Watches"
/>
<NavigationItem
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkSm}
label="Browse Full Auction Calendar"
/>
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="Auction Calendar" />
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="Auction Results" />
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="Artists & Makers" />
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="How To Buy" />
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="Remote Bidding" />
</NavigationList>
</NavigationItemTrigger>
<NavigationItem href="#" label="Calendar" />
<NavigationItemTrigger id="departments" label="Departments">
<NavigationList id={`${px}-departments-nav-list`}>
<NavigationItem
href="#"
navGroup="nav-link-sm"
navType={LinkVariants.navLinkSm}
label="Modern & Contemporary Art"
/>
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="Design" />
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="Editions" />
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="Jewels" />
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="Photographs" />
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="Watches" />
<NavigationItem href="#" navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} label="Private Sales" />
</NavigationList>
</NavigationItemTrigger>
<NavigationItemTrigger id="exhibitions" label="Exhibitions">
<NavigationList id={`${px}-exhibitions-nav-list`}>
<NavigationItem
badge="New York"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="Written in the Sky: Works by Ed Ruscha"
/>
<NavigationItem
badge="Paris"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="Modeler le papier // Shapes On Paper"
/>
<NavigationItem
badge="New York"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="ALT POP: An Alternative History to American Pop Art"
/>
<NavigationItem
badge="New York"
href="#"
navGroup="nav-link-lg"
navType={LinkVariants.navLinkLg}
label="New Terrains: Contemporary Native American Art"
/>
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="Past Exhibitions" />
</NavigationList>
</NavigationItemTrigger>
<NavigationItem href="#" label="Perpetual" />
<NavigationItem href="#" label="Dropshop" />
<NavigationItemTrigger id="buy-sell" label="Buy & Sell">
<NavigationList id={`${px}-buy-sell-nav-list`}>
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="How To Buy" />
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="How To Sell" />
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="Remote Bidding" />
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="Private Services" />
<NavigationItem
navGroup="nav-link-sm"
navType={LinkVariants.navLinkSm}
href="#"
label="Trusts, Estates & Valuations"
/>
<NavigationItem
navGroup="nav-link-sm"
navType={LinkVariants.navLinkSm}
href="#"
label="Fiduciary Services"
/>
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="Buy Catalogues" />
</NavigationList>
</NavigationItemTrigger>
<NavigationItem href="#" label="Editorial" />
<NavigationItemTrigger id="about-us" label="About Us">
<NavigationList id={`${px}-about-us-nav-list`}>
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="Our History" />
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="Our Team" />
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="Locations" />
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="Press" />
<NavigationItem navGroup="nav-link-sm" navType={LinkVariants.navLinkSm} href="#" label="Careers" />
</NavigationList>
</NavigationItemTrigger>
<UserManagement></UserManagement>
</NavigationList>
</Navigation>
</Header>
);

Playground.args = {
logo: typeof Logo === 'string' ? Logo : <Logo />,
};
84 changes: 78 additions & 6 deletions src/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,84 @@
import { render, screen } from '@testing-library/react';

import userEvent from '@testing-library/user-event';
import Header from './Header';
import LogoSVG from '../../assets/PhillipsLogo.svg?react';
import LogoIMG from '../../assets/PhillipsLogo.svg';
import { px } from '../../utils';
import Navigation from '../Navigation/Navigation';
import NavigationItem from '../Navigation/NavigationItem/NavigationItem';
import NavigationItemTrigger from '../Navigation/NavigationItemTrigger/NavigationItemTrigger';
import NavigationList from '../Navigation/NavigationList/NavigationList';
import { LinkVariants } from '../Link/utils';

describe('Header', () => {
it('is will render username if user object is passed in', () => {
const { rerender } = render(<Header />);
expect(screen.queryByText(/Dave/)).not.toBeInTheDocument();
rerender(<Header user={{ name: 'Dave' }} />);
expect(screen.queryByText(/Dave/)).toBeInTheDocument();
const headerComponent = () => (
<Header logo={LogoIMG}>
<Navigation id={`${px}-main-nav`} backBtnLabel="Back">
<NavigationList id={`${px}-main-nav-list`}>
<NavigationItemTrigger id="auctions" label={`Auctions`}>
<NavigationList id={`${px}-auction-nav-list`}>
<NavigationItem
badge={'New York'}
href="#"
navGroup={'nav-link-lg'}
navType={LinkVariants.navLinkLg}
label={`Editions & Works on Paper`}
/>
</NavigationList>
</NavigationItemTrigger>
</NavigationList>
</Navigation>
</Header>
);
it('should render the header component with default props', () => {
render(headerComponent());
const toggleButton = screen.getByRole('button', { name: /Open Menu/i });
const logo = screen.getByTestId('header-logo');
const nav = screen.getByTestId(`${px}-main-nav`);
const search = screen.getByTestId('header-search');
expect(toggleButton).toBeInTheDocument();
expect(logo).toBeInTheDocument();
expect(nav).toBeInTheDocument();
expect(search).toBeInTheDocument();
});

it('should toggle the menu when the toggle button is clicked', async () => {
render(headerComponent());
const nav = screen.getByTestId(`${px}-main-nav`);
const toggleButton = screen.getByRole('button', { name: /Open Menu/i });
const navItem = screen.getByTestId('nav-item-trigger-auctions');
expect(nav).toHaveClass(`${px}-nav`);
await userEvent.click(toggleButton);
await userEvent.click(navItem);
expect(toggleButton).toHaveTextContent(/Close Menu/i);
expect(nav).toHaveClass(`${px}-nav--expanded`);
await userEvent.click(toggleButton);
expect(toggleButton).toHaveTextContent(/Open Menu/i);
expect(nav).toHaveClass(`${px}-nav`);
});

it('should expand a nav category in the mobile menu when a nav item trigger is selected', async () => {
render(headerComponent());
const navItemTrigger = screen.getByTestId(`nav-item-trigger-auctions`);
const backBtn = screen.getByText(`Back`);
const navLabel = screen.getByTestId('phillips-main-nav-label');
await userEvent.click(navItemTrigger);
expect(navItemTrigger).toHaveClass(`${px}-nav__item--expanded`);
expect(navLabel).toHaveTextContent('Auctions');
await userEvent.click(backBtn);
expect(navItemTrigger).not.toHaveClass(`${px}-nav__item--expanded`);
expect(navLabel).toHaveTextContent('Main Menu');
});

it('should render the logo as an object', () => {
render(<Header logo={<LogoSVG />} />);
const logoElement = screen.getByTestId('header-logo-svg');
expect(logoElement).toBeInTheDocument();
});

it('should render the logo as an image', () => {
render(<Header logo={LogoIMG} />);
const logoElement = screen.getByTestId('header-logo');
expect(logoElement).toContainHTML(`<img data-testid="header-logo-img" src=${LogoIMG} height="14" />`);
});
});
Loading
Loading