ally: making categories drop-down & project cards keyboard navigatable

This commit is contained in:
MTG2000
2022-05-06 11:52:43 +03:00
parent dd172f1c86
commit dd2674a1d9
2 changed files with 15 additions and 6 deletions

View File

@@ -52,7 +52,6 @@ export default function NavDesktop() {
};
return (<nav className="bg-white w-full flex fixed h-[118px] top-0 left-0 py-36 px-32 items-center z-[2010]">
<a href="https://bolt.fun/">
<h2 className="text-h5 font-bold mr-40 lg:mr-64">
@@ -70,11 +69,16 @@ export default function NavDesktop() {
)}
<li
ref={categoriesRef}
className="relative cursor-pointer" onClick={() => toggleCategories(!categoriesOpen)}>
<p className='text-body4 hover:text-primary-600'>
className="relative"
>
<button
onClick={() => toggleCategories(!categoriesOpen)}
onKeyDown={e => (e.key !== 'Escape') || toggleCategories(false)}
className='text-body4 hover:text-primary-600 cursor-pointer'
>
<IoExtensionPuzzle className={`text-body2 inline-block mr-8 text-primary-600`} />
<span className="align-middle">Categories</span>
</p>
</button>
{<motion.div
initial={{ opacity: 0, y: 200, display: 'none' }}
animate={categoriesOpen ? {
@@ -94,7 +98,7 @@ export default function NavDesktop() {
}
}}
className="absolute top-full left-0 w-[256px] bg-white border border-primary-50 rounded-8 shadow-3xl">
<CategoriesList />
<CategoriesList onClick={() => toggleCategories(false)} />
</motion.div>}
</li>
</ul>

View File

@@ -10,7 +10,12 @@ interface Props {
export default function ProjectCardMini({ project, onClick }: Props) {
return (
<div className="bg-gray-25 select-none px-16 py-16 flex min-w-[296px] gap-16 border border-gray-200 rounded-10 hover:cursor-pointer hover:bg-gray-100" onClick={() => onClick(project.id)}>
<div
className="bg-gray-25 select-none px-16 py-16 flex min-w-[296px] gap-16 border border-gray-200 rounded-10 hover:cursor-pointer hover:bg-gray-100"
onClick={() => onClick(project.id)}
onKeyDown={e => e.key !== 'Enter' || onClick(project.id)}
tabIndex={0}
>
<img src={project.thumbnail_image} alt={project.title} draggable="false" className="flex-shrink-0 w-80 h-80 bg-gray-200 border-0 rounded-8"></img>
<div className="justify-around items-start min-w-0">
<p className="text-body4 w-full font-bold overflow-ellipsis overflow-hidden whitespace-nowrap">{project.title}</p>