Created
March 7, 2019 23:10
-
-
Save twof/ba112889c401dee2a065ce77db47bd92 to your computer and use it in GitHub Desktop.
This file contains 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
class Gradient extends React.Component { | |
render() { | |
// var topColor = this.props.topColor | |
// var bottomColor = this.props.bottomColor | |
console.log(typeof this.props.children) | |
var child = this.props.children | |
// console.log(child.props.children) | |
while(typeof child.props.children == 'object') { | |
console.log(typeof child) | |
child = child.props.children | |
} | |
// console.log(child) | |
var rows = child.split("\n") | |
console.log(rows) | |
var colored = rows.map((val, index) => { | |
var red = Math.trunc( 67 + (((215 - 67) / rows.length) * index) ) | |
var green = Math.trunc( 196 - (((196 - 73) / rows.length) * index) ) | |
var blue = Math.trunc( 252 - (((252 - 246) / rows.length) * index) ) | |
console.log(val) | |
console.log(red, green, blue) | |
return <Box key={index}><Color rgb={[red, green, blue]}>{val}</Color></Box> | |
}) | |
return colored | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment