lbry-desktop/ui/component/publishText/view.jsx

60 lines
1.9 KiB
React
Raw Normal View History

// @flow
import { SIMPLE_SITE } from 'config';
import { FF_MAX_CHARS_IN_DESCRIPTION } from 'constants/form-field';
import React from 'react';
import { FormField } from 'component/common/form';
2019-09-27 20:56:15 +02:00
import usePersistedState from 'effects/use-persisted-state';
import Card from 'component/common/card';
type Props = {
title: ?string,
description: ?string,
disabled: boolean,
updatePublishForm: ({}) => void,
};
function PublishText(props: Props) {
const { title, description, updatePublishForm, disabled } = props;
const [advancedEditor, setAdvancedEditor] = usePersistedState('publish-form-description-mode', false);
function toggleMarkdown() {
setAdvancedEditor(!advancedEditor);
}
return (
2019-09-27 20:56:15 +02:00
<Card
actions={
<React.Fragment>
<FormField
type="text"
name="content_title"
label={__('Title')}
2020-07-23 19:11:53 +02:00
placeholder={__('Descriptive titles work best')}
2019-09-27 20:56:15 +02:00
disabled={disabled}
value={title}
onChange={e => updatePublishForm({ title: e.target.value })}
/>
2019-09-27 20:56:15 +02:00
<FormField
type={!SIMPLE_SITE && advancedEditor ? 'markdown' : 'textarea'}
2019-09-27 20:56:15 +02:00
name="content_description"
label={__('Description')}
2020-07-23 19:11:53 +02:00
placeholder={__(
'What is your content about? Use this space to include any other relevant details you may like to share about your content and channel.'
)}
2019-09-27 20:56:15 +02:00
value={description}
disabled={disabled}
onChange={value =>
updatePublishForm({ description: !SIMPLE_SITE && advancedEditor ? value : value.target.value })
}
quickActionLabel={!SIMPLE_SITE && (advancedEditor ? __('Simple Editor') : __('Advanced Editor'))}
quickActionHandler={toggleMarkdown}
textAreaMaxLength={FF_MAX_CHARS_IN_DESCRIPTION}
2019-09-27 20:56:15 +02:00
/>
</React.Fragment>
}
/>
);
}
export default PublishText;