Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

chore: add placeholder props for the HeaderSearchBar component #2313

Merged
merged 5 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("HeaderSearchBar", () => {

fireEvent.click(getByTestId("header-search-bar__button"));

const input = getByTestId("Input");
const input = getByTestId("Input") as HTMLInputElement;

act(() => {
fireEvent.change(input, {
Expand Down
9 changes: 7 additions & 2 deletions src/app/components/Header/HeaderSearchBar/HeaderSearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { clickOutsideHandler, useDebounce } from "app/hooks";
import React, { useEffect, useRef, useState } from "react";

type HeaderSearchBarProps = {
placeholder?: string;
children?: React.ReactNode;
onSearch?: any;
};

export const HeaderSearchBar = ({ children, onSearch }: HeaderSearchBarProps) => {
export const HeaderSearchBar = ({ placeholder, children, onSearch }: HeaderSearchBarProps) => {
const [searchbarVisible, setSearchbarVisible] = useState(false);
const [query, setQuery] = useState("");

Expand Down Expand Up @@ -60,7 +61,7 @@ export const HeaderSearchBar = ({ children, onSearch }: HeaderSearchBarProps) =>
<div className="flex-1 mx-4">
<Input
className="border-none shadow-none"
placeholder="Search..."
placeholder={placeholder}
value={query}
onChange={(e) => setQuery((e.target as HTMLInputElement).value)}
/>
Expand All @@ -72,3 +73,7 @@ export const HeaderSearchBar = ({ children, onSearch }: HeaderSearchBarProps) =>
</>
);
};

HeaderSearchBar.defaultProps = {
placeholder: "Search...",
};