Docs: Basic docs for FormValidationMessage (#27658)

This commit is contained in:
Peter Holmberg 2020-09-21 09:05:38 +02:00 committed by GitHub
parent e8a6b9db10
commit 60cf95fa21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 3 deletions

View File

@ -0,0 +1,27 @@
import { Meta, Props } from '@storybook/addon-docs/blocks';
import { FieldValidationMessage } from './FieldValidationMessage';
<Meta title="MDX|FieldValidationMessage" component={FieldValidationMessage} />
# FieldValidationMessage
Component for displaying a validation error message under an element.
### Example usage
An example usage of this is in out `FormField` component.
```tsx
export const CustomFormField = () => {
return (
<div>
Label
<div>
<input />
{error &&
(<FormValidationMessage>Invalid input</FormValidationMessage>)}
</div>
</div>
)
}
```
<Props of={FieldValidationMessage} />

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { FieldValidationMessage } from './FieldValidationMessage';
import { text } from '@storybook/addon-knobs'; import { text } from '@storybook/addon-knobs';
import { FieldValidationMessage } from './FieldValidationMessage';
import mdx from './FieldValidationMessage.mdx';
const getKnobs = () => { const getKnobs = () => {
return { return {
@ -11,6 +12,11 @@ const getKnobs = () => {
export default { export default {
title: 'Forms/FieldValidationMessage', title: 'Forms/FieldValidationMessage',
component: FieldValidationMessage, component: FieldValidationMessage,
parameters: {
docs: {
page: mdx,
},
},
}; };
export const simple = () => { export const simple = () => {

View File

@ -1,11 +1,12 @@
import React from 'react'; import React from 'react';
import { useTheme, stylesFactory } from '../../themes';
import { GrafanaTheme } from '@grafana/data';
import { css, cx } from 'emotion'; import { css, cx } from 'emotion';
import { GrafanaTheme } from '@grafana/data';
import { Icon } from '../Icon/Icon'; import { Icon } from '../Icon/Icon';
import { useTheme, stylesFactory } from '../../themes';
export interface FieldValidationMessageProps { export interface FieldValidationMessageProps {
children: string; children: string;
/** Override component style */
className?: string; className?: string;
} }