mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-16 02:29:50 +00:00
* Refactoring codecs * Plugging in new processor * Fixing decorator * MozJPEG free issue * Better worker aborting, and terminate workers that aren't used for 10 seconds * Better comment * Ooops, half-typed comment * Uncommenting problematic line * Surma fixed it! * Abstracting WASM initialisation * Better comment * Don't need this. * Adding ticket * noInitalRun * Reverting MozJPEG issue demo * Making a const for worker timeout * Inline docs * Bail early rather than nesting * Addressing nits
41 lines
973 B
TypeScript
41 lines
973 B
TypeScript
import { h, Component } from 'preact';
|
|
import { bind } from '../../lib/initial-util';
|
|
import { inputFieldValueAsNumber } from '../../lib/util';
|
|
import { EncodeOptions } from './encoder-meta';
|
|
|
|
type Props = {
|
|
options: EncodeOptions;
|
|
onChange(newOptions: EncodeOptions): void;
|
|
};
|
|
|
|
export default class OptiPNGEncoderOptions extends Component<Props, {}> {
|
|
@bind
|
|
onChange(event: Event) {
|
|
const form = (event.currentTarget as HTMLInputElement).closest('form') as HTMLFormElement;
|
|
|
|
const options: EncodeOptions = {
|
|
level: inputFieldValueAsNumber(form.level),
|
|
};
|
|
this.props.onChange(options);
|
|
}
|
|
|
|
render({ options }: Props) {
|
|
return (
|
|
<form>
|
|
<label>
|
|
Effort:
|
|
<input
|
|
name="level"
|
|
type="range"
|
|
min="0"
|
|
max="7"
|
|
step="1"
|
|
value={'' + options.level}
|
|
onChange={this.onChange}
|
|
/>
|
|
</label>
|
|
</form>
|
|
);
|
|
}
|
|
}
|