Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Feature/convert jade to jsx#25

Merged
uppal101 merged 32 commits intomasterfrom
feature/convert-jade-to-jsx
Sep 13, 2017
Merged

Feature/convert jade to jsx#25
uppal101 merged 32 commits intomasterfrom
feature/convert-jade-to-jsx

Conversation

@uppal101
Copy link
Copy Markdown
Contributor

@uppal101 uppal101 commented Sep 8, 2017

  • 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

@domharrington
Copy link
Copy Markdown
Member

domharrington commented Sep 8, 2017

Can you run npm test in the top level to see what test failures you have? https://circleci.com/gh/readmeio/api-explorer/15?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link Looks like mostly lint issues so far.

Lots of them are from packages/api-explorer-ui/src/lib/emojis.js so you should be able to add this line to the end of this file https://github.com/readmeio/api-explorer/blob/master/packages/api-explorer-ui/.eslintignore to ignore those.

Some of the lint errors are automatically fixable, you can try and run this to make it fix them for you:

./node_modules/.bin/eslint . --fix

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.

Copy link
Copy Markdown
Member

@domharrington domharrington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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

Comment thread .eslintignore Outdated
coverage
index.js
emojis.js
marked.ks
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be marked.js?

Comment thread legacy-stuff/magic/callout.jade Outdated
if block.data && block.data.body
div.callout-body
!= marked(block.data.body)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff can be removed now right? We dont need to make any changes to the original legacy jade files?

Comment thread lerna-debug.log Outdated
@@ -0,0 +1,101 @@
0 silly input [ 'test' ]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you delete this file and add it to the .gitignore in the top level?

api: { method },
swagger: { path },
body: `
[block:textarea]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>)}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont need () around either of these

{ image.caption && <figcaption>{ image.caption }</figcaption> }

);
};

const ImagesBlock = ({ block }) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to support multiple images per image block?

const columns = block.data.cols;
const rows = block.data.rows;

const Th = () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>))

Copy link
Copy Markdown
Contributor Author

@uppal101 uppal101 Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

columns and rows aren't an array it returns a number

};

const Tr = () => {
const tr = [];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above ^^

{
(block.data.data['h-0'] || block.data.data['h-1']) && (
<div className="tr">
{Th()}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 />

@domharrington
Copy link
Copy Markdown
Member

domharrington commented Sep 12, 2017

Items from previous review @uppal101 can you check the ones you've now done?

  • 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

Copy link
Copy Markdown
Member

@domharrington domharrington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to make this work 👍

);
};

const Opts = (props) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this from Opts to be Content or BlockContent or something?

@@ -0,0 +1,113 @@
import CallOut from './CallOut';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' :
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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', () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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', () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to skip this one?


describe('Embed', () => {
test('Embed will have src property if iframe is true', () => {
const block = { type: 'embed',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also indent this one on multiple lines?

@@ -0,0 +1,63 @@

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this empty line?

uppal101 and others added 9 commits September 12, 2017 13:24
# 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
@uppal101 uppal101 merged commit 09d3433 into master Sep 13, 2017
@erunion erunion deleted the feature/convert-jade-to-jsx branch July 1, 2019 16:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants