mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Docs: Basic docs for FormValidationMessage (#27658)
This commit is contained in:
parent
e8a6b9db10
commit
60cf95fa21
@ -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} />
|
@ -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 = () => {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user