Skip to content

Commit

Permalink
fix: improve example playground
Browse files Browse the repository at this point in the history
  • Loading branch information
zoubingwu committed Jul 22, 2022
1 parent d21a398 commit 45916d1
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules/
dist/
example/src/mock/
example/src/mock.js

.idea/
.vscode/
Expand Down
42 changes: 0 additions & 42 deletions example/src/App.css

This file was deleted.

28 changes: 20 additions & 8 deletions example/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import { useState } from 'react';

function App() {
const [state, setState] = useState(null);
const [endpoint, setEndpoint] = useState('/admin/tokens');
const [res, setRes] = useState(null);

return (
<div className="App">
<button onClick={async () => {
const res = await (await fetch('/')).json()
setState(res)
}}>fetch</button>
<h2>GitHub API mock playground</h2>
<label>Endpoint: </label>
<input
type="text"
value={endpoint}
onChange={e => setEndpoint(e.target.value)}
/>
<button
onClick={async () => {
const res = await (await fetch(endpoint)).json();
setRes(res);
}}
>
fetch
</button>

<pre>
<code>{state ? JSON.stringify(state, null, 4) : null}</code>
</pre>
<pre>
<code>{res ? JSON.stringify(res, null, 4) : null}</code>
</pre>
</div>
);
}
Expand Down
15 changes: 0 additions & 15 deletions example/src/favicon.svg

This file was deleted.

1 change: 1 addition & 0 deletions example/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ body {
}

code {
font-size: 11px;
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
7 changes: 0 additions & 7 deletions example/src/logo.svg

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"scripts": {
"build": "tsup",
"fmt": "prettier {example,src}/**/*.{js,jsx,ts,tsx,css,md,html} --write",
"test": "vitest run"
"test": "vitest run",
"gen:example": "node ./dist/cli.js https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/ghes-3.3/ghes-3.3.json --output ./example/src/mock.js"
},
"author": "zoubingwu<[email protected]>",
"license": "MIT",
Expand Down

0 comments on commit 45916d1

Please sign in to comment.