Conversation
…o feature/convert-jade-to-jsx
…o feature/convert-jade-to-jsx
…o feature/convert-jade-to-jsx
|
Can you run Lots of them are from Some of the lint errors are automatically fixable, you can try and run this to make it fix them for you: I'll wait to review the code until these style issues are fixed! Ask me on here or on Slack if you need advice for how to fix specific issues. |
…o feature/convert-jade-to-jsx
There was a problem hiding this comment.
- Rename JSX component files to be TitleCased e.g. api-header.jsx => ApiHeader.jsx
- We need to add marked in. Can you do a search on the legacy jade templates and add a TODO in the code everywhere where marked needs to be added?
- Tests!
- Make Code component be able to switch between tabs
| coverage | ||
| index.js | ||
| emojis.js | ||
| marked.ks |
| if block.data && block.data.body | ||
| div.callout-body | ||
| != marked(block.data.body) | ||
|
|
There was a problem hiding this comment.
This stuff can be removed now right? We dont need to make any changes to the original legacy jade files?
| @@ -0,0 +1,101 @@ | |||
| 0 silly input [ 'test' ] | |||
There was a problem hiding this comment.
Can you delete this file and add it to the .gitignore in the top level?
| api: { method }, | ||
| swagger: { path }, | ||
| body: ` | ||
| [block:textarea] |
There was a problem hiding this comment.
This is okay for now, but we should probably come up with a better solution for testing out these blocks in future.
| @@ -0,0 +1,36 @@ | |||
| import uslug from 'uslug'; | |||
There was a problem hiding this comment.
Can you change this to use require instead of import?
const uslug = require('uslug');
Just to be consistent with the rest
| <img src={image.image[0]} alt={image.caption} /> | ||
| </a> | ||
| </figure> | ||
| { (image.caption) && (<figcaption> { image.caption } </figcaption>)} |
There was a problem hiding this comment.
You dont need () around either of these
{ image.caption && <figcaption>{ image.caption }</figcaption> }
| ); | ||
| }; | ||
|
|
||
| const ImagesBlock = ({ block }) => { |
There was a problem hiding this comment.
Do we need to support multiple images per image block?
| const columns = block.data.cols; | ||
| const rows = block.data.rows; | ||
|
|
||
| const Th = () => { |
There was a problem hiding this comment.
I always prefer Array.map over for. This can be made shorter by doing:
return columns.map(column =>(<div className="th">{block.data.data[`h-${c}`]}</div>))
There was a problem hiding this comment.
columns and rows aren't an array it returns a number
| }; | ||
|
|
||
| const Tr = () => { | ||
| const tr = []; |
| { | ||
| (block.data.data['h-0'] || block.data.data['h-1']) && ( | ||
| <div className="tr"> | ||
| {Th()} |
There was a problem hiding this comment.
If it's just a function and not a react component, then it needs to be camelCased th(). If you're expecting it to be a react component, then it needs to be instantiated as one:
<Th />
|
Items from previous review @uppal101 can you check the ones you've now done?
|
domharrington
left a comment
There was a problem hiding this comment.
Really great stuff! I've added a few comments but mostly small stylistic things.
Also can you add .DS_Store to the gitignore and remove the committed one?
| @@ -0,0 +1,12 @@ | |||
| const React = require('react'); | |||
| const { mount } = require('enzyme'); | |||
There was a problem hiding this comment.
Do you need to use mount everywhere that you are? I think shallow rendering is better if you don't have to mount and you dont have child components.
| <a | ||
| href="" | ||
| onClick={() => { | ||
| // eslint-disable-next-line |
There was a problem hiding this comment.
We still need to make this work 👍
| ); | ||
| }; | ||
|
|
||
| const Opts = (props) => { |
There was a problem hiding this comment.
Can we rename this from Opts to be Content or BlockContent or something?
| @@ -0,0 +1,113 @@ | |||
| import CallOut from './CallOut'; | |||
There was a problem hiding this comment.
Can you change these from imports to using require() for consistency.
| case 'textarea': | ||
| // eslint-disable-next-line react/no-array-index-key | ||
| return <TextArea key={i} block={block} />; | ||
| case 'html' : |
There was a problem hiding this comment.
Can you remove the space between the case and the colon?
case 'html':
Can you do the same for the next ones too?
| const Opts = require('../../src/block-types/Content'); | ||
|
|
||
| describe('Opts', () => { | ||
| test('Maps through content to return text area block type', () => { |
There was a problem hiding this comment.
For this file, i would use a snapshot test instead. This is mostly just a sanity check to make sure the Content component is passing stuff through correctly to the children. To clean up the file i would also move the block content into a fixtures file and read it in using fs.readFileSync(). This keeps the test a little cleaner and means we dont have to have so many long lines like the embed one below. I can help with this if you need.
| expect(embedInput.find('iframe').prop('src')).toBe('http://jsbin.com/fewilipowi/edit?js,output'); | ||
| }); | ||
|
|
||
| xtest('Embed will have src property if iframe is false', () => { |
There was a problem hiding this comment.
Did you mean to skip this one?
|
|
||
| describe('Embed', () => { | ||
| test('Embed will have src property if iframe is true', () => { | ||
| const block = { type: 'embed', |
There was a problem hiding this comment.
Can you fix the indentation on this and the one below?
const block = {
type: 'embed',
data: {
html: false,
url: 'http://jsbin.com/fewilipowi/edit?js,output',
title: 'JS Bin',
favicon: 'http://static.jsbin.com/images/favicon.png',
image: 'http://static.jsbin.com/images/logo.png',
iframe: true,
width: '100%',
height: '300px'
},
sidebar: undefined
};
|
|
||
| describe('Image', () => { | ||
| test('Image has a tag with property href set to url', () => { | ||
| const block = { type: 'image', data: { images: [{ image: ['https://files.readme.io/924824e-fullsizeoutput_314.jpeg', 'fullsizeoutput_314.jpeg', 640, 1136, '#c8b396'] }] }, sidebar: undefined }; |
There was a problem hiding this comment.
Can you also indent this one on multiple lines?
| @@ -0,0 +1,63 @@ | |||
|
|
|||
There was a problem hiding this comment.
Can you remove this empty line?
# Conflicts: # packages/api-explorer-ui/.eslintignore # packages/api-explorer-ui/src/Doc.jsx
Refine interface a little bit, remove `configure()` function. Allow passing in `opts` as a second parameter. Possible options: - `correctnewlines` - comes from `project.flags.correctnewlines` - `stripHtml` - passed in in certain cases Outstanding issues: https://github.com/readmeio/api-explorer/issues/29 https://github.com/readmeio/api-explorer/issues/28
…meio/api-explorer into feature/convert-jade-to-jsx
write test cases for each block type
take care of embed iframe condition
Fix bugs on code to make sure they render correctly
Correct styling issue when images are rendered in the right column