Skip to content

Commit ae5253c

Browse files
authored
feat: expose containerProps in StudioHeader [FC-0062] (#529)
1 parent e44001e commit ae5253c

File tree

7 files changed

+28
-12
lines changed

7 files changed

+28
-12
lines changed

package-lock.json

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"@openedx/frontend-plugin-framework": "^1.3.0",
6464
"axios-mock-adapter": "1.22.0",
6565
"babel-polyfill": "6.26.0",
66+
"classnames": "^2.5.1",
6667
"jest-environment-jsdom": "^29.7.0",
6768
"react-responsive": "8.2.0",
6869
"react-transition-group": "4.4.5"

src/studio-header/HeaderBody.jsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { useIntl } from '@edx/frontend-platform/i18n';
4+
import classNames from 'classnames';
45
import {
56
ActionRow,
67
Button,
@@ -37,6 +38,7 @@ const HeaderBody = ({
3738
mainMenuDropdowns,
3839
outlineLink,
3940
searchButtonAction,
41+
containerProps,
4042
}) => {
4143
const intl = useIntl();
4244

@@ -50,8 +52,14 @@ const HeaderBody = ({
5052
/>
5153
);
5254

55+
const { className: containerClassName, ...restContainerProps } = containerProps || {};
56+
5357
return (
54-
<Container size="xl" className="px-2.5">
58+
<Container
59+
size="xl"
60+
className={classNames('px-2.5', containerClassName)}
61+
{...restContainerProps}
62+
>
5563
<ActionRow as="header">
5664
{isHiddenMainMenu ? (
5765
<Row className="flex-nowrap ml-4">
@@ -110,6 +118,7 @@ const HeaderBody = ({
110118
iconAs={Icon}
111119
onClick={searchButtonAction}
112120
aria-label={intl.formatMessage(messages['header.label.search.nav'])}
121+
alt={intl.formatMessage(messages['header.label.search.nav'])}
113122
/>
114123
</Nav>
115124
)}
@@ -147,14 +156,15 @@ HeaderBody.propTypes = {
147156
isHiddenMainMenu: PropTypes.bool,
148157
mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({
149158
id: PropTypes.string,
150-
buttonTitle: PropTypes.string,
159+
buttonTitle: PropTypes.node,
151160
items: PropTypes.arrayOf(PropTypes.shape({
152161
href: PropTypes.string,
153-
title: PropTypes.string,
162+
title: PropTypes.node,
154163
})),
155164
})),
156165
outlineLink: PropTypes.string,
157166
searchButtonAction: PropTypes.func,
167+
containerProps: PropTypes.shape(Container.propTypes),
158168
};
159169

160170
HeaderBody.defaultProps = {
@@ -174,6 +184,7 @@ HeaderBody.defaultProps = {
174184
mainMenuDropdowns: [],
175185
outlineLink: null,
176186
searchButtonAction: null,
187+
containerProps: {},
177188
};
178189

179190
export default HeaderBody;

src/studio-header/MobileHeader.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ MobileHeader.propTypes = {
4848
isAdmin: PropTypes.bool,
4949
mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({
5050
id: PropTypes.string,
51-
buttonTitle: PropTypes.string,
51+
buttonTitle: PropTypes.node,
5252
items: PropTypes.arrayOf(PropTypes.shape({
5353
href: PropTypes.string,
54-
title: PropTypes.string,
54+
title: PropTypes.node,
5555
})),
5656
})),
5757
outlineLink: PropTypes.string,

src/studio-header/MobileMenu.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ const MobileMenu = ({
3737
MobileMenu.propTypes = {
3838
mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({
3939
id: PropTypes.string,
40-
buttonTitle: PropTypes.string,
40+
buttonTitle: PropTypes.node,
4141
items: PropTypes.arrayOf(PropTypes.shape({
4242
href: PropTypes.string,
43-
title: PropTypes.string,
43+
title: PropTypes.node,
4444
})),
4545
})),
4646
};

src/studio-header/NavDropdownMenu.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const NavDropdownMenu = ({
3030

3131
NavDropdownMenu.propTypes = {
3232
id: PropTypes.string.isRequired,
33-
buttonTitle: PropTypes.string.isRequired,
33+
buttonTitle: PropTypes.node.isRequired,
3434
items: PropTypes.arrayOf(PropTypes.shape({
3535
href: PropTypes.string,
36-
title: PropTypes.string,
36+
title: PropTypes.node,
3737
})).isRequired,
3838
};
3939

src/studio-header/StudioHeader.jsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ensureConfig([
1616
], 'Studio Header component');
1717

1818
const StudioHeader = ({
19-
number, org, title, isHiddenMainMenu, mainMenuDropdowns, outlineLink, searchButtonAction,
19+
number, org, title, containerProps, isHiddenMainMenu, mainMenuDropdowns, outlineLink, searchButtonAction,
2020
}) => {
2121
const { authenticatedUser, config } = useContext(AppContext);
2222
const props = {
@@ -25,6 +25,7 @@ const StudioHeader = ({
2525
number,
2626
org,
2727
title,
28+
containerProps,
2829
username: authenticatedUser?.username,
2930
isAdmin: authenticatedUser?.administrator,
3031
authenticatedUserAvatar: authenticatedUser?.avatar,
@@ -53,13 +54,14 @@ StudioHeader.propTypes = {
5354
number: PropTypes.string,
5455
org: PropTypes.string,
5556
title: PropTypes.string.isRequired,
57+
containerProps: HeaderBody.propTypes.containerProps,
5658
isHiddenMainMenu: PropTypes.bool,
5759
mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({
5860
id: PropTypes.string,
59-
buttonTitle: PropTypes.string,
61+
buttonTitle: PropTypes.node,
6062
items: PropTypes.arrayOf(PropTypes.shape({
6163
href: PropTypes.string,
62-
title: PropTypes.string,
64+
title: PropTypes.node,
6365
})),
6466
})),
6567
outlineLink: PropTypes.string,
@@ -69,6 +71,7 @@ StudioHeader.propTypes = {
6971
StudioHeader.defaultProps = {
7072
number: '',
7173
org: '',
74+
containerProps: {},
7275
isHiddenMainMenu: false,
7376
mainMenuDropdowns: [],
7477
outlineLink: null,

0 commit comments

Comments
 (0)