feat(Search): make search placeholder text configurable

This commit is contained in:
Danny Koppenhagen
2021-10-26 19:44:09 +02:00
committed by Bastian
parent c8a3b528b8
commit 1f01f6ccb6
4 changed files with 8 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import React, { FormEvent } from "react";
import { useMessages } from "../../context/MessagesContext";
import classNames from "classnames";
import "./search.scss";
@@ -18,6 +19,7 @@ function Search(
{ value, onChange, onClose, open = false, onSubmit = () => {} }: SearchProps,
ref: any
) {
const { searchPlaceholder } = useMessages();
const closable = onClose !== undefined;
const handleSubmit = (e: FormEvent) => {
@@ -44,7 +46,7 @@ function Search(
onChange(e.target.value);
}}
className="search__field"
placeholder="What are you looking for?"
placeholder={searchPlaceholder}
ref={ref}
/>
<span className={classNames("search__button", { "is-open": open })}>

View File

@@ -32,6 +32,7 @@ export interface Messages {
socialLinks?: SocialLink[];
legalInformationLink?: string;
pageHelp?: PageHelp;
searchPlaceholder?: string;
}
const MessagesContext = createContext<Messages | undefined>(undefined);