Skip to content

Commit cc16b81

Browse files
committed
1 parent 367fde7 commit cc16b81

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/MainNavigation/MainNavigation.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,28 @@ export namespace MainNavigationProps {
4646

4747
export type Link = Common & {
4848
linkProps: RegisteredLinkProps;
49-
menuLinks?: undefined;
50-
megaMenu?: undefined;
49+
menuLinks?: never;
50+
megaMenu?: never;
51+
buttonProps?: never;
5152
};
5253

5354
export type Menu = Common & {
54-
linkProps?: undefined;
55+
linkProps?: never;
5556
menuLinks: MenuProps.Link[];
56-
megaMenu?: undefined;
57+
megaMenu?: never;
58+
/** @see <https://github.com/codegouvfr/react-dsfr/issues/38> */
59+
buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;
5760
};
5861

5962
export type MegaMenu = Common & {
60-
linkProps?: undefined;
61-
menuLinks?: undefined;
63+
linkProps?: never;
64+
menuLinks?: never;
6265
megaMenu: {
6366
leader?: MegaMenuProps.Leader;
6467
categories: MegaMenuProps.Category[];
6568
};
69+
/** @see <https://github.com/codegouvfr/react-dsfr/issues/38> */
70+
buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;
6671
};
6772
}
6873
}
@@ -102,7 +107,8 @@ export const MainNavigation = memo(
102107
isActive = false,
103108
linkProps,
104109
menuLinks = [],
105-
megaMenu
110+
megaMenu,
111+
buttonProps = {}
106112
},
107113
i
108114
) => (
@@ -125,7 +131,12 @@ export const MainNavigation = memo(
125131
) : (
126132
<>
127133
<button
128-
className={cx(fr.cx("fr-nav__btn"), classes.btn)}
134+
{...buttonProps}
135+
className={cx(
136+
fr.cx("fr-nav__btn"),
137+
buttonProps.className,
138+
classes.btn
139+
)}
129140
aria-expanded={false}
130141
aria-controls={getMenuId(i)}
131142
{...(isActive && { ["aria-current"]: true })}

stories/MainNavigation.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const DirectLinks = getStory({
3838
"href": "/",
3939
"title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)"
4040
},
41-
"navItems": [
41+
"navigation": [
4242
{
4343
"text": "accès direct",
4444
"linkProps": {
@@ -84,7 +84,7 @@ export const DropdownMenu = getStory({
8484
"href": "/",
8585
"title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)"
8686
},
87-
"navItems": [
87+
"navigation": [
8888
{
8989
"text": "Entrée menu active",
9090
"isActive": true,
@@ -199,7 +199,7 @@ export const MegaMenu = getStory({
199199
"href": "/",
200200
"title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)"
201201
},
202-
"navItems": [
202+
"navigation": [
203203
{
204204
"text": "Entrée mega menu",
205205
"isActive": true,

0 commit comments

Comments
 (0)