Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MarkdownHelp component #58

Merged
merged 9 commits into from
Aug 7, 2017
Merged

Add MarkdownHelp component #58

merged 9 commits into from
Aug 7, 2017

Conversation

jelliotartz
Copy link
Contributor

Resolves #57.

Creates a MarkdownzHelp component, based on MarkdownzHelp, with Talk and custom title conditionally available via props.

Multiline Markdown elements (e.g., lists, headers) are currently rendered with template literal syntax.
Avatar image is currently rendered with string literal.

Originally written in a Zooniverse-React-Components PR to address zooniverse/Zooniverse-React-Components#18.

Copy link
Contributor

@mcbouslog mcbouslog left a comment

Choose a reason for hiding this comment

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

Few initial comments, and I don't think the package-lock.json should be included in the PR.

README.md Outdated
@@ -6,6 +6,8 @@ Markdown viewer and editor for the [Zooniverse](https://www.zooniverse.org). Req

Available on [npm](http://npmjs.com), include as a dependency using `npm install --save markdownz`

Any default styles can be added to `src/css/markdown-help.css`. Don't forget to add a `require` statement for the css file!

This package contains two publicly accessible components a Markdown viewer and a Markdown editor for Zooniverse-flavored Markdown:
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll want to describe the Help component similar to how the Viewer and Editor are as follows:

README.md Outdated
@@ -6,6 +6,8 @@ Markdown viewer and editor for the [Zooniverse](https://www.zooniverse.org). Req

Available on [npm](http://npmjs.com), include as a dependency using `npm install --save markdownz`

Any default styles can be added to `src/css/markdown-help.css`. Don't forget to add a `require` statement for the css file!
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't quite clear to me if I didn't know what we did. I think there may be two things we'll want to explain, how as a contributor or dev working in the repo we should include styles (currently the first sentence touches on), and how someone using this as a dependency should use the styles (current the second sentence touches on), but I think they could be separate sentences and explained in a little more detail?

@mcbouslog mcbouslog requested review from srallen and mcbouslog July 27, 2017 19:30
@eatyourgreens
Copy link
Contributor

Flagging up that zooniverse/Panoptes-Front-End#3958 has changed the markdown help file.

Copy link
Contributor

@srallen srallen left a comment

Choose a reason for hiding this comment

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

I have a few comments, plus @eatyourgreens's needs to be addressed.

README.md Outdated

## Usage

Available on [npm](http://npmjs.com), include as a dependency using `npm install --save markdownz`

This package contains two publicly accessible components a Markdown viewer and a Markdown editor for Zooniverse-flavored Markdown:
For the MarkdownHelp component, any default styles can be added to `src/css/markdown-help.css`. Don't forget to add a `require` statement for the css file!
Copy link
Contributor

Choose a reason for hiding this comment

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

How about we just have a concise statement of about importing the file with the example?

README.md Outdated
This package contains two publicly accessible components a Markdown viewer and a Markdown editor for Zooniverse-flavored Markdown:
For the MarkdownHelp component, any default styles can be added to `src/css/markdown-help.css`. Don't forget to add a `require` statement for the css file!

This package contains three publicly accessible components: a Markdown viewer and a Markdown editor for Zooniverse-flavored Markdown, and a MarkdownHelp component that displays a modal illustrating styles and how to implement them.
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't display a modal. It's just the content. It's up to the dev to decide how to implement.

@@ -24,6 +26,14 @@ import { MarkdownEditor } from 'markdownz';
<MarkdownEditor rows={20} value="A String of `Markdown`" onChange={this.handleMarkdownChange} />
```

Help:

```jsx
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think putting jsx at the top of the file is necessary.

@@ -0,0 +1,269 @@
import React from 'react';
import Markdown from './markdown';
import simpleAvatar from '../images/simple-avatar.png';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not import an image like this. Use a hosted service, like https://placeholder.com, for a placeholder as the image example instead.

</tr>
</tbody>
</table>
{ talk &&
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a style thing, but can you get rid of the extra spaces after and before the curly braces?

</table>);

const MarkdownHelp = ({ title, talk }) => {
const bulletedList = `
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are there a few sections of content here pulled into separate constant variables? Why not just have the content directly in with the rest of the content below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Markdown component was not rendering multi-line content correctly, so I created the separate variables with string interpolation as a workaround (I tried both with and without string interpolation in the Markdown component, no difference in the result). Below are some screen shots showing the difference. Happy to change this if there's a way to render multiline content in the Markdown component, but so far I haven't found anything on Stack Overflow/google.

image

image

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any string interpolation happening? The backticks in javascript are template strings. I think that's your issue and it's being used in both. Remove the backticks and the markdown should be interpreted correctly inline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I meant template strings. Removing them does not resolve the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok, I understand better now. You need to tell javascript that you want line breaks (which in a round about way using template strings was doing). You could just do this instead: {'- item one\n- item two\n- item three'} which is a bit more clear to me what's going on.


MarkdownHelp.propTypes = {
talk: React.PropTypes.bool,
title: React.PropTypes.string
Copy link
Contributor

Choose a reason for hiding this comment

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

I know the original in PFE had this, but why is the title a prop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why, I made it a prop because it was so in the original PFE. Would you like me to take it out or leave it?

Copy link
Contributor

Choose a reason for hiding this comment

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

For questions like this, you can look at the git blame information to find out who the original author was and ask the question. I think this might have been @mcbouslog's first work on PFE...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @mcbouslog, should we leave the title prop in here?

test/helper.js Outdated
@@ -20,6 +20,10 @@ Object.keys(document.defaultView).forEach((property) => {
}
});

// prevent mocha from compiling .png files
function noop() { return null; }
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be removed once the image import is removed.

/* eslint-disable func-names, prefer-arrow-callback */
/* eslint import/no-extraneous-dependencies: ["error", { "devDependencies": true }] */
import React from 'react';
import { mount } from 'enzyme';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use shallow instead of mount. The first answer on this stackoverflow question has a good explanation.

});
});

describe('custom props', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's collapse the two describe blocks into one and just use setProps after the first two that tested the default props to change the props and then include the next two tests.

README.md Outdated

Viewer:

```jsx
Copy link
Contributor Author

@jelliotartz jelliotartz Aug 2, 2017

Choose a reason for hiding this comment

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

Removing this from the readme messed up the code blocks - Adding again as javascript, but let me know if you have something else in mind.

Copy link
Contributor

Choose a reason for hiding this comment

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

No I forgot that github flavored markdown does syntax highlighting this way. If jsx is supported, that should be fine.

@srallen
Copy link
Contributor

srallen commented Aug 3, 2017

@jelliotartz Don't forget to incorporate the changes @eatyourgreens mentioned. Ok you got it. Please next time leave a comment that you've made those kind of changes since that wasn't tied to specific inline review. Thanks.

@jelliotartz
Copy link
Contributor Author

Ok, will do! :)

@srallen srallen merged commit f496ae8 into master Aug 7, 2017
@srallen srallen deleted the markdownz-help branch August 7, 2017 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants