Extract AOE specific texts as messages.json

This commit is contained in:
dennis.ludwig
2021-06-30 16:51:27 +02:00
parent e2d2cd6e86
commit ab72666052
6 changed files with 239 additions and 129 deletions

View File

@@ -0,0 +1,46 @@
import { createContext, FC, useContext } from "react";
import { Props as SocialIcon } from "../../components/SocialIcon/SocialIcon";
interface Quadrant {
name: string;
description: string;
}
interface Ring {
name: string;
description: string;
}
interface PageHelp {
introduction: string[];
whatIsTheRadar: string[];
howItIsCreated: string[];
howShouldItBeUsed: string[];
quadrants: Quadrant[];
rings: Ring[];
}
export interface Messages {
footerFootnote: string;
socialIcons: SocialIcon[];
pageHelp: PageHelp;
}
const MessagesContext = createContext<Messages | undefined>(undefined);
export const MessagesProvider: FC<{ messages: Messages }> = ({
messages,
children,
}) => (
<MessagesContext.Provider value={messages}>
{children}
</MessagesContext.Provider>
);
export const useMessages = () => {
const context = useContext(MessagesContext);
if (context === undefined) {
throw new Error("useMessages must be used within a MessagesProvider");
}
return context;
};