Skip to content

Commit

Permalink
update the plugin and footer
Browse files Browse the repository at this point in the history
  • Loading branch information
im6 committed Mar 22, 2020
1 parent 5b2697f commit f34a124
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 298 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"homepage": "https://github.com/im6/javascript-fun#readme",
"dependencies": {
"@babel/core": "^7.9.0",
"@babel/plugin-transform-react-jsx": "^7.9.1",
"@babel/preset-env": "^7.9.0",
"@babel/preset-react": "^7.9.1",
"@testing-library/react": "^10.0.1",
Expand Down Expand Up @@ -105,10 +104,12 @@
"babel": {
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-transform-react-jsx"
[
"@babel/preset-react",
{
"runtime": "classic"
}
]
]
},
"jest": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import style from './style.less';

const Footer = ({ hideAuthor, author, year }) => (
const Footer = ({ hideAuthor, author, year, pageSpeedUrl }) => (
<footer className={style.footer}>
<span>
&copy; Copyright {year}&nbsp;
Expand All @@ -14,11 +14,7 @@ const Footer = ({ hideAuthor, author, year }) => (
'Javascript.Fun'
)}
.&nbsp;All rights reserved. &#9989; by&nbsp;
<a
href="https://developers.google.com/speed/pagespeed/insights/?url=www.javascript.fun&tab=desktop"
target="_blank"
className={style.blue}
>
<a href={pageSpeedUrl} target="_blank" className={style.blue}>
Google PageSpeed
</a>
</span>
Expand All @@ -27,6 +23,7 @@ const Footer = ({ hideAuthor, author, year }) => (

Footer.propTypes = {
author: PropTypes.string.isRequired,
pageSpeedUrl: PropTypes.string.isRequired,
hideAuthor: PropTypes.bool,
year: PropTypes.number.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ import Footer from '.';
describe('render properly', () => {
test('render correct', () => {
const authorName = 'hello';
const pageSpeedUrl = 'www.cnn.com';
const { getByText, rerender } = render(
<Footer author={authorName} year={1998} hideAuthor />
<Footer
author={authorName}
year={1998}
hideAuthor
pageSpeedUrl={pageSpeedUrl}
/>
);
rerender(
<Footer author={authorName} year={1998} pageSpeedUrl={pageSpeedUrl} />
);
rerender(<Footer author={authorName} year={1998} />);
expect(getByText(authorName)).toBeTruthy();
});
});
9 changes: 8 additions & 1 deletion src/components/AppContainer/Layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Layout = ({
children,
leftNavText,
author,
pageSpeedUrl,
iconCdnUrl,
topNavConfig,
hideOwnerDetail,
Expand All @@ -27,7 +28,12 @@ const Layout = ({
<TopNav url={url} topNavConfig={topNavConfig} iconCdnUrl={iconCdnUrl} />
{children}
<TopNav url={url} topNavConfig={topNavConfig} iconCdnUrl={iconCdnUrl} />
<Footer hideAuthor={hideOwnerDetail} author={author} year={year} />
<Footer
hideAuthor={hideOwnerDetail}
author={author}
year={year}
pageSpeedUrl={pageSpeedUrl}
/>
</div>
</div>
);
Expand All @@ -36,6 +42,7 @@ Layout.propTypes = {
url: PropTypes.string.isRequired,
iconCdnUrl: PropTypes.string.isRequired,
author: PropTypes.string.isRequired,
pageSpeedUrl: PropTypes.string.isRequired,
hideOwnerDetail: PropTypes.bool,
gitRepo: PropTypes.string.isRequired,
year: PropTypes.number.isRequired,
Expand Down
2 changes: 2 additions & 0 deletions src/components/AppContainer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Layout from './Layout';

import {
author,
pageSpeedUrl,
hideOwnerDetail,
gitRepo,
publicPath,
Expand All @@ -32,6 +33,7 @@ const AppContainer = ({ url, children, criticalCss }) => (
topNavConfig={topNavConfig}
leftNavText={leftNavText}
author={author}
pageSpeedUrl={pageSpeedUrl}
gitRepo={gitRepo}
year={leftNavText[0]}
hideOwnerDetail={hideOwnerDetail}
Expand Down
2 changes: 2 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const publicPath = '/assets';
export const iconCdnUrl = '//dkny.oss-cn-hangzhou.aliyuncs.com/1/icons';
export const nonLazyImg = 2;
export const author = 'ZJ Guo';
export const pageSpeedUrl =
'https://developers.google.com/speed/pagespeed/insights/?url=www.javascript.fun&tab=desktop';
export const hideOwnerDetail = false;
export const githubUrl = 'https://github.com';
export const gitRepo = `${githubUrl}/im6/javascript-fun/issues`;
Expand Down
9 changes: 1 addition & 8 deletions webpack/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,7 @@ const server = Object.assign(serverBaseConfig, {
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
],
use: ['babel-loader'],
},
{
test: /\.less$/,
Expand Down
9 changes: 1 addition & 8 deletions webpack/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,7 @@ const server = Object.assign(serverBaseConfig, {
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
],
use: ['babel-loader'],
},
{
test: /\.less$/,
Expand Down
Loading

0 comments on commit f34a124

Please sign in to comment.