Skip to content

Commit 0053cfa

Browse files
committed
Playground: add version
1 parent 34626f6 commit 0053cfa

File tree

3 files changed

+53
-48
lines changed

3 files changed

+53
-48
lines changed

docs/bundle.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playground/index.tsx

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Options, lenses, defaultOptions } from '../src/ast'
55
import Editor from 'react-simple-code-editor'
66
import { highlight, languages } from 'prismjs'
77
import 'prismjs/components/prism-typescript'
8+
import * as pkg from '../package.json'
89

910
const defaultSource = 'data Option A = None | Some A'
1011

@@ -13,9 +14,7 @@ interface Props {
1314
encoding: Options['encoding']
1415
}
1516

16-
interface State {
17-
source: string
18-
encoding: Options['encoding']
17+
interface State extends Props {
1918
code: string
2019
}
2120

@@ -51,48 +50,53 @@ class App extends React.Component<Props, State> {
5150
this.setState(getState(e.currentTarget.value, this.state.encoding))
5251
}
5352
return (
54-
<table>
55-
<thead>
56-
<tr>
57-
<th>Source</th>
58-
<th>Output</th>
59-
</tr>
60-
</thead>
61-
<tbody>
62-
<tr>
63-
<td className="source">
64-
<textarea rows={10} value={this.state.source} onChange={onCodeChange} />
65-
<input type="checkbox" onChange={onEncodingChange} /> fp-ts encoding
66-
<br />
67-
<br />
68-
Examples:
69-
<select onChange={onExampleChange}>
70-
<option value="data Option A = None | Some A">Option</option>
71-
<option value="data Either A B = Left A | Right B">Either</option>
72-
<option value="data These A B = Left A | Right B | Both A B">These</option>
73-
<option value="data Tree A = Leaf | Node (Tree A) A (Tree A)">Tree</option>
74-
<option value="data These A B = Left { left :: A } | Right { right :: B } | Both { left :: A, right :: B }">
75-
These (record syntax)
76-
</option>
77-
</select>
78-
</td>
79-
<td className="code">
80-
<Editor
81-
value={this.state.code}
82-
onValueChange={code => onValueChange(code)}
83-
highlight={code => {
84-
return highlight(code, languages.js)
85-
}}
86-
padding={10}
87-
style={{
88-
fontFamily: '"Fira code", monospace',
89-
fontSize: 12
90-
}}
91-
/>
92-
</td>
93-
</tr>
94-
</tbody>
95-
</table>
53+
<div>
54+
<h1>
55+
{pkg.name} playground (v{pkg.version})
56+
</h1>
57+
<table>
58+
<thead>
59+
<tr>
60+
<th>Source</th>
61+
<th>Output</th>
62+
</tr>
63+
</thead>
64+
<tbody>
65+
<tr>
66+
<td className="source">
67+
<textarea rows={10} value={this.state.source} onChange={onCodeChange} />
68+
<input type="checkbox" onChange={onEncodingChange} /> fp-ts encoding
69+
<br />
70+
<br />
71+
Examples:
72+
<select onChange={onExampleChange}>
73+
<option value="data Option A = None | Some A">Option</option>
74+
<option value="data Either A B = Left A | Right B">Either</option>
75+
<option value="data These A B = Left A | Right B | Both A B">These</option>
76+
<option value="data Tree A = Leaf | Node (Tree A) A (Tree A)">Tree</option>
77+
<option value="data These A B = Left { left :: A } | Right { right :: B } | Both { left :: A, right :: B }">
78+
These (record syntax)
79+
</option>
80+
</select>
81+
</td>
82+
<td className="code">
83+
<Editor
84+
value={this.state.code}
85+
onValueChange={code => onValueChange(code)}
86+
highlight={code => {
87+
return highlight(code, languages.js)
88+
}}
89+
padding={10}
90+
style={{
91+
fontFamily: '"Fira code", monospace',
92+
fontSize: 12
93+
}}
94+
/>
95+
</td>
96+
</tr>
97+
</tbody>
98+
</table>
99+
</div>
96100
)
97101
}
98102
}

playground/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"moduleResolution": "node",
1111
"forceConsistentCasingInFileNames": true,
1212
"lib": ["es6", "dom"],
13-
"jsx": "react"
13+
"jsx": "react",
14+
"resolveJsonModule": true
1415
}
1516
}

0 commit comments

Comments
 (0)