-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(main page) - Add color picker
Use the tachyons framework to create a color picker and allow changing colors on the grid
- Loading branch information
1 parent
7b6b451
commit 3a56539
Showing
8 changed files
with
125 additions
and
63 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = [ | ||
'red', | ||
'orange', | ||
'gold', | ||
'yellow', | ||
'purple', | ||
'pink', | ||
'green', | ||
'navy', | ||
'blue' | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict' | ||
|
||
module.exports = [ | ||
'box empty', | ||
'box full', | ||
'box top-left', | ||
'box top-right', | ||
'box bottom-right', | ||
'box bottom-left', | ||
'flat-border top-left', | ||
'flat-border top-right', | ||
'flat-border bottom-right', | ||
'flat-border bottom-left' | ||
] |
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict' | ||
|
||
const html = require('choo/html') | ||
const styles = require('../catalogs/styles') | ||
const colors = require('../catalogs/colors') | ||
|
||
|
||
module.exports = (state, prev, send) => { | ||
return html` | ||
<div> | ||
<div class="header"> | ||
<h2>Go ahead, click it!</h2> | ||
</div> | ||
<table class="grid"> | ||
${state.grid.map((row, m) => html` | ||
<tr> | ||
${row.map((value, n) => { | ||
const { element, styleID, colorID } = state.grid[m][n] | ||
const color = colors[colorID] | ||
return html` | ||
<td> | ||
<div class="bg-${color} b--${color} ${styles[styleID]}" onclick=${changeStyle(m, n)}> | ||
${element} | ||
</div> | ||
</td> | ||
` | ||
})} | ||
</tr> | ||
`)} | ||
</table> | ||
<table class="color-picker"> | ||
<tr> | ||
${colors.map((color, colorID) => { | ||
const border = colorID === state.colorPicker.selectionID ? 'ba bw1 b--gray' : '' | ||
return html` | ||
<td> | ||
<div class="fl w-10 color-box bg-${color} ${border}" onclick=${changeColor(colorID)}></div> | ||
</td> | ||
` | ||
})} | ||
</tr> | ||
</table> | ||
<div class="footer"> | ||
<iframe src="https://ghbtns.com/github-btn.html?user=delaguilaluis&repo=patchwork&type=star&count=true" frameborder="0" scrolling="0" width="80px" height="20px"></iframe> | ||
</div> | ||
</div> | ||
` | ||
|
||
function changeStyle (m, n) { | ||
return () => send('changeStyle', { m, n }) | ||
} | ||
|
||
function changeColor (colorID) { | ||
return () => send('changeColor', { selectionID: colorID }) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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