Skip to content

Commit 385acb0

Browse files
committed
some changes to addText and also an example
1 parent bfdd028 commit 385acb0

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

examples/main.jsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import 'flexboxgrid';
99
import './main.css';
1010
import AppBar from '@material-ui/core/AppBar';
1111
import Card from '@material-ui/core/Card';
12-
import CardActions from '@material-ui/core/CardActions';
1312
import CardContent from '@material-ui/core/CardContent';
14-
import GridList from '@material-ui/core/GridList';
1513
import ExpandMore from '@material-ui/icons/ExpandMore';
1614
import CardHeader from '@material-ui/core/CardHeader';
1715
import GridListTile from '@material-ui/core/GridListTile';
@@ -23,18 +21,18 @@ import TextField from '@material-ui/core/TextField';
2321
import Switch from '@material-ui/core/Switch';
2422
import FormControlLabel from '@material-ui/core/FormControlLabel';
2523
import Collapse from '@material-ui/core/Collapse';
26-
import {MuiThemeProvider, createMuiTheme} from '@material-ui/core/styles';
24+
import {createMuiTheme, MuiThemeProvider} from '@material-ui/core/styles';
2725
import color from '@material-ui/core/colors/blueGrey';
2826

2927
import UndoIcon from '@material-ui/icons/Undo';
3028
import RedoIcon from '@material-ui/icons/Redo';
3129
import DeleteIcon from '@material-ui/icons/Delete';
3230
import SaveIcon from '@material-ui/icons/Save';
3331
import ClearIcon from '@material-ui/icons/Clear';
32+
import AddIcon from '@material-ui/icons/Add';
3433
import DownloadIcon from '@material-ui/icons/CloudDownload';
3534
import ZoomInIcon from '@material-ui/icons/ZoomIn';
3635
import ZoomOutIcon from '@material-ui/icons/ZoomOut';
37-
import RemoveIcon from '@material-ui/icons/Remove';
3836
import dataJson from './data.json';
3937
import dataJsonControlled from './data.json.controlled';
4038
import {SketchField, Tools} from '../src';
@@ -145,6 +143,7 @@ class SketchFieldDemo extends React.Component {
145143
expandBack: false,
146144
expandImages: false,
147145
expandControlled: false,
146+
text: 'a text, cool!',
148147
};
149148
}
150149

@@ -263,6 +262,8 @@ class SketchFieldDemo extends React.Component {
263262
}
264263
};
265264

265+
_addText = () => this._sketch.addText(this.state.text);
266+
266267
componentDidMount = () => {
267268
(function(console) {
268269
console.save = function(data, filename) {
@@ -427,6 +428,23 @@ class SketchFieldDemo extends React.Component {
427428
<ZoomOutIcon/>
428429
</IconButton>
429430
<br/>
431+
<div className="row">
432+
<div className="col-lg-7">
433+
<TextField
434+
label='Text'
435+
helperText='Add text to Sketch'
436+
onChange={(e) => this.setState({ text: e.target.value })}
437+
value={this.state.text}/>
438+
</div>
439+
<div className="col-lg-3">
440+
<IconButton
441+
color="primary"
442+
onClick={this._addText}>
443+
<AddIcon/>
444+
</IconButton>
445+
</div>
446+
</div>
447+
430448
<br/>
431449
<FormControlLabel
432450
control={

src/SketchField.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,10 @@ class SketchField extends PureComponent {
527527
iText.set({
528528
'left': options.left,
529529
'top': options.top
530-
})
530+
});
531531

532532
canvas.add(iText);
533-
}
533+
};
534534

535535
componentDidMount = () => {
536536
let {

0 commit comments

Comments
 (0)