added unwrap so that HelpItem can be on a button (#540)

fixing: #539
This commit is contained in:
Erik Jan de Wit 2021-04-20 10:06:20 +02:00 committed by GitHub
parent 820af6abca
commit 3332bd1a01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 9 deletions

View file

@ -408,6 +408,7 @@ export const EvaluateScopes = ({ clientId, protocol }: EvaluateScopesProps) => {
forLabel={t("effectiveProtocolMappers")} forLabel={t("effectiveProtocolMappers")}
helpText="clients-help:effectiveProtocolMappers" helpText="clients-help:effectiveProtocolMappers"
noVerticalAlign={false} noVerticalAlign={false}
unWrap
/> />
</TabTitleText> </TabTitleText>
} }
@ -425,6 +426,7 @@ export const EvaluateScopes = ({ clientId, protocol }: EvaluateScopesProps) => {
forLabel={t("effectiveRoleScopeMappings")} forLabel={t("effectiveRoleScopeMappings")}
helpText="clients-help:effectiveRoleScopeMappings" helpText="clients-help:effectiveRoleScopeMappings"
noVerticalAlign={false} noVerticalAlign={false}
unWrap
/> />
</TabTitleText> </TabTitleText>
} }
@ -442,6 +444,7 @@ export const EvaluateScopes = ({ clientId, protocol }: EvaluateScopesProps) => {
forLabel={t("generatedAccessToken")} forLabel={t("generatedAccessToken")}
helpText="clients-help:generatedAccessToken" helpText="clients-help:generatedAccessToken"
noVerticalAlign={false} noVerticalAlign={false}
unWrap
/> />
</TabTitleText> </TabTitleText>
} }

View file

@ -9,6 +9,7 @@ type HelpItemProps = {
forLabel: string; forLabel: string;
forID: string; forID: string;
noVerticalAlign?: boolean; noVerticalAlign?: boolean;
unWrap?: boolean;
}; };
export const HelpItem = ({ export const HelpItem = ({
@ -16,6 +17,7 @@ export const HelpItem = ({
forLabel, forLabel,
forID, forID,
noVerticalAlign = true, noVerticalAlign = true,
unWrap = false,
}: HelpItemProps) => { }: HelpItemProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { enabled } = useContext(HelpContext); const { enabled } = useContext(HelpContext);
@ -23,6 +25,8 @@ export const HelpItem = ({
<> <>
{enabled && ( {enabled && (
<Popover bodyContent={t(helpText)}> <Popover bodyContent={t(helpText)}>
<>
{!unWrap && (
<button <button
id={helpText} id={helpText}
aria-label={t(`helpLabel`, { label: forLabel })} aria-label={t(`helpLabel`, { label: forLabel })}
@ -32,6 +36,9 @@ export const HelpItem = ({
> >
<HelpIcon noVerticalAlign={noVerticalAlign} /> <HelpIcon noVerticalAlign={noVerticalAlign} />
</button> </button>
)}
{unWrap && <HelpIcon noVerticalAlign={noVerticalAlign} />}
</>
</Popover> </Popover>
)} )}
</> </>