From 9b572f9541f9449050b4c309679b15bf6de50b2e Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Fri, 9 Nov 2018 09:13:32 -0800 Subject: [PATCH] Ta-da. Back button. (#254) --- src/components/App/index.tsx | 7 ++++++- .../Output/custom-els/TwoUp/index.ts | 11 ++++++----- src/components/Output/index.tsx | 11 +++++++++-- src/components/Output/style.scss | 19 ++++++++++++++++--- src/components/compress/index.tsx | 4 +++- src/components/compress/style.scss | 2 +- src/lib/icons.tsx | 6 ++++++ 7 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index 794ecb0c..e28b498e 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -82,6 +82,11 @@ export default class App extends Component { return this.snackbar.showSnackbar(message, options); } + @bind + private onBack() { + this.setState({ file: undefined }); + } + render({}: Props, { file, Compress }: State) { return (
@@ -89,7 +94,7 @@ export default class App extends Component { {(!file) ? : (Compress) - ? + ? : } diff --git a/src/components/Output/custom-els/TwoUp/index.ts b/src/components/Output/custom-els/TwoUp/index.ts index 0d771eaa..3c8c566e 100644 --- a/src/components/Output/custom-els/TwoUp/index.ts +++ b/src/components/Output/custom-els/TwoUp/index.ts @@ -70,12 +70,13 @@ export default class TwoUp extends HTMLElement { connectedCallback() { this._childrenChange(); + this._handle.innerHTML = `
${ + `${ + '' + }` + }
`; + if (!this._everConnected) { - this._handle.innerHTML = `
${ - `${ - '' - }` - }
`; this._resetPosition(); this._everConnected = true; } diff --git a/src/components/Output/index.tsx b/src/components/Output/index.tsx index a78d01e1..2c9496c9 100644 --- a/src/components/Output/index.tsx +++ b/src/components/Output/index.tsx @@ -5,7 +5,7 @@ import './custom-els/TwoUp'; import * as style from './style.scss'; import { bind, linkRef } from '../../lib/initial-util'; import { shallowEqual, drawDataToCanvas } from '../../lib/util'; -import { ToggleIcon, AddIcon, RemoveIcon } from '../../lib/icons'; +import { ToggleIcon, AddIcon, RemoveIcon, BackIcon } from '../../lib/icons'; import { twoUpHandle } from './custom-els/TwoUp/styles.css'; interface Props { @@ -15,6 +15,7 @@ interface Props { rightCompressed?: ImageData; leftImgContain: boolean; rightImgContain: boolean; + onBack: () => void; } interface State { @@ -191,7 +192,7 @@ export default class Output extends Component { } render( - { mobileView, leftImgContain, rightImgContain, originalImage }: Props, + { mobileView, leftImgContain, rightImgContain, originalImage, onBack }: Props, { scale, editingScale, altBackground }: State, ) { const leftDraw = this.leftDrawable(); @@ -243,6 +244,12 @@ export default class Output extends Component { +
+ +
+