Skip to content
Snippets Groups Projects
Commit b6c5ff6f authored by Matthias Konitzny's avatar Matthias Konitzny :fire:
Browse files

Added close button to searchbar.

parent 41f905c2
No related branches found
No related tags found
1 merge request!3Master into new editor
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
flex-wrap: nowrap; flex-wrap: nowrap;
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
gap: 10px;
} }
.searchbar-input[type="search"] { .searchbar-input[type="search"] {
...@@ -15,13 +14,21 @@ ...@@ -15,13 +14,21 @@
outline: none; outline: none;
} }
.searchbar-icon-div { .searchbar-open-icon-div {
cursor: pointer; cursor: pointer;
opacity: 0.7; opacity: 0.7;
width: 30px; width: 30px;
height: 30px; height: 30px;
} }
.searchbar-close-icon-div {
cursor: pointer;
opacity: 0.7;
width: 18px;
margin-right: 10px;
margin-bottom: 2px;
}
.searchbar-icon { .searchbar-icon {
max-width: 100%; max-width: 100%;
transition: all 0.5s; transition: all 0.5s;
...@@ -32,7 +39,6 @@ ...@@ -32,7 +39,6 @@
} }
.searchbar-form { .searchbar-form {
margin-right: 10px;
} }
.searchbar-text { .searchbar-text {
......
...@@ -2,6 +2,7 @@ import React, { useEffect, useRef, useState } from "react"; ...@@ -2,6 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
import "./searchbar.css"; import "./searchbar.css";
import searchicon from "./search_icon.svg"; import searchicon from "./search_icon.svg";
import closeicon from "./close_icon.svg";
import { NodeData } from "../../common/graph"; import { NodeData } from "../../common/graph";
interface SearchBarProps { interface SearchBarProps {
...@@ -26,6 +27,12 @@ function SearchBar({ ...@@ -26,6 +27,12 @@ function SearchBar({
setMinified((prev) => !prev); setMinified((prev) => !prev);
}; };
const clearInput = () => {
setInputText("");
inputField.current.value = "";
inputField.current.focus();
};
useEffect(() => { useEffect(() => {
if (isMinified) { if (isMinified) {
setWidth(0); setWidth(0);
...@@ -61,7 +68,10 @@ function SearchBar({ ...@@ -61,7 +68,10 @@ function SearchBar({
style={{ backgroundColor: isMinified ? "" : "white" }} style={{ backgroundColor: isMinified ? "" : "white" }}
> >
<div className={"searchbar"}> <div className={"searchbar"}>
<div className={"searchbar-icon-div"} onClick={toggleMinified}> <div
className={"searchbar-open-icon-div"}
onClick={toggleMinified}
>
<img <img
className={`searchbar-icon ${ className={`searchbar-icon ${
isMinified ? "searchbar-icon-white" : "" isMinified ? "searchbar-icon-white" : ""
...@@ -70,7 +80,6 @@ function SearchBar({ ...@@ -70,7 +80,6 @@ function SearchBar({
alt={"Searchbar"} alt={"Searchbar"}
/> />
</div> </div>
<div></div>
<div <div
className={"searchbar-text"} className={"searchbar-text"}
style={{ width: width + "%" }} style={{ width: width + "%" }}
...@@ -89,6 +98,18 @@ function SearchBar({ ...@@ -89,6 +98,18 @@ function SearchBar({
</form> </form>
)} )}
</div> </div>
{!isMinified && (
<div
className={"searchbar-close-icon-div"}
onClick={clearInput}
>
<img
className={"searchbar-icon"}
src={closeicon}
alt={"Close"}
/>
</div>
)}
</div> </div>
<div className={"searchbar-results"}> <div className={"searchbar-results"}>
{filtered.map((el) => ( {filtered.map((el) => (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment