keycloak-scim/src/stories/HelpSystem.stories.tsx

82 lines
1.7 KiB
TypeScript
Raw Normal View History

import React, { useContext } from "react";
import {
Page,
PageHeader,
PageHeaderTools,
PageHeaderToolsItem,
PageSection,
FormGroup,
Form,
TextInput,
} from "@patternfly/react-core";
2020-09-04 10:38:58 +00:00
import { Meta } from "@storybook/react";
2020-09-08 17:12:42 +00:00
import { HelpItem } from "../components/help-enabler/HelpItem";
import {
Help,
HelpContext,
HelpHeader,
} from "../components/help-enabler/HelpHeader";
export default {
title: "Help System Example",
component: HelpHeader,
} as Meta;
2020-09-08 17:12:42 +00:00
export const HelpSystem = () => (
<Help>
<HelpSystemTest />
</Help>
);
export const HelpItems = () => (
<HelpItem
helpText="This explains the related field"
forLabel="Field label"
forID="storybook-example-id"
/>
);
export const FormFieldHelp = () => (
<Form isHorizontal>
<FormGroup
label="Label"
labelIcon={
<HelpItem
helpText="This explains the related field"
forLabel="Field label"
forID="storybook-form-help"
/>
}
fieldId="storybook-form-help"
>
<TextInput isRequired type="text" id="storybook-form-help"></TextInput>
</FormGroup>
</Form>
2020-09-08 17:12:42 +00:00
);
const HelpSystemTest = () => {
const { enabled } = useContext(HelpContext);
return (
<Page
header={
<PageHeader
headerTools={
<PageHeaderTools>
<PageHeaderToolsItem>
<HelpHeader />
</PageHeaderToolsItem>
<PageHeaderToolsItem>dummy user...</PageHeaderToolsItem>
</PageHeaderTools>
}
/>
}
>
<PageSection>Help system is {enabled ? "enabled" : "not on"}</PageSection>
<PageSection variant="light">
<FormFieldHelp />
</PageSection>
</Page>
);
};