Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[사전 미션 - 워밍업] - 썬데이(김유선) 미션 제출합니다. #30

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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>
19 changes: 11 additions & 8 deletions a11y/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import "./Typography.css";
import "./App.css";
import './Typography.css';
import './App.css';

import FlightBooking from "./components/FlightBooking";
import FlightBooking from './components/FlightBooking';

function App() {
return (
<div className="app">
<div className="app-main">
<div className="flight-booking-container">
<div className='app'>
<main className='app-main'>
<article className='flight-booking-container'>
<header>
<h1 className='heading-1-text'>Wooteco Air</h1>
</header>
<FlightBooking />
</div>
</div>
</article>
</main>
</div>
);
}
Expand Down
13 changes: 12 additions & 1 deletion a11y/src/components/FlightBooking.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
width: 30px;
height: 30px;
border-radius: 16px;
border: 1px solid #C0C0C0;
border: 1px solid #c0c0c0;
background-color: #fff;
cursor: pointer;
display: flex;
Expand All @@ -61,3 +61,14 @@
border-radius: 4px;
cursor: pointer;
}

.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
55 changes: 43 additions & 12 deletions a11y/src/components/FlightBooking.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
import { useState } from "react";
import { useState } from 'react';

import "./FlightBooking.css";
import './FlightBooking.css';

const MAX_PASSENGERS = 3;

const FlightBooking = () => {
const [adultCount, setAdultCount] = useState(1);
const [alertMessage, setAlertMessage] = useState('');

const updateAlert = (message: string) => {
setAlertMessage('');
setTimeout(() => {
setAlertMessage(message);
}, 0);
};

const incrementCount = () => {
if (adultCount === MAX_PASSENGERS) {
updateAlert('최대 승객 수에 도달하였습니다.');
return;
}

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

const decrementCount = () => {
if (adultCount === 1) {
updateAlert('최소 승객 수에 도달하였습니다.');
return;
}

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

return (
<div className="flight-booking">
<h2 className="heading-2-text">항공권 예매</h2>
<div className="passenger-count">
<span className="body-text">성인</span>
<div className="counter">
<button className="button-text" onClick={decrementCount}>
<section className='flight-booking'>
<h2 className='heading-2-text'>항공권 예매</h2>
<div className='passenger-count'>
<span className='body-text'>성인</span>
<div className='counter'>
<button
aria-label='성인 승객 감소'
className='button-text'
onClick={decrementCount}
>
-
</button>
<span>{adultCount}</span>
<button className="button-text" onClick={incrementCount}>
<span aria-live='polite'>{adultCount}</span>
<button
aria-label='성인 승객 증가'
className='button-text'
onClick={incrementCount}
>
+
</button>
</div>
</div>
<button className="search-button">항공편 검색</button>
</div>
<button className='search-button'>항공편 검색</button>
{alertMessage && (
<div className='visually-hidden' role='alert'>
{alertMessage}
</div>
)}
</section>
);
};

Expand Down