import { h, Component } from 'preact';
import PropTypes from 'prop-types';
import { Modal } from '@crayons';
export class Help extends Component {
constructor(props) {
super(props);
this.state = {
liquidHelpHTML:
document.getElementById('editor-liquid-help') &&
document.getElementById('editor-liquid-help').innerHTML,
markdownHelpHTML:
document.getElementById('editor-markdown-help') &&
document.getElementById('editor-markdown-help').innerHTML,
frontmatterHelpHTML:
document.getElementById('editor-frontmatter-help') &&
document.getElementById('editor-frontmatter-help').innerHTML,
liquidShowing: false,
markdownShowing: false,
frontmatterShowing: false,
};
}
showModal = (sectionShowing, isOpen) => () => {
this.setState({ [sectionShowing]: isOpen });
};
renderArticleFormTitleHelp = () => {
return (
Writing a Great Post Title
-
Think of your post title as a super short (but compelling!)
description — like an overview of the actual post in one short
sentence.
-
Use keywords where appropriate to help ensure people can find your
post by search.
);
};
renderTagInputHelp = () => {
return (
Tagging Guidelines
- Tags help people find your post.
-
Think of tags as the topics or categories that best describe your
post.
-
Add up to four comma-separated tags per post. Combine tags to reach
the appropriate subcommunities.
- Use existing tags whenever possible.
-
Some tags, such as “help” or “healthydebate”, have special posting
guidelines.
);
};
renderBasicEditorHelp = () => {
return (
);
};
renderFormatHelp = () => {
return (
Editor Basics
-
Use{' '}
Markdown
{' '}
to write and format posts.
Commonly used syntax
# Header
...
###### Header
|
H1 Header
...
H6 Header
|
| *italics* or _italics_ |
italics
|
| **bold** |
bold
|
| [Link](https://...) |
Link
|
* item 1 * item 2
|
|
1. item 1
2. item 2
|
|
| > quoted text |
quoted text
|
| `inline code` |
inline code
|
```
code block
```
|
code block
|
-
You can use{' '}
Liquid tags
{' '}
to add rich content such as Tweets, YouTube videos, etc.
-
In addition to images for the post's content, you can also drag and
drop a cover image
);
};
renderModal = (onClose, title, helpHtml) => {
return (
);
};
render() {
const { previewShowing, helpFor, helpPosition, version } = this.props;
const {
liquidHelpHTML,
markdownHelpHTML,
frontmatterHelpHTML,
liquidShowing,
markdownShowing,
frontmatterShowing,
} = this.state;
return (
{!previewShowing && (
{helpFor === 'article-form-title' &&
this.renderArticleFormTitleHelp()}
{helpFor === 'tag-input' && this.renderTagInputHelp()}
{version === 'v1' && this.renderBasicEditorHelp()}
{(helpFor === 'article_body_markdown' || version === 'v1') &&
this.renderFormatHelp()}
)}
{liquidShowing &&
this.renderModal(
this.showModal('liquidShowing', false),
'🌊 Liquid Tags',
liquidHelpHTML,
)}
{markdownShowing &&
this.renderModal(
this.showModal('markdownShowing', false),
'✍️ Markdown',
markdownHelpHTML,
)}
{frontmatterShowing &&
this.renderModal(
this.showModal('frontmatterShowing', false),
'Jekyll Front Matter',
frontmatterHelpHTML,
)}
);
}
}
Help.propTypes = {
previewShowing: PropTypes.bool.isRequired,
helpFor: PropTypes.string.isRequired,
helpPosition: PropTypes.string.isRequired,
version: PropTypes.string.isRequired,
};
Help.displayName = 'Help';