@@ -25,6 +25,8 @@ const About = ({ data }: AboutProps) => {
2525 const [ isEditMode , setIsEditMode ] = useState ( false ) ;
2626 const [ isLoading , setIsLoading ] = useState ( false ) ;
2727 const [ hasAboutPoints , setHasAboutPoints ] = useState ( false ) ;
28+ const [ isExpanded , setIsExpanded ] = useState ( false ) ;
29+
2830
2931 const {
3032 register,
@@ -40,6 +42,11 @@ const About = ({ data }: AboutProps) => {
4042
4143 const currentAboutValue = watch ( "about" ) ;
4244
45+ useEffect ( ( ) => {
46+ if ( isEditMode ) setIsExpanded ( true ) ;
47+ else setIsExpanded ( false ) ;
48+ } , [ isEditMode ] ) ;
49+
4350 // Check if user has earned points for the 'about' field
4451 useEffect ( ( ) => {
4552 async function checkAboutPoints ( ) {
@@ -139,19 +146,63 @@ const About = ({ data }: AboutProps) => {
139146 < Label > Tell more about yourself</ Label >
140147
141148 < div >
142- < Textarea
143- variant = "resume"
144- placeholder = "Write something about yourself..."
145- id = "about_me"
146- { ...register ( "about" ) }
147- disabled = { ! isEditMode }
148- value = { watch ( "about" ) || "" }
149- className = { `placeholder:text-gray-400 dark:placeholder:text-gray-500 ${
150- isEditMode
151- ? "border-lightgray text-black dark:text-white bg-white dark:bg-dark-200 border dark:border-zinc-700"
152- : "text-gray-500 dark:text-gray-400 bg-white dark:bg-dark-200 border-none"
153- } `}
154- />
149+ { ! isEditMode ? (
150+ < div className = "relative" >
151+ < div
152+ className = "
153+ w-full rounded-md
154+ bg-light-200 dark:bg-dark-200
155+ text-gray-500 dark:text-gray-400
156+ overflow-hidden
157+ "
158+ >
159+ < div
160+ className = { `
161+ px-3 py-2
162+ text-base leading-normal
163+ whitespace-pre-wrap
164+ ${
165+ isExpanded ? "" : "line-clamp-2"
166+ }
167+ ` }
168+ style = { ! isExpanded ? { maxHeight : '3.7rem' } : { } }
169+ >
170+ { currentAboutValue || "Write something about yourself..." }
171+ </ div >
172+ </ div >
173+
174+ { currentAboutValue && currentAboutValue . length > 120 && (
175+ < button
176+ type = "button"
177+ onClick = { ( ) => setIsExpanded ( ( prev ) => ! prev ) }
178+ className = "
179+ mt-1 text-xs underline
180+ text-gray-500 dark:text-gray-400
181+ hover:opacity-80
182+ transition-opacity
183+ "
184+ >
185+ { isExpanded ? "Show less" : "Show more" }
186+ </ button >
187+ ) }
188+ </ div >
189+ ) : (
190+ < Textarea
191+ variant = "resume"
192+ placeholder = "Write something about yourself..."
193+ id = "about_me"
194+ { ...register ( "about" ) }
195+ rows = { 8 }
196+ className = "
197+ px-3 py-2
198+ text-base leading-normal
199+ bg-light-100 dark:bg-dark-200
200+ text-dark-900 dark:text-light-900
201+ border-none
202+ rounded-md
203+ "
204+ />
205+ ) }
155206 </ div >
156207 </ div >
157208
0 commit comments