feat: upgrading deps, retheme with from @edx/brand, pull logo from config settings (#104)
* feat: upgrading deps, use logo from @edx/brand * feat: upgrading peer deps * feat: pr feedback * update snapshots and example app * pull config from AppContext Co-authored-by: Adam Stankiewicz <agstanki@gmail.com>
This commit is contained in:
19
.env.development
Normal file
19
.env.development
Normal file
@@ -0,0 +1,19 @@
|
||||
ACCESS_TOKEN_COOKIE_NAME=edx-jwt-cookie-header-payload
|
||||
BASE_URL=localhost:8080
|
||||
CREDENTIALS_BASE_URL=http://localhost:18150
|
||||
CSRF_TOKEN_API_PATH=/csrf/api/v1/token
|
||||
ECOMMERCE_BASE_URL=http://localhost:18130
|
||||
LANGUAGE_PREFERENCE_COOKIE_NAME=openedx-language-preference
|
||||
LMS_BASE_URL=http://localhost:18000
|
||||
LOGIN_URL=http://localhost:18000/login
|
||||
LOGOUT_URL=http://localhost:18000/login
|
||||
MARKETING_SITE_BASE_URL=http://localhost:18000
|
||||
ORDER_HISTORY_URL=localhost:1996/orders
|
||||
REFRESH_ACCESS_TOKEN_ENDPOINT=http://localhost:18000/login_refresh
|
||||
SEGMENT_KEY=null
|
||||
SITE_NAME=Open edX
|
||||
USER_INFO_COOKIE_NAME=edx-user-info
|
||||
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
|
||||
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
|
||||
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
|
||||
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
|
||||
@@ -1,3 +1,4 @@
|
||||
coverage
|
||||
dist
|
||||
example
|
||||
node_modules
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ temp
|
||||
src/i18n/transifex_input.json
|
||||
temp/babel-plugin-react-intl
|
||||
/.vscode
|
||||
module.config.js
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
import 'babel-polyfill';
|
||||
|
||||
import React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { initialize, getConfig, subscribe, APP_READY } from '@edx/frontend-platform';
|
||||
import { AppContext, AppProvider } from '@edx/frontend-platform/react';
|
||||
import Footer from '@edx/frontend-component-footer';
|
||||
|
||||
import './index.scss';
|
||||
import Footer from '../src';
|
||||
|
||||
const App = () => (
|
||||
<div>
|
||||
<IntlProvider locale="en">
|
||||
subscribe(APP_READY, () => {
|
||||
ReactDOM.render(
|
||||
<AppProvider>
|
||||
<AppContext.Provider value={{
|
||||
authenticatedUser: null,
|
||||
config: getConfig(),
|
||||
}}>
|
||||
<Footer
|
||||
onLanguageSelected={() => {}}
|
||||
supportedLanguages={[
|
||||
@@ -15,8 +22,12 @@ const App = () => (
|
||||
{ label: 'Español', value: 'es' },
|
||||
]}
|
||||
/>
|
||||
</IntlProvider>
|
||||
</div>
|
||||
</AppContext.Provider>
|
||||
</AppProvider>,
|
||||
document.getElementById('root'),
|
||||
);
|
||||
});
|
||||
|
||||
render(<App />, document.getElementById('root'));
|
||||
initialize({
|
||||
messages: []
|
||||
});
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
@import "~@edx/paragon/scss/core/core.scss";
|
||||
@import "../src/footer";
|
||||
@import "@edx/brand/paragon/fonts";
|
||||
@import "@edx/brand/paragon/variables";
|
||||
@import "@edx/paragon/scss/core/core";
|
||||
@import "@edx/brand/paragon/overrides";
|
||||
|
||||
@import "@edx/frontend-component-footer/footer";
|
||||
|
||||
14252
package-lock.json
generated
14252
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -38,9 +38,10 @@
|
||||
"@commitlint/config-angular": "8.2.0",
|
||||
"@commitlint/prompt": "8.2.0",
|
||||
"@commitlint/prompt-cli": "8.2.0",
|
||||
"@edx/frontend-build": "^2.0.4",
|
||||
"@edx/frontend-platform": "1.1.6",
|
||||
"@edx/paragon": "7.1.5",
|
||||
"@edx/brand": "npm:@edx/brand-openedx@1.1.0",
|
||||
"@edx/frontend-build": "5.4.0",
|
||||
"@edx/frontend-platform": "1.8.0",
|
||||
"@edx/paragon": "12.0.5",
|
||||
"codecov": "3.7.2",
|
||||
"enzyme": "3.10.0",
|
||||
"enzyme-adapter-react-16": "1.14.0",
|
||||
@@ -48,8 +49,11 @@
|
||||
"prop-types": "15.7.2",
|
||||
"react": "16.10.2",
|
||||
"react-dom": "16.10.2",
|
||||
"react-redux": "^7.1.1",
|
||||
"react-router-dom": "^5.1.2",
|
||||
"react-test-renderer": "16.10.2",
|
||||
"reactifex": "1.1.1"
|
||||
"reactifex": "1.1.1",
|
||||
"redux": "^4.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "1.2.30",
|
||||
@@ -59,7 +63,7 @@
|
||||
"@fortawesome/react-fontawesome": "0.1.11"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@edx/frontend-platform": "^1.1.4",
|
||||
"@edx/frontend-platform": "^1.8.0",
|
||||
"@edx/paragon": "^7.0.0",
|
||||
"prop-types": "^15.5.10",
|
||||
"react": "^16.9.0",
|
||||
|
||||
@@ -2,11 +2,16 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
||||
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
|
||||
import { ensureConfig } from '@edx/frontend-platform/config';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
|
||||
import messages from './Footer.messages';
|
||||
import FooterLogo from '../edx-openedx-logo-tag.png';
|
||||
import LanguageSelector from './LanguageSelector';
|
||||
|
||||
ensureConfig([
|
||||
'LOGO_TRADEMARK_URL',
|
||||
], 'Footer component');
|
||||
|
||||
const EVENT_NAMES = {
|
||||
FOOTER_LINK: 'edx.bi.footer.link',
|
||||
};
|
||||
@@ -43,6 +48,7 @@ class SiteFooter extends React.Component {
|
||||
intl,
|
||||
} = this.props;
|
||||
const showLanguageSelector = supportedLanguages.length > 0 && onLanguageSelected;
|
||||
const { config } = this.context;
|
||||
|
||||
return (
|
||||
<footer
|
||||
@@ -50,31 +56,33 @@ class SiteFooter extends React.Component {
|
||||
aria-label={intl.formatMessage(messages['footer.logo.ariaLabel'])}
|
||||
className="footer d-flex border-top py-3 px-4"
|
||||
>
|
||||
<div className="container d-flex">
|
||||
<div className="container-fluid d-flex">
|
||||
<a
|
||||
className="d-block mb-3"
|
||||
className="d-block"
|
||||
href="https://open.edx.org"
|
||||
aria-label={intl.formatMessage(messages['footer.logo.ariaLabel'])}
|
||||
>
|
||||
<img
|
||||
style={{ maxWidth: 150 }}
|
||||
src={logo || FooterLogo}
|
||||
style={{ maxHeight: 45 }}
|
||||
src={logo || config.LOGO_TRADEMARK_URL}
|
||||
alt={intl.formatMessage(messages['footer.logo.altText'])}
|
||||
/>
|
||||
</a>
|
||||
<div className="flex-grow-1" />
|
||||
{showLanguageSelector &&
|
||||
{showLanguageSelector && (
|
||||
<LanguageSelector
|
||||
options={supportedLanguages}
|
||||
onSubmit={onLanguageSelected}
|
||||
/>
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SiteFooter.contextType = AppContext;
|
||||
|
||||
SiteFooter.propTypes = {
|
||||
intl: intlShape.isRequired,
|
||||
logo: PropTypes.string,
|
||||
|
||||
@@ -2,6 +2,7 @@ import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import { mount } from 'enzyme';
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import { AppContext } from '@edx/frontend-platform/react';
|
||||
|
||||
import Footer from './Footer';
|
||||
|
||||
@@ -11,7 +12,16 @@ describe('<Footer />', () => {
|
||||
const tree = renderer
|
||||
.create((
|
||||
<IntlProvider locale="en">
|
||||
<AppContext.Provider
|
||||
value={{
|
||||
authenticatedUser: null,
|
||||
config: {
|
||||
LOGO_TRADEMARK_URL: process.env.LOGO_TRADEMARK_URL,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Footer />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
))
|
||||
.toJSON();
|
||||
@@ -21,7 +31,16 @@ describe('<Footer />', () => {
|
||||
const tree = renderer
|
||||
.create((
|
||||
<IntlProvider locale="es">
|
||||
<AppContext.Provider
|
||||
value={{
|
||||
authenticatedUser: null,
|
||||
config: {
|
||||
LOGO_TRADEMARK_URL: process.env.LOGO_TRADEMARK_URL,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Footer />
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
))
|
||||
.toJSON();
|
||||
@@ -31,6 +50,14 @@ describe('<Footer />', () => {
|
||||
const tree = renderer
|
||||
.create((
|
||||
<IntlProvider locale="en">
|
||||
<AppContext.Provider
|
||||
value={{
|
||||
authenticatedUser: null,
|
||||
config: {
|
||||
LOGO_TRADEMARK_URL: process.env.LOGO_TRADEMARK_URL,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Footer
|
||||
onLanguageSelected={() => {}}
|
||||
supportedLanguages={[
|
||||
@@ -38,6 +65,7 @@ describe('<Footer />', () => {
|
||||
{ label: 'Español', value: 'es' },
|
||||
]}
|
||||
/>
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
))
|
||||
.toJSON();
|
||||
@@ -50,6 +78,14 @@ describe('<Footer />', () => {
|
||||
const mockHandleLanguageSelected = jest.fn();
|
||||
const wrapper = mount((
|
||||
<IntlProvider locale="en">
|
||||
<AppContext.Provider
|
||||
value={{
|
||||
authenticatedUser: null,
|
||||
config: {
|
||||
LOGO_TRADEMARK_URL: process.env.LOGO_TRADEMARK_URL,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Footer
|
||||
onLanguageSelected={mockHandleLanguageSelected}
|
||||
supportedLanguages={[
|
||||
@@ -57,6 +93,7 @@ describe('<Footer />', () => {
|
||||
{ label: 'Español', value: 'es' },
|
||||
]}
|
||||
/>
|
||||
</AppContext.Provider>
|
||||
</IntlProvider>
|
||||
));
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ const LanguageSelector = ({
|
||||
onSubmit={handleSubmit}
|
||||
{...props}
|
||||
>
|
||||
{/* eslint-disable-next-line jsx-a11y/label-has-for */}
|
||||
<div className="form-group">
|
||||
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
||||
<label htmlFor="site-footer-language-select" className="d-inline-block m-0">
|
||||
<FormattedMessage
|
||||
id="footer.languageForm.select.label"
|
||||
@@ -32,8 +32,7 @@ const LanguageSelector = ({
|
||||
name="site-footer-language-select"
|
||||
defaultValue={intl.locale}
|
||||
>
|
||||
{options.map(({ value, label }) =>
|
||||
<option key={value} value={value}>{label}</option>)}
|
||||
{options.map(({ value, label }) => <option key={value} value={value}>{label}</option>)}
|
||||
</select>
|
||||
<button className="btn btn-outline-primary btn-sm" type="submit">
|
||||
<FormattedMessage
|
||||
|
||||
@@ -7,19 +7,19 @@ exports[`<Footer /> renders correctly renders with a language selector 1`] = `
|
||||
role="contentinfo"
|
||||
>
|
||||
<div
|
||||
className="container d-flex"
|
||||
className="container-fluid d-flex"
|
||||
>
|
||||
<a
|
||||
aria-label="edX Home"
|
||||
className="d-block mb-3"
|
||||
className="d-block"
|
||||
href="https://open.edx.org"
|
||||
>
|
||||
<img
|
||||
alt="Powered by Open edX"
|
||||
src="test-file-stub"
|
||||
src="https://edx-cdn.org/v3/default/logo-trademark.svg"
|
||||
style={
|
||||
Object {
|
||||
"maxWidth": 150,
|
||||
"maxHeight": 45,
|
||||
}
|
||||
}
|
||||
/>
|
||||
@@ -80,19 +80,19 @@ exports[`<Footer /> renders correctly renders without a language selector 1`] =
|
||||
role="contentinfo"
|
||||
>
|
||||
<div
|
||||
className="container d-flex"
|
||||
className="container-fluid d-flex"
|
||||
>
|
||||
<a
|
||||
aria-label="edX Home"
|
||||
className="d-block mb-3"
|
||||
className="d-block"
|
||||
href="https://open.edx.org"
|
||||
>
|
||||
<img
|
||||
alt="Powered by Open edX"
|
||||
src="test-file-stub"
|
||||
src="https://edx-cdn.org/v3/default/logo-trademark.svg"
|
||||
style={
|
||||
Object {
|
||||
"maxWidth": 150,
|
||||
"maxHeight": 45,
|
||||
}
|
||||
}
|
||||
/>
|
||||
@@ -111,19 +111,19 @@ exports[`<Footer /> renders correctly renders without a language selector in es
|
||||
role="contentinfo"
|
||||
>
|
||||
<div
|
||||
className="container d-flex"
|
||||
className="container-fluid d-flex"
|
||||
>
|
||||
<a
|
||||
aria-label="edX Home"
|
||||
className="d-block mb-3"
|
||||
className="d-block"
|
||||
href="https://open.edx.org"
|
||||
>
|
||||
<img
|
||||
alt="Powered by Open edX"
|
||||
src="test-file-stub"
|
||||
src="https://edx-cdn.org/v3/default/logo-trademark.svg"
|
||||
style={
|
||||
Object {
|
||||
"maxWidth": 150,
|
||||
"maxHeight": 45,
|
||||
}
|
||||
}
|
||||
/>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
@@ -2,3 +2,25 @@ import Enzyme from 'enzyme';
|
||||
import Adapter from 'enzyme-adapter-react-16';
|
||||
|
||||
Enzyme.configure({ adapter: new Adapter() });
|
||||
|
||||
// These configuration values are usually set in webpack's EnvironmentPlugin however
|
||||
// Jest does not use webpack so we need to set these so for testing
|
||||
process.env.ACCESS_TOKEN_COOKIE_NAME = 'edx-jwt-cookie-header-payload';
|
||||
process.env.BASE_URL = 'localhost:1995';
|
||||
process.env.CREDENTIALS_BASE_URL = 'http://localhost:18150';
|
||||
process.env.CSRF_TOKEN_API_PATH = '/csrf/api/v1/token';
|
||||
process.env.ECOMMERCE_BASE_URL = 'http://localhost:18130';
|
||||
process.env.LANGUAGE_PREFERENCE_COOKIE_NAME = 'openedx-language-preference';
|
||||
process.env.LMS_BASE_URL = 'http://localhost:18000';
|
||||
process.env.LOGIN_URL = 'http://localhost:18000/login';
|
||||
process.env.LOGOUT_URL = 'http://localhost:18000/login';
|
||||
process.env.MARKETING_SITE_BASE_URL = 'http://localhost:18000';
|
||||
process.env.ORDER_HISTORY_URL = 'localhost:1996/orders';
|
||||
process.env.REFRESH_ACCESS_TOKEN_ENDPOINT = 'http://localhost:18000/login_refresh';
|
||||
process.env.SEGMENT_KEY = 'segment_whoa';
|
||||
process.env.SITE_NAME = 'edX';
|
||||
process.env.USER_INFO_COOKIE_NAME = 'edx-user-info';
|
||||
process.env.LOGO_URL = 'https://edx-cdn.org/v3/default/logo.svg';
|
||||
process.env.LOGO_TRADEMARK_URL = 'https://edx-cdn.org/v3/default/logo-trademark.svg';
|
||||
process.env.LOGO_WHITE_URL = 'https://edx-cdn.org/v3/default/logo-white.svg';
|
||||
process.env.FAVICON_URL = 'https://edx-cdn.org/v3/default/favicon.ico';
|
||||
|
||||
@@ -7,4 +7,9 @@ module.exports = createConfig('webpack-dev', {
|
||||
path: path.resolve(__dirname, 'example/dist'),
|
||||
publicPath: '/',
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@edx/frontend-component-footer': path.resolve(__dirname, 'src'),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user