From 49b1398d9f0729a2b4386136043c2fbc9a706f34 Mon Sep 17 00:00:00 2001 From: Ritesh Kumar Date: Thu, 31 Aug 2017 21:45:52 +0530 Subject: [PATCH 1/3] remove code from url --- components/ConversionPanel.js | 32 ++++++++++---------------------- components/Layout.js | 2 +- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/components/ConversionPanel.js b/components/ConversionPanel.js index c67122a..757d848 100644 --- a/components/ConversionPanel.js +++ b/components/ConversionPanel.js @@ -72,16 +72,19 @@ export default class ConversionPanel extends PureComponent { }; componentDidMount() { - const code = this.props.url.query.code || this.props.defaultText; - const splitValue = this.props.url.query.splitValue || this.props.splitValue; + const {defaultText, splitValue} = this.props + + const code = defaultText; + const sValue = splitValue; this.setState({ value: code, - splitValue, - resultValue: this.props.getTransformedValue(code, splitValue) + splitValue: sValue, + resultValue: this.props.getTransformedValue(code, sValue) }); } - onChange = (newValue: string, leftSplitValue: string) => { + onChange = (newValue, leftSplitValue) => { + debugger const nValue = newValue || this.state.value; const splitValue = leftSplitValue && typeof leftSplitValue === "string" @@ -96,8 +99,6 @@ export default class ConversionPanel extends PureComponent { info: "", infoType: "" }); - - this.setCodeInUrl(newValue, leftSplitValue); } catch (e) { this.setState({ info: e.message, @@ -111,17 +112,7 @@ export default class ConversionPanel extends PureComponent { }); }; - setCodeInUrl = (code, leftSplitValue) => { - Router.replace({ - pathname: this.props.url.pathname, - query: { - code, - splitValue: leftSplitValue - } - }); - }; - - toggleCheckbox = (e: MouseEvent) => { + toggleCheckbox = (e) => { const checked = e.currentTarget.checked; if (this.props.onCheckboxChange) { this.props.onCheckboxChange(checked, () => { @@ -132,13 +123,10 @@ export default class ConversionPanel extends PureComponent { } }; - setResult = (result: string) => { + setResult = (result) => { this.setState( { value: result - }, - () => { - this.setCodeInUrl(result); } ); }; diff --git a/components/Layout.js b/components/Layout.js index 4a6659f..9c08fc1 100644 --- a/components/Layout.js +++ b/components/Layout.js @@ -430,7 +430,7 @@ export default class Layout extends PureComponent { } > {route.content.map(a => ( - + {a.label} ))} From c52a4e52fa1de395cea1bfaa9cc15f52f2a5e985 Mon Sep 17 00:00:00 2001 From: Ritesh Kumar Date: Thu, 31 Aug 2017 21:59:03 +0530 Subject: [PATCH 2/3] fix height for graphql --- components/ConversionPanel.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/ConversionPanel.js b/components/ConversionPanel.js index 757d848..92f47aa 100644 --- a/components/ConversionPanel.js +++ b/components/ConversionPanel.js @@ -217,7 +217,7 @@ export default class ConversionPanel extends PureComponent { .section { flex: 1; position: relative; - height: calc(100vh - 100px); + height: calc(100vh - 50px); } .right { @@ -282,7 +282,7 @@ export default class ConversionPanel extends PureComponent { } .split #code { - height: 50% !important; + height: calc(50% - 52px) !important; } .right #code { @@ -318,6 +318,7 @@ export default class ConversionPanel extends PureComponent {
+
{leftTitle}
{splitLeft && isBrowser && (
From ea62608e96a1e2fe6db2ec5ea363d46097ba2738 Mon Sep 17 00:00:00 2001 From: Ritesh Kumar Date: Thu, 31 Aug 2017 22:05:56 +0530 Subject: [PATCH 3/3] fixes #17 --- components/Layout.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/Layout.js b/components/Layout.js index 9c08fc1..3f4402c 100644 --- a/components/Layout.js +++ b/components/Layout.js @@ -215,6 +215,10 @@ export default class Layout extends PureComponent { return path === this.props.pathname ? "active" : ""; } + componentWillMount() { + this.setKey(this.props.pathname) + } + componentDidMount() { this.setKey(this.props.pathname); } @@ -412,6 +416,7 @@ export default class Layout extends PureComponent { onChange={this.onChange} accordion activeKey={this.state.activeKey} + defaultActiveKey={this.state.activeKey} > {x.map((route, i) => { return (