sidebar: adapt sidebar to mobile display
This commit is contained in:
		| @ -25,11 +25,11 @@ function App() { | |||||||
|         <main className="bg-amber-50 px-10 dark:bg-gray-900"> |         <main className="bg-amber-50 px-10 dark:bg-gray-900"> | ||||||
|           <section className="min-h-screen"> |           <section className="min-h-screen"> | ||||||
|             <Navbar toggleDarkMode={toggleDarkMode} darkMode={darkMode} /> |             <Navbar toggleDarkMode={toggleDarkMode} darkMode={darkMode} /> | ||||||
|             <div className="flex flex-row h-full"> |             <div className="md:flex md:flex-row md:h-full"> | ||||||
|               <div className="w-1/4 max-w-[260px] max-h-[928px] border-2 border-gray-300 dark:border-gray-700 rounded-lg shadow-sm"> |               <div className="mb-4 md:w-1/4 md:max-w-[260px] md:max-h-[900px] border-2 border-gray-300 dark:border-gray-700 rounded-lg shadow-sm"> | ||||||
|                 <Sidebar /> |                 <Sidebar /> | ||||||
|               </div> |               </div> | ||||||
|               <div className="flex-1"> |               <div className="md:flex-1"> | ||||||
|                 <Router> |                 <Router> | ||||||
|                   <Routes> |                   <Routes> | ||||||
|                     <Route path="/" element={<Home />} /> |                     <Route path="/" element={<Home />} /> | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ const Footer = () => { | |||||||
|   const currentYear = new Date().getFullYear() |   const currentYear = new Date().getFullYear() | ||||||
|  |  | ||||||
|   return ( |   return ( | ||||||
|     <footer className="mt-24 py-6 border-t border-gray-200 dark:border-gray-800"> |     <footer className="mt-12 md:mt-24 py-6 border-t border-gray-200 dark:border-gray-800"> | ||||||
|       <div className="max-w-4xl mx-auto px-4"> |       <div className="max-w-4xl mx-auto px-4"> | ||||||
|         <div className="flex flex-col items-center gap-4 text-gray-600 dark:text-gray-400 text-sm"> |         <div className="flex flex-col items-center gap-4 text-gray-600 dark:text-gray-400 text-sm"> | ||||||
|           <div className="flex items-center gap-2"> |           <div className="flex items-center gap-2"> | ||||||
|  | |||||||
| @ -1,24 +1,28 @@ | |||||||
| import { COLORS, SOCIALLINKS } from '../constants' | import { COLORS, SOCIALLINKS } from '../constants' | ||||||
|  | import { Tooltip } from './Tooltip' | ||||||
|  |  | ||||||
| interface LinkProps { | interface LinkProps { | ||||||
|   href: string |   href: string | ||||||
|   children: React.ReactNode |   children: React.ReactNode | ||||||
|   icon: React.ReactNode |   icon: React.ReactNode | ||||||
|  |   label: string | ||||||
| } | } | ||||||
|  |  | ||||||
| const Link: React.FC<LinkProps> = ({ icon, href, children }) => { | const Link: React.FC<LinkProps> = ({ icon, href, children, label }) => { | ||||||
|   return ( |   return ( | ||||||
|     <div className="transition-all duration-200 hover:translate-x-1"> |     <div className="transition-all duration-200 hover:translate-x-1"> | ||||||
|       <div className="mb-2 border border-gray-200 dark:border-gray-700 p-3 rounded-lg hover:shadow-md"> |       <div className="m-2 border border-gray-200 dark:border-gray-700 p-2 md:p-3 rounded-lg hover:shadow-md"> | ||||||
|         <a |         <Tooltip label={label} position="top" additionalClass="md:hidden"> | ||||||
|           href={href} |           <a | ||||||
|           target="_blank" |             href={href} | ||||||
|           rel="noopener noreferrer" |             target="_blank" | ||||||
|           className="flex items-center text-gray-700 dark:text-gray-200 hover:text-blue-600 dark:hover:text-blue-400" |             rel="noopener noreferrer" | ||||||
|         > |             className="flex items-center text-gray-700 dark:text-gray-200 hover:text-blue-600 dark:hover:text-blue-400" | ||||||
|           {icon} |           > | ||||||
|           <span className="text-sm font-medium hidden md:inline">{children}</span> |             {icon} | ||||||
|         </a> |             <span className="text-sm font-medium hidden md:inline">{children}</span> | ||||||
|  |           </a> | ||||||
|  |         </Tooltip> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|   ) |   ) | ||||||
| @ -26,39 +30,41 @@ const Link: React.FC<LinkProps> = ({ icon, href, children }) => { | |||||||
|  |  | ||||||
| const Sidebar = () => { | const Sidebar = () => { | ||||||
|   const SectionTitle = ({ children }: { children: React.ReactNode }) => ( |   const SectionTitle = ({ children }: { children: React.ReactNode }) => ( | ||||||
|     <h2 className={`mt-6 mb-4 text-lg font-semibold ${COLORS.PRIMARY} ${COLORS.DARK_PRIMARY}`}> |     <h2 | ||||||
|  |       className={`mt-4 mb-4 text-lg font-semibold ${COLORS.PRIMARY} ${COLORS.DARK_PRIMARY} hidden md:block`} | ||||||
|  |     > | ||||||
|       {children} |       {children} | ||||||
|     </h2> |     </h2> | ||||||
|   ) |   ) | ||||||
|  |  | ||||||
|   return ( |   return ( | ||||||
|     <div |     <div | ||||||
|       className={`p-6 max-w-xs mx-auto ${COLORS.PRIMARY} ${COLORS.DARK_PRIMARY} rounded-xl shadow-sm`} |       className={`grid grid-cols-4 md:grid-cols-1 p-2 md:p-6 max-w-xs mx-auto ${COLORS.PRIMARY} ${COLORS.DARK_PRIMARY} rounded-xl shadow-sm`} | ||||||
|     > |     > | ||||||
|       <SectionTitle>Contact</SectionTitle> |       <SectionTitle>Contact</SectionTitle> | ||||||
|       {SOCIALLINKS.contact.map((link, index) => ( |       {SOCIALLINKS.contact.map((link, index) => ( | ||||||
|         <Link key={index} icon={link.icon} href={link.href}> |         <Link key={index} icon={link.icon} href={link.href} label={link.text}> | ||||||
|           {link.text} |           {link.text} | ||||||
|         </Link> |         </Link> | ||||||
|       ))} |       ))} | ||||||
|  |  | ||||||
|       <SectionTitle>Connect</SectionTitle> |       <SectionTitle>Connect</SectionTitle> | ||||||
|       {SOCIALLINKS.connect.map((link, index) => ( |       {SOCIALLINKS.connect.map((link, index) => ( | ||||||
|         <Link key={index} icon={link.icon} href={link.href}> |         <Link key={index} icon={link.icon} href={link.href} label={link.text}> | ||||||
|           {link.text} |           {link.text} | ||||||
|         </Link> |         </Link> | ||||||
|       ))} |       ))} | ||||||
|  |  | ||||||
|       <SectionTitle>Follow</SectionTitle> |       <SectionTitle>Follow</SectionTitle> | ||||||
|       {SOCIALLINKS.follow.map((link, index) => ( |       {SOCIALLINKS.follow.map((link, index) => ( | ||||||
|         <Link key={index} icon={link.icon} href={link.href}> |         <Link key={index} icon={link.icon} href={link.href} label={link.text}> | ||||||
|           {link.text} |           {link.text} | ||||||
|         </Link> |         </Link> | ||||||
|       ))} |       ))} | ||||||
|  |  | ||||||
|       <SectionTitle>Achievements</SectionTitle> |       <SectionTitle>Achievements</SectionTitle> | ||||||
|       {SOCIALLINKS.publications.map((link, index) => ( |       {SOCIALLINKS.publications.map((link, index) => ( | ||||||
|         <Link key={index} icon={link.icon} href={link.href}> |         <Link key={index} icon={link.icon} href={link.href} label={link.text}> | ||||||
|           {link.text} |           {link.text} | ||||||
|         </Link> |         </Link> | ||||||
|       ))} |       ))} | ||||||
|  | |||||||
| @ -2,9 +2,10 @@ export interface TooltipProps { | |||||||
|   children: React.ReactNode |   children: React.ReactNode | ||||||
|   label: string |   label: string | ||||||
|   position: 'top' | 'bottom' | 'left' | 'right' |   position: 'top' | 'bottom' | 'left' | 'right' | ||||||
|  |   additionalClass?: string | ||||||
| } | } | ||||||
|  |  | ||||||
| export const Tooltip: React.FC<TooltipProps> = ({ children, label, position }) => { | export const Tooltip: React.FC<TooltipProps> = ({ children, label, position, additionalClass }) => { | ||||||
|   const tooltipStyles = { |   const tooltipStyles = { | ||||||
|     top: 'bottom-full left-1/2 -translate-x-1/2', |     top: 'bottom-full left-1/2 -translate-x-1/2', | ||||||
|     bottom: 'top-full left-1/2 -translate-x-1/2', |     bottom: 'top-full left-1/2 -translate-x-1/2', | ||||||
| @ -12,7 +13,7 @@ export const Tooltip: React.FC<TooltipProps> = ({ children, label, position }) = | |||||||
|     right: 'left-full top-1/2 -translate-y-1/2', |     right: 'left-full top-1/2 -translate-y-1/2', | ||||||
|   } |   } | ||||||
|   const tooltipPosition: string = tooltipStyles[position] |   const tooltipPosition: string = tooltipStyles[position] | ||||||
|   const tooltipClass = `pointer-events-none absolute mt-2 whitespace-nowrap rounded bg-slate-800 px-2 py-1 text-xs text-slate-100 opacity-0 transition before:absolute before:left-1/2 before:top-full before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-slate-800 before:content-[''] group-hover:opacity-100 ${tooltipPosition}` |   const tooltipClass = `pointer-events-none absolute mt-2 whitespace-nowrap rounded bg-slate-800 px-2 py-1 text-xs text-slate-100 opacity-0 transition before:absolute before:left-1/2 before:top-full before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-slate-800 before:content-[''] group-hover:opacity-100 ${tooltipPosition} ${additionalClass}` | ||||||
|  |  | ||||||
|   return ( |   return ( | ||||||
|     <div className="group relative"> |     <div className="group relative"> | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user