Skip to content

Commit

Permalink
feat(Header): make Header texts configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
d-koppenhagen authored and bastianccm committed Nov 10, 2021
1 parent 9d2efc1 commit 887d4cd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion messages_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"publishedLabel": "Quadrant Overview"
},
"legalInformationLink": "https://www.aoe.com/en/imprint.html",
"search": "What are you looking for?",
"searchLabel": "Search",
"searchPlaceholder": "What are you looking for?",
"revisionsText": "Revisions:"
}
3 changes: 2 additions & 1 deletion public/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"publishedLabel": "Quadrant Overview"
},
"legalInformationLink": "https://www.aoe.com/en/imprint.html",
"search": "What are you looking for?",
"searchLabel": "Search",
"searchPlaceholder": "What are you looking for?",
"revisionsText": "Revisions:"
}
8 changes: 4 additions & 4 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useMessages } from "../../context/MessagesContext";
export default function Header({ pageName }: { pageName: string }) {
const [searchOpen, setSearchOpen] = useState(false);
const [search, setSearch] = useState("");
const { pageHelp } = useMessages();
const { searchLabel, pageHelp, pageOverview } = useMessages();
const history = useHistory();
const searchRef = useRef<HTMLInputElement>(null);

Expand Down Expand Up @@ -55,20 +55,20 @@ export default function Header({ pageName }: { pageName: string }) {
<div className="nav__item">
<Link pageName="help-and-about-tech-radar" className="icon-link">
<span className="icon icon--question icon-link__icon" />
How to Use {radarNameShort}?
{pageHelp.headlinePrefix || 'How to use' } {radarNameShort}?
</Link>
</div>
)}
<div className="nav__item">
<Link pageName="overview" className="icon-link">
<span className="icon icon--overview icon-link__icon" />
Technologies Overview
{ pageOverview?.title || 'Technologies Overview' }
</Link>
</div>
<div className="nav__item">
<button className="icon-link" onClick={handleOpenClick}>
<span className="icon icon--search icon-link__icon" />
Search
{ searchLabel || 'Search' }
</button>
<div className={classNames("nav__search", { "is-open": searchOpen })}>
<Search
Expand Down
4 changes: 2 additions & 2 deletions src/components/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Search(
{ value, onChange, onClose, open = false, onSubmit = () => {} }: SearchProps,
ref: any
) {
const { searchPlaceholder } = useMessages();
const { searchLabel, searchPlaceholder } = useMessages();
const closable = onClose !== undefined;

const handleSubmit = (e: FormEvent) => {
Expand Down Expand Up @@ -52,7 +52,7 @@ function Search(
<span className={classNames("search__button", { "is-open": open })}>
<button type="submit" className="button">
<span className="icon icon--search button__icon" />
Search
{ searchLabel }
</button>
</span>
{closable && (
Expand Down
1 change: 1 addition & 0 deletions src/context/MessagesContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface Messages {
pageOverview?: PageOverview;
pageItem?: PageItem;
pageIndex?: PageIndex;
searchLabel?: string;
searchPlaceholder?: string;
revisionsText?: string;
}
Expand Down

0 comments on commit 887d4cd

Please sign in to comment.