forked from external-repos/squoosh
Copy setting button
This commit is contained in:
@@ -17,7 +17,7 @@ import Toggle from './Toggle';
|
|||||||
import Select from './Select';
|
import Select from './Select';
|
||||||
import { Options as QuantOptionsComponent } from 'features/processors/quantize/client';
|
import { Options as QuantOptionsComponent } from 'features/processors/quantize/client';
|
||||||
import { Options as ResizeOptionsComponent } from 'features/processors/resize/client';
|
import { Options as ResizeOptionsComponent } from 'features/processors/resize/client';
|
||||||
import { CLIIcon } from 'client/lazy-app/icons';
|
import { CLIIcon, SwapIcon } from 'client/lazy-app/icons';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
index: 0 | 1;
|
index: 0 | 1;
|
||||||
@@ -28,6 +28,7 @@ interface Props {
|
|||||||
onEncoderTypeChange(index: 0 | 1, newType: OutputType): void;
|
onEncoderTypeChange(index: 0 | 1, newType: OutputType): void;
|
||||||
onEncoderOptionsChange(index: 0 | 1, newOptions: EncoderOptions): void;
|
onEncoderOptionsChange(index: 0 | 1, newOptions: EncoderOptions): void;
|
||||||
onProcessorOptionsChange(index: 0 | 1, newOptions: ProcessorState): void;
|
onProcessorOptionsChange(index: 0 | 1, newOptions: ProcessorState): void;
|
||||||
|
onCopyToOtherSideClick(index: 0 | 1): void;
|
||||||
onCopyCliClick(index: 0 | 1): void;
|
onCopyCliClick(index: 0 | 1): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +112,10 @@ export default class Options extends Component<Props, State> {
|
|||||||
this.props.onCopyCliClick(this.props.index);
|
this.props.onCopyCliClick(this.props.index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onCopyToOtherSideClick = () => {
|
||||||
|
this.props.onCopyToOtherSideClick(this.props.index);
|
||||||
|
};
|
||||||
|
|
||||||
render(
|
render(
|
||||||
{ source, encoderState, processorState }: Props,
|
{ source, encoderState, processorState }: Props,
|
||||||
{ supportedEncoderMap }: State,
|
{ supportedEncoderMap }: State,
|
||||||
@@ -140,6 +145,13 @@ export default class Options extends Component<Props, State> {
|
|||||||
>
|
>
|
||||||
<CLIIcon />
|
<CLIIcon />
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
class={style.copyOverButton}
|
||||||
|
title="Copy settings to other side"
|
||||||
|
onClick={this.onCopyToOtherSideClick}
|
||||||
|
>
|
||||||
|
<SwapIcon />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</h3>
|
</h3>
|
||||||
<label class={style.sectionEnabler}>
|
<label class={style.sectionEnabler}>
|
||||||
|
|||||||
@@ -87,6 +87,7 @@
|
|||||||
grid-auto-columns: max-content;
|
grid-auto-columns: max-content;
|
||||||
grid-auto-flow: column;
|
grid-auto-flow: column;
|
||||||
display: grid;
|
display: grid;
|
||||||
|
gap: 0.8rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title-button {
|
.title-button {
|
||||||
@@ -106,3 +107,11 @@
|
|||||||
stroke: var(--header-text-color);
|
stroke: var(--header-text-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.copy-over-button {
|
||||||
|
composes: title-button;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
fill: var(--header-text-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ export default class Compress extends Component<Props, State> {
|
|||||||
this.queueUpdateImage();
|
this.queueUpdateImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async onCopyToOtherClick(index: 0 | 1) {
|
private onCopyToOtherClick = async (index: 0 | 1) => {
|
||||||
const otherIndex = index ? 0 : 1;
|
const otherIndex = index ? 0 : 1;
|
||||||
const oldSettings = this.state.sides[otherIndex];
|
const oldSettings = this.state.sides[otherIndex];
|
||||||
const newSettings = { ...this.state.sides[index] };
|
const newSettings = { ...this.state.sides[index] };
|
||||||
@@ -405,7 +405,7 @@ export default class Compress extends Component<Props, State> {
|
|||||||
this.setState({
|
this.setState({
|
||||||
sides: cleanSet(this.state.sides, otherIndex, oldSettings),
|
sides: cleanSet(this.state.sides, otherIndex, oldSettings),
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
private onPreprocessorChange = async (
|
private onPreprocessorChange = async (
|
||||||
preprocessorState: PreprocessorState,
|
preprocessorState: PreprocessorState,
|
||||||
@@ -830,6 +830,7 @@ export default class Compress extends Component<Props, State> {
|
|||||||
onEncoderOptionsChange={this.onEncoderOptionsChange}
|
onEncoderOptionsChange={this.onEncoderOptionsChange}
|
||||||
onProcessorOptionsChange={this.onProcessorOptionsChange}
|
onProcessorOptionsChange={this.onProcessorOptionsChange}
|
||||||
onCopyCliClick={this.onCopyCliClick}
|
onCopyCliClick={this.onCopyCliClick}
|
||||||
|
onCopyToOtherSideClick={this.onCopyToOtherClick}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -83,3 +83,9 @@ export const CLIIcon = () => (
|
|||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const SwapIcon = () => (
|
||||||
|
<svg viewBox="0 0 18 14">
|
||||||
|
<path d="M5.5 3.6v6.8L2.1 7l3.4-3.4M7 0L0 7l7 7V0zm4 0v14l7-7-7-7z" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user