Skip to content

Commit

Permalink
feat: expose containerProps in StudioHeader [FC-0062] (openedx#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido authored Oct 1, 2024
1 parent e44001e commit ae5253c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@openedx/frontend-plugin-framework": "^1.3.0",
"axios-mock-adapter": "1.22.0",
"babel-polyfill": "6.26.0",
"classnames": "^2.5.1",
"jest-environment-jsdom": "^29.7.0",
"react-responsive": "8.2.0",
"react-transition-group": "4.4.5"
Expand Down
17 changes: 14 additions & 3 deletions src/studio-header/HeaderBody.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useIntl } from '@edx/frontend-platform/i18n';
import classNames from 'classnames';
import {
ActionRow,
Button,
Expand Down Expand Up @@ -37,6 +38,7 @@ const HeaderBody = ({
mainMenuDropdowns,
outlineLink,
searchButtonAction,
containerProps,
}) => {
const intl = useIntl();

Expand All @@ -50,8 +52,14 @@ const HeaderBody = ({
/>
);

const { className: containerClassName, ...restContainerProps } = containerProps || {};

return (
<Container size="xl" className="px-2.5">
<Container
size="xl"
className={classNames('px-2.5', containerClassName)}
{...restContainerProps}
>
<ActionRow as="header">
{isHiddenMainMenu ? (
<Row className="flex-nowrap ml-4">
Expand Down Expand Up @@ -110,6 +118,7 @@ const HeaderBody = ({
iconAs={Icon}
onClick={searchButtonAction}
aria-label={intl.formatMessage(messages['header.label.search.nav'])}
alt={intl.formatMessage(messages['header.label.search.nav'])}
/>
</Nav>
)}
Expand Down Expand Up @@ -147,14 +156,15 @@ HeaderBody.propTypes = {
isHiddenMainMenu: PropTypes.bool,
mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string,
buttonTitle: PropTypes.string,
buttonTitle: PropTypes.node,
items: PropTypes.arrayOf(PropTypes.shape({
href: PropTypes.string,
title: PropTypes.string,
title: PropTypes.node,
})),
})),
outlineLink: PropTypes.string,
searchButtonAction: PropTypes.func,
containerProps: PropTypes.shape(Container.propTypes),
};

HeaderBody.defaultProps = {
Expand All @@ -174,6 +184,7 @@ HeaderBody.defaultProps = {
mainMenuDropdowns: [],
outlineLink: null,
searchButtonAction: null,
containerProps: {},
};

export default HeaderBody;
4 changes: 2 additions & 2 deletions src/studio-header/MobileHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ MobileHeader.propTypes = {
isAdmin: PropTypes.bool,
mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string,
buttonTitle: PropTypes.string,
buttonTitle: PropTypes.node,
items: PropTypes.arrayOf(PropTypes.shape({
href: PropTypes.string,
title: PropTypes.string,
title: PropTypes.node,
})),
})),
outlineLink: PropTypes.string,
Expand Down
4 changes: 2 additions & 2 deletions src/studio-header/MobileMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const MobileMenu = ({
MobileMenu.propTypes = {
mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string,
buttonTitle: PropTypes.string,
buttonTitle: PropTypes.node,
items: PropTypes.arrayOf(PropTypes.shape({
href: PropTypes.string,
title: PropTypes.string,
title: PropTypes.node,
})),
})),
};
Expand Down
4 changes: 2 additions & 2 deletions src/studio-header/NavDropdownMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const NavDropdownMenu = ({

NavDropdownMenu.propTypes = {
id: PropTypes.string.isRequired,
buttonTitle: PropTypes.string.isRequired,
buttonTitle: PropTypes.node.isRequired,
items: PropTypes.arrayOf(PropTypes.shape({
href: PropTypes.string,
title: PropTypes.string,
title: PropTypes.node,
})).isRequired,
};

Expand Down
9 changes: 6 additions & 3 deletions src/studio-header/StudioHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ensureConfig([
], 'Studio Header component');

const StudioHeader = ({
number, org, title, isHiddenMainMenu, mainMenuDropdowns, outlineLink, searchButtonAction,
number, org, title, containerProps, isHiddenMainMenu, mainMenuDropdowns, outlineLink, searchButtonAction,
}) => {
const { authenticatedUser, config } = useContext(AppContext);
const props = {
Expand All @@ -25,6 +25,7 @@ const StudioHeader = ({
number,
org,
title,
containerProps,
username: authenticatedUser?.username,
isAdmin: authenticatedUser?.administrator,
authenticatedUserAvatar: authenticatedUser?.avatar,
Expand Down Expand Up @@ -53,13 +54,14 @@ StudioHeader.propTypes = {
number: PropTypes.string,
org: PropTypes.string,
title: PropTypes.string.isRequired,
containerProps: HeaderBody.propTypes.containerProps,
isHiddenMainMenu: PropTypes.bool,
mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string,
buttonTitle: PropTypes.string,
buttonTitle: PropTypes.node,
items: PropTypes.arrayOf(PropTypes.shape({
href: PropTypes.string,
title: PropTypes.string,
title: PropTypes.node,
})),
})),
outlineLink: PropTypes.string,
Expand All @@ -69,6 +71,7 @@ StudioHeader.propTypes = {
StudioHeader.defaultProps = {
number: '',
org: '',
containerProps: {},
isHiddenMainMenu: false,
mainMenuDropdowns: [],
outlineLink: null,
Expand Down

0 comments on commit ae5253c

Please sign in to comment.