-
Notifications
You must be signed in to change notification settings - Fork 860
[EuiInlineEdit] Create Component Directory and Base Functionality #6598
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
breehall
merged 34 commits into
elastic:feature/EuiInlineEdit
from
breehall:feature/inline-edit
Mar 28, 2023
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
68c2404
Initial directory setup for EuiInlineEdit
breehall be9f7f7
Initial structure for EuiInlineEdit docs
breehall dd7db36
Created EuiInlineEdit base component that toggles between a text inpu…
breehall 66bc49b
Replaced button icons with full EuiButtons with text. Positioned the …
breehall 7b0438d
Added early snapshot for component
breehall 832e350
Added aria-labels with i18n for the editView input, save button, and …
breehall d03210d
Combined with last commit - forgot to hit save
breehall cd0c93a
Made defaultValue a required field because if there is no value passe…
breehall c0071db
Updated basic snapshot tests, updated docs
breehall c1f83f1
Added button groups to documentation to make toggling button sizes ea…
breehall e5c91d2
Update src/components/text/index.ts
breehall 278430d
Update src-docs/src/views/inline_edit/inline_edit.tsx
breehall cb5b2f3
Update src-docs/src/views/inline_edit/inline_edit.tsx
breehall c80cf8c
Update src/components/inline_edit/inline_edit.tsx
breehall 3bcfbb4
Update src/components/inline_edit/inline_edit.tsx
breehall ce1746e
Update src/components/inline_edit/inline_edit.test.tsx
breehall b249e18
Update src/components/inline_edit/inline_edit.tsx
breehall 6ad90ae
Separated the two EuiInlineEdit examples into their own files
breehall 66d16b8
Created additional logic to resize buttons and fieldtext elements whe…
breehall 5ec5273
Created a heading prop to allow consumers to choose the level heading…
breehall cffb415
Updated basic test snapshots for EuiInlineEdit
breehall b9c64be
Updated new i18n tokens to be more explicit about their purpose
breehall cb41bdf
Split EuiInlineEdit into three components: EuiInlineEditText, EuiInli…
breehall 0e98d74
Oops
breehall 4db32f6
EuiInlineEdit Updates
breehall 937564e
Remove testing props from inline edit example
breehall 354f914
Separated repeated logic inside of EuiInlineEditTitle and EuiInlineEd…
breehall d3e37c4
Move types to shared internal form component
cee-chen 73a3b13
Pass top-level props instead of in a `props` obj
cee-chen 01be4a0
Remove top level read state, use render prop instead
cee-chen f26ae12
Remove EuiInlineEditButtons, roll into EuiInlineEditForm as inline
cee-chen 77a9497
Removed utility in favor of component-specific size logic
cee-chen d44818a
Fix types and update snapshots
cee-chen 9129469
Clean up type def
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,29 @@ | ||
| 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; | ||
| return flag; | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <EuiInlineEditText | ||
| inputAriaLabel="Edit text inline" | ||
| defaultValue="Hello World!" | ||
| size="m" | ||
| editModeProps={{ | ||
| icon: 'cross', | ||
| }} | ||
| readModeProps={{ | ||
| color: 'success', | ||
| }} | ||
| onConfirm={confirmInlineEditChanges} | ||
| /> | ||
| </> | ||
| ); | ||
| }; | ||
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,86 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { GuideSectionTypes } from '../../components'; | ||
|
|
||
| import { | ||
| EuiText, | ||
| EuiInlineEditText, | ||
| EuiInlineEditTitle, | ||
| } from '../../../../src'; | ||
|
|
||
| import InlineEditText from './inline_edit_text'; | ||
| const inlineEditTextSource = require('!!raw-loader!./inline_edit_text'); | ||
|
|
||
| import InlineEditTitle from './inline_edit_title'; | ||
| const inlineEditTitleSource = require('!!raw-loader!./inline_edit_title'); | ||
|
|
||
| import InlineEditConfirm from './inline_edit_confirm'; | ||
| const inlineEditConfirmSource = require('!!raw-loader!././inline_edit_confirm'); | ||
|
|
||
| export const InlineEditExample = { | ||
| title: 'Inline edit', | ||
| intro: ( | ||
| <> | ||
| <EuiText>This is where the description will go</EuiText> | ||
| </> | ||
| ), | ||
| sections: [ | ||
| { | ||
| title: 'InlineEditText', | ||
| text: ( | ||
| <> | ||
| <p> | ||
| Description needed: how to use the <strong>EuiInlineEdit</strong>{' '} | ||
| component. | ||
| </p> | ||
| </> | ||
| ), | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: inlineEditTextSource, | ||
| }, | ||
| ], | ||
| demo: <InlineEditText />, | ||
| props: { EuiInlineEditText }, | ||
| }, | ||
| { | ||
| title: 'InlineEditTitle', | ||
| text: ( | ||
| <> | ||
| <p> | ||
| Description needed: how to use the <strong>EuiInlineEdit</strong>{' '} | ||
| component. | ||
| </p> | ||
| </> | ||
| ), | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: inlineEditTitleSource, | ||
| }, | ||
| ], | ||
| demo: <InlineEditTitle />, | ||
| props: { EuiInlineEditTitle }, | ||
| }, | ||
| { | ||
| title: 'Confirm inline edit', | ||
| text: ( | ||
| <> | ||
| <p> | ||
| Description needed: how to use the <strong>EuiInlineEdit</strong>{' '} | ||
| component. | ||
| </p> | ||
| </> | ||
| ), | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: inlineEditConfirmSource, | ||
| }, | ||
| ], | ||
| demo: <InlineEditConfirm />, | ||
| props: { EuiInlineEditText }, | ||
| }, | ||
| ], | ||
| }; |
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,52 @@ | ||
| import React, { useState } from 'react'; | ||
|
|
||
| import { | ||
| EuiInlineEditText, | ||
| EuiSpacer, | ||
| EuiButtonGroup, | ||
| EuiInlineEditTextSizes, | ||
| } from '../../../../src'; | ||
|
|
||
| export default () => { | ||
| const textSizeButtons = [ | ||
| { | ||
| id: 'xs', | ||
| label: 'Extra Small', | ||
| }, | ||
| { | ||
| id: 's', | ||
| label: 'Small', | ||
| }, | ||
| { | ||
| id: 'm', | ||
| label: 'Medium', | ||
| }, | ||
| ]; | ||
|
|
||
| const [toggleTextButtonSize, setToggleTextButtonSize] = useState< | ||
| EuiInlineEditTextSizes | ||
| >('m'); | ||
|
|
||
| const textSizeOnChange = (optionId: EuiInlineEditTextSizes) => { | ||
| setToggleTextButtonSize(optionId); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <EuiButtonGroup | ||
| legend="Text size" | ||
| options={textSizeButtons} | ||
| idSelected={toggleTextButtonSize as string} | ||
| onChange={(id) => textSizeOnChange(id as EuiInlineEditTextSizes)} | ||
| /> | ||
|
|
||
| <EuiSpacer /> | ||
|
|
||
| <EuiInlineEditText | ||
| inputAriaLabel="Edit text inline" | ||
| defaultValue="Hello World!" | ||
| size={toggleTextButtonSize} | ||
| /> | ||
| </> | ||
| ); | ||
| }; |
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,71 @@ | ||
| import React, { useState } from 'react'; | ||
|
|
||
| import { | ||
| EuiInlineEditTitle, | ||
| EuiSpacer, | ||
| EuiButtonGroup, | ||
| EuiTitleSize, | ||
| } from '../../../../src'; | ||
|
|
||
| export default () => { | ||
| const titleSizeButtons = [ | ||
| { | ||
| id: 'xxxs', | ||
| label: '3X Small', | ||
| }, | ||
| { | ||
| id: 'xxs', | ||
| label: '2X Small', | ||
| }, | ||
| { | ||
| id: 'xs', | ||
| label: 'Extra small', | ||
| }, | ||
| { | ||
| id: 's', | ||
| label: 'Small', | ||
| }, | ||
| { | ||
| id: 'm', | ||
| label: 'Medium', | ||
| }, | ||
| { | ||
| id: 'l', | ||
| label: 'Large', | ||
| }, | ||
| ]; | ||
|
|
||
| const [toggleTitleButtonSize, setToggleTitleButtonSize] = useState< | ||
| EuiTitleSize | ||
| >('m'); | ||
|
|
||
| const titleSizeOnChange = (optionId: EuiTitleSize) => { | ||
| setToggleTitleButtonSize(optionId); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <EuiButtonGroup | ||
| legend="Title size" | ||
| options={titleSizeButtons} | ||
| idSelected={toggleTitleButtonSize} | ||
| onChange={(id) => titleSizeOnChange(id as EuiTitleSize)} | ||
| /> | ||
|
|
||
| <EuiSpacer /> | ||
|
|
||
| <EuiInlineEditTitle | ||
| inputAriaLabel="Edit title inline" | ||
| defaultValue="Hello World (but as a title)!" | ||
| size={toggleTitleButtonSize} | ||
| heading="h3" | ||
| editModeProps={{ | ||
| icon: 'cross', | ||
| }} | ||
| readModeProps={{ | ||
| color: 'success', | ||
| }} | ||
| /> | ||
| </> | ||
| ); | ||
| }; |
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 |
|---|---|---|
|
|
@@ -91,7 +91,9 @@ export interface CommonEuiButtonEmptyProps | |
|
|
||
| type EuiButtonEmptyPropsForAnchor = PropsForAnchor<CommonEuiButtonEmptyProps>; | ||
|
|
||
| type EuiButtonEmptyPropsForButton = PropsForButton<CommonEuiButtonEmptyProps>; | ||
| export type EuiButtonEmptyPropsForButton = PropsForButton< | ||
| CommonEuiButtonEmptyProps | ||
| >; | ||
|
Comment on lines
+94
to
+96
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exported this type because |
||
|
|
||
| export type EuiButtonEmptyProps = ExclusiveUnion< | ||
| EuiButtonEmptyPropsForAnchor, | ||
|
|
||
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
31 changes: 31 additions & 0 deletions
31
src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap
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 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`EuiInlineEditText props renders as text 1`] = ` | ||
| <div | ||
| class="euiInlineEdit euiInlineEditText testClass1 testClass2" | ||
| > | ||
| <button | ||
| class="euiButtonEmpty euiButtonEmpty--flushBoth css-wvaqcf-empty-text" | ||
| type="button" | ||
| > | ||
| <span | ||
| class="euiButtonContent euiButtonContent--iconRight euiButtonEmpty__content" | ||
| > | ||
| <span | ||
| class="euiButtonContent__icon" | ||
| color="inherit" | ||
| data-euiicon-type="pencil" | ||
| /> | ||
| <span | ||
| class="euiButtonEmpty__text" | ||
| > | ||
| <div | ||
| class="euiText emotion-euiText-m" | ||
| > | ||
| hello world | ||
| </div> | ||
| </span> | ||
| </span> | ||
| </button> | ||
| </div> | ||
| `; |
31 changes: 31 additions & 0 deletions
31
src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap
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 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`EuiInlineEditTitle props renders as title 1`] = ` | ||
| <div | ||
| class="euiInlineEdit euiInlineEditTitle testClass1 testClass2" | ||
| > | ||
| <button | ||
| class="euiButtonEmpty euiButtonEmpty--flushBoth css-wvaqcf-empty-text" | ||
| type="button" | ||
| > | ||
| <span | ||
| class="euiButtonContent euiButtonContent--iconRight euiButtonEmpty__content" | ||
| > | ||
| <span | ||
| class="euiButtonContent__icon" | ||
| color="inherit" | ||
| data-euiicon-type="pencil" | ||
| /> | ||
| <span | ||
| class="euiButtonEmpty__text" | ||
| > | ||
| <h2 | ||
| class="euiTitle emotion-euiTitle-m" | ||
| > | ||
| hello world | ||
| </h2> | ||
| </span> | ||
| </span> | ||
| </button> | ||
| </div> | ||
| `; |
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,13 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| export { EuiInlineEditText } from './inline_edit_text'; | ||
|
|
||
| export { EuiInlineEditTitle } from './inline_edit_title'; | ||
|
|
||
| export type { EuiInlineEditTextSizes } from './inline_edit_text'; |
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,19 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import { css } from '@emotion/react'; | ||
| import { UseEuiTheme } from '../../services'; | ||
|
|
||
| export const euiInlineEditStyles = ({ euiTheme }: UseEuiTheme) => { | ||
| return { | ||
| euiInlineEdit: css` | ||
| // Always start the object with the first key being the name of the component | ||
| color: ${euiTheme.colors.primaryText}; | ||
| `, | ||
| }; | ||
| }; | ||
breehall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.