forked from external-repos/squoosh
Remove lambda from JSX
This commit is contained in:
@@ -48,6 +48,7 @@ export default class QuantizerOptions extends Component<Props, {}> {
|
|||||||
type="range"
|
type="range"
|
||||||
min="0"
|
min="0"
|
||||||
max="1"
|
max="1"
|
||||||
|
step="0.01"
|
||||||
value={'' + options.dither}
|
value={'' + options.dither}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import BrowserJPEGEncoderOptions from '../../codecs/browser-jpeg/options';
|
|||||||
import WebPEncoderOptions from '../../codecs/webp/options';
|
import WebPEncoderOptions from '../../codecs/webp/options';
|
||||||
import BrowserWebPEncoderOptions from '../../codecs/browser-webp/options';
|
import BrowserWebPEncoderOptions from '../../codecs/browser-webp/options';
|
||||||
|
|
||||||
import QuantizerOptions from '../../codecs/imagequant/options';
|
import QuantizerOptionsComponent from '../../codecs/imagequant/options';
|
||||||
|
|
||||||
import * as identity from '../../codecs/identity/encoder';
|
import * as identity from '../../codecs/identity/encoder';
|
||||||
import * as mozJPEG from '../../codecs/mozjpeg/encoder';
|
import * as mozJPEG from '../../codecs/mozjpeg/encoder';
|
||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
EncoderSupportMap,
|
EncoderSupportMap,
|
||||||
PreprocessorState,
|
PreprocessorState,
|
||||||
} from '../../codecs/encoders';
|
} from '../../codecs/encoders';
|
||||||
|
import { QuantizeOptions } from '../../codecs/imagequant/quantizer';
|
||||||
|
|
||||||
const encoderOptionsComponentMap = {
|
const encoderOptionsComponentMap = {
|
||||||
[identity.type]: undefined,
|
[identity.type]: undefined,
|
||||||
@@ -85,6 +86,17 @@ export default class Options extends Component<Props, State> {
|
|||||||
this.props.onPreprocessorOptionsChange(preprocessorState);
|
this.props.onPreprocessorOptionsChange(preprocessorState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@bind
|
||||||
|
onQuantizerOptionsChange(opts: QuantizeOptions) {
|
||||||
|
this.props.onPreprocessorOptionsChange({
|
||||||
|
...this.props.preprocessorState,
|
||||||
|
quantizer: {
|
||||||
|
...opts,
|
||||||
|
enabled: this.props.preprocessorState.quantizer.enabled,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render(
|
render(
|
||||||
{ class: className, encoderState, preprocessorState, onEncoderOptionsChange }: Props,
|
{ class: className, encoderState, preprocessorState, onEncoderOptionsChange }: Props,
|
||||||
{ encoderSupportMap }: State,
|
{ encoderSupportMap }: State,
|
||||||
@@ -105,16 +117,9 @@ export default class Options extends Component<Props, State> {
|
|||||||
Enable
|
Enable
|
||||||
</label>
|
</label>
|
||||||
{preprocessorState.quantizer.enabled ? (
|
{preprocessorState.quantizer.enabled ? (
|
||||||
<QuantizerOptions
|
<QuantizerOptionsComponent
|
||||||
options={preprocessorState.quantizer}
|
options={preprocessorState.quantizer}
|
||||||
// tslint:disable-next-line:jsx-no-lambda
|
onChange={this.onQuantizerOptionsChange}
|
||||||
onChange={quantizeOpts => this.props.onPreprocessorOptionsChange({
|
|
||||||
...preprocessorState,
|
|
||||||
quantizer: {
|
|
||||||
...quantizeOpts,
|
|
||||||
enabled: preprocessorState.quantizer.enabled,
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div/>
|
<div/>
|
||||||
|
|||||||
Reference in New Issue
Block a user