Chore: Use ReactNode type for Field error prop (#43852)

* Chore: Use ReactNode type for Field error prop

* add LoadingPlaceholder
pull/43916/head
Josh Hunt 4 years ago committed by GitHub
parent 963ae4ef87
commit 7ea951b35d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/grafana-ui/src/components/Forms/Field.tsx
  2. 12
      packages/grafana-ui/src/components/Forms/FieldValidationMessage.story.tsx
  3. 1
      packages/grafana-ui/src/components/Forms/FieldValidationMessage.tsx
  4. 2
      packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.tsx

@ -22,7 +22,7 @@ export interface FieldProps extends HTMLAttributes<HTMLDivElement> {
/** Indicates if field is required */
required?: boolean;
/** Error message to display */
error?: string | null;
error?: React.ReactNode;
/** Indicates horizontal layout of the field */
horizontal?: boolean;
/** make validation message overflow horizontally. Prevents pushing out adjacent inline components */

@ -1,9 +1,9 @@
import React from 'react';
import { Meta, Story } from '@storybook/react';
import { FieldValidationMessage, FieldValidationMessageProps } from './FieldValidationMessage';
import { FieldValidationMessage } from './FieldValidationMessage';
import mdx from './FieldValidationMessage.mdx';
export default {
const story = {
title: 'Forms/FieldValidationMessage',
component: FieldValidationMessage,
parameters: {
@ -21,8 +21,12 @@ export default {
argTypes: {
children: { name: 'message' },
},
} as Meta;
};
export default story as Meta;
type Args = typeof story['args'];
export const Basic: Story<FieldValidationMessageProps> = (args) => {
export const Basic: Story<Args> = (args) => {
return <FieldValidationMessage horizontal={args.horizontal}>{args.children}</FieldValidationMessage>;
};

@ -5,7 +5,6 @@ import { Icon } from '../Icon/Icon';
import { stylesFactory, useTheme2 } from '../../themes';
export interface FieldValidationMessageProps {
children: string;
/** Override component style */
className?: string;
horizontal?: boolean;

@ -8,7 +8,7 @@ import { useStyles } from '../../themes';
* @public
*/
export interface LoadingPlaceholderProps extends HTMLAttributes<HTMLDivElement> {
text: string;
text: React.ReactNode;
}
/**

Loading…
Cancel
Save