From 70c18d376cb718849b807d9d17e7c0a6388ffda3 Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Fri, 26 Jul 2019 15:14:45 -0400 Subject: [PATCH] add preview of markdown swap out --- src/components/base/TextField.jsx | 10 +++++- src/components/projects/CreateProject.jsx | 43 ++++++++++++++++++----- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/components/base/TextField.jsx b/src/components/base/TextField.jsx index 85d9fa5..c3aad8e 100644 --- a/src/components/base/TextField.jsx +++ b/src/components/base/TextField.jsx @@ -61,6 +61,11 @@ const styles = theme => ({ fontSize: '15px', gridRowStart: 4, gridColumnStart: 1, + }, + topRight: { + gridRowStart: 1, + gridColumnStart: 11, + gridColumnEnd: 12 } }) @@ -91,9 +96,11 @@ function Input({ onChange, onBlur, value, - multiline + multiline, + topRight }) { const labelForm = label ? renderLabel(classnames(classes.formLabel, classes.top), idFor, label, isRequired) : null + const topRightLabel = topRight ? renderLabel(classnames(classes.topRight), idFor, topRight) : null const bottomLeft = bottomLeftLabel ? renderLabel(classnames(classes.formLabel, classes.bottomLeft), idFor, bottomLeftLabel) : null const bottomRight = bottomRightLabel ? renderLabel(classnames(classes.formLabel, classes.bottomRight), idFor, bottomRightLabel) : null return ( @@ -101,6 +108,7 @@ function Input({ className={classnames(classes.margin, classes.container, className)} > { labelForm } + { topRightLabel } ({ height: 'fit-content' }, markdown: { - borderStyle: 'solid', - borderWidth: 'thin', - borderColor: 'darkgray', + display: 'grid', margin: '16px 0 8px 0', padding: '10%' }, + markdownPreview: { + gridColumnStart: 12 + }, textInput: { fontSize: '2rem' }, @@ -119,6 +120,9 @@ const styles = theme => ({ }, icon: { background: '#ECEFFC' + }, + preview: { + fontSize: '20px' } }) @@ -335,7 +339,23 @@ const SubmissionSection = ({ classes, history }) => { } label="Autoplay video?" /> - +
{ + setStatus({ ...status, showPreview: false }) + }} + > + Hide preview +
+ + } + {(!status || !status.showPreview) && { onBlur={handleBlur} value={values.description || ''} multiline={true} - /> + topRight={ + { + setStatus({ ...status, showPreview: true }) + }} + > + Preview + + } + />} { } style={{display: 'none'}} /> -
- -
)