Skip to content

Commit

Permalink
feat(examples): improve codesandbox example (#1523)
Browse files Browse the repository at this point in the history
* initial commit

* feat(ci): add bump chart

* feat(ci): add calendar chart

* feat(ci): add chord chart

* feat(ci): add choropleth chart

* feat(ci): add circle-packing chart

* feat(ci): add funnel chart

* feat(ci): add geomap chart

* feat(ci): add heatmap chart

* feat(ci): add line chart

* feat(ci): add marimekko chart

* feat(ci): add network chart

* feat(ci): add parallel-coordinates chart

* feat(ci): add pie chart

* feat(ci): add radar chart

* feat(ci): add sankey chart

* feat(ci): add scatterplot chart

* feat(ci): add stream chart

* feat(ci): add sunburst chart

* feat(ci): add swarmplot chart

* feat(ci): add treemap chart

* feat(ci): add voronoi chart

* feat(ci): add waffle chart

* feat(ci): add some styling

* refactor(ci): update useChart hook

* fix(ci): remove unused import

* fix(ci): remove inline styles
  • Loading branch information
wyze authored May 21, 2021
1 parent b323e98 commit bdbb48f
Show file tree
Hide file tree
Showing 41 changed files with 46,627 additions and 80 deletions.
76 changes: 42 additions & 34 deletions examples/codesandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,50 @@
],
"main": "src/index.js",
"dependencies": {
"@nivo/annotations": "0.63.1",
"@nivo/axes": "0.63.0",
"@nivo/bar": "0.63.1",
"@nivo/bullet": "0.63.1",
"@nivo/bump": "0.63.1",
"@nivo/calendar": "0.63.1",
"@nivo/chord": "0.63.1",
"@nivo/circle-packing": "0.63.1",
"@nivo/colors": "0.63.0",
"@nivo/core": "0.63.1",
"@nivo/funnel": "0.63.1",
"@nivo/generators": "0.63.0",
"@nivo/geo": "0.63.1",
"@nivo/heatmap": "0.63.0",
"@nivo/legends": "0.63.1",
"@nivo/line": "0.63.1",
"@nivo/network": "0.63.1",
"@nivo/parallel-coordinates": "0.63.1",
"@nivo/pie": "0.63.1",
"@nivo/radar": "0.63.1",
"@nivo/sankey": "0.63.1",
"@nivo/scales": "0.63.0",
"@nivo/scatterplot": "0.63.1",
"@nivo/stream": "0.63.1",
"@nivo/sunburst": "0.63.1",
"@nivo/swarmplot": "0.63.1",
"@nivo/tooltip": "0.63.0",
"@nivo/treemap": "0.63.0",
"@nivo/voronoi": "0.63.1",
"@nivo/waffle": "0.63.1",
"react": "17.0.0",
"react-dom": "17.0.0",
"react-scripts": "3.4.3"
"@nivo/annotations": "0.69.0",
"@nivo/arcs": "0.69.0",
"@nivo/axes": "0.69.1",
"@nivo/bar": "0.69.1",
"@nivo/bullet": "0.69.1",
"@nivo/bump": "0.69.1",
"@nivo/calendar": "0.69.0",
"@nivo/chord": "0.69.0",
"@nivo/circle-packing": "0.69.0",
"@nivo/colors": "0.69.0",
"@nivo/core": "0.69.0",
"@nivo/funnel": "0.69.0",
"@nivo/generators": "0.69.0",
"@nivo/geo": "0.69.0",
"@nivo/heatmap": "0.69.1",
"@nivo/legends": "0.69.0",
"@nivo/line": "0.69.1",
"@nivo/marimekko": "0.69.1",
"@nivo/network": "0.69.0",
"@nivo/parallel-coordinates": "0.69.1",
"@nivo/pie": "0.69.0",
"@nivo/radar": "0.69.0",
"@nivo/recompose": "0.69.0",
"@nivo/sankey": "0.69.0",
"@nivo/scales": "0.69.0",
"@nivo/scatterplot": "0.69.1",
"@nivo/stream": "0.69.1",
"@nivo/sunburst": "0.69.0",
"@nivo/swarmplot": "0.69.1",
"@nivo/tooltip": "0.69.0",
"@nivo/treemap": "0.69.0",
"@nivo/voronoi": "0.69.0",
"@nivo/waffle": "0.69.0",
"history": "5.0.0",
"otion": "0.6.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-router-dom": "6.0.0-beta.0",
"react-scripts": "4.0.3"
},
"devDependencies": {
"typescript": "3.8.3"
"@types/react": "17.0.5",
"@types/react-dom": "17.0.5",
"typescript": "4.2.4"
},
"scripts": {
"start": "react-scripts start",
Expand Down
41 changes: 21 additions & 20 deletions examples/codesandbox/public/index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -20,15 +22,15 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<title>Nivo CodeSandbox Demo</title>
</head>

<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -38,6 +40,5 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>

</html>
</body>
</html>
10 changes: 0 additions & 10 deletions examples/codesandbox/src/App.js

This file was deleted.

128 changes: 128 additions & 0 deletions examples/codesandbox/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import {
AreaBump,
Bar,
Bullet,
Bump,
Calendar,
Chord,
Choropleth,
CirclePacking,
Funnel,
GeoMap,
HeatMap,
Line,
Marimekko,
Network,
ParallelCoordinates,
Pie,
Radar,
Sankey,
ScatterPlot,
Stream,
Sunburst,
SwarmPlot,
TreeMap,
Voronoi,
Waffle,
} from './charts'
import {
BrowserRouter as Router,
Route,
Routes,
useLocation,
} from 'react-router-dom'
import { css } from 'otion'
import { useChart } from './hooks'
import ChartContainer from './ChartContainer'
import Navigation from './Navigation'

console.clear()

function Title() {
const [, flavor] = useChart()
const { pathname } = useLocation()
const title = pathname
.slice(1)
.split('-')
.concat(flavor === 'svg' ? '' : flavor)
.map((text) =>
text.replace(/((^| )(.))/g, (letter) => letter.toUpperCase())
)

return <h1 className={css({ textAlign: 'center' })}>{title}</h1>
}

function Welcome() {
return (
<div className={css({ fontSize: '1.2em', textAlign: 'center' })}>
<div>
Welcome to <strong>nivo</strong>'s CodeSandbox examples!
</div>
<br />
<div>
Here would be a great starting point to fork and create a reproduction
for your bug report.
</div>
<br />
<div>
This example will also be built with every PR and make it easier to
verify a bugfix or new feature.
</div>
<br />
<div>
You can get started by selecting the chart from the left side menu. You
can find the charts in <code>src/charts</code> to modify to your needs.
</div>
</div>
)
}

export default function App() {
return (
<Router>
<div className={css({ display: 'flex', height: '100vh' })}>
<Navigation />
<div
className={css({
display: 'flex',
flex: 1,
flexDirection: 'column',
})}>
<ChartContainer title={<Title />}>
<Routes>
<Route path="" element={<Welcome />} />
<Route path="area-bump" element={<AreaBump />} />
<Route path="bar" element={<Bar />} />
<Route path="bullet" element={<Bullet />} />
<Route path="bump" element={<Bump />} />
<Route path="calendar" element={<Calendar />} />
<Route path="chord" element={<Chord />} />
<Route path="choropleth" element={<Choropleth />} />
<Route path="circle-packing" element={<CirclePacking />} />
<Route path="funnel" element={<Funnel />} />
<Route path="geomap" element={<GeoMap />} />
<Route path="heatmap" element={<HeatMap />} />
<Route path="line" element={<Line />} />
<Route path="marimekko" element={<Marimekko />} />
<Route path="network" element={<Network />} />
<Route
path="parallel-coordinates"
element={<ParallelCoordinates />}
/>
<Route path="pie" element={<Pie />} />
<Route path="radar" element={<Radar />} />
<Route path="sankey" element={<Sankey />} />
<Route path="scatterplot" element={<ScatterPlot />} />
<Route path="stream" element={<Stream />} />
<Route path="sunburst" element={<Sunburst />} />
<Route path="swarmplot" element={<SwarmPlot />} />
<Route path="treemap" element={<TreeMap />} />
<Route path="voronoi" element={<Voronoi />} />
<Route path="waffle" element={<Waffle />} />
</Routes>
</ChartContainer>
</div>
</div>
</Router>
)
}
Loading

0 comments on commit bdbb48f

Please sign in to comment.