From 2ecfe20416d24f9eae96acdae228b887791325f9 Mon Sep 17 00:00:00 2001 From: madarsbiss Date: Sat, 17 Jul 2021 15:05:56 +0300 Subject: [PATCH] add search fx --- pages/index.js | 20 +++++++++++++++----- styles/Home.module.css | 20 +++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/pages/index.js b/pages/index.js index 457c239..37f275c 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import styles from "../styles/Home.module.css"; import Image from "next/image"; @@ -14,7 +14,13 @@ export default function Home() { }); const data = await res.json(); setWeatherData({ ...data }); - console.log(data); + setInput(""); + }; + + const something = (event) => { + if (event.keyCode === 13) { + clickHandler(); + } }; return ( @@ -41,13 +47,17 @@ export default function Home() { )} (e.target.value = "")} onChange={(e) => setInput(e.target.value)} + onKeyDown={(e) => something(e)} /> - + ); } diff --git a/styles/Home.module.css b/styles/Home.module.css index a5664c7..1f3d0af 100644 --- a/styles/Home.module.css +++ b/styles/Home.module.css @@ -16,14 +16,24 @@ font-size: 84px; } -.search { +.searchInput { margin-top: 300px; height: 40px; width: 300px; - border-radius: 25px; - border: 1px solid rgb(209, 209, 252); + border-radius: 5px; + 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; - color: grey; }