Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/app/rewards/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ export default function RewardsPage() {
try {
await claim(claimableId);
addToast("Reward claimed successfully!", "success");
} catch (err) {
} catch {
addToast("Failed to claim reward. Please try again.", "error");
throw err;
}
};

Expand Down
6 changes: 0 additions & 6 deletions src/app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
changeFrequency: "daily",
priority: 0.9,
},
{
url: `${SITE_URL}/connect`,
lastModified: new Date(),
changeFrequency: "monthly",
priority: 0.5,
},
];

let courseRoutes: MetadataRoute.Sitemap = [];
Expand Down
30 changes: 23 additions & 7 deletions src/components/course/course-card.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { memo } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import Image from "next/image";
import { cn } from "@/lib/utils/cn";
import { Card, CardContent, CardFooter } from "@/components/ui/card";
Expand Down Expand Up @@ -44,19 +44,36 @@ export const CourseCard = memo(function CourseCard({
onContinue,
className,
}: CourseCardProps) {
const router = useRouter();

const handleNavigate = () => {
router.push(`/courses/${course.id}`);
};

const handleCardKeyDown = (e: React.KeyboardEvent) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
handleNavigate();
}
};

const handleEnroll = (e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
onEnroll?.(course.id);
};

const handleContinue = (e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
onContinue?.(course.id);
};

return (
<Link href={`/courses/${course.id}`}>
<Card
role="link"
tabIndex={0}
aria-label={course.title}
onClick={handleNavigate}
onKeyDown={handleCardKeyDown}
className={cn(
"group cursor-pointer transition-all hover:shadow-lg hover:-translate-y-1",
className,
Expand Down Expand Up @@ -107,9 +124,9 @@ export const CourseCard = memo(function CourseCard({

<div
className="absolute top-2 right-2"
onClick={(e) => e.preventDefault()}
onClick={(e) => e.stopPropagation()}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") e.preventDefault();
if (e.key === "Enter" || e.key === " ") e.stopPropagation();
}}
>
<DropdownMenu>
Expand Down Expand Up @@ -192,6 +209,5 @@ export const CourseCard = memo(function CourseCard({
)}
</CardFooter>
</Card>
</Link>
);
});
38 changes: 38 additions & 0 deletions src/components/wallet/connect-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,48 @@ export function ConnectButton() {
const [showMainnetConfirm, setShowMainnetConfirm] = useState(false);
const dropdownRef = useRef<HTMLDivElement>(null);
const triggerRef = useRef<HTMLButtonElement>(null);
const menuRef = useRef<HTMLDivElement>(null);

const closeDropdown = useCallback(() => {
setShowDropdown(false);
triggerRef.current?.focus();
}, []);

const getMenuItems = useCallback(() => {
if (!menuRef.current) return [];
return Array.from(
menuRef.current.querySelectorAll<HTMLElement>('[role="menuitem"]')
);
}, []);

const handleMenuKeyDown = (e: React.KeyboardEvent) => {
const items = getMenuItems();
if (items.length === 0) return;

const currentIndex = items.findIndex(
(item) => item === document.activeElement
);

switch (e.key) {
case "ArrowDown":
e.preventDefault();
items[(currentIndex + 1 + items.length) % items.length].focus();
break;
case "ArrowUp":
e.preventDefault();
items[(currentIndex - 1 + items.length) % items.length].focus();
break;
case "Home":
e.preventDefault();
items[0].focus();
break;
case "End":
e.preventDefault();
items[items.length - 1].focus();
break;
}
};

useEffect(() => {
if (!showDropdown) return;

Expand Down Expand Up @@ -116,8 +152,10 @@ export function ConnectButton() {

{showDropdown && (
<div
ref={menuRef}
className="absolute right-0 top-full mt-2 w-56 rounded-xl border border-gray-200 bg-white p-1.5 shadow-xl z-50 dark:border-gray-800 dark:bg-gray-900"
role="menu"
onKeyDown={handleMenuKeyDown}
>
<div className="px-3 py-2 border-b border-gray-100 dark:border-gray-800">
<div className="text-xs text-gray-400 font-medium">Connected Wallet</div>
Expand Down
Loading