@@ -47,7 +47,7 @@ interface CompaniesTabProps {
4747const fadeIn = { hidden : { opacity : 0 , y : 20 } , visible : { opacity : 1 , y : 0 , transition : { duration : 0.6 } } }
4848const staggerContainer = { hidden : { } , visible : { transition : { staggerChildren : 0.1 } } }
4949
50- const CompaniesTab : React . FC < CompaniesTabProps > = ( { companyTips= [ ] } ) => {
50+ const CompaniesTab : React . FC < CompaniesTabProps > = ( { companyTips = [ ] } ) => {
5151 const [ searchTerm , setSearchTerm ] = useState ( "" )
5252 const [ selectedIndustry , setSelectedIndustry ] = useState ( "" )
5353 const [ selectedRole , setSelectedRole ] = useState ( "" )
@@ -77,6 +77,15 @@ const CompaniesTab: React.FC<CompaniesTabProps> = ({ companyTips=[] }) => {
7777 [ key ] : ! prev [ key ] ,
7878 } ) )
7979 }
80+ const [ expandedCompanies , setExpandedCompanies ] = useState < { [ key : number ] : boolean } > ( { } )
81+
82+ const toggleCompany = ( index : number ) => {
83+ setExpandedCompanies ( prev => ( {
84+ ...prev ,
85+ [ index ] : ! prev [ index ]
86+ } ) )
87+ }
88+
8089
8190 return (
8291 < motion . div initial = "hidden" animate = "visible" variants = { staggerContainer } className = "space-y-8" >
@@ -153,7 +162,7 @@ const CompaniesTab: React.FC<CompaniesTabProps> = ({ companyTips=[] }) => {
153162 stats : "100+ Questions" ,
154163 } ,
155164 ] ?. map ( ( item , i ) => (
156- item ? ( < motion . div
165+ item ? ( < motion . div
157166 key = { i }
158167 className = "bg-white dark:bg-gray-800 rounded-2xl p-6 text-center shadow-lg hover:shadow-xl transition-all duration-300 transform hover:scale-105"
159168 whileHover = { { y : - 5 } }
@@ -176,7 +185,7 @@ const CompaniesTab: React.FC<CompaniesTabProps> = ({ companyTips=[] }) => {
176185 < div className = "inline-flex items-center px-3 py-1 bg-gray-100 dark:bg-gray-700 rounded-full text-xs font-semibold text-gray-700 dark:text-gray-300" >
177186 { item . stats }
178187 </ div >
179- </ motion . div > ) : null
188+ </ motion . div > ) : null
180189 ) ) }
181190 </ div >
182191
@@ -186,20 +195,20 @@ const CompaniesTab: React.FC<CompaniesTabProps> = ({ companyTips=[] }) => {
186195 { metric : "150+" , label : "Companies Covered" , icon : "🏢" , color : "text-blue-600" } ,
187196 { metric : "50K+" , label : "Successful Candidates" , icon : "👥" , color : "text-purple-600" } ,
188197 ] ?. map ( ( stat , i ) => (
189- stat ? (
190- < motion . div
191- key = { i }
192- className = "text-center p-6 bg-white/50 dark:bg-gray-800/50 rounded-xl backdrop-blur-sm border company-border"
193- initial = { { opacity : 0 , scale : 0.8 } }
194- animate = { { opacity : 1 , scale : 1 } }
195- transition = { { duration : 0.5 , delay : 0.5 + i * 0.1 } }
196- >
197- < div className = { `text-3xl font-bold ${ stat . color } mb-2` } > { stat . metric } </ div >
198- < div className = "text-sm text-gray-600 dark:text-gray-300 flex items-center justify-center gap-2" >
199- < span > { stat . icon } </ span >
200- { stat . label }
201- </ div >
202- </ motion . div > ) : null
198+ stat ? (
199+ < motion . div
200+ key = { i }
201+ className = "text-center p-6 bg-white/50 dark:bg-gray-800/50 rounded-xl backdrop-blur-sm border company-border"
202+ initial = { { opacity : 0 , scale : 0.8 } }
203+ animate = { { opacity : 1 , scale : 1 } }
204+ transition = { { duration : 0.5 , delay : 0.5 + i * 0.1 } }
205+ >
206+ < div className = { `text-3xl font-bold ${ stat . color } mb-2` } > { stat . metric } </ div >
207+ < div className = "text-sm text-gray-600 dark:text-gray-300 flex items-center justify-center gap-2" >
208+ < span > { stat . icon } </ span >
209+ { stat . label }
210+ </ div >
211+ </ motion . div > ) : null
203212 ) ) }
204213 </ div >
205214 </ div >
@@ -250,7 +259,7 @@ const CompaniesTab: React.FC<CompaniesTabProps> = ({ companyTips=[] }) => {
250259 < div className = "flex items-center justify-between" >
251260 < div className = "text-sm text-gray-600 dark:text-gray-400 flex items-center gap-2" >
252261 < Building2 className = "w-4 h-4" />
253- Showing { filteredCompanies . length } of { companyTips ?. length || 0 } companies
262+ Showing { filteredCompanies . length } of { companyTips ?. length || 0 } companies
254263 </ div >
255264 < div className = "flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400" >
256265 < Star className = "w-3 h-3" />
@@ -261,7 +270,7 @@ const CompaniesTab: React.FC<CompaniesTabProps> = ({ companyTips=[] }) => {
261270
262271 < div className = "space-y-12" >
263272 { filteredCompanies . map ( ( company , companyIndex ) => {
264- const [ isOpen , setIsOpen ] = useState ( false )
273+ const isOpen = expandedCompanies [ companyIndex ] || false
265274 return (
266275 < motion . div key = { companyIndex } variants = { fadeIn } className = "group" >
267276 < Card className = "overflow-hidden shadow-xl hover:shadow-2xl transition-all duration-500 transform hover:scale-[1.02] border-0" >
@@ -355,7 +364,7 @@ const CompaniesTab: React.FC<CompaniesTabProps> = ({ companyTips=[] }) => {
355364
356365 { /* collapse toggle */ }
357366 < button
358- onClick = { ( ) => setIsOpen ( ! isOpen ) }
367+ onClick = { ( ) => toggleCompany ( companyIndex ) }
359368 className = "p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition"
360369 >
361370 < motion . div animate = { { rotate : isOpen ? 180 : 0 } } transition = { { duration : 0.2 } } >
@@ -440,12 +449,12 @@ const CompaniesTab: React.FC<CompaniesTabProps> = ({ companyTips=[] }) => {
440449 < Badge
441450 variant = "outline"
442451 className = { `text-xs px-2 py-1 rounded-full ${ item . category === "System Design"
443- ? "badge-system border-blue-300 text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900/20"
444- : item . category === "Behavioral"
445- ? "badge-behavioral border-green-300 text-green-700 dark:text-green-300 bg-green-50 dark:bg-green-900/20"
446- : item . category === "Technical"
447- ? "badge-technical border-purple-300 text-purple-700 dark:text-purple-300 bg-purple-50 dark:bg-purple-900/20"
448- : "badge-other border-orange-300 text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900/20"
452+ ? "badge-system border-blue-300 text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900/20"
453+ : item . category === "Behavioral"
454+ ? "badge-behavioral border-green-300 text-green-700 dark:text-green-300 bg-green-50 dark:bg-green-900/20"
455+ : item . category === "Technical"
456+ ? "badge-technical border-purple-300 text-purple-700 dark:text-purple-300 bg-purple-50 dark:bg-purple-900/20"
457+ : "badge-other border-orange-300 text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900/20"
449458 } `}
450459 >
451460 { item . category }
0 commit comments