-
Notifications
You must be signed in to change notification settings - Fork 3
feat(hackathons): tabs en la página de detalle + ajustes de timeline y datos #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| "use client"; | ||
|
|
||
| import { useState, type ReactNode } from "react"; | ||
| import { FolderGit2, Info, Trophy } from "lucide-react"; | ||
| import { cn } from "@/lib/cn"; | ||
| import { isDevMode } from "@/lib/devMode"; | ||
| import { | ||
| HackathonTabContext, | ||
| type HackathonTabId, | ||
| } from "@/lib/hackathonTabsContext"; | ||
|
|
||
| const TABS: { id: HackathonTabId; label: string; icon: typeof FolderGit2 }[] = [ | ||
| { id: "proyectos", label: "Proyectos", icon: FolderGit2 }, | ||
| { id: "resultados", label: "Resultados", icon: Trophy }, | ||
| { id: "datos", label: "Datos", icon: Info }, | ||
| ]; | ||
|
|
||
| /** | ||
| * Splits the hackathon detail page into three panels (Proyectos / Resultados / | ||
| * Datos), all server-rendered server-side and passed in as slots — only the | ||
| * active one is visually shown (the others stay mounted but `hidden`, so the | ||
| * voting subscriptions and project scan inside them don't restart on every tab | ||
| * switch). Provides `HackathonTabContext` so a CTA inside one panel (e.g. "Ver | ||
| * resultados" inside Resultados) can switch to another panel before scrolling | ||
| * to an element that lives there. | ||
| */ | ||
| export default function HackathonTabs({ | ||
| proyectos, | ||
| resultados, | ||
| datos, | ||
| defaultTab = "proyectos", | ||
| projectsCount, | ||
| votingOpen, | ||
| }: { | ||
| proyectos: ReactNode; | ||
| resultados: ReactNode; | ||
| datos: ReactNode; | ||
| defaultTab?: HackathonTabId; | ||
| projectsCount: number; | ||
| votingOpen: boolean; | ||
| }) { | ||
| const [tab, setTab] = useState<HackathonTabId>(defaultTab); | ||
|
|
||
| return ( | ||
| <HackathonTabContext.Provider value={{ tab, setTab }}> | ||
| <div | ||
| className={cn( | ||
| "sticky z-20 border-y border-border bg-background/90 backdrop-blur-sm", | ||
| // Stick right below the fixed navbar — which itself sits lower when | ||
| // the DEV MODE bar (32px) is present (see Navbar.tsx). | ||
| isDevMode() ? "top-24" : "top-16", | ||
| )} | ||
| > | ||
| <div className="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8"> | ||
| <div | ||
| role="tablist" | ||
| aria-label="Secciones del hackatón" | ||
| className="no-scrollbar flex items-center gap-1 overflow-x-auto py-2.5" | ||
| > | ||
| {TABS.map(({ id, label, icon: Icon }) => { | ||
| const active = tab === id; | ||
| return ( | ||
| <button | ||
| key={id} | ||
| type="button" | ||
| role="tab" | ||
| aria-selected={active} | ||
| onClick={() => setTab(id)} | ||
| className={cn( | ||
| "relative inline-flex shrink-0 items-center gap-1.5 rounded-xl px-4 py-2 text-xs font-mono font-bold uppercase tracking-widest transition-colors", | ||
| active | ||
| ? "bg-white/[0.07] text-foreground" | ||
| : "text-foreground-muted hover:bg-white/[0.03] hover:text-foreground", | ||
| )} | ||
| > | ||
| <Icon className="h-3.5 w-3.5" /> | ||
| {label} | ||
| {id === "proyectos" && projectsCount > 0 && ( | ||
| <span className="text-foreground-subtle"> | ||
| {projectsCount} | ||
| </span> | ||
| )} | ||
| {id === "resultados" && votingOpen && ( | ||
| <span className="relative flex h-1.5 w-1.5"> | ||
| <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-success/70" /> | ||
| <span className="relative inline-flex h-1.5 w-1.5 rounded-full bg-success" /> | ||
| </span> | ||
| )} | ||
| </button> | ||
| ); | ||
| })} | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className={cn(tab === "proyectos" ? "block" : "hidden")}> | ||
| {proyectos} | ||
| </div> | ||
| <div className={cn(tab === "resultados" ? "block" : "hidden")}> | ||
| {resultados} | ||
| </div> | ||
| <div className={cn(tab === "datos" ? "block" : "hidden")}>{datos}</div> | ||
| </HackathonTabContext.Provider> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Keydown bubbles past the stopPropagation guards, causing unintended card navigation from nested controls.
stopPropagationis only applied toonClickon the chip (Line 557) and CTA (Line 623) wrappers, not to keyboard events. A nativekeydownevent fired on any nested focusable element — theInfoChipbuttons, the inscription button, or the "Ver detalle"Link— still bubbles up to the outer<div>'sonKeyDownhandler at Lines 504-506, which unconditionally callsrouter.pushon Enter. So keyboard users pressing Enter on any nested control (tags tooltip trigger, difficulty chip, "Ver detalle") also trigger the card's own navigation, on top of (or instead of) the nested control's intended action.🔧 Proposed fix: guard against nested-target key events
<div role="link" tabIndex={0} - onClick={() => router.push(`/hackathons/${h.slug}`)} - onKeyDown={(e) => { - if (e.key === "Enter") router.push(`/hackathons/${h.slug}`); - }} + onClick={(e) => { + if (e.target === e.currentTarget) router.push(`/hackathons/${h.slug}`); + }} + onKeyDown={(e) => { + if (e.key === "Enter" && e.target === e.currentTarget) { + router.push(`/hackathons/${h.slug}`); + } + }}And add
onKeyDown={(e) => e.stopPropagation()}alongside the existingonClick={(e) => e.stopPropagation()}on the chip (Line 557) and CTA (Line 623) wrapperdivs.Also applies to: 554-559, 620-625
🤖 Prompt for AI Agents