-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
There was a problem hiding this 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: |
There was a problem hiding this comment.
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! |
There was a problem hiding this comment.
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?
Flagging up that zooniverse/Panoptes-Front-End#3958 has changed the markdown help file. |
There was a problem hiding this 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! |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
src/components/markdown-help.jsx
Outdated
@@ -0,0 +1,269 @@ | |||
import React from 'react'; | |||
import Markdown from './markdown'; | |||
import simpleAvatar from '../images/simple-avatar.png'; |
There was a problem hiding this comment.
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.
src/components/markdown-help.jsx
Outdated
</tr> | ||
</tbody> | ||
</table> | ||
{ talk && |
There was a problem hiding this comment.
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?
src/components/markdown-help.jsx
Outdated
</table>); | ||
|
||
const MarkdownHelp = ({ title, talk }) => { | ||
const bulletedList = ` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
src/components/markdown-help.jsx
Outdated
|
||
MarkdownHelp.propTypes = { | ||
talk: React.PropTypes.bool, | ||
title: React.PropTypes.string |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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.
test/markdown-help.test.js
Outdated
/* eslint-disable func-names, prefer-arrow-callback */ | ||
/* eslint import/no-extraneous-dependencies: ["error", { "devDependencies": true }] */ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; |
There was a problem hiding this comment.
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.
test/markdown-help.test.js
Outdated
}); | ||
}); | ||
|
||
describe('custom props', function() { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
Ok, will do! :) |
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.