From c59a7198c9ea3f8fdfcfdc9a334dc5b364186fbb Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 8 Sep 2020 19:12:42 +0200 Subject: [PATCH] initial version of help items (#70) --- src/components/help-enabler/HelpItem.test.tsx | 11 ++++++++ src/components/help-enabler/HelpItem.tsx | 19 ++++++++++++++ .../__snapshots__/HelpItem.test.tsx.snap | 26 +++++++++++++++++++ src/help.json | 7 +++++ src/i18n.ts | 5 +++- src/messages.json | 2 +- src/stories/HelpSystem.stories.tsx | 21 ++++++++++----- 7 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 src/components/help-enabler/HelpItem.test.tsx create mode 100644 src/components/help-enabler/HelpItem.tsx create mode 100644 src/components/help-enabler/__snapshots__/HelpItem.test.tsx.snap create mode 100644 src/help.json diff --git a/src/components/help-enabler/HelpItem.test.tsx b/src/components/help-enabler/HelpItem.test.tsx new file mode 100644 index 0000000000..62297a6999 --- /dev/null +++ b/src/components/help-enabler/HelpItem.test.tsx @@ -0,0 +1,11 @@ +import React from "react"; +import { render } from "@testing-library/react"; + +import { HelpItem } from "./HelpItem"; + +describe("", () => { + it("render", () => { + const comp = render(); + expect(comp.asFragment()).toMatchSnapshot(); + }); +}); diff --git a/src/components/help-enabler/HelpItem.tsx b/src/components/help-enabler/HelpItem.tsx new file mode 100644 index 0000000000..f7ca0e3205 --- /dev/null +++ b/src/components/help-enabler/HelpItem.tsx @@ -0,0 +1,19 @@ +import React from "react"; +import { Tooltip } from "@patternfly/react-core"; +import { HelpIcon } from "@patternfly/react-icons"; +import { useTranslation } from "react-i18next"; + +type HelpItemProps = { + item: string; +}; + +export const HelpItem = ({ item }: HelpItemProps) => { + const { t } = useTranslation(); + return ( + + + + + + ); +}; diff --git a/src/components/help-enabler/__snapshots__/HelpItem.test.tsx.snap b/src/components/help-enabler/__snapshots__/HelpItem.test.tsx.snap new file mode 100644 index 0000000000..cf1f43377e --- /dev/null +++ b/src/components/help-enabler/__snapshots__/HelpItem.test.tsx.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` render 1`] = ` + + + + + +`; diff --git a/src/help.json b/src/help.json new file mode 100644 index 0000000000..0d706d03e4 --- /dev/null +++ b/src/help.json @@ -0,0 +1,7 @@ +{ + "en": { + "help": { + "storybook": "Sometimes you need some help and it's nice when the app does that" + } + } +} diff --git a/src/i18n.ts b/src/i18n.ts index bb29a1cb7d..a83e535a42 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -3,9 +3,12 @@ import { initReactI18next } from "react-i18next"; // import backend from "i18next-http-backend"; import messages from "./messages.json"; +import help from "./help.json"; const initOptions = { - resources: messages, + ns: ["messages", "help"], + defaultNS: "messages", + resources: { ...messages, ...help }, lng: "en", fallbackLng: "en", saveMissing: true, diff --git a/src/messages.json b/src/messages.json index aebbbf6912..f7de1d2a5f 100644 --- a/src/messages.json +++ b/src/messages.json @@ -1,6 +1,6 @@ { "en": { - "translation": { + "messages": { "personalInfoHtmlTitle": "Personal Info", "personalInfoIntroMessage": "Manage your basic information", "Account Security": "Account Security", diff --git a/src/stories/HelpSystem.stories.tsx b/src/stories/HelpSystem.stories.tsx index b0078ff5a0..958cae6586 100644 --- a/src/stories/HelpSystem.stories.tsx +++ b/src/stories/HelpSystem.stories.tsx @@ -7,24 +7,31 @@ import { } from "@patternfly/react-core"; import { Meta } from "@storybook/react"; +import { HelpItem } from "../components/help-enabler/HelpItem"; import { Help, HelpContext, HelpHeader, } from "../components/help-enabler/HelpHeader"; +import { I18nextProvider } from "react-i18next"; +import { i18n } from "../i18n"; export default { title: "Help System Example", component: HelpHeader, } as Meta; -export const HelpSystem = () => { - return ( - - - - ); -}; +export const HelpSystem = () => ( + + + +); + +export const HelpItemz = () => ( + + + +); const HelpSystemTest = () => { const { enabled } = useContext(HelpContext);