getting ready for real

This commit is contained in:
2018-12-28 22:15:00 -08:00
parent 7d530df658
commit 948a22b10b
6 changed files with 30 additions and 4 deletions

View File

@@ -11,6 +11,14 @@ export interface Props {
export class BigPicture extends React.PureComponent<Props, {}> {
static displayName = "BigPicture";
componentDidMount() {
window.addEventListener("keyup", this._onEscape as any);
}
componentWillUnmount() {
window.removeEventListener("keyup", this._onEscape as any);
}
render() {
const src = `img/1600/${this.props.image.src}`;
return (
@@ -47,4 +55,10 @@ export class BigPicture extends React.PureComponent<Props, {}> {
this.props.onClose();
}
};
private _onEscape = (e: React.KeyboardEvent) => {
if (e.key === "Escape") {
this.props.onClose();
}
};
}

View File

@@ -39,6 +39,10 @@ export class Picture extends React.PureComponent<Props, {}> {
}
});
if (srcs.length === 0) {
return `img/1600/${this.props.image.src} 1x`;
}
return srcs.join(",");
};
}