Skip to content

Commit 4ba87cb

Browse files
author
shenli.cs
committed
add .npmignore
1 parent 917dac2 commit 4ba87cb

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

example/bundle.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ var App = React.createClass({
118118
value: this.state.text,
119119
placeholder: 'input string' }),
120120
React.createElement(QRCode, { className: 'qrcode', value: this.state.text,
121-
size: 300, fgColor: 'purple',
121+
size: 300,
122+
fgColor: 'purple',
122123
bgColor: 'white',
123-
logo: './seven.jpg' })
124+
logo: 'http://hdwallpapersfit.com/wp-content/uploads/2015/03/sexy-nami-wallpaper.jpg' })
124125
);
125126
}
126127
});
@@ -232,9 +233,13 @@ var QRCode = React.createClass({
232233
var image = document.createElement('img');
233234
image.src = this.props.logo;
234235
image.onload = function () {
235-
var dx = size / 2 - size * 0.1;
236-
var dwidth = size * 0.2;
237-
ctx.drawImage(image, dx, dx, dwidth, dwidth);
236+
var dwidth = size * 0.25;
237+
var dx = (size - dwidth) / 2;
238+
var dheight = image.height / image.width * dwidth;
239+
var dy = (size - dheight) / 2;
240+
image.width = dwidth;
241+
image.height = dheight;
242+
ctx.drawImage(image, dx, dy, dwidth, dheight);
238243
};
239244
}
240245
},

example/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ var App = React.createClass({
2121
value={this.state.text}
2222
placeholder="input string"/>
2323
<QRCode className='qrcode' value={this.state.text}
24-
size={300} fgColor='purple'
24+
size={300}
25+
fgColor='purple'
2526
bgColor='white'
26-
logo='./seven.jpg'/>
27+
logo='http://hdwallpapersfit.com/wp-content/uploads/2015/03/sexy-nami-wallpaper.jpg'/>
2728
</div>
2829
);
2930
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "React component to generate QRCode with logo",
55
"main": "lib/index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "browserify -t [ babelify --presets [ react ] ] example/index.js -o example/bundle.js"
89
},
910
"repository": {
1011
"type": "git",

0 commit comments

Comments
 (0)