feat(Header): make Header texts configurable

This commit is contained in:
Danny Koppenhagen
2021-10-26 20:24:24 +02:00
committed by Bastian
parent 9d2efc10d9
commit 887d4cd9c3
5 changed files with 11 additions and 8 deletions

View File

@@ -97,6 +97,7 @@
"publishedLabel": "Quadrant Overview" "publishedLabel": "Quadrant Overview"
}, },
"legalInformationLink": "https://www.aoe.com/en/imprint.html", "legalInformationLink": "https://www.aoe.com/en/imprint.html",
"search": "What are you looking for?", "searchLabel": "Search",
"searchPlaceholder": "What are you looking for?",
"revisionsText": "Revisions:" "revisionsText": "Revisions:"
} }

View File

@@ -97,6 +97,7 @@
"publishedLabel": "Quadrant Overview" "publishedLabel": "Quadrant Overview"
}, },
"legalInformationLink": "https://www.aoe.com/en/imprint.html", "legalInformationLink": "https://www.aoe.com/en/imprint.html",
"search": "What are you looking for?", "searchLabel": "Search",
"searchPlaceholder": "What are you looking for?",
"revisionsText": "Revisions:" "revisionsText": "Revisions:"
} }

View File

@@ -12,7 +12,7 @@ import { useMessages } from "../../context/MessagesContext";
export default function Header({ pageName }: { pageName: string }) { export default function Header({ pageName }: { pageName: string }) {
const [searchOpen, setSearchOpen] = useState(false); const [searchOpen, setSearchOpen] = useState(false);
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const { pageHelp } = useMessages(); const { searchLabel, pageHelp, pageOverview } = useMessages();
const history = useHistory(); const history = useHistory();
const searchRef = useRef<HTMLInputElement>(null); const searchRef = useRef<HTMLInputElement>(null);
@@ -55,20 +55,20 @@ export default function Header({ pageName }: { pageName: string }) {
<div className="nav__item"> <div className="nav__item">
<Link pageName="help-and-about-tech-radar" className="icon-link"> <Link pageName="help-and-about-tech-radar" className="icon-link">
<span className="icon icon--question icon-link__icon" /> <span className="icon icon--question icon-link__icon" />
How to Use {radarNameShort}? {pageHelp.headlinePrefix || 'How to use' } {radarNameShort}?
</Link> </Link>
</div> </div>
)} )}
<div className="nav__item"> <div className="nav__item">
<Link pageName="overview" className="icon-link"> <Link pageName="overview" className="icon-link">
<span className="icon icon--overview icon-link__icon" /> <span className="icon icon--overview icon-link__icon" />
Technologies Overview { pageOverview?.title || 'Technologies Overview' }
</Link> </Link>
</div> </div>
<div className="nav__item"> <div className="nav__item">
<button className="icon-link" onClick={handleOpenClick}> <button className="icon-link" onClick={handleOpenClick}>
<span className="icon icon--search icon-link__icon" /> <span className="icon icon--search icon-link__icon" />
Search { searchLabel || 'Search' }
</button> </button>
<div className={classNames("nav__search", { "is-open": searchOpen })}> <div className={classNames("nav__search", { "is-open": searchOpen })}>
<Search <Search

View File

@@ -19,7 +19,7 @@ function Search(
{ value, onChange, onClose, open = false, onSubmit = () => {} }: SearchProps, { value, onChange, onClose, open = false, onSubmit = () => {} }: SearchProps,
ref: any ref: any
) { ) {
const { searchPlaceholder } = useMessages(); const { searchLabel, searchPlaceholder } = useMessages();
const closable = onClose !== undefined; const closable = onClose !== undefined;
const handleSubmit = (e: FormEvent) => { const handleSubmit = (e: FormEvent) => {
@@ -52,7 +52,7 @@ function Search(
<span className={classNames("search__button", { "is-open": open })}> <span className={classNames("search__button", { "is-open": open })}>
<button type="submit" className="button"> <button type="submit" className="button">
<span className="icon icon--search button__icon" /> <span className="icon icon--search button__icon" />
Search { searchLabel }
</button> </button>
</span> </span>
{closable && ( {closable && (

View File

@@ -50,6 +50,7 @@ export interface Messages {
pageOverview?: PageOverview; pageOverview?: PageOverview;
pageItem?: PageItem; pageItem?: PageItem;
pageIndex?: PageIndex; pageIndex?: PageIndex;
searchLabel?: string;
searchPlaceholder?: string; searchPlaceholder?: string;
revisionsText?: string; revisionsText?: string;
} }