Skip to content

Commit b3f6f03

Browse files
refactor: add className prop to header components
1 parent d44a81c commit b3f6f03

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

packages/ui-react/src/components/Header/Header.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ type TypeHeader = 'static' | 'fixed';
77

88
type Props = {
99
headerType?: TypeHeader;
10+
className?: string;
1011
searchActive: boolean;
1112
};
1213

13-
const Header = ({ children, headerType = 'static', searchActive }: PropsWithChildren<Props>) => {
14-
const headerClassName = classNames(styles.header, styles[headerType], {
14+
const Header = ({ children, className, headerType = 'static', searchActive }: PropsWithChildren<Props>) => {
15+
const headerClassName = classNames(styles.header, styles[headerType], className, {
1516
[styles.searchActive]: searchActive,
1617
});
1718

Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React, { type PropsWithChildren } from 'react';
2+
import classNames from 'classnames';
23

34
import styles from './Header.module.scss';
45

5-
const HeaderActions = ({ children }: PropsWithChildren) => {
6-
return <div className={styles.actions}>{children}</div>;
6+
const HeaderActions = ({ children, className }: PropsWithChildren<{ className?: string }>) => {
7+
return <div className={classNames(styles.actions, className)}>{children}</div>;
78
};
89

910
export default HeaderActions;

packages/ui-react/src/components/Header/HeaderBrand.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import React from 'react';
22
import { useTranslation } from 'react-i18next';
3+
import classNames from 'classnames';
34

45
import Logo from '../Logo/Logo';
56

67
import styles from './Header.module.scss';
78

89
type Props = {
10+
className?: string;
911
siteName?: string;
1012
logoSrc?: string | null;
1113
setLogoLoaded: (loaded: boolean) => void;
1214
};
1315

14-
const HeaderBrand = ({ siteName, logoSrc, setLogoLoaded }: Props) => {
16+
const HeaderBrand = ({ className, siteName, logoSrc, setLogoLoaded }: Props) => {
1517
const { t } = useTranslation('menu');
1618

1719
if (!logoSrc) return null;
1820

1921
return (
20-
<div className={styles.brand}>
22+
<div className={classNames(styles.brand, className)}>
2123
<Logo alt={t('logo_alt', { siteName })} src={logoSrc} onLoad={() => setLogoLoaded(true)} />
2224
</div>
2325
);

packages/ui-react/src/components/Header/HeaderMenu.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import classNames from 'classnames';
23
import { useTranslation } from 'react-i18next';
34
import Menu from '@jwp/ott-theme/assets/icons/menu.svg?react';
45

@@ -7,11 +8,17 @@ import IconButton from '../IconButton/IconButton';
78

89
import styles from './Header.module.scss';
910

10-
const HeaderMenu = ({ sideBarOpen, onClick }: { sideBarOpen: boolean; onClick: () => void }) => {
11+
type Props = {
12+
className?: string;
13+
sideBarOpen: boolean;
14+
onClick: () => void;
15+
};
16+
17+
const HeaderMenu = ({ className, sideBarOpen, onClick }: Props) => {
1118
const { t } = useTranslation('menu');
1219

1320
return (
14-
<div className={styles.menu}>
21+
<div className={classNames(styles.menu, className)}>
1522
<IconButton className={styles.iconButton} aria-label={t('open_menu')} aria-expanded={sideBarOpen} onClick={onClick}>
1623
<Icon icon={Menu} />
1724
</IconButton>

packages/ui-react/src/components/Header/HeaderNavigation.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useRef } from 'react';
2+
import classNames from 'classnames';
23

34
import Button from '../Button/Button';
45

@@ -11,7 +12,7 @@ type NavItem = {
1112

1213
const scrollOffset = 100;
1314

14-
const HeaderNavigation = ({ navItems }: { navItems: NavItem[] }) => {
15+
const HeaderNavigation = ({ className, navItems }: { className?: string; navItems: NavItem[] }) => {
1516
const navRef = useRef<HTMLElement>(null);
1617

1718
const focusHandler = (event: React.FocusEvent) => {
@@ -30,7 +31,7 @@ const HeaderNavigation = ({ navItems }: { navItems: NavItem[] }) => {
3031
};
3132

3233
return (
33-
<nav className={styles.nav} ref={navRef}>
34+
<nav className={classNames(styles.nav, className)} ref={navRef}>
3435
<ul onFocus={focusHandler}>
3536
{navItems.map((item, index) => (
3637
<li key={index}>

packages/ui-react/src/components/Header/HeaderSkipLink.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React from 'react';
2+
import classNames from 'classnames';
23
import { useTranslation } from 'react-i18next';
34

45
import styles from './Header.module.scss';
56

6-
const HeaderSkipLink = () => {
7+
const HeaderSkipLink = ({ className }: { className?: string }) => {
78
const { t } = useTranslation('menu');
89
return (
9-
<a href="#content" className={styles.skipToContent}>
10+
<a href="#content" className={classNames(styles.skipToContent, className)}>
1011
{t('skip_to_content')}
1112
</a>
1213
);

0 commit comments

Comments
 (0)