Add Select/index.tsx, Select/Filter.tsx

This commit is contained in:
0x1eef 2024-04-26 22:23:45 -03:00
parent 12a5d51ab1
commit 935643cff2
2 changed files with 25 additions and 22 deletions

View file

@ -0,0 +1,24 @@
import React from "react";
type Props = {
onTextChange: (text: string) => void;
placeholder: string;
};
export function Filter({ onTextChange, placeholder }: Props) {
return (
<input
type="text"
className="p-3 rounded border-secondary border-solid outline-none"
autoFocus={true}
placeholder={placeholder}
onClick={e => e.stopPropagation()}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
const {
target: { value: text },
} = e;
onTextChange(text);
}}
/>
);
}

View file

@ -1,4 +1,5 @@
import { ReactNode, useState, useEffect } from "react";
import { Filter } from "./Filter";
const LI_CLASSNAME = [
"flex",
@ -112,25 +113,3 @@ export const Select = ({
</ul>
);
};
type FilterProps = {
onTextChange: (text: string) => void;
placeholder: string;
};
function Filter({ onTextChange, placeholder }: FilterProps) {
return (
<input
type="text"
className="p-3 rounded border-secondary border-solid outline-none"
autoFocus={true}
placeholder={placeholder}
onClick={e => e.stopPropagation()}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
const {
target: { value: text },
} = e;
onTextChange(text);
}}
/>
);
}