forked from GoogleChromeLabs/squoosh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving image open time (GoogleChromeLabs#185)
* Moving intro into its own component * Tidying JSX, and allowing image to render before first compression. Fixes GoogleChromeLabs#164.
- Loading branch information
1 parent
f02a0b0
commit 405f7ca
Showing
4 changed files
with
97 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Props, State> { | ||
@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 ( | ||
<div class={style.welcome}> | ||
<h1>Drop, paste or select an image</h1> | ||
<input type="file" onChange={this.onFileChange} /> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |