edit error scr

This commit is contained in:
madarsbiss 2021-09-21 22:05:40 +03:00
parent e4dcd3183b
commit 729f98f68f
4 changed files with 13 additions and 31 deletions

View File

@ -1,16 +1,10 @@
import styles from "./ErrorScreen.module.css"; import styles from "./ErrorScreen.module.css";
const ErrorScreen = ({ onFocus, onChange, onKeyDown }) => { const ErrorScreen = ({ errorMessage, children }) => {
return ( return (
<div className={styles.wrapper}> <div className={styles.wrapper}>
<h1 className={styles.message}>City not found, try again!</h1> <h1 className={styles.message}>{errorMessage}</h1>
<input {children}
type="text"
className={styles.input}
onFocus={onFocus}
onChange={onChange}
onKeyDown={onKeyDown}
/>
</div> </div>
); );
}; };

View File

@ -8,17 +8,3 @@
.message { .message {
margin-bottom: 30px; margin-bottom: 30px;
} }
.input {
max-width: 100%;
margin-bottom: 20px;
height: 40px;
border: none;
padding: 0 10px;
color: #303030;
font-size: 20px;
text-align: right;
border-radius: 10px;
font-family: "Varela Round", sans-serif;
font-size: 18px;
}

View File

@ -1,9 +1,9 @@
import styles from "./LoadingScreen.module.css"; import styles from "./LoadingScreen.module.css";
const LoadingScreen = () => { const LoadingScreen = ({ loadingMessage }) => {
return ( return (
<div className={styles.wrapper}> <div className={styles.wrapper}>
<h1>Loading data...</h1> <h1>{loadingMessage}</h1>
</div> </div>
); );
}; };

View File

@ -74,13 +74,15 @@ const App = () => {
</div> </div>
</div> </div>
) : weatherData && weatherData.message ? ( ) : weatherData && weatherData.message ? (
<ErrorScreen <ErrorScreen errorMessage="City not found, try again!">
onFocus={(e) => (e.target.value = "")} <Search
onChange={(e) => setInput(e.target.value)} onFocus={(e) => (e.target.value = "")}
onKeyDown={(e) => enterKeydown(e)} onChange={(e) => setInput(e.target.value)}
/> onKeyDown={(e) => enterKeydown(e)}
/>
</ErrorScreen>
) : ( ) : (
<LoadingScreen /> <LoadingScreen loadingMessage="Loading data..." />
); );
}; };