mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-17 11:09:41 +00:00
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { h, Component } from 'preact';
|
|
import { bind } from '../../lib/initial-util';
|
|
import { inputFieldValueAsNumber, preventDefault } from '../../lib/util';
|
|
import { EncodeOptions } from './encoder-meta';
|
|
import * as style from '../../components/Options/style.scss';
|
|
// import Checkbox from '../../components/checkbox';
|
|
// import Expander from '../../components/expander';
|
|
// import Select from '../../components/select';
|
|
import Range from '../../components/range';
|
|
// import linkState from 'linkstate';
|
|
|
|
interface Props {
|
|
options: EncodeOptions;
|
|
onChange(newOptions: EncodeOptions): void;
|
|
}
|
|
|
|
interface State {}
|
|
|
|
export default class JXLEncoderOptions extends Component<Props, State> {
|
|
state: State = {};
|
|
|
|
@bind
|
|
onChange(event: Event) {
|
|
const form = (event.currentTarget as HTMLInputElement).closest(
|
|
'form',
|
|
) as HTMLFormElement;
|
|
const { options } = this.props;
|
|
|
|
const newOptions: EncodeOptions = {
|
|
// Copy over options the form doesn't care about, eg emulate_jpeg_size
|
|
...options,
|
|
speed: inputFieldValueAsNumber(form.speed, options.speed),
|
|
};
|
|
this.props.onChange(newOptions);
|
|
}
|
|
|
|
render({ options }: Props) {
|
|
return (
|
|
<form class={style.optionsSection} onSubmit={preventDefault}>
|
|
<div class={style.optionOneCell}>
|
|
<Range
|
|
name="speed"
|
|
min="1"
|
|
max="7"
|
|
value={options.speed}
|
|
onInput={this.onChange}
|
|
>
|
|
Speed:
|
|
</Range>
|
|
</div>
|
|
</form>
|
|
);
|
|
}
|
|
}
|