-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from puripant/master
Create a waffle chart component and add one to the homepage
- Loading branch information
Showing
5 changed files
with
222 additions
and
197 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from "react" | ||
|
||
import "../styles/global.css" | ||
import "./waffle.css" | ||
|
||
const split_array = (array, size, callback) => | ||
Array(Math.ceil(array.length / size)) | ||
.fill() | ||
.map((_, index) => index * size) | ||
.map(start => array.slice(start, start + size)) | ||
.map(callback) | ||
const full_name = node => `${node.title}${node.name} ${node.lastname}` | ||
const waffle = (data, cls) => | ||
split_array(data, 100, (hundred, hi) => ( | ||
<div key={hi} className="hundred"> | ||
{split_array(hundred, 25, (quarter, qi) => ( | ||
<div key={qi} className="quarter"> | ||
{quarter.map(({ node }) => ( | ||
<div key={node.id} title={full_name(node)} className={cls}> | ||
{/* <Link to={node.fields.slug}>{full_name(node)}</Link> */} | ||
</div> | ||
))} | ||
</div> | ||
))} | ||
</div> | ||
)) | ||
|
||
const Waffle = ({ data }) => ( | ||
<div className="waffle"> | ||
{waffle(data[0], "person of-interest")} | ||
<div className="line"></div> | ||
{waffle(data[1], "person other")} | ||
</div> | ||
) | ||
|
||
export default Waffle |
Oops, something went wrong.