-
Notifications
You must be signed in to change notification settings - Fork 894
[EuiInlineEdit] Add EuiInlineEditText and EuiInlineEditTitle components
#6757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b88b07c
[EuiInlineEdit] Create Component Directory and Base Functionality (#6…
breehall d69c093
[EuiInlineEdit] Add Dynamic Font Sizing & Truncation Styling (#6660)
breehall 117c8b7
[EuiInlineEdit] Creation of the `isLoading` and `isInvalid` Props (#6…
breehall 8b5a47f
[EuiInlineEdit] Create `EuiInlineEdit` Docs (#6697)
breehall 7061496
[EuiInlineEdit] Test Cases for `EuiInlineEdit` (#6722)
breehall f288e12
Merge branch 'main' into feature/EuiInlineEdit
cee-chen db8d2d7
[EuiInlineEdit] Refactor multiple props to harden for real-world prod…
cee-chen e021b62
Merge branch 'main' into feature/EuiInlineEdit
cee-chen e8989de
[EuiInlineEdit] Add `onKeyDown` Mapping for Saving and Canceling Edit…
breehall 8845e13
[EuiInlineEdit] Add Playground & Code Snippets (#6743)
breehall a7f2abc
Merge branch 'main' into feature/EuiInlineEdit
cee-chen cdbd2c7
[EuiInlineEdit] DOM cleanup, a11y improvements, and fix breaking `onC…
cee-chen cfe32fa
Removed unneeded style file and references to it. (#6751)
breehall d3277ec
Update src-docs/src/views/inline_edit/inline_edit_example.js
breehall 469ab65
Update src/components/inline_edit/inline_edit_form.tsx
breehall e11c50f
Update src-docs/src/views/inline_edit/inline_edit_example.js
breehall abce404
[EuiInlineEdit] `CHANGELOG` & Copy Linting (#6788)
breehall a864a9f
[EuiInlineEdit] Create `isReadOnly` Prop for Read Mode (#6777)
breehall 35ee0a5
Merge branch 'main' into feature/EuiInlineEdit
cee-chen 83d2cd3
Snapshots
cee-chen cee0519
[EuiInlineEdit] Final screen reader / a11y polish pass (#6805)
cee-chen 98a264a
Revert Escape preventDefault
cee-chen 08bfd42
[misc UX enhancement]
cee-chen 52ef469
[mobile] Fix edit mode buttons wrapping to next line in small screens
cee-chen 6fb4b59
[misc docs tweaks]
cee-chen cd9511f
Add demo section for `startWithEditOpen` prop
cee-chen 704d372
[misc cleanup/nits]
cee-chen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,239 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { Link } from 'react-router-dom'; | ||
|
|
||
| import { GuideSectionTypes } from '../../components'; | ||
|
|
||
| import { | ||
| EuiCode, | ||
| EuiText, | ||
| EuiInlineEditText, | ||
| EuiInlineEditTitle, | ||
| } from '../../../../src'; | ||
|
|
||
| import { inlineEditTextConfig, inlineEditTitleConfig } from './playground'; | ||
|
|
||
| import InlineEditText from './inline_edit_text'; | ||
| const inlineEditTextSource = require('!!raw-loader!./inline_edit_text'); | ||
| const inlineEditTextSnippet = `<EuiInlineEditText | ||
| inputAriaLabel="Edit text inline" | ||
| defaultValue="Hello World!" | ||
| />`; | ||
|
|
||
| import InlineEditTitle from './inline_edit_title'; | ||
| const inlineEditTitleSource = require('!!raw-loader!./inline_edit_title'); | ||
| const inlineEditTitleSnippet = `<EuiInlineEditTitle | ||
| inputAriaLabel="Edit title inline" | ||
| defaultValue="Hello World (but as a title)!" | ||
| heading="h3" | ||
| />`; | ||
|
|
||
| import InlineEditModeProps from './inline_edit_mode_props'; | ||
| const inlineEditModePropsSource = require('!!raw-loader!./inline_edit_mode_props'); | ||
| const inlineEditModePropsSnippet = `<EuiInlineEditText | ||
| inputAriaLabel="Edit text inline for readMode and editMode props" | ||
| defaultValue="This inline edit component has been customized!" | ||
| size="m" | ||
| readModeProps={{ | ||
| color: 'primary', | ||
| iconSide: 'left', | ||
| }} | ||
| editModeProps={{ | ||
| inputProps: { | ||
| prepend: 'Prepend example', | ||
| }, | ||
| formRowProps: { | ||
| helpText: 'Example help text', | ||
| }, | ||
| saveButtonProps: { | ||
| color: 'primary', | ||
| }, | ||
| cancelButtonProps: { | ||
| display: 'empty', | ||
| }, | ||
| }} | ||
| />`; | ||
|
|
||
| import InlineEditSave from './inline_edit_save'; | ||
| const inlineEditSaveSource = require('!!raw-loader!././inline_edit_save'); | ||
| const inlineEditModeSaveSnippet = `<EuiInlineEditText | ||
| inputAriaLabel="Edit text inline" | ||
| defaultValue={defaultInlineEditValue} | ||
| onSave={(newInlineEditValue: string) => { | ||
| localStorage.setItem('inlineEditValue', newInlineEditValue); | ||
| }} | ||
| />`; | ||
|
|
||
| import InlineEditValidation from './inline_edit_validation'; | ||
| const inlineEditValidationSource = require('!!raw-loader!././inline_edit_validation'); | ||
|
|
||
| export const InlineEditExample = { | ||
| title: 'Inline edit', | ||
| intro: ( | ||
| <> | ||
| <EuiText> | ||
| The <strong>EuiInlineEdit</strong> components are useful for updating | ||
| single-line text outside of a form. The component has two states:{' '} | ||
| <EuiCode>readMode</EuiCode> shows editable text inside of a button and{' '} | ||
| <EuiCode>editMode</EuiCode> displays a form control to update the text. | ||
| </EuiText> | ||
| </> | ||
| ), | ||
| isNew: true, | ||
| sections: [ | ||
| { | ||
| title: 'Display and edit basic text', | ||
| text: ( | ||
| <> | ||
| <p> | ||
| Use <strong>EuiInlineEditText</strong> to display and edit basic | ||
| text. Adjust the <EuiCode>size</EuiCode> property to change the font | ||
| size in both <EuiCode>readMode</EuiCode> and{' '} | ||
| <EuiCode>editMode</EuiCode>. | ||
| </p> | ||
| </> | ||
| ), | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.TSX, | ||
| code: inlineEditTextSource, | ||
| }, | ||
| ], | ||
| demo: <InlineEditText />, | ||
| props: { EuiInlineEditText }, | ||
| snippet: inlineEditTextSnippet, | ||
| playground: inlineEditTextConfig, | ||
| }, | ||
| { | ||
| title: 'Display and edit headings and titles', | ||
| text: ( | ||
| <> | ||
| <p> | ||
| Use <strong>EuiInlineEditTitle</strong> to display and edit titles. | ||
| Use the <EuiCode>heading</EuiCode> property to set the heading level | ||
| in <EuiCode>readMode</EuiCode>. | ||
| </p> | ||
| </> | ||
| ), | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.TSX, | ||
| code: inlineEditTitleSource, | ||
| }, | ||
| ], | ||
| demo: <InlineEditTitle />, | ||
| props: { EuiInlineEditTitle }, | ||
| snippet: inlineEditTitleSnippet, | ||
| playground: inlineEditTitleConfig, | ||
| }, | ||
| { | ||
| title: 'Saving edited text', | ||
| text: ( | ||
| <p> | ||
| Use the <EuiCode>onSave</EuiCode> property to retrieve the value of | ||
| the edited text when the save button is pressed.{' '} | ||
| <EuiCode>onSave</EuiCode> does not fire if the user cancels their | ||
| edit. | ||
| </p> | ||
| ), | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.TSX, | ||
| code: inlineEditSaveSource, | ||
| }, | ||
| ], | ||
| demo: <InlineEditSave />, | ||
| snippet: inlineEditModeSaveSnippet, | ||
| }, | ||
| { | ||
| title: 'Validating edited text', | ||
| text: ( | ||
| <> | ||
| <p> | ||
| Validation states (<EuiCode>isLoading</EuiCode> and{' '} | ||
| <EuiCode>isInvalid</EuiCode>) only display while the user is in edit | ||
| mode. | ||
| </p> | ||
| <p> | ||
| To validate text when the user presses the save button but before | ||
| the user is returned to read mode, return a boolean (or an async | ||
| promise returning a boolean) from your <EuiCode>onSave</EuiCode>{' '} | ||
| callback. | ||
|
breehall marked this conversation as resolved.
Outdated
|
||
| </p> | ||
| <p> | ||
| Returning <EuiCode>false</EuiCode> from <EuiCode>onSave</EuiCode>{' '} | ||
| will keep the user in edit mode, where you can then display | ||
| validation state and messages. Returning <EuiCode>true</EuiCode> or{' '} | ||
| <EuiCode>undefined</EuiCode> will return the user to read mode. | ||
| </p> | ||
| </> | ||
| ), | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.TSX, | ||
| code: inlineEditValidationSource, | ||
| }, | ||
| ], | ||
| demo: <InlineEditValidation />, | ||
| }, | ||
| { | ||
| title: 'Customizing read and edit modes', | ||
| text: ( | ||
| <> | ||
| <p> | ||
| Customize the read mode by passing <EuiCode>readModeProps</EuiCode>, | ||
| which accepts any{' '} | ||
| <Link to="/navigation/button#empty-button"> | ||
| <strong>EuiButtonEmpty</strong> | ||
| </Link>{' '} | ||
| properties. | ||
| </p> | ||
|
|
||
| <p> | ||
| Customize the edit mode by passing <EuiCode>editModeProps</EuiCode>. | ||
| This prop contains nested object properties that are applied to | ||
| various child components in edit mode: | ||
| </p> | ||
| <ul> | ||
| <li> | ||
| <EuiCode>editMode.formRowProps</EuiCode> accepts any{' '} | ||
| <Link to="/forms/form-layouts#form-and-form-rows"> | ||
| <strong>EuiFormRow</strong> | ||
| </Link>{' '} | ||
| properties | ||
| </li> | ||
| <li> | ||
| <EuiCode>editMode.inputRowProps</EuiCode> accepts any{' '} | ||
| <Link to="/forms/form-controls#text-field"> | ||
| <strong>EuiFieldText</strong> | ||
| </Link>{' '} | ||
| properties | ||
| </li> | ||
| <li> | ||
| <EuiCode>editMode.saveButtonProps</EuiCode> accepts any{' '} | ||
| <Link to="/navigation/button#icon-buttons"> | ||
| <strong>EuiIconButton</strong> | ||
| </Link>{' '} | ||
| properties | ||
| </li> | ||
| <li> | ||
| <EuiCode>editMode.cancelButtonProps</EuiCode> accepts any{' '} | ||
| <Link to="/navigation/button#icon-buttons"> | ||
| <strong>EuiIconButton</strong> | ||
| </Link>{' '} | ||
| properties | ||
| </li> | ||
| </ul> | ||
| </> | ||
| ), | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.TSX, | ||
| code: inlineEditModePropsSource, | ||
| }, | ||
| ], | ||
| demo: <InlineEditModeProps />, | ||
| snippet: inlineEditModePropsSnippet, | ||
| }, | ||
| ], | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { EuiInlineEditText } from '../../../../src'; | ||
|
|
||
| export default () => { | ||
| return ( | ||
| <EuiInlineEditText | ||
| inputAriaLabel="Edit text inline for readMode and editMode props" | ||
| defaultValue="This inline edit component has been customized!" | ||
| size="m" | ||
| readModeProps={{ | ||
| color: 'primary', | ||
| iconSide: 'left', | ||
| }} | ||
| editModeProps={{ | ||
| inputProps: { | ||
| prepend: 'Prepend example', | ||
| }, | ||
| formRowProps: { | ||
| helpText: 'Example help text', | ||
| }, | ||
| saveButtonProps: { | ||
| color: 'primary', | ||
| }, | ||
| cancelButtonProps: { | ||
| display: 'empty', | ||
| }, | ||
| }} | ||
| /> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { EuiInlineEditText } from '../../../../src'; | ||
|
|
||
| export default () => { | ||
| const saveToLocalStorage = (newInlineEditValue: string) => { | ||
| localStorage.setItem('inlineEditValue', newInlineEditValue); | ||
| }; | ||
|
|
||
| const defaultInlineEditValue = | ||
| localStorage.getItem('inlineEditValue') || | ||
| 'This value will persist when you refresh the page!'; | ||
|
|
||
| return ( | ||
| <EuiInlineEditText | ||
| inputAriaLabel="Edit text inline" | ||
| defaultValue={defaultInlineEditValue} | ||
| onSave={saveToLocalStorage} | ||
| /> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import React, { useState } from 'react'; | ||
|
|
||
| import { | ||
| EuiInlineEditText, | ||
| EuiSpacer, | ||
| EuiButtonGroup, | ||
| EuiInlineEditTextProps, | ||
| } from '../../../../src'; | ||
|
|
||
| export default () => { | ||
| const textSizeButtons = [ | ||
| { | ||
| id: 'xs', | ||
| label: 'Extra Small', | ||
| }, | ||
| { | ||
| id: 's', | ||
| label: 'Small', | ||
| }, | ||
| { | ||
| id: 'm', | ||
| label: 'Medium', | ||
| }, | ||
| ]; | ||
|
|
||
| const [toggleTextButtonSize, setToggleTextButtonSize] = useState< | ||
| EuiInlineEditTextProps['size'] | ||
| >('m'); | ||
|
|
||
| const textSizeOnChange = (optionId: EuiInlineEditTextProps['size']) => { | ||
| setToggleTextButtonSize(optionId); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <EuiButtonGroup | ||
| legend="Text size" | ||
| options={textSizeButtons} | ||
| idSelected={toggleTextButtonSize as string} | ||
| onChange={(id) => | ||
| textSizeOnChange(id as EuiInlineEditTextProps['size']) | ||
| } | ||
| /> | ||
|
|
||
| <EuiSpacer /> | ||
|
|
||
| <EuiInlineEditText | ||
| inputAriaLabel="Edit text inline" | ||
| defaultValue="Hello World!" | ||
| size={toggleTextButtonSize} | ||
| /> | ||
| </> | ||
| ); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.