Skip to content

Commit 7d41260

Browse files
committed
Better instructions and compression
1 parent cde6f5d commit 7d41260

File tree

3 files changed

+48
-14
lines changed

3 files changed

+48
-14
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<title>img2css</title>
55
<link rel="stylesheet" href="style/main.css">
6+
<link href='https://fonts.googleapis.com/css?family=Roboto:300,300italic,100' rel='stylesheet' type='text/css'>
67
</head>
78
<body>
89
<div id='root'></div>

src/App.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,51 @@ export const App = React.createClass({
99

1010
getInitialState () {
1111
return {
12-
rgbArray: null
12+
rgbArray: null,
13+
loadingImage: false
1314
}
1415
},
1516

1617
onDrop (files) {
1718
var file = files[0]
1819
var fr = new window.FileReader()
20+
21+
this.setState({
22+
loadingImage: true
23+
})
24+
1925
fr.onload = (data) => {
2026
const base64 = data.currentTarget.result
2127

2228
base64ImageToRGBArray(base64, (err, data) => {
2329
if (err) return console.error(err)
2430

2531
this.setState({
26-
rgbArray: data
32+
rgbArray: data,
33+
loadingImage: false
2734
})
2835
})
2936
}
3037
fr.readAsDataURL(file)
3138
},
3239

3340
render () {
34-
var {rgbArray} = this.state
41+
var {rgbArray, loadingImage} = this.state
3542

3643
var masterShadow = _.map(rgbArray, (row, rowIndex) => {
3744
return _.map(row, (col, colIndex) => {
38-
return `rgb(${col.r}, ${col.g}, ${col.b}) ${colIndex}px ${rowIndex}px`
45+
return `rgb(${col.r},${col.g},${col.b}) ${colIndex ? colIndex + 'px' : 0} ${rowIndex ? rowIndex + 'px' : 0}`
3946
}).join(',')
4047
}).join(',')
4148

4249
return (
43-
<div>
50+
<div className='padding-2x'>
51+
<h1>img2css.</h1>
52+
<div>This is a tool that can convert any image into a <i>pure css</i> image.</div>
53+
<div>Try it! (It's cpu heavy, please try with a small image first).</div>
54+
4455
<Dropzone onDrop={this.onDrop} className='dropZone'>
45-
<div>Drop image here, or click to upload.</div>
56+
{loadingImage ? 'Processing...' : 'Drop an image here, or click to upload.'}
4657
</Dropzone>
4758

4859
{rgbArray && (
@@ -57,15 +68,19 @@ export const App = React.createClass({
5768
}} />
5869

5970
<div className='tutorial'>
60-
Now you can create a single pixel 'div' and with these styles you will get your image!
71+
The code:
6172
</div>
6273

6374
<div className='code'>
64-
{`box-shadow: ${masterShadow}`}
75+
{`<div style="height: 1px; width: 1px; box-shadow: ${masterShadow}"></div>`}
6576
</div>
6677
</div>
6778
)}
6879

80+
<div className='tutorial'>
81+
Created by <a href='http://github.com/javierbyte/'>javierbyte</a>.
82+
</div>
83+
6984
</div>
7085
)
7186
}

style/main.css

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,60 @@
1-
@import 'san-francisco.css';
2-
31
* {
42
padding: 0;
53
margin: 0;
64
position: relative;
75
}
86

97
body {
10-
font-family: 'San Francisco', serif;
8+
font-family: 'Roboto', sans-serif;
9+
font-size: 16px;
10+
line-height: 1.618;
1111
font-weight: 300;
12+
color: #404143;
13+
}
14+
15+
h1 {
16+
font-weight: 100;
17+
font-size: 3em;
18+
line-height: 1;
19+
padding-bottom: 0.309em;
20+
}
21+
22+
.padding-2x {
23+
padding: 2em;
1224
}
1325

1426
.pixel {
1527
height: 1px;
1628
width: 1px;
1729
background: #000;
18-
margin-left: 1em;
1930
}
2031

2132
.dropZone {
2233
height: 150px;
2334
width: 150px;
24-
margin: 1em;
35+
margin: 1em 0;
2536
display: flex;
2637
text-align: center;
2738
align-items: center;
2839
border: 2px dashed #ccc;
2940
padding: 2em;
3041
cursor: pointer;
3142
}
43+
.dropZone span {
44+
width: 100%;
45+
}
46+
.dropZone:hover {
47+
border-color: #999;
48+
}
3249

3350
.tutorial {
34-
padding: 1em;
51+
padding: 1em 0;
3552
}
3653

3754
.code {
3855
font-family: monaco, monospace;
3956
font-size: 0.6em;
57+
line-height: 1.309;
4058
padding: 2em;
4159
background: #f0f0f0;
4260
}

0 commit comments

Comments
 (0)