Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

Commit

Permalink
feat: Answer component
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeason Centaure committed Jan 26, 2018
1 parent 88cf421 commit b521d84
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
.next/
lib/
!db/structure.sql
.env
21 changes: 21 additions & 0 deletions components/Answer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable jsx-a11y/label-has-for */
import React from 'react'
import ReactMarkdown from 'react-markdown'
import 'prismjs'
import Head from 'next/head'
import PrismCode from 'react-prism'

const code = { code: PrismCode }
const Answer = ({ answer }) => (
<div>
<Head>
<link rel="stylesheet" href="/prism.css" />
</Head>
<label>
<input type="radio" />
{<ReactMarkdown source={answer} renderer={code} />}
</label>
</div>
)

export default Answer
10 changes: 10 additions & 0 deletions components/Answer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { shallow } from 'enzyme'
import React from 'react'
import Answer from './Answer'

describe('#Answer', () => {
it('should render an answer component', () => {
const wrapper = shallow(<Answer answer="2 + 2 = 4" />)
expect(wrapper.find('ReactMarkdown').prop('source')).toEqual('2 + 2 = 4')
})
})
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
"passport-github2": "^0.1.11",
"pg": "^7.4.1",
"polished": "^1.9.0",
"prismjs": "^1.10.0",
"prop-types": "^15.6.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-markdown": "^3.1.4",
"react-prism": "^4.3.2",
"styled-components": "^2.4.0"
},
"scripts": {
Expand Down
Loading

0 comments on commit b521d84

Please sign in to comment.