From 586282d7fa596265315383d082e5bc4a003e27c9 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Thu, 12 Jun 2025 12:27:39 -0700 Subject: [PATCH] Added doc preview --- .../src/components/BackstoryTextField.tsx | 10 ++- frontend/src/components/ui/ResumeInfo.tsx | 86 +++++++++++++++---- 2 files changed, 73 insertions(+), 23 deletions(-) diff --git a/frontend/src/components/BackstoryTextField.tsx b/frontend/src/components/BackstoryTextField.tsx index 9046a42..5d55fa0 100644 --- a/frontend/src/components/BackstoryTextField.tsx +++ b/frontend/src/components/BackstoryTextField.tsx @@ -13,7 +13,8 @@ interface BackstoryTextFieldProps { value?: string; disabled?: boolean; placeholder: string; - onEnter: (value: string) => void; + onEnter?: (value: string) => void; + onChange?: (value: string) => void; style?: CSSProperties; } @@ -23,6 +24,7 @@ const BackstoryTextField = React.forwardRef) => { if (event.key === 'Enter' && !event.shiftKey) { event.preventDefault(); // Prevent newline - onEnter(editValue); + onEnter && onEnter(editValue); setEditValue(''); // Clear textarea } }; @@ -95,7 +97,7 @@ const BackstoryTextField = React.forwardRef setEditValue(e.target.value)} + onChange={(e) => { setEditValue(e.target.value); onChange && onChange(e.target.value); }} onKeyDown={handleKeyDown} style={fullStyle} /> diff --git a/frontend/src/components/ui/ResumeInfo.tsx b/frontend/src/components/ui/ResumeInfo.tsx index e72c82b..0bb7ea4 100644 --- a/frontend/src/components/ui/ResumeInfo.tsx +++ b/frontend/src/components/ui/ResumeInfo.tsx @@ -23,7 +23,9 @@ import { Dialog, DialogTitle, DialogContent, - DialogActions + DialogActions, + Tabs, + Tab } from '@mui/material'; import { Delete as DeleteIcon, @@ -37,10 +39,13 @@ import { Visibility as VisibilityIcon, VisibilityOff as VisibilityOffIcon } from '@mui/icons-material'; +import PreviewIcon from '@mui/icons-material/Preview'; +import EditDocumentIcon from '@mui/icons-material/EditDocument'; import { useAuth } from 'hooks/AuthContext'; import { useAppState } from 'hooks/GlobalContext'; import { StyledMarkdown } from 'components/StyledMarkdown'; import { Resume } from 'types/types'; +import { BackstoryTextField } from 'components/BackstoryTextField'; interface ResumeInfoProps { resume: Resume; @@ -71,6 +76,7 @@ const ResumeInfo: React.FC = (props: ResumeInfoProps) => { const [editContent, setEditContent] = useState(''); const [saving, setSaving] = useState(false); const contentRef = useRef(null); + const [tabValue, setTabValue] = useState("markdown"); useEffect(() => { if (resume && resume.id !== activeResume?.id) { @@ -137,6 +143,10 @@ const ResumeInfo: React.FC = (props: ResumeInfoProps) => { }).format(date); }; + const handleTabChange = (event: React.SyntheticEvent, newValue: string) => { + setTabValue(newValue); + }; + return ( = (props: ResumeInfoProps) => { onClose={() => setEditDialogOpen(false)} maxWidth="lg" fullWidth - fullScreen={isMobile} + fullScreen={true} > Edit Resume Content @@ -342,23 +352,61 @@ const ResumeInfo: React.FC = (props: ResumeInfoProps) => { Resume for {activeResume.candidate?.fullName || activeResume.candidateId} - - setEditContent(e.target.value)} - variant="outlined" - sx={{ - mt: 1, - '& .MuiInputBase-input': { - fontFamily: 'monospace', - fontSize: '0.875rem' - } - }} - placeholder="Enter resume content..." - /> + + + } label="Markdown" /> + } label="Preview" /> + + *:not(.Scrollable)": { + flexShrink: 0, /* Prevent shrinking */ + }, + position: "relative", + border: "2px solid purple", + }}> + + {tabValue === "markdown" && + setEditContent(value)} + style={{ + position: "relative", + // maxHeight: "100%", + height: "100%", + width: "100%", + display: "flex", + minHeight: "100%", + + flexGrow: 1, + flex: 1, /* Take remaining space in some-container */ + overflowY: "auto", /* Scroll if content overflows */ + }} + placeholder="Enter resume content..." + /> + } + {tabValue === "preview" && <> + + + } + +