A Pen by Roger Taylor

Thumbnail
This awesome code was written by ro6er, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright ro6er ©
  • HTML
  • CSS
  • JavaScript
    <div id="app"></app>

/*Downloaded from https://www.codeseek.co/ro6er/a-pen-by-roger-taylor-jxdQZe */
    html, body {
  height: 100%;
}

body {
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: Helvetica Neue;
}

h1 {
  font-size: 2em;
  color: #eeeeee;
  display: inline-block;
}

a {
  color: white;
}

p {
  margin-top: 1em;
  text-align: center;
  color: #aaaaaa;
}


/*Downloaded from https://www.codeseek.co/ro6er/a-pen-by-roger-taylor-jxdQZe */
    

var Table= React.createClass({
    render: function() {
        return <table>
            {this.props.data.map(function(row){
                return <tr>
                    {row.map(function(cell){
                        return <td> {cell} </td>
                    })}
                </tr>
            })}
        </table>;
    }
});
var DubbledTable= React.createClass({
    render: function() {
        var firstColumn= 
            this.props.data.map(function(row){
                return [row[0]]
            })
        return <span>
            <Table data={firstColumn} />
            <Table data={this.props.data} />
        </span>
    }
})

data= [
    ['a', 'b', 'c', 'd'],
    ['1', '2', '3', '4'],
    ['i', 'ii', 'iii', 'iv']
]
ReactDOM.render(<DubbledTable data={data} />, document.body);


Comments