From 6173d3b9663b545e45b058dce227fab72283639b Mon Sep 17 00:00:00 2001 From: Graeme Date: Thu, 5 Apr 2018 20:51:12 -0700 Subject: [PATCH] Better downloading now downloads file on button click --- src/core/components/highlight-code.jsx | 19 +++++++++---------- src/style/_layout.scss | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/core/components/highlight-code.jsx b/src/core/components/highlight-code.jsx index 5cfa9d61..ab971ea5 100644 --- a/src/core/components/highlight-code.jsx +++ b/src/core/components/highlight-code.jsx @@ -26,10 +26,11 @@ export default class HighlightCode extends Component { this.setState({ contentsHidden: !this.state.contentsHidden }) } - downloadJSON = (value) => { - let fileName = 'response' - let fileToSave = new Blob([value], {type: 'text/json', name: fileName}) - saveAs(fileToSave) + downloadJSON = () => { + let content = this.props.value + let fileName = "response" + let fileToSave = new Blob([content], {type: 'text/plain'}) + saveAs(fileToSave, fileName) } render () { @@ -39,6 +40,9 @@ export default class HighlightCode extends Component { return (
+
+ {"Download"} +
@@ -46,12 +50,7 @@ export default class HighlightCode extends Component {
         
{ value.length > 600 &&
- { contentsHidden ? 'See full contents' : 'Collapse contents'} -
- } - { value.length > 600 && -
- {'Download'} + { contentsHidden ? "See full contents" : "Collapse contents"}
}
diff --git a/src/style/_layout.scss b/src/style/_layout.scss index 6155c69e..25515990 100644 --- a/src/style/_layout.scss +++ b/src/style/_layout.scss @@ -654,6 +654,23 @@ height: 20px; } +.download-contents { + display: inline-flex; + justify-content: center; + align-items: center; + cursor: pointer; + background: #7d8293; + padding: 5px 5px 5px; + border: 10px solid #41444e; + border-top-right-radius: 6px; + border-top-left-radius: 6px; + font-family: 'Titillium Web', sans-serif; + font-weight: 600; + color: white; + font-size: 14px; + bottom: 0px; +} + .scheme-container { margin: 0 0 20px 0;