@@ -3,15 +3,25 @@ import LoadingIndicator from '../../../../components/LoadingIndicator';
33import { ChecklistCreateArgs , useCreateChecklist } from '../../../../hooks/onboarding.hook' ;
44import { useToast } from '../../../../hooks/toasts.hooks' ;
55import { yupResolver } from '@hookform/resolvers/yup' ;
6- import { FormControl , FormLabel , TextField , InputAdornment , Checkbox , IconButton , useTheme } from '@mui/material' ;
7- import { Box } from '@mui/system' ;
6+ import {
7+ FormControl ,
8+ FormLabel ,
9+ TextField ,
10+ InputAdornment ,
11+ Checkbox ,
12+ IconButton ,
13+ useTheme ,
14+ Typography
15+ } from '@mui/material' ;
16+ import { Box , Stack } from '@mui/system' ;
817import React , { useState } from 'react' ;
918import { useForm , useFieldArray , Controller } from 'react-hook-form' ;
1019import { CreateChecklistPreview } from 'shared' ;
1120import NERFormModal from '../../../../components/NERFormModal' ;
1221import * as yup from 'yup' ;
1322import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline' ;
1423import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline' ;
24+ import NERMarkdown from '../../../../components/NERMarkdown' ;
1525
1626interface CreateChecklistModalProps {
1727 open : boolean ;
@@ -64,6 +74,7 @@ const CreateChecklistModal = ({ open, handleClose, teamId, teamTypeId }: CreateC
6474 const {
6575 handleSubmit,
6676 control,
77+ watch,
6778 reset,
6879 formState : { errors }
6980 } = useForm < ChecklistFormValues > ( {
@@ -136,6 +147,7 @@ const CreateChecklistModal = ({ open, handleClose, teamId, teamTypeId }: CreateC
136147 onFormSubmit = { onFormSubmit }
137148 formId = { 'create-task-form' }
138149 showCloseButton
150+ paperProps = { { maxWidth : '80vw' } }
139151 >
140152 < Box sx = { { display : 'flex' , flexDirection : 'column' , gap : 3 } } >
141153 < FormControl fullWidth >
@@ -255,53 +267,113 @@ const CreateChecklistModal = ({ open, handleClose, teamId, teamTypeId }: CreateC
255267 color : theme . palette . error . main ,
256268 fontWeight : 'bold' ,
257269 fontSize : '1.5rem' ,
258- textDecoration : 'underline'
270+ textDecoration : 'underline' ,
271+ mb : 2
259272 } }
260273 >
261274 Descriptions*
262275 </ FormLabel >
263276 { fields . map ( ( item , index ) => (
264- < Box key = { item . id } sx = { { display : 'flex' , alignItems : 'center' , gap : 1 } } >
265- < Controller
266- name = { `descriptions.${ index } .name` }
267- control = { control }
268- defaultValue = { item . name || '' }
269- render = { ( { field } ) => (
270- < TextField
271- { ...field }
272- placeholder = "Enter description..."
273- fullWidth
274- multiline
275- variant = "outlined"
276- InputProps = { {
277- endAdornment : (
278- < InputAdornment position = "end" >
279- { index !== 0 && (
277+ < Stack key = { item . id } direction = { 'row' } spacing = { 3 } sx = { { mb : 3 } } >
278+ < Box
279+ sx = { {
280+ display : 'flex' ,
281+ width : '30vw' ,
282+ alignItems : 'stretch'
283+ } }
284+ >
285+ < Controller
286+ name = { `descriptions.${ index } .name` }
287+ control = { control }
288+ defaultValue = { item . name || '' }
289+ render = { ( { field } ) => (
290+ < TextField
291+ { ...field }
292+ placeholder = "Enter description markdown..."
293+ fullWidth
294+ multiline
295+ variant = "outlined"
296+ minRows = { 12 }
297+ maxRows = { 20 }
298+ InputProps = { {
299+ endAdornment : index !== 0 && (
300+ < InputAdornment position = "end" sx = { { alignSelf : 'flex-start' , mt : 1 } } >
280301 < IconButton onClick = { ( ) => remove ( index ) } >
281302 < RemoveCircleOutlineIcon sx = { { color : 'white' } } />
282303 </ IconButton >
283- ) }
284- </ InputAdornment >
285- ) ,
286- disableUnderline : true ,
287- sx : { '& fieldset' : { border : 'none' } }
288- } }
289- sx = { {
290- backgroundColor : theme . palette . background . paper ,
291- borderRadius : 5 ,
292- mt : 1 ,
293- width : '100%' ,
294- ...( index === 0 && {
295- minHeight : '150px' ,
296- fontSize : '1.25rem'
297- } )
298- } }
299- error = { ! ! errors . descriptions ?. [ index ] ?. name }
300- helperText = { errors . descriptions ?. [ index ] ?. name ?. message }
301- />
302- ) }
303- />
304- </ Box >
304+ </ InputAdornment >
305+ ) ,
306+ disableUnderline : true ,
307+ sx : {
308+ '& fieldset' : { border : 'none' } ,
309+ fontSize : '1.1rem' ,
310+ lineHeight : 1.6 ,
311+ padding : 2
312+ }
313+ } }
314+ sx = { {
315+ backgroundColor : theme . palette . background . paper ,
316+ borderRadius : 3 ,
317+ width : '100%' ,
318+ '& .MuiInputBase-root' : {
319+ alignItems : 'flex-start'
320+ }
321+ } }
322+ error = { ! ! errors . descriptions ?. [ index ] ?. name }
323+ helperText = { errors . descriptions ?. [ index ] ?. name ?. message }
324+ />
325+ ) }
326+ />
327+ </ Box >
328+ < Box
329+ sx = { {
330+ backgroundColor : theme . palette . background . paper ,
331+ borderRadius : 3 ,
332+ width : '30vw' ,
333+ padding : 2 ,
334+ display : 'flex' ,
335+ flexDirection : 'column' ,
336+ overflow : 'hidden' ,
337+ wordWrap : 'break-word' ,
338+ border : `1px solid ${ theme . palette . divider } ` ,
339+ '& *' : {
340+ wordWrap : 'break-word' ,
341+ overflowWrap : 'break-word'
342+ }
343+ } }
344+ >
345+ < Typography
346+ variant = "caption"
347+ sx = { {
348+ color : theme . palette . text . secondary ,
349+ mb : 1 ,
350+ fontStyle : 'italic'
351+ } }
352+ >
353+ Preview:
354+ </ Typography >
355+ < Box
356+ sx = { {
357+ flex : 1 ,
358+ overflow : 'auto'
359+ } }
360+ >
361+ { watch ( `descriptions.${ index } .name` ) ? (
362+ < NERMarkdown markdown = { watch ( `descriptions.${ index } .name` ) } />
363+ ) : (
364+ < Typography
365+ variant = "body2"
366+ sx = { {
367+ color : theme . palette . text . disabled ,
368+ fontStyle : 'italic'
369+ } }
370+ >
371+ Start typing to see formatted markdown...
372+ </ Typography >
373+ ) }
374+ </ Box >
375+ </ Box >
376+ </ Stack >
305377 ) ) }
306378
307379 < IconButton
0 commit comments