generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Head component. Update frontend-platform to version 2.5.0. Update the footer and header to avoid peer dependency errors. Create a component Head, that uses Helmet library and integrates internationalization to change the MFE name in the title tag according to the language, and change the favicon in runtime. Add react-helmet-async, enzyme and enzyme-adapter-react-16. Co-authored-by: anfbermudezme <[email protected]> Co-authored-by: Diana Catalina Olarte <[email protected]>
- Loading branch information
1 parent
61eb2e9
commit 44f1527
Showing
10 changed files
with
708 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,9 +34,9 @@ | |
}, | ||
"dependencies": { | ||
"@edx/brand": "npm:@edx/[email protected]", | ||
"@edx/frontend-component-footer": "10.3.0", | ||
"@edx/frontend-component-header": "2.6.1", | ||
"@edx/frontend-platform": "1.15.6", | ||
"@edx/frontend-component-footer": "11.1.1", | ||
"@edx/frontend-component-header": "3.1.1", | ||
"@edx/frontend-platform": "2.5.0", | ||
"@edx/paragon": "19.25.3", | ||
"@fortawesome/fontawesome-svg-core": "1.2.36", | ||
"@fortawesome/free-brands-svg-icons": "5.15.4", | ||
|
@@ -51,6 +51,7 @@ | |
"prop-types": "15.8.1", | ||
"react": "16.14.0", | ||
"react-dom": "16.14.0", | ||
"react-helmet-async": "^1.3.0", | ||
"react-redux": "7.2.9", | ||
"react-router": "5.3.3", | ||
"react-router-dom": "5.3.3", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { Helmet } from 'react-helmet-async'; | ||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
|
||
import messages from './messages'; | ||
|
||
function Head({ intl }) { | ||
return ( | ||
<Helmet> | ||
<title> | ||
{intl.formatMessage(messages.PageTitle, { siteName: getConfig().SITE_NAME })} | ||
</title> | ||
<link rel="shortcut icon" href={getConfig().FAVICON_URL} type="image/x-icon" /> | ||
</Helmet> | ||
); | ||
} | ||
|
||
Head.propTypes = { | ||
intl: intlShape.isRequired, | ||
}; | ||
|
||
export default injectIntl(Head); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line no-restricted-exports | ||
export { default } from './Head'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineMessages } from '@edx/frontend-platform/i18n'; | ||
|
||
const messages = defineMessages({ | ||
PageTitle: { | ||
id: 'PageTitle', | ||
defaultMessage: 'My Learner Records | {siteName}', | ||
description: 'Title tag', | ||
}, | ||
}); | ||
|
||
export default messages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
import { waitFor } from '@testing-library/react'; | ||
import { render, initializeMockApp } from '../../../setupTest'; | ||
import Head from '../Head'; | ||
|
||
describe('Head', () => { | ||
beforeAll(async () => { | ||
await initializeMockApp(); | ||
}); | ||
|
||
const props = {}; | ||
it('should match render title tag and favicon with the site configuration values', async () => { | ||
render(<Head {...props} />); | ||
|
||
await waitFor(() => { | ||
expect(document.title).toEqual(`My Learner Records | ${getConfig().SITE_NAME}`); | ||
expect(document.querySelector('link').rel).toEqual('shortcut icon'); | ||
expect(document.querySelector('link').href).toEqual(getConfig().FAVICON_URL); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters