This Gist was automatically created by Carbide, a free online programming environment.
Last active
August 25, 2016 18:59
-
-
Save alehlopeh/55463196384e267d79d71bb462987442 to your computer and use it in GitHub Desktop.
untitled
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
import React from 'react' | |
const height = 200; | |
const width = 200; | |
class TTTWidget extends React.Component{ | |
static title = 't' | |
static match(value, ast){ | |
return value === 't' | |
} | |
constructor(props){ | |
super() | |
this.state ={ | |
cells: [0,1,2,3,4,5,6,7,8,9].reduce((acc,el)=>{ | |
acc[el] = null; | |
return acc | |
},{}) | |
} | |
} | |
render(){ | |
alert('x') | |
return ( | |
<div> | |
<div style={{height,width,flexWrap:'wrap',flexDirection:'row'}}> | |
{Object.keys(this.state.cells).map((c,cell) => { | |
return ( | |
<div data-cell={cell} | |
style={{ | |
height:height/3, | |
flex:1, | |
width:width/3, | |
display:'inline-flex', | |
border: '0px solid #000000', | |
borderLeftWidth: cell % 3 === 0 ? 0 : 1, | |
borderTopWidth: cell < 3 ? 0 : 1, | |
borderRightWidth: cell % 3 === 2 ? 0 : 1, | |
borderBottomWidth: cell > 5 ? 0 : 1, | |
}}> | |
{this.state.cells[cell]} | |
</div> | |
) | |
})} | |
</div> | |
</div> | |
) | |
} | |
} | |
doc.kernel.widgets.push(TTTWidget) |
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
<TTTWidget/> |
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
var hi; | |
hi = 't' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment