diff --git a/src/App.js b/src/App.js index 2ef583a..2bb7f61 100644 --- a/src/App.js +++ b/src/App.js @@ -2,6 +2,8 @@ import './App.css'; import DeriveCard from './deriveCard'; import TextInput2 from './Components/TextInput2' +import TextInputSelect from './Components/TextInputSelect'; + import Dropdown from './Components/DropdownButton/Dropdown'; function App() { const options = [ @@ -196,15 +198,12 @@ const menuItems = [
Text Input
-
- -
-
- +
+
); } -export default App; +export default App; \ No newline at end of file diff --git a/src/Components/TextInputSelect.jsx b/src/Components/TextInputSelect.jsx new file mode 100644 index 0000000..cc21f1e --- /dev/null +++ b/src/Components/TextInputSelect.jsx @@ -0,0 +1,61 @@ +import { useState, useEffect, useRef } from 'react'; +import {FaRegWindowClose} from 'react-icons/fa' +import './DropdownButton/scrollbar.css'; +let arrSelected = []; +const TextInputSelect = ({ options }) => { + const [search, setSearch] = useState(''); + const [open, setOpen] = useState(false); + const [selected, setSelected] = useState(arrSelected); + console.log('renders'); + console.log(search); + + return ( +
+
+ setSearch(e.target.value)} + onFocus={() => { + setOpen(true); + }} + onBlur={() => { + setTimeout(() => setOpen(false), 200) + }} + value={search} + /> + +
+ {open &&
+ { + options.filter((item, i) => { + if (search === "") { + return item; + } else if (item.title.toLowerCase().includes(search.toLowerCase())) { + return item; + } + return null; + }).map((item, i) => { + return ( +
+ {

{ arrSelected.push(item.title); setSelected(arrSelected) }}>{item.title}

} +
+ ) + }) + } +
} +
+
    + { + selected.map((select, i) => { + return
  • {select} {arrSelected.splice(i,1);setSelected([...arrSelected]); }}>
  • + }) + } +
+
+
+ ); + +} + +export default TextInputSelect; \ No newline at end of file