Last active
March 18, 2019 19:01
-
-
Save ajcrites/a660f9602e2151d543abf51a6965fd30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export const HexInput = ({ hex, setHex }) => { | |
const onChange = ({ target: { value } }) => { | |
setHex(value); | |
}; | |
return ( | |
<label> | |
Hex: | |
<input value={hex} onChange={onChange} /> | |
</label> | |
); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export const RgbaInput = ({ rgba, setRgba }) => { | |
const onChange = idx => ({ target: { value } }) => { | |
const newRgba = [...rgba]; | |
newRgba[idx] = value; | |
setRgba(newRgba); | |
}; | |
return ( | |
<label> | |
RGB(A): | |
<input value={rgba[0]} onChange={onChange(0)} /> | |
<input value={rgba[1]} onChange={onChange(1)} /> | |
<input value={rgba[2]} onChange={onChange(2)} /> | |
<input value={rgba[3]} onChange={onChange(3)} /> | |
</label> | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -9,8 +9,8 @@ export const ColorToolApp = () => { | |
return ( | |
<main> | |
- <HexInput /> | |
- <RgbaInput /> | |
+ <HexInput hex={hex} setHex={setHex} /> | |
+ <RgbaInput rgba={rgba} setRgba={setRgba} /> | |
</main> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment