diff --git a/.all-contributorsrc b/.all-contributorsrc index 41cf41d..13f196e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -100,6 +100,15 @@ "contributions": [ "code" ] + }, + { + "login": "bcherny", + "name": "Boris Cherny", + "avatar_url": "https://avatars2.githubusercontent.com/u/1761758?v=4", + "profile": "https://performancejs.com", + "contributions": [ + "code" + ] } ] } diff --git a/components/ConversionPanel.js b/components/ConversionPanel.js index 1323252..3f726c4 100644 --- a/components/ConversionPanel.js +++ b/components/ConversionPanel.js @@ -77,7 +77,7 @@ export default class ConversionPanel extends PureComponent { prettifyRightPanel: true, splitLeft: false, showFetchButton: true, - fetchButtonText: 'Fetch JSON from URL' + fetchButtonText: "Fetch JSON from URL" }; state = { @@ -91,16 +91,23 @@ export default class ConversionPanel extends PureComponent { componentDidMount() { const { defaultText, splitValue } = this.props; - this.onChange(defaultText, splitValue) + this.onChange(defaultText, splitValue); } fetchJSON = async () => { - const url = window.prompt('Enter URL to fetch JSON from a remote server.') - if (!url) return - const res = await unfetch(url) - const json = await res.json() - this.onChange(JSON.stringify(json, null, 2)) - } + const url = window.prompt("Enter URL to fetch JSON from a remote server."); + if (!url) return; + try { + const res = await unfetch(url); + const json = await res.json(); + this.onChange(JSON.stringify(json, null, 2)); + } catch (e) { + this.setState({ + info: e.message, + infoType: "error" + }); + } + }; onChange = async (newValue, leftSplitValue) => { const nValue = newValue || this.state.value; @@ -133,7 +140,7 @@ export default class ConversionPanel extends PureComponent { const checked = e.currentTarget.checked; if (this.props.onCheckboxChange) { this.props.onCheckboxChange(checked, () => { - this.onChange() + this.onChange(); }); } }; @@ -240,12 +247,14 @@ export default class ConversionPanel extends PureComponent { flex: 1; display: flex; flex-direction: row; + overflow: hidden; } .section { flex: 1; position: relative; - height: calc(100vh - 50px); + display: flex; + flex-direction: column; } .right { @@ -294,6 +303,13 @@ export default class ConversionPanel extends PureComponent { color: #666; font-weight: normal; } + + .panel { + flex: 1; + display: flex; + flex-direction: column; + overflow: hidden; + } `}