forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
54 lines (45 loc) · 1.44 KB
/
index.tsx
File metadata and controls
54 lines (45 loc) · 1.44 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
47
48
49
50
51
52
53
54
import { Button } from '@codesandbox/common/lib/components/Button';
import Input from '@codesandbox/common/lib/components/Input';
import { Props } from 'app/components/CodeEditor/types'; // eslint-disable-line
import React from 'react';
import { Container, Image, MaxWidth, SubTitle, Title } from './elements';
export class ImageViewer extends React.Component<Props> {
onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (this.props.onSave) {
this.props.onSave(this.input.value);
}
};
input: HTMLInputElement;
doChangeCode = (e: React.ChangeEvent<HTMLInputElement>) => {
this.props.onChange(e.target.value);
};
render() {
const { currentModule } = this.props;
return (
<Container
style={{ width: this.props.width, height: this.props.height }}
horizontal
>
<Title>Image</Title>
<SubTitle>
We refer to these files by URL, you can edit this url to change the
image.
</SubTitle>
<Image src={currentModule.code} alt={currentModule.code} />
<MaxWidth onSubmit={this.onSubmit}>
<Input
ref={el => {
this.input = el;
}}
onChange={this.doChangeCode}
value={currentModule.code}
/>
<Button disabled={!currentModule.isNotSynced} type="submit">
Save
</Button>
</MaxWidth>
</Container>
);
}
}