Moved examples into example directory

Moved routes to separate file
Used route constants
This commit is contained in:
2022-07-26 10:32:11 +02:00
parent de1484e9a1
commit 8496f5cfbe
18 changed files with 93 additions and 42 deletions

View File

@@ -1,4 +1,5 @@
import deepmerge from "deepmerge";
import { RunTimeConfig } from "./RunTimeConfig";
/**
* gets and merges both the regular config and the override config from the window
@@ -12,4 +13,4 @@ export const mergeConfigs = () => {
mergeConfigs();
export const Config = window.mergedConfig;
export const Config: RunTimeConfig = window.mergedConfig;

View File

@@ -2,12 +2,14 @@ import { DateTime } from "luxon";
import { FunctionComponent } from "react";
import { Trans, useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { ROUTE_KEYS } from "../../Routes";
import { Config } from "../config";
import "./Navbar.css";
type Props = {};
export const Navbar: FunctionComponent<Props> = () => {
const [translate, i18n] = useTranslation();
const { home, about, counter } = ROUTE_KEYS;
return (
<>
<h1>{translate("navBar.intro")}</h1>
@@ -20,13 +22,13 @@ export const Navbar: FunctionComponent<Props> = () => {
{/* This translation uses a formatter in the translation files */}
<p>{translate("navBar.currentDate", { date: DateTime.now().toJSDate() })}</p>
<nav data-testid="nav">
<Link to="/" data-testid="nav.home">
<Link to={home} data-testid="nav.home">
{translate("nav.home")}
</Link>
<Link to="/about" data-testid="nav.about">
<Link to={about} data-testid="nav.about">
{translate("nav.about")}
</Link>
<Link to="/counter" data-testid="nav.counter">
<Link to={counter} data-testid="nav.counter">
{translate("nav.counter")}
</Link>
<button onClick={() => i18n.changeLanguage("en")}>en</button>