diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index 943ab940..60755b6c 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -38,6 +38,7 @@ import { import { decodeImage } from '../../codecs/decoders'; import { cleanMerge, cleanSet } from '../../lib/clean-modify'; +import Intro from '../intro'; type Orientation = 'horizontal' | 'vertical'; @@ -209,14 +210,6 @@ export default class App extends Component { } } - @bind - async onFileChange(event: Event): Promise { - const fileInput = event.target as HTMLInputElement; - const file = fileInput.files && fileInput.files[0]; - if (!file) return; - await this.updateFile(file); - } - @bind async onFileDrop(event: FileDropEvent) { const { file } = event; @@ -342,38 +335,38 @@ export default class App extends Component { return (
- {(leftImageData && rightImageData && source) ? ( - - ) : ( -
-

Drop, paste or select an image

- -
- )} - {(leftImageData && rightImageData && source) && images.map((image, index) => ( - - ))} + {source + ? +
+ + {images.map((image, index) => ( + + ))} +
+ : + + } {anyLoading && Loading...}
diff --git a/src/components/App/style.scss b/src/components/App/style.scss index 4ee707af..e9e8db3d 100644 --- a/src/components/App/style.scss +++ b/src/components/App/style.scss @@ -11,39 +11,6 @@ Note: These styles are temporary. They will be replaced before going live. overflow: hidden; contain: strict; display: flex; - justify-content: flex-end; - - &.horizontal { - justify-content: space-between; - align-items: flex-end; - } - - &.vertical { - flex-direction: column; - } -} - -.welcome { - margin: auto; - text-align: center; - - h1 { - font-weight: inherit; - font-size: 150%; - text-align: center; - } - - input { - display: inline-block; - width: 16em; - padding: 10px; - margin: 0 auto; - -webkit-appearance: none; - border: 1px solid var(--button-fg); - background: rgba(var(--button-fg-color), 0.1); - border-radius: 3px; - cursor: pointer; - } } :global { @@ -87,3 +54,18 @@ Note: These styles are temporary. They will be replaced before going live. } } } + +.option-pair { + display: flex; + justify-content: flex-end; + width: 100%; + + &.horizontal { + justify-content: space-between; + align-items: flex-end; + } + + &.vertical { + flex-direction: column; + } +} diff --git a/src/components/intro/index.tsx b/src/components/intro/index.tsx new file mode 100644 index 00000000..5d46ff75 --- /dev/null +++ b/src/components/intro/index.tsx @@ -0,0 +1,27 @@ +import { h, Component } from 'preact'; +import * as style from './style.scss'; +import { bind } from '../../lib/util'; + +interface Props { + onFile: (file: File) => void; +} +interface State {} + +export default class Intro extends Component { + @bind + onFileChange(event: Event): void { + const fileInput = event.target as HTMLInputElement; + const file = fileInput.files && fileInput.files[0]; + if (!file) return; + this.props.onFile(file); + } + + render({ }: Props, { }: State) { + return ( +
+

Drop, paste or select an image

+ +
+ ); + } +} diff --git a/src/components/intro/style.scss b/src/components/intro/style.scss new file mode 100644 index 00000000..3fa37a8c --- /dev/null +++ b/src/components/intro/style.scss @@ -0,0 +1,22 @@ +.welcome { + margin: auto; + text-align: center; + + h1 { + font-weight: inherit; + font-size: 150%; + text-align: center; + } + + input { + display: inline-block; + width: 16em; + padding: 10px; + margin: 0 auto; + -webkit-appearance: none; + border: 1px solid var(--button-fg); + background: rgba(var(--button-fg-color), 0.1); + border-radius: 3px; + cursor: pointer; + } +}