This repository has been archived by the owner on Feb 4, 2022. It is now read-only.
-
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.
Sandbox cards have some cool new methods for content
- Loading branch information
Showing
7 changed files
with
192 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const chunkArray = (array, size) => { | ||
if (!array) return []; | ||
const firstChunk = array.slice(0, size); | ||
if (!firstChunk.length) return array; // base case/terminates recursion | ||
return [firstChunk].concat(chunkArray(array.slice(size, array.length), size)); | ||
} | ||
|
||
exports.chunkArray = chunkArray; |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"name": "gatsby-starter-default", | ||
"private": true, | ||
"description": "A simple starter to get up and developing quickly with Gatsby", | ||
"version": "0.1.0", | ||
"author": "Kyle Mathews <[email protected]>", | ||
"name": "cristin-io", | ||
"private": false, | ||
"description": "Cristin O'Connor's Front End Development Blog and Portfolio Site", | ||
"version": "1.0.0", | ||
"author": "Cristin O'Connor <[email protected]>", | ||
"dependencies": { | ||
"@emotion/core": "^10.0.28", | ||
"@emotion/styled": "^10.0.27", | ||
|
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,80 @@ | ||
import React, { useState } from 'react' | ||
import EmbeddedGist from '../EmbeddedGist/EmbeddedGist' | ||
import ReactHtmlParser from 'react-html-parser' | ||
import * as Styled from './FlashCard.styles' | ||
import SEO from "../SEO/seo" | ||
|
||
const Snippet = ({item}) => { | ||
const { lines, lang } = item; | ||
const compiledLines = lines.map(line => line).join("\n"); | ||
|
||
return ( | ||
<pre className="prettyprint"><code className={`lang-${lang}`}> | ||
{ReactHtmlParser(compiledLines)} | ||
</code></pre> | ||
) | ||
} | ||
|
||
const FlashCard = ({...props}) => { | ||
const { question, name } = props; | ||
const [ visible, setVisible ] = useState(props.visible); | ||
|
||
const generateAnswerMedia = item => { | ||
switch (item.type) { | ||
case 'image': | ||
return <img | ||
src={item.url} | ||
alt={item.desc} | ||
style={{width: `${item.width}px`}} | ||
key={item.url} />; | ||
case 'gist': | ||
return <EmbeddedGist gist={item.gist} key={item.id}/>; | ||
case 'snippet': | ||
console.log(item); | ||
return <Snippet item={item} key={Math.random()} />; | ||
default: | ||
// do nothing | ||
} | ||
} | ||
|
||
const answerMedia = question.answer_media.map(item => { | ||
return generateAnswerMedia(item); | ||
}); | ||
|
||
const style = visible ? {display: 'block'} : { display: 'none'}; | ||
|
||
return ( | ||
<div className="flashcard" style={style} css={Styled.Card}> | ||
<SEO stitle='Sandbox' sdescription='Testing out the Q-and-API API I built using Node and Express' slug="sandbox"> | ||
<script defer async src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?skin=doxy"></script> | ||
</SEO> | ||
{/* <img src={imgPath} width={300} alt="" role="presentation"/> */} | ||
{/* <EmbeddedGist gist={`cnocon/25c10c5a228ef004de9ca54fe64f7411`} /> */} | ||
{/* <h4>Prompt:</h4> {ReactHtmlParser(test.prompt)} */} | ||
{/* <h4>Answer:</h4> {ReactHtmlParser(test.answer)} */} | ||
|
||
<section className="front"> | ||
<header> | ||
<h2>Question</h2> | ||
<h4>Category: {name}</h4> | ||
</header> | ||
{ReactHtmlParser(question.prompt)} | ||
<footer><h5>Difficulty: {question.difficulty}/10</h5></footer> | ||
</section> | ||
|
||
<section className="back"> | ||
<header> | ||
<h2>Answer</h2> | ||
<h4>Category: {name}</h4> | ||
</header> | ||
{ReactHtmlParser(question.answer)} | ||
{answerMedia} | ||
<footer><h5>Difficulty: {question.difficulty}/10</h5></footer> | ||
</section> | ||
|
||
|
||
</div> | ||
); | ||
}; | ||
|
||
export default FlashCard; |
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,31 @@ | ||
// import styled from "@emotion/styled" | ||
import { css } from "@emotion/core" | ||
import Theme from '../Theme/Theme' | ||
|
||
export const Card = css` | ||
line-height: ${Theme.fonts.sizes.lineHeights.sm}; | ||
border: 3px solid ${Theme.colors.grays.border}; | ||
border-radius: 3px; | ||
padding: ${Theme.spacing.default} ${Theme.spacing.default} 0; | ||
margin: 60px auto 0; | ||
max-width: 600px; | ||
pre:not(.prettyprint) { | ||
display: inline-block; | ||
line-height: inherit; | ||
background-color: ${Theme.colors.grays.background}; | ||
padding: 1px 6px; | ||
margin: 0; | ||
} | ||
pre > code span { | ||
font-size: 12px; | ||
} | ||
footer { | ||
border-top: 2px solid ${Theme.colors.grays.border}; | ||
background-color: ${Theme.colors.grays.border}; | ||
padding: 10px 15px; | ||
margin: 20px -16px 0; | ||
} | ||
` |
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