diff --git a/.eslintrc.js b/.eslintrc.js index 205ed3e..4f8c774 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -18,6 +18,7 @@ module.exports = { }, plugins: ['react', 'react-hooks'], rules: { + 'react/prop-types': ['off'], 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'warn', 'react/default-props-match-prop-types': ['error'], diff --git a/package.json b/package.json index 666e580..d6ce188 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "msw": "^0.28.0", "npm-run-all": "^4.1.5", "prettier": "^2.2.1", + "ramda": "^0.27.1", "react": "^17.0.2", "react-dom": "^17.0.2", "react-hook-form": "^6.15.5", @@ -60,4 +61,4 @@ "msw": { "workerDirectory": "public" } -} \ No newline at end of file +} diff --git a/src/App.js b/src/App.js index 6c7b7f1..0d20d14 100644 --- a/src/App.js +++ b/src/App.js @@ -1,17 +1,121 @@ import './App.css' -import { Redirect, Route, Router, Switch } from 'react-router-dom' +import { Button, AppBar, Toolbar, Typography } from '@material-ui/core' +import { makeStyles } from '@material-ui/core/styles' +import { + Redirect, + Route, + Router, + Switch, + useParams, + Link, +} from 'react-router-dom' import { history } from 'utils/history' import { Example01 } from './examples/01' +import { Example02 } from './examples/02' +import { Example03 } from './examples/03' +import { Example04 } from './examples/04' +import { Example05 } from './examples/05' +import { Example06 } from './examples/06' -export const App = () => ( - - - - - - - - -) +const examples = [ + { key: 1, Component: Example01 }, + { key: 2, Component: Example02 }, + { key: 3, Component: Example03 }, + { key: 4, Component: Example04 }, + { key: 5, Component: Example05 }, + { key: 6, Component: Example06 }, +] + +const fallbackUi = () =>

Example not found

+ +export const App = () => { + const classes = useStyles() + return ( + +
+
+ + + + + + +
+
+
+ ) +} + +const Menu = () => { + const classes = useStyles() + const { exampleId } = useParams() + + const id = Number(exampleId) + const first = Number(id) === 1 + const last = Number(id) >= examples.length + + return ( + + + {!first && ( + + )} + Example #{id} + {!last && ( + + )} + + + ) +} + +const RenderExample = () => { + const { exampleId } = useParams() + const example = examples.find(({ key }) => Number(key) === Number(exampleId)) + const Component = example?.Component ?? fallbackUi + return ( + <> + + + + ) +} + +const useStyles = makeStyles(() => ({ + container: { + width: '100v', + height: '100vh', + display: 'flex', + }, + examples: { + margin: 'auto', + maxWidth: '800px', + }, + appBar: { + top: 'auto', + bottom: 0, + }, + toolbar: { + justifyContent: 'center', + '& > *': { + marginLeft: 8, + marginRight: 8, + }, + }, +})) diff --git a/yarn.lock b/yarn.lock index 49641d1..3c834ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8379,6 +8379,10 @@ raf@^3.4.1: dependencies: performance-now "^2.1.0" +ramda@^0.27.1: + version "0.27.1" + resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.1.tgz#66fc2df3ef873874ffc2da6aa8984658abacf5c9" + randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"