keycloak-scim/src/components/help-enabler/HelpItem.tsx

33 lines
891 B
TypeScript
Raw Normal View History

import React, { useContext } from "react";
import { Popover } from "@patternfly/react-core";
2020-09-08 17:12:42 +00:00
import { HelpIcon } from "@patternfly/react-icons";
import { useTranslation } from "react-i18next";
import { HelpContext } from "./HelpHeader";
2020-09-08 17:12:42 +00:00
type HelpItemProps = {
helpText: string;
forLabel: string;
forID: string;
2020-09-08 17:12:42 +00:00
};
export const HelpItem = ({ helpText, forLabel, forID }: HelpItemProps) => {
2020-09-08 17:12:42 +00:00
const { t } = useTranslation();
const { enabled } = useContext(HelpContext);
2020-09-08 17:12:42 +00:00
return (
<>
{enabled && (
<Popover bodyContent={helpText}>
<button
aria-label={t(`helpLabel`, { label: forLabel })}
onClick={(e) => e.preventDefault()}
aria-describedby={forID}
className="pf-c-form__group-label-help"
>
<HelpIcon noVerticalAlign />
</button>
</Popover>
)}
</>
2020-09-08 17:12:42 +00:00
);
};