-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from useon/step1
[항공사 웹사이트의 컴포넌트 접근성 높이기] 썬데이(김유선) 미션 제출합니다.
- Loading branch information
Showing
21 changed files
with
235 additions
and
102 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,15 +1,13 @@ | ||
<!doctype html> | ||
<!DOCTYPE html> | ||
<html lang="ko"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>항공권 예약 및 여행 정보 | 썬데이 항공</title> | ||
</head> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>React App</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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,98 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
|
||
import close from '../../assets/close.svg'; | ||
|
||
import styles from './PromotionModal.module.css'; | ||
|
||
const PromotionModal = () => { | ||
const [isOpen, setIsOpen] = useState(true); | ||
const modalRef = useRef<HTMLDivElement>(null); | ||
const closeButtonRef = useRef<HTMLButtonElement>(null); | ||
|
||
const closeModal = () => { | ||
setIsOpen(false); | ||
}; | ||
|
||
useEffect(() => { | ||
if (isOpen && modalRef.current) { | ||
const previouslyFocusedElement = document.activeElement as HTMLElement; | ||
closeButtonRef.current?.focus(); | ||
|
||
const handleKeyDown = (e: KeyboardEvent) => { | ||
if (e.key === 'Escape') { | ||
closeModal(); | ||
} | ||
|
||
const focusableElements = modalRef.current?.querySelectorAll<HTMLElement>( | ||
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])' | ||
); | ||
if (!focusableElements) return; | ||
const firstFocusableElement = focusableElements[0]; | ||
const lastFocusableElement = focusableElements[focusableElements.length - 1]; | ||
|
||
if (e.key === 'Tab') { | ||
if (e.shiftKey) { | ||
if (document.activeElement === firstFocusableElement) { | ||
lastFocusableElement.focus(); | ||
e.preventDefault(); | ||
} | ||
} else { | ||
if (document.activeElement === lastFocusableElement) { | ||
firstFocusableElement.focus(); | ||
e.preventDefault(); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
document.addEventListener('keydown', handleKeyDown); | ||
|
||
return () => { | ||
document.removeEventListener('keydown', handleKeyDown); | ||
previouslyFocusedElement?.focus(); | ||
}; | ||
} | ||
}, [isOpen]); | ||
|
||
if (!isOpen) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<section | ||
className={styles.modal} | ||
role="dialog" | ||
aria-modal="true" | ||
aria-labelledby="modal-title" | ||
aria-live="assertive" | ||
ref={modalRef} | ||
> | ||
<div className="visually-hidden"> | ||
모달 창이 열렸습니다. 닫기 버튼 또는 esc 버튼을 눌러 이 창을 닫을 수 있습니다. | ||
</div> | ||
<div className={styles.modalBackdrop} onClick={closeModal}></div> | ||
<div className={styles.modalContainer}> | ||
<section className={styles.modalContent}> | ||
<h2 id="modal-title" className={`${styles.modalTitle} heading-2-text`}> | ||
여행할 땐 SUNDAY AIRLINE 앱 | ||
</h2> | ||
<p className={`${styles.modalDescription} body-text`}> | ||
체크인, 탑승권 저장, 수하물 알림까지 | ||
<br />- 앱으로 더욱 편하게 여행하세요! | ||
</p> | ||
<button className={`${styles.modalActionButton} button-text`}>앱에서 열기</button> | ||
<button | ||
ref={closeButtonRef} | ||
className={`${styles.modalCloseButton} heading-2-text`} | ||
onClick={closeModal} | ||
aria-label="닫기" | ||
> | ||
<img src={close} alt="닫기" /> | ||
</button> | ||
</section> | ||
</div> | ||
</section> | ||
); | ||
}; | ||
|
||
export default PromotionModal; |
This file contains 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,24 @@ | ||
.skipLink { | ||
position: absolute; | ||
transform: translateY(-40px); | ||
left: 0; | ||
background-color: #007bff; | ||
color: #fff; | ||
padding: 8px 16px; | ||
z-index: 100; | ||
border-radius: 4px; | ||
border: none; | ||
text-decoration: none; | ||
transition: transform 0.3s ease-in-out; | ||
clip: rect(1px, 1px, 1px, 1px); | ||
overflow: hidden; | ||
height: 1px; | ||
width: 1px; | ||
} | ||
|
||
.skipLink:focus { | ||
clip: auto; | ||
transform: translateY(0); | ||
height: auto; | ||
width: auto; | ||
} |
This file contains 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,15 @@ | ||
import styles from './SkipToContent.module.css'; | ||
|
||
interface SkipToContentProps { | ||
linkTarget?: string; | ||
} | ||
|
||
const SkipToContent = ({ linkTarget = '#main-content' }: SkipToContentProps) => { | ||
return ( | ||
<a href={linkTarget} className={styles.skipLink}> | ||
Skip to content | ||
</a> | ||
); | ||
}; | ||
|
||
export default SkipToContent; |
This file contains 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
Oops, something went wrong.