add search fx
This commit is contained in:
parent
c81443eff7
commit
2ecfe20416
@ -1,4 +1,4 @@
|
|||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import styles from "../styles/Home.module.css";
|
import styles from "../styles/Home.module.css";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
|
||||||
@ -14,7 +14,13 @@ export default function Home() {
|
|||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
setWeatherData({ ...data });
|
setWeatherData({ ...data });
|
||||||
console.log(data);
|
setInput("");
|
||||||
|
};
|
||||||
|
|
||||||
|
const something = (event) => {
|
||||||
|
if (event.keyCode === 13) {
|
||||||
|
clickHandler();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -41,13 +47,17 @@ export default function Home() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<input
|
<input
|
||||||
className={styles.search}
|
|
||||||
defaultValue="Search city"
|
|
||||||
type="text"
|
type="text"
|
||||||
|
className={styles.searchInput}
|
||||||
|
defaultValue="Search a city"
|
||||||
|
value={input}
|
||||||
onFocus={(e) => (e.target.value = "")}
|
onFocus={(e) => (e.target.value = "")}
|
||||||
onChange={(e) => setInput(e.target.value)}
|
onChange={(e) => setInput(e.target.value)}
|
||||||
|
onKeyDown={(e) => something(e)}
|
||||||
/>
|
/>
|
||||||
<button onClick={clickHandler}>Search</button>
|
<button className={styles.searchBtn} onClick={clickHandler}>
|
||||||
|
Search
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,24 @@
|
|||||||
font-size: 84px;
|
font-size: 84px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search {
|
.searchInput {
|
||||||
margin-top: 300px;
|
margin-top: 300px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
border-radius: 25px;
|
border-radius: 5px;
|
||||||
border: 1px solid rgb(209, 209, 252);
|
border: 2px solid rgb(80, 80, 80);
|
||||||
|
|
||||||
color: rgb(224, 237, 241);
|
background-color: #d3ddea;
|
||||||
|
padding: 0 10px;
|
||||||
|
color: #242424;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBtn {
|
||||||
|
background-color: limegreen;
|
||||||
|
width: 100px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 20px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
color: grey;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user