Skip to content
Merged
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
8 changes: 8 additions & 0 deletions src/components/mainPage/PromotionBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState, useRef } from "react";
import { useNavigate } from "react-router"; // [demo-day] 데모데이 끝나면 제거
import {
promotionBanner1,
promotionBanner2,
Expand All @@ -9,13 +10,15 @@ interface MainBannerProps {
id: number;
alt: string;
src: string;
link?: string; // [demo-day] 데모데이 끝나면 제거
}

const BANNERS: MainBannerProps[] = [
{
id: 1,
alt: "AI 사진 복원 프로모션 배너",
src: promotionBanner1,
link: "/demo-day", // [demo-day] 데모데이 끝나면 제거
},
{
id: 2,
Expand All @@ -30,6 +33,7 @@ const BANNERS: MainBannerProps[] = [
];

export default function PromotionBanner() {
const navigate = useNavigate(); // [demo-day] 데모데이 끝나면 제거
const [currentIndex, setCurrentIndex] = useState(0);
const scrollRef = useRef<HTMLDivElement>(null);

Expand All @@ -52,6 +56,10 @@ export default function PromotionBanner() {
<div
key={banner.id}
className="min-w-[calc(100%-3px)] shrink-0 snap-center"
// [demo-day] 아래 3줄 데모데이 끝나면 제거
onClick={banner.link ? () => navigate(banner.link!) : undefined}
role={banner.link ? "link" : undefined}
style={banner.link ? { cursor: "pointer" } : undefined}
Comment on lines +60 to +62
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

링크 역할을 하는 div 요소의 접근성을 개선하기 위해 키보드 탐색 및 실행 기능을 추가하는 것이 좋습니다.

  1. tabIndex="0"을 추가하여 키보드 사용자가 요소에 포커스할 수 있도록 합니다.
  2. onKeyDown 핸들러를 추가하여 'Enter' 또는 'Space' 키로 내비게이션을 트리거할 수 있게 합니다. 'Space' 키의 경우 e.preventDefault()를 호출하여 페이지 스크롤을 방지하는 것이 좋습니다.
  3. banner.link!의 non-null assertion(!)은 onClickbanner.link가 존재할 때만 할당되므로 불필요합니다.

아래와 같이 수정하는 것을 제안합니다.

(참고: 제안을 적용하시면 // [demo-day] 아래 3줄 데모데이 끝나면 제거 주석도 5줄로 업데이트해야 합니다.)

            onClick={banner.link ? () => navigate(banner.link) : undefined}
            onKeyDown={banner.link ? (e) => {
              if (e.key === "Enter" || e.key === " ") {
                e.preventDefault();
                navigate(banner.link);
              }
            } : undefined}
            role={banner.link ? "link" : undefined}
            tabIndex={banner.link ? 0 : undefined}
            style={banner.link ? { cursor: "pointer" } : undefined}

>
<div className="relative aspect-335/250 w-full overflow-hidden rounded-2xl">
<img
Expand Down