Skip to content

Commit 591a8c2

Browse files
committed
Better www
1 parent d5c0446 commit 591a8c2

File tree

10 files changed

+308
-84
lines changed

10 files changed

+308
-84
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
}
88
],
99
"@babel/react"
10-
]
10+
],
1111
}

src/components/Chart.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,24 @@ export default function Chart({
100100

101101
getSeriesID = React.useCallback(
102102
Utils.normalizeGetter(getSeriesID),
103-
getSeriesID
103+
[getSeriesID]
104104
);
105-
getLabel = React.useCallback(Utils.normalizeGetter(getLabel), getLabel);
105+
getLabel = React.useCallback(Utils.normalizeGetter(getLabel), [getLabel]);
106106
getPrimaryAxisID = React.useCallback(
107107
Utils.normalizeGetter(getPrimaryAxisID),
108-
getPrimaryAxisID
108+
[getPrimaryAxisID]
109109
);
110110
getSecondaryAxisID = React.useCallback(
111111
Utils.normalizeGetter(getSecondaryAxisID),
112-
getSecondaryAxisID
112+
[getSecondaryAxisID]
113113
);
114-
getDatums = React.useCallback(Utils.normalizeGetter(getDatums), getDatums);
115-
getPrimary = React.useCallback(Utils.normalizeGetter(getPrimary), getPrimary);
114+
getDatums = React.useCallback(Utils.normalizeGetter(getDatums), [getDatums]);
115+
getPrimary = React.useCallback(Utils.normalizeGetter(getPrimary), [getPrimary]);
116116
getSecondary = React.useCallback(
117117
Utils.normalizeGetter(getSecondary),
118-
getSecondary
118+
[getSecondary]
119119
);
120-
getR = React.useCallback(Utils.normalizeGetter(getR), getR);
120+
getR = React.useCallback(Utils.normalizeGetter(getR), [getR]);
121121

122122
let materializedData = calculateMaterializeData({
123123
data,

www/.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"presets": ["next/babel"],
3-
// "plugins": [["styled-components", { "ssr": true }]]
3+
"plugins": ["source", "styled-components"]
44
}

www/next.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ Module.prototype.require = function(modulePath) {
3333
}
3434

3535
const baseConfig = {
36-
// target: 'serverless',
37-
// distDir: '../.next',
36+
target: 'serverless',
3837
pageExtensions: ['js', 'jsx'],
3938
webpack(config) {
4039
config.resolve.modules = [...config.resolve.modules, path.resolve('./src')]

www/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"devDependencies": {
2222
"@zeit/next-css": "^1.0.1",
2323
"babel-eslint": "10.0.3",
24+
"babel-plugin-source": "^0.0.6",
25+
"babel-plugin-styled-components": "^1.10.6",
2426
"eslint": "6.6.0",
2527
"eslint-plugin-flowtype": "4.4.1",
2628
"eslint-plugin-import": "2.18.2",
File renamed without changes.

www/pages/examples/line.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import React from 'react'
55

66
import useChartConfig from 'hooks/useChartConfig'
77
import Box from 'components/Box'
8-
// import SyntaxHighlighter from 'components/SyntaxHighlighter'
8+
import SyntaxHighlighter from 'components/SyntaxHighlighter'
99
import { Chart } from 'react-charts'
1010

11-
// let sourceCode
11+
let sourceCode
1212

1313
export default function Line () {
1414
const { data, randomizeData } = useChartConfig({
@@ -39,7 +39,7 @@ export default function Line () {
3939
<Chart data={data} series={series} axes={axes} tooltip />
4040
</Box>
4141
<br />
42-
{/* <SyntaxHighlighter code={sourceCode} /> */}
42+
<SyntaxHighlighter code={sourceCode} />
4343
</>
4444
)
4545
}

www/src/components/Sidebar.js

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -244,57 +244,45 @@ const Menu = ({ items }) => (
244244
</div>
245245
)
246246

247-
class Sidebar extends React.Component {
248-
state = {
249-
isOpen: false
250-
}
251-
toggle = isOpen =>
252-
this.setState({
253-
isOpen
254-
})
255-
render() {
256-
const { children } = this.props
257-
const { isOpen } = this.state
258-
259-
return (
260-
<SidebarStyles className="sidebar" isOpen={isOpen}>
261-
<ClickOutside
262-
onClickOutside={
263-
isOpen
264-
? () => {
265-
this.setState({
266-
isOpen: false
267-
})
268-
}
269-
: undefined
270-
}
271-
>
272-
<div className="sidebar">
273-
<button
274-
className="toggle"
275-
onClick={() => {
276-
this.toggle(!isOpen)
277-
}}
278-
>
279-
280-
</button>
281-
<div className="header">
282-
<span className="link">
283-
<a href="https://github.com/react-tools/react-charts">
284-
React Charts
285-
</a>
286-
</span>
287-
<div className="version" />
288-
</div>
289-
<div className="scroll">
290-
<Menu items={menuItems} />
291-
</div>
247+
export default function Sidebar ({ children }) {
248+
const [isOpen, setIsOpen] = React.useState(false)
249+
250+
const toggle = () => setIsOpen(old => !old)
251+
252+
return (
253+
<SidebarStyles className="sidebar" isOpen={isOpen}>
254+
<ClickOutside
255+
onClickOutside={
256+
isOpen
257+
? () => {
258+
this.setState({
259+
isOpen: false
260+
})
261+
}
262+
: undefined
263+
}
264+
>
265+
<div className="sidebar">
266+
<button
267+
className="toggle"
268+
onClick={toggle}
269+
>
270+
271+
</button>
272+
<div className="header">
273+
<span className="link">
274+
<a href="https://github.com/react-tools/react-charts">
275+
React Charts
276+
</a>
277+
</span>
278+
<div className="version" />
292279
</div>
293-
</ClickOutside>
294-
<div className="content">{children}</div>
295-
</SidebarStyles>
296-
)
297-
}
280+
<div className="scroll">
281+
<Menu items={menuItems} />
282+
</div>
283+
</div>
284+
</ClickOutside>
285+
<div className="content">{children}</div>
286+
</SidebarStyles>
287+
)
298288
}
299-
300-
export default Sidebar

0 commit comments

Comments
 (0)