Skip to content

Commit

Permalink
add empty preview
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshj01 committed Oct 8, 2024
1 parent c963834 commit 388e718
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
2 changes: 1 addition & 1 deletion public/sw.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 29 additions & 20 deletions src/app/(main)/_components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,36 @@ const Editor: React.FC<PSEditorProps> = ({ value, onChange, placeHolder, preview
`;

const customClass = `px-2 py-2 rounded-b-lg border-surface focus:ring-secondary focus:outline-none focus:ring-2 focus:ring-2 resize-y min-h-80 w-full ${className}`;
if (preview) {
return <MDPreview
className={`${customClass} reactMarkDown`}
value={value}
/>;
}
return (
<TextCompletionInput
customClass={`${customClass} line-break`}
// We need editor state only when editing
value={isRepublish ? value : editorStateRef.current.getCurrentValue()}
onChange={handleChange}
disabled={disabled}
placeholder={placeHolder || placeholder}
height="70vh"
autoSuggest={false}
maxHeight="100%"
onUndo={handleUndo}
onRedo={handleRedo}
/>
);
<div className="relative">
{preview ? (
// if value is empty, show placeholder
value ? (
<MDPreview
className={`${customClass} reactMarkDown ${preview ? 'fade-in-animation' : 'fade-out-animation'}`}
value={value}
/>
) : (
<div className={`flex justify-center items-center rounded-b-lg ${customClass}`} >
<p>Nothing to Preview</p>
</div>)
) : (
<TextCompletionInput
customClass={`${customClass} line-break ${!preview ? 'fade-in-animation' : 'fade-out-animation'}`}
// We need editor state only when editing
value={isRepublish ? value : editorStateRef.current?.getCurrentValue()}
onChange={handleChange}
disabled={disabled}
placeholder={placeHolder || placeholder}
height="70vh"
autoSuggest={false}
maxHeight="100%"
onUndo={handleUndo}
onRedo={handleRedo}
/>
)}
</div>
)

};

Expand Down
14 changes: 14 additions & 0 deletions src/app/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
}
}

@keyframes fadeIn{
0% {
opacity: 0;
}

100% {
opacity: 1;
}
}

@keyframes revealFromBottom {
0% {
clip-path: inset(100% 0 0 0);
Expand Down Expand Up @@ -72,6 +82,10 @@
animation: fadeOut 0.5s ease-out forwards;
}

.fade-in-animation {
animation: fadeIn 0.5s ease-out forwards;
}

.reveal-in-animation {
animation: revealFromLeft 1s ease-out;
overflow: hidden
Expand Down

0 comments on commit 388e718

Please sign in to comment.