-
Notifications
You must be signed in to change notification settings - Fork 166
feat: expose containerProps in StudioHeader [FC-0062] #529
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
Changes from 4 commits
ce107bf
e2249b2
35c2040
d7c69a2
10c3e12
89c949d
06bfcc7
ccee347
61243f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -38,7 +38,7 @@ | |||||
| "@edx/frontend-platform": "8.1.1", | ||||||
| "@edx/reactifex": "^2.1.1", | ||||||
| "@openedx/frontend-build": "14.1.2", | ||||||
| "@openedx/paragon": "22.7.0", | ||||||
| "@openedx/paragon": "^22.8.0", | ||||||
| "@testing-library/dom": "10.4.0", | ||||||
| "@testing-library/jest-dom": "5.17.0", | ||||||
| "@testing-library/react": "10.4.9", | ||||||
|
|
@@ -68,7 +68,8 @@ | |||||
| }, | ||||||
| "peerDependencies": { | ||||||
| "@edx/frontend-platform": "^7.0.0 || ^8.0.0", | ||||||
| "@openedx/paragon": ">= 21.5.7 < 23.0.0", | ||||||
| "@openedx/paragon": "^22.8.0", | ||||||
|
||||||
| "node_modules/@openedx/paragon": { | |
| "version": "22.8.1", |
Could you help me to understand?
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I'm not sure if we should have @openedx/paragon (and some other packages such as react, react-dom, etc..) in the devDependencias, but I think this is an issue for another PR. 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package-lock.json is pointing to 22.8.1 due to @openedx/paragon getting installed as a devDependency, which is intentional. Because this library relies on consumers to provide their own copy of @openedx/paragon (per the peerDependencies), the devDependencies copy of @openedx/paragon is what allows for local development of the library. Without Paragon in the devDependencies, the example app within this repo couldn't run due to the missing installed node_modules/@openedx/paragon.
The devDependencies are not included in the production bundle published to NPM, as confirmed by noting that @openedx/paragon is included only in the npm list --include=dev command, but not npm list --omit=dev as seen below:
❯ npm list --omit=dev --depth=0
@edx/frontend-component-header@1.0.0-semantically-released /Users/astankiewicz/Desktop/edx/frontend-component-header
├── @fortawesome/fontawesome-svg-core@6.6.0
├── @fortawesome/free-brands-svg-icons@6.6.0
├── @fortawesome/free-regular-svg-icons@6.6.0
├── @fortawesome/free-solid-svg-icons@6.6.0
├── @fortawesome/react-fontawesome@0.2.2
├── @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
❯ npm list --include=dev --depth=0
@edx/frontend-component-header@1.0.0-semantically-released /Users/astankiewicz/Desktop/edx/frontend-component-header
├── @edx/brand@npm:@openedx/brand-openedx@1.2.3
├── @edx/browserslist-config@1.2.0
├── @edx/frontend-platform@8.1.1
├── @edx/reactifex@2.2.0
├── @fortawesome/fontawesome-svg-core@6.6.0
├── @fortawesome/free-brands-svg-icons@6.6.0
├── @fortawesome/free-regular-svg-icons@6.6.0
├── @fortawesome/free-solid-svg-icons@6.6.0
├── @fortawesome/react-fontawesome@0.2.2
├── @openedx/frontend-build@14.1.5
├── @openedx/frontend-plugin-framework@1.3.0
├── @openedx/paragon@22.8.1
├── @testing-library/dom@10.4.0
├── @testing-library/jest-dom@5.17.0
├── @testing-library/react@10.4.9
├── axios-mock-adapter@1.22.0
├── babel-polyfill@6.26.0
├── classnames@2.5.1
├── husky@8.0.3
├── jest-chain@1.1.6
├── jest-environment-jsdom@29.7.0
├── jest@29.7.0
├── prop-types@15.8.1
├── react-dom@17.0.2
├── react-redux@7.2.9
├── react-responsive@8.2.0
├── react-router-dom@6.26.2
├── react-test-renderer@17.0.2
├── react-transition-group@4.4.5
├── react@17.0.2
├── redux-saga@1.3.0
└── redux@4.2.1There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I got it! Thank you for the explanation!
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we may want to make this a regular dependency under dependencies so consumers don't need to explicitly install classnames themselves. Otherwise, any consuming MFE that doesn't use classnames@^2.5.1 already will need to install it (also technically a breaking change).
classNames is different from packages that should be peerDependencies, which are either large (e.g., @openedx/paragon) and/or should only have a single copy within the consuming application (e.g., @edx/frontend-platform).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation! Fixed here: 61243f4
| 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, | ||
|
|
@@ -37,6 +38,7 @@ const HeaderBody = ({ | |
| mainMenuDropdowns, | ||
| outlineLink, | ||
| searchButtonAction, | ||
| containerProps, | ||
| }) => { | ||
| const intl = useIntl(); | ||
|
|
||
|
|
@@ -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"> | ||
|
|
@@ -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'])} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to this feature. This is a fly-by fix of a console warning. Let me know if I should create a different PR for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for fixing these! Fewer warnings is always good. |
||
| /> | ||
| </Nav> | ||
| )} | ||
|
|
@@ -155,6 +164,7 @@ HeaderBody.propTypes = { | |
| })), | ||
| outlineLink: PropTypes.string, | ||
| searchButtonAction: PropTypes.func, | ||
| containerProps: PropTypes.shape(Container.propTypes), | ||
| }; | ||
|
|
||
| HeaderBody.defaultProps = { | ||
|
|
@@ -174,6 +184,7 @@ HeaderBody.defaultProps = { | |
| mainMenuDropdowns: [], | ||
| outlineLink: null, | ||
| searchButtonAction: null, | ||
| containerProps: {}, | ||
| }; | ||
|
|
||
| export default HeaderBody; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ const NavDropdownMenu = ({ | |
|
|
||
| NavDropdownMenu.propTypes = { | ||
| id: PropTypes.string.isRequired, | ||
| buttonTitle: PropTypes.string.isRequired, | ||
| buttonTitle: PropTypes.node.isRequired, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to this feature. This is a fly-by fix of a console warning. Let me know if I should create a different PR for this.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed other places here: 06bfcc7 |
||
| items: PropTypes.arrayOf(PropTypes.shape({ | ||
| href: PropTypes.string, | ||
| title: PropTypes.string, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 = { | ||
|
|
@@ -25,6 +25,7 @@ const StudioHeader = ({ | |
| number, | ||
| org, | ||
| title, | ||
| containerProps, | ||
| username: authenticatedUser?.username, | ||
| isAdmin: authenticatedUser?.administrator, | ||
| authenticatedUserAvatar: authenticatedUser?.avatar, | ||
|
|
@@ -53,6 +54,7 @@ StudioHeader.propTypes = { | |
| number: PropTypes.string, | ||
| org: PropTypes.string, | ||
| title: PropTypes.string.isRequired, | ||
| containerProps: HeaderBody.propTypes.containerProps, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed here: e2249b2 |
||
| isHiddenMainMenu: PropTypes.bool, | ||
| mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({ | ||
| id: PropTypes.string, | ||
|
|
@@ -69,6 +71,7 @@ StudioHeader.propTypes = { | |
| StudioHeader.defaultProps = { | ||
| number: '', | ||
| org: '', | ||
| containerProps: {}, | ||
| isHiddenMainMenu: false, | ||
| mainMenuDropdowns: [], | ||
| outlineLink: null, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need paragon in the
devDependencies, but I'm keeping it