Skip to content
Open
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
26 changes: 12 additions & 14 deletions a11y/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Accessibility</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Accessibility</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --host",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
Expand Down
11 changes: 11 additions & 0 deletions a11y/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@
.flight-booking-container {
padding: 26px 24px;
}
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
8 changes: 4 additions & 4 deletions a11y/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import FlightBooking from "./components/FlightBooking";
function App() {
return (
<div className="app">
<div className="app-main">
<div className="flight-booking-container">
<main className="app-main">
<section className="flight-booking-container">
<FlightBooking />
</div>
</div>
</section>
</main>
</div>
);
}
Expand Down
45 changes: 42 additions & 3 deletions a11y/src/components/FlightBooking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,65 @@ const MAX_PASSENGERS = 3;

const FlightBooking = () => {
const [adultCount, setAdultCount] = useState(1);
const [statusMessage, setStatusMessage] = useState("");

const incrementCount = () => {
if (adultCount === MAX_PASSENGERS) {
setStatusMessage("최대 승객 수에 도달했습니다");
return;
}
setTimeout(() => {
setStatusMessage("");
}, 500);

setAdultCount((prev) => Math.min(MAX_PASSENGERS, prev + 1));
};

const decrementCount = () => {
if (adultCount === 1) {
setStatusMessage("최소 승객 수에 도달했습니다");
return;
}
setTimeout(() => {
setStatusMessage("");
}, 500);

setAdultCount((prev) => Math.max(1, prev - 1));
};

return (
<div className="flight-booking">
<h2 className="heading-2-text">항공권 예매</h2>
<div className="passenger-count">
{statusMessage && (
<div id="status-message" className="visually-hidden" role="alert">
{statusMessage}
</div>
)}

<span className="body-text">성인</span>
<div className="counter">
<button className="button-text" onClick={decrementCount}>
<button
className="button-text"
onClick={decrementCount}
disabled={adultCount === 1}
aria-label={`성인 인원 감소 (현재 ${adultCount}명${
adultCount === 1 ? ", 최소 인원" : ""
})`}
aria-describedby="status-message"
>
-
</button>
<span>{adultCount}</span>
<button className="button-text" onClick={incrementCount}>
<span aria-live="polite">{adultCount}</span>
<button
className="button-text"
onClick={incrementCount}
disabled={adultCount === MAX_PASSENGERS}
aria-label={`성인 인원 증가 (현재 ${adultCount}명${
adultCount === MAX_PASSENGERS ? ", 최대 인원" : ""
})`}
aria-describedby="status-message"
>
+
</button>
</div>
Expand Down