components#InputSearch TypeScript Examples

The following examples show how to use components#InputSearch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.page.tsx    From webapis-playground with MIT License 5 votes vote down vote up
export default function Home() {
  const { demos, searchText, setSearchText } = useSearchApi();

  const handleChange = ({
    target: { value },
  }: ChangeEvent<HTMLInputElement>) => {
    setSearchText(value);
  };

  const handleClear = () => {
    setSearchText('');
  };

  return (
    <>
      <InputSearch
        placeholder="Search by API names"
        value={searchText}
        onClear={handleClear}
        onChange={handleChange}
      />

      {demos.length ? (
        <div
          className="
            tw-w-full
            tw-max-w-container
            tw-m-auto
            tw-mt-4
            md:tw-mt-8
            tw-grid
            tw-grid-cols-1
            tw-gap-4
            md:tw-grid-cols-2
            lg:tw-grid-cols-3
            xl:tw-grid-cols-4
          "
        >
          {demos.map((demo: Demo, index: number) => (
            <Card data={demo} key={index} />
          ))}
        </div>
      ) : (
        <div className="not-found">{NOT_FOUND_TEXT}</div>
      )}
    </>
  );
}