-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathregionSelection.tsx
More file actions
46 lines (39 loc) · 1.42 KB
/
regionSelection.tsx
File metadata and controls
46 lines (39 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import * as Log from "../../logging/log";
import {ExtensionUtils} from "../../extensions/extensionUtils";
import {ComponentBase} from "../componentBase";
import { Localization } from "../../localization/localization";
export interface RegionSelectionProps {
imageSrc: string;
index: number;
onRemove?: (index: number) => void;
}
class RegionSelectionClass extends ComponentBase<{}, RegionSelectionProps> {
buttonHandler() {
if (this.props.onRemove) {
this.props.onRemove(this.props.index);
}
}
public getRemoveButton(): any[] {
// No remove button is rendered if there's no callback specified
return (
this.props.onRemove
? <a className="region-selection-remove-button" role="button" style="z-index: 100;"
{...this.enableInvoke({callback: this.buttonHandler, tabIndex: 300, idOverride: Log.Click.Label.regionSelectionRemoveButton})}>
<img src={ExtensionUtils.getImageResourceUrl("editorOptions/delete_button.svg")} alt={Localization.getLocalizedString("WebClipper.Preview.RemoveSelectedRegion")} /></a>
: undefined
);
}
public render() {
return (
<div>
<p className="region-selection">
{this.getRemoveButton()}
<img className="region-selection-image"
src={this.props.imageSrc} alt={Localization.getLocalizedString("WebClipper.Preview.SelectedRegion")}/>
</p>
</div>
);
}
}
let component = RegionSelectionClass.componentize();
export {component as RegionSelection};