diff --git a/src-docs/src/views/inline_edit/inline_edit_confirm.tsx b/src-docs/src/views/inline_edit/inline_edit_confirm.tsx index ec930061870..432fcd73e42 100644 --- a/src-docs/src/views/inline_edit/inline_edit_confirm.tsx +++ b/src-docs/src/views/inline_edit/inline_edit_confirm.tsx @@ -3,7 +3,6 @@ import React from 'react'; import { EuiInlineEditText } from '../../../../src'; export default () => { - // TO DO: Convert this example to use something like a modal const confirmInlineEditChanges = () => { // eslint-disable-next-line no-restricted-globals const flag = confirm('Are you sure you want to save?') ? true : false; @@ -14,14 +13,8 @@ export default () => { <> diff --git a/src-docs/src/views/inline_edit/inline_edit_example.js b/src-docs/src/views/inline_edit/inline_edit_example.js index 1c92571b730..a8e311eecb5 100644 --- a/src-docs/src/views/inline_edit/inline_edit_example.js +++ b/src-docs/src/views/inline_edit/inline_edit_example.js @@ -1,5 +1,7 @@ import React from 'react'; +import { Link } from 'react-router-dom'; + import { GuideSectionTypes } from '../../components'; import { @@ -15,6 +17,9 @@ const inlineEditTextSource = require('!!raw-loader!./inline_edit_text'); import InlineEditTitle from './inline_edit_title'; const inlineEditTitleSource = require('!!raw-loader!./inline_edit_title'); +import InlineEditModeProps from './inline_edit_mode_props'; +const inlineEditModePropsSource = require('!!raw-loader!./inline_edit_mode_props'); + import InlineEditConfirm from './inline_edit_confirm'; const inlineEditConfirmSource = require('!!raw-loader!././inline_edit_confirm'); @@ -25,17 +30,24 @@ export const InlineEditExample = { title: 'Inline edit', intro: ( <> - This is where the description will go + + The EuiInlineEdit components are useful for updating + single-line text outside of a form. The component has two states:{' '} + readMode shows editable text inside of a button and{' '} + editMode displays a form control to update the text. + ), sections: [ { - title: 'InlineEditText', + title: 'Display and edit basic text', text: ( <>

- Description needed: how to use the EuiInlineEdit{' '} - component. + Use EuiInlineEditText to display and edit basic + text. Adjust the size property to change the font + size in both readMode and{' '} + editMode.

), @@ -49,12 +61,13 @@ export const InlineEditExample = { props: { EuiInlineEditText }, }, { - title: 'InlineEditTitle', + title: 'Display and edit headings and titles', text: ( <>

- Description needed: how to use the EuiInlineEdit{' '} - component. + Use EuiInlineEditTitle to display and edit titles. + Use the heading property to set the heading level + in readMode.

), @@ -67,13 +80,38 @@ export const InlineEditExample = { demo: , props: { EuiInlineEditTitle }, }, + { + title: 'Loading and invalid states', + text: ( + <> +

+ Setting the isLoading prop to true will add a + spinner to the input element in editMode and add + the loading state to the confirm and cancel input buttons. +

+

+ Setting the isInvalid prop to true will display{' '} + EuiInlineEdit's error state. Optionally, use{' '} + editModeProps.formRowProps.error to pass an error + message that will be displayed on the form control. +

+ + ), + source: [ + { + type: GuideSectionTypes.TSX, + code: inlineEditStatesSource, + }, + ], + demo: , + }, { title: 'Confirm inline edit', text: ( <>

- Description needed: how to use the EuiInlineEdit{' '} - component. + Use the onConfirm property to pass a function + that will prompt users to confirm their changes.

), @@ -84,32 +122,43 @@ export const InlineEditExample = { }, ], demo: , - props: { EuiInlineEditText }, }, { - title: 'Loading and invalid states', + title: 'Customizing read and edit modes', text: ( <>

- Setting the isLoading prop to true will add a - spinner to the input element in editMode and add - the loading state to the confirm and cancel input buttons. + Customize the readMode state by passing{' '} + readModeProps. readMode{' '} + accepts{' '} + + EuiButtonEmpty + {' '} + properties with the exception of onClick.

+

- Setting the isInvalid prop to true will display{' '} - EuiInlineEdit's error state. Optionally, use{' '} - editModeProps.formRowProps.error to pass an error - message that will be displayed on the form control. + Customize the editMode state by passing{' '} + editModeProps. These properties are applied + directly to the{' '} + + EuiFormRow + {' '} + and{' '} + + EuiFieldText + {' '} + components.

), source: [ { type: GuideSectionTypes.TSX, - code: inlineEditStatesSource, + code: inlineEditModePropsSource, }, ], - demo: , + demo: , }, ], }; diff --git a/src-docs/src/views/inline_edit/inline_edit_mode_props.tsx b/src-docs/src/views/inline_edit/inline_edit_mode_props.tsx new file mode 100644 index 00000000000..c855d91707d --- /dev/null +++ b/src-docs/src/views/inline_edit/inline_edit_mode_props.tsx @@ -0,0 +1,19 @@ +import React from 'react'; + +import { EuiInlineEditText } from '../../../../src'; + +export default () => { + return ( + + ); +}; diff --git a/src-docs/src/views/inline_edit/inline_edit_text.tsx b/src-docs/src/views/inline_edit/inline_edit_text.tsx index df4657d17b2..80330c2dd81 100644 --- a/src-docs/src/views/inline_edit/inline_edit_text.tsx +++ b/src-docs/src/views/inline_edit/inline_edit_text.tsx @@ -4,7 +4,7 @@ import { EuiInlineEditText, EuiSpacer, EuiButtonGroup, - EuiInlineEditTextSizes, + EuiInlineEditTextProps, } from '../../../../src'; export default () => { @@ -24,10 +24,10 @@ export default () => { ]; const [toggleTextButtonSize, setToggleTextButtonSize] = useState< - EuiInlineEditTextSizes + EuiInlineEditTextProps['size'] >('m'); - const textSizeOnChange = (optionId: EuiInlineEditTextSizes) => { + const textSizeOnChange = (optionId: EuiInlineEditTextProps['size']) => { setToggleTextButtonSize(optionId); }; @@ -37,7 +37,9 @@ export default () => { legend="Text size" options={textSizeButtons} idSelected={toggleTextButtonSize as string} - onChange={(id) => textSizeOnChange(id as EuiInlineEditTextSizes)} + onChange={(id) => + textSizeOnChange(id as EuiInlineEditTextProps['size']) + } /> diff --git a/src/components/inline_edit/index.ts b/src/components/inline_edit/index.ts index fb491c0aa6b..8e38132e9b1 100644 --- a/src/components/inline_edit/index.ts +++ b/src/components/inline_edit/index.ts @@ -7,7 +7,7 @@ */ export { EuiInlineEditText } from './inline_edit_text'; +export type { EuiInlineEditTextProps } from './inline_edit_text'; export { EuiInlineEditTitle } from './inline_edit_title'; - -export type { EuiInlineEditTextSizes } from './inline_edit_text'; +export type { EuiInlineEditTitleProps } from './inline_edit_title';