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

50 lines
1.5 KiB
React
Raw Permalink Normal View History

// @flow
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 = {
description: ?string,
disabled: boolean,
updatePublishForm: ({}) => void,
};
2020-07-29 22:30:26 +02:00
function PublishDescription(props: Props) {
const { description, updatePublishForm, disabled } = props;
const [advancedEditor, setAdvancedEditor] = usePersistedState('publish-form-description-mode', false);
function toggleMarkdown() {
setAdvancedEditor(!advancedEditor);
}
function handleCommentChange(event) {
let descriptionValue = advancedEditor ? event : event.target.value;
updatePublishForm({ description: descriptionValue });
}
return (
2019-09-27 20:56:15 +02:00
<Card
actions={
2020-10-05 20:24:57 +02:00
<FormField
type={advancedEditor ? 'markdown' : 'textarea'}
2020-10-05 20:24:57 +02:00
name="content_description"
label={__('Description')}
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.'
)}
value={description}
disabled={disabled}
onChange={handleCommentChange}
2021-10-19 01:37:58 +02:00
quickActionLabel={advancedEditor ? __('Simple Editor') : __('Advanced Editor')}
2020-10-05 20:24:57 +02:00
quickActionHandler={toggleMarkdown}
textAreaMaxLength={FF_MAX_CHARS_IN_DESCRIPTION}
/>
2019-09-27 20:56:15 +02:00
}
/>
);
}
2020-07-29 22:30:26 +02:00
export default PublishDescription;