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
2 changes: 1 addition & 1 deletion a11y/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="ko">

<head>
<meta charset="UTF-8" />
Expand Down
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: 40 additions & 5 deletions a11y/src/components/FlightBooking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,30 @@ const MAX_PASSENGERS = 3;

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

const incrementCount = () => {
setAdultCount((prev) => Math.min(MAX_PASSENGERS, prev + 1));
setAdultCount((prev) => {
const newCount = Math.min(MAX_PASSENGERS, prev + 1);
if (newCount === MAX_PASSENGERS && prev < MAX_PASSENGERS) {
setStatusMessage(`최대 ${MAX_PASSENGERS}명까지 선택할 수 있습니다.`);
} else {
setStatusMessage("");
}
return newCount;
});
};

const decrementCount = () => {
setAdultCount((prev) => Math.max(1, prev - 1));
setAdultCount((prev) => {
const newCount = Math.max(1, prev - 1);
if (newCount === 1 && prev > 1) {
setStatusMessage("최소 1명은 선택해야 합니다.");
} else {
setStatusMessage("");
}
return newCount;
});
};

return (
Expand All @@ -21,15 +38,33 @@ const FlightBooking = () => {
<div className="passenger-count">
<span className="body-text">성인</span>
<div className="counter">
<button className="button-text" onClick={decrementCount}>
<button
className="button-text"
onClick={decrementCount}
aria-label="성인 승객 감소"
>
-
</button>
<span>{adultCount}</span>
<button className="button-text" onClick={incrementCount}>
<span aria-live="polite">{adultCount}</span>
<button
className="button-text"
onClick={incrementCount}
aria-label="성인 승객 증가"
>
+
</button>
</div>
</div>
{statusMessage && (
<div
className="status-message"
aria-live="polite"
aria-atomic="true"
role="status"
>
{statusMessage}
</div>
)}
<button className="search-button">항공편 검색</button>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions a11y/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
host: "0.0.0.0",
},
});