Skip to content

Commit 0601b95

Browse files
committed
Update to use base64-image-utils
1 parent a5bd1e4 commit 0601b95

File tree

6 files changed

+20
-52
lines changed

6 files changed

+20
-52
lines changed

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ <h1>img2css.</h1>
2323
<div id='root'></div>
2424

2525
<div class="padding-2x">
26+
Want a programatic way to do this? Look at <a target="_blank" href="https://github.com/javierbyte/base64-image-utils">base64-image-utils.</a>
27+
<br>
2628
Created by <a href='http://github.com/javierbyte/'>javierbyte</a>.
2729
<br /><br />
2830
<a href="https://twitter.com/javierbyte" class="twitter-follow-button" data-show-count="true">Follow @javierbyte</a>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"webpack-hot-middleware": "^2.0.0"
3939
},
4040
"dependencies": {
41+
"base64-image-utils": "^0.1.0",
4142
"lodash": "^3.10.1",
4243
"react": "^0.13.0",
4344
"react-dropzone": "^2.2.1",

src/App.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React from 'react'
2-
import tinycolor from 'tinycolor2'
1+
var React = require('react');
2+
var tinycolor = require('tinycolor2');
33

44
var _ = require('lodash')
55
var Dropzone = require('react-dropzone')
66

7-
var base64ImageToRGBArray = require('./lib/base64ImageToRGBArray')
7+
var {base64ImageToRGBMatrix} = require('base64-image-utils')
88

99
function compressColor (rgb) {
1010
var hex = tinycolor(rgb).toHexString()
@@ -58,11 +58,11 @@ export const App = React.createClass({
5858
}
5959
}
6060

61-
base64ImageToRGBArray(base64, (err, data) => {
61+
base64ImageToRGBMatrix(base64, (err, data) => {
6262
if (err) return console.error(err)
6363

6464
this.setState({
65-
rgbArray: data,
65+
rgbMatrix: data,
6666
loadingImage: false
6767
})
6868
})
@@ -71,9 +71,9 @@ export const App = React.createClass({
7171
},
7272

7373
render () {
74-
var {rgbArray, loadingImage} = this.state
74+
var {rgbMatrix, loadingImage} = this.state
7575

76-
var masterShadow = _.map(rgbArray, (row, rowIndex) => {
76+
var masterShadow = _.map(rgbMatrix, (row, rowIndex) => {
7777
return _.map(row, (col, colIndex) => {
7878
var color = compressColor(`rgb(${col.r},${col.g},${col.b})`)
7979

@@ -88,7 +88,7 @@ export const App = React.createClass({
8888
{loadingImage ? 'Processing...' : 'Drop an image here, or click to upload.'}
8989
</Dropzone>
9090

91-
{rgbArray && (
91+
{rgbMatrix && (
9292
<div>
9393
<div className='tutorial'>
9494
This is your pure css (and single div) image! Enjoy! {masterShadow.length.toLocaleString()}b
@@ -98,7 +98,7 @@ export const App = React.createClass({
9898
height: 1,
9999
width: 1,
100100
boxShadow: masterShadow,
101-
marginBottom: rgbArray.length
101+
marginBottom: rgbMatrix.length
102102
}} />
103103

104104
<div className='tutorial'>

src/lib/base64ImageToRGBArray.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

static/bundle.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)