11import React , { useState , useEffect , useRef } from 'react' ;
22import { Link } from 'react-router-dom' ;
3- import { ArrowLeftIcon , DownloadSimple , Trash , CloudRain , FloppyDisk , FolderOpen } from '@phosphor-icons/react' ;
3+ import { ArrowLeftIcon , DownloadSimple , Trash , CloudRain , FloppyDisk , FolderOpen , ArrowsOutLineHorizontal , ArrowsInLineHorizontal } from '@phosphor-icons/react' ;
44import useSeo from '../../hooks/useSeo' ;
55import { useToast } from '../../hooks/useToast' ;
66import ConfirmationModal from '../../components/ConfirmationModal' ;
7+ import usePersistentState from '../../hooks/usePersistentState' ;
78
89const NotepadPage = ( ) => {
910 useSeo ( {
@@ -15,6 +16,7 @@ const NotepadPage = () => {
1516 const [ text , setText ] = useState ( '' ) ;
1617 const [ isRainy , setIsRainy ] = useState ( false ) ;
1718 const [ isClearModalOpen , setIsClearModalOpen ] = useState ( false ) ;
19+ const [ isFixedSize , setIsFixedSize ] = usePersistentState ( 'fezcodex-notepad-fixed-size' , true ) ; // Default to true for fixed height
1820 const textareaRef = useRef ( null ) ;
1921 const fileInputRef = useRef ( null ) ;
2022 const { addToast} = useToast ( ) ;
@@ -96,6 +98,15 @@ const NotepadPage = () => {
9698 } ) ;
9799 } ;
98100
101+ const toggleFixedSize = ( ) => {
102+ setIsFixedSize ( prev => ! prev ) ;
103+ addToast ( {
104+ title : isFixedSize ? 'Expanded' : 'Fixed Height' ,
105+ message : isFixedSize ? 'Notepad expanded to fill space.' : 'Notepad height is now fixed.' ,
106+ duration : 2000
107+ } ) ;
108+ } ;
109+
99110 return (
100111 < div
101112 className = { `min-h-screen flex flex-col transition-colors duration-500 ${ isRainy ? 'bg-gray-900' : 'bg-[#fdfbf7]' } ` } >
@@ -153,6 +164,13 @@ const NotepadPage = () => {
153164 >
154165 < FolderOpen size = { 20 } />
155166 </ button >
167+ < button
168+ onClick = { toggleFixedSize }
169+ className = { `p-2 rounded-full transition-colors ${ isFixedSize ? 'text-gray-500 hover:bg-gray-200' : 'text-blue-300 bg-blue-900/30 hover:bg-blue-900/50' } ` }
170+ title = { isFixedSize ? 'Expand Notepad' : 'Fix Notepad Height' }
171+ >
172+ { isFixedSize ? < ArrowsOutLineHorizontal size = { 20 } /> : < ArrowsInLineHorizontal size = { 20 } /> }
173+ </ button >
156174 < button
157175 onClick = { toggleRain }
158176 className = { `p-2 rounded-full transition-colors ${ isRainy ? 'text-blue-300 bg-blue-900/30 hover:bg-blue-900/50' : 'text-gray-500 hover:bg-gray-200' } ` }
@@ -179,7 +197,7 @@ const NotepadPage = () => {
179197
180198 { /* Notepad Area */ }
181199 < div
182- className = { `flex-grow rounded-lg shadow-lg relative overflow-hidden transition-all duration-500 ${ isRainy ? 'bg-gray-800 border border-gray-700' : 'bg-white border border-gray-200' } ` } >
200+ className = { `${ isFixedSize ? 'h-[60vh]' : ' flex-grow' } rounded-lg shadow-lg relative overflow-hidden flex flex-col transition-all duration-500 ${ isRainy ? 'bg-gray-800 border border-gray-700' : 'bg-white border border-gray-200' } ` } >
183201 { /* Paper Lines Background */ }
184202 < div
185203 className = "absolute inset-0 pointer-events-none opacity-50"
@@ -196,7 +214,8 @@ const NotepadPage = () => {
196214
197215 < textarea
198216 ref = { textareaRef }
199- className = { `w-full h-full p-8 pl-16 text-lg font-mono leading-8 bg-transparent border-none resize-none focus:ring-0 focus:outline-none relative z-10 ${ isRainy ? 'text-gray-300 placeholder-gray-600' : 'text-gray-800 placeholder-gray-400' } ` }
217+ rows = { 1 }
218+ className = { `w-full p-8 pl-16 text-lg font-mono leading-8 bg-transparent border-none resize-none focus:ring-0 focus:outline-none relative z-10 min-h-0 flex-1 ${ isRainy ? 'text-gray-300 placeholder-gray-600' : 'text-gray-800 placeholder-gray-400' } ` }
200219 placeholder = "Start typing..."
201220 value = { text }
202221 onChange = { ( e ) => setText ( e . target . value ) }
0 commit comments