Skip to content
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

[EuiInlineEdit] Create Component Directory and Base Functionality #6598

Merged
merged 34 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
68c2404
Initial directory setup for EuiInlineEdit
breehall Feb 7, 2023
be9f7f7
Initial structure for EuiInlineEdit docs
breehall Feb 7, 2023
dd7db36
Created EuiInlineEdit base component that toggles between a text inpu…
breehall Feb 10, 2023
66bc49b
Replaced button icons with full EuiButtons with text. Positioned the …
breehall Feb 13, 2023
7b0438d
Added early snapshot for component
breehall Feb 13, 2023
832e350
Added aria-labels with i18n for the editView input, save button, and …
breehall Feb 15, 2023
d03210d
Combined with last commit - forgot to hit save
breehall Feb 15, 2023
cd0c93a
Made defaultValue a required field because if there is no value passe…
breehall Feb 15, 2023
c0071db
Updated basic snapshot tests, updated docs
breehall Feb 15, 2023
c1f83f1
Added button groups to documentation to make toggling button sizes ea…
breehall Feb 15, 2023
e5c91d2
Update src/components/text/index.ts
breehall Feb 22, 2023
278430d
Update src-docs/src/views/inline_edit/inline_edit.tsx
breehall Feb 22, 2023
cb5b2f3
Update src-docs/src/views/inline_edit/inline_edit.tsx
breehall Feb 22, 2023
c80cf8c
Update src/components/inline_edit/inline_edit.tsx
breehall Feb 22, 2023
3bcfbb4
Update src/components/inline_edit/inline_edit.tsx
breehall Feb 22, 2023
ce1746e
Update src/components/inline_edit/inline_edit.test.tsx
breehall Feb 22, 2023
b249e18
Update src/components/inline_edit/inline_edit.tsx
breehall Feb 22, 2023
6ad90ae
Separated the two EuiInlineEdit examples into their own files
breehall Feb 22, 2023
66d16b8
Created additional logic to resize buttons and fieldtext elements whe…
breehall Feb 22, 2023
5ec5273
Created a heading prop to allow consumers to choose the level heading…
breehall Feb 22, 2023
cffb415
Updated basic test snapshots for EuiInlineEdit
breehall Feb 22, 2023
b9c64be
Updated new i18n tokens to be more explicit about their purpose
breehall Feb 23, 2023
cb41bdf
Split EuiInlineEdit into three components: EuiInlineEditText, EuiInli…
breehall Mar 2, 2023
0e98d74
Oops
breehall Mar 2, 2023
4db32f6
EuiInlineEdit Updates
breehall Mar 2, 2023
937564e
Remove testing props from inline edit example
breehall Mar 2, 2023
354f914
Separated repeated logic inside of EuiInlineEditTitle and EuiInlineEd…
breehall Mar 23, 2023
d3e37c4
Move types to shared internal form component
cee-chen Mar 28, 2023
73a3b13
Pass top-level props instead of in a `props` obj
cee-chen Mar 28, 2023
01be4a0
Remove top level read state, use render prop instead
cee-chen Mar 28, 2023
f26ae12
Remove EuiInlineEditButtons, roll into EuiInlineEditForm as inline
cee-chen Mar 28, 2023
77a9497
Removed utility in favor of component-specific size logic
cee-chen Mar 28, 2023
d44818a
Fix types and update snapshots
cee-chen Mar 28, 2023
9129469
Clean up type def
cee-chen Mar 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ import { ImageExample } from './views/image/image_example';

import { InnerTextExample } from './views/inner_text/inner_text_example';

import { InlineEditExample } from './views/inline_edit/inline_edit_example';

import { KeyPadMenuExample } from './views/key_pad_menu/key_pad_menu_example';

import { LinkExample } from './views/link/link_example';
Expand Down Expand Up @@ -561,6 +563,7 @@ const navigation = [
HealthExample,
IconExample,
ImageExample,
InlineEditExample,
ListGroupExample,
LoadingExample,
NotificationEventExample,
Expand Down
29 changes: 29 additions & 0 deletions src-docs/src/views/inline_edit/inline_edit_confirm.tsx
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;
};
breehall marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
<EuiInlineEditText
inputAriaLabel="Edit text inline"
defaultValue="Hello World!"
size="m"
editModeProps={{
icon: 'cross',
}}
readModeProps={{
color: 'success',
}}
onConfirm={confirmInlineEditChanges}
/>
</>
);
};
86 changes: 86 additions & 0 deletions src-docs/src/views/inline_edit/inline_edit_example.js
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 },
},
],
};
52 changes: 52 additions & 0 deletions src-docs/src/views/inline_edit/inline_edit_text.tsx
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}
/>
</>
);
};
71 changes: 71 additions & 0 deletions src-docs/src/views/inline_edit/inline_edit_title.tsx
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',
}}
/>
</>
);
};
4 changes: 3 additions & 1 deletion src/components/button/button_empty/button_empty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exported this type because EuiButtonEmptyProps was causing TS errors when attempting to set up readModeProps.


export type EuiButtonEmptyProps = ExclusiveUnion<
EuiButtonEmptyPropsForAnchor,
Expand Down
2 changes: 2 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ export * from './image';

export * from './inner_text';

export * from './inline_edit';

export * from './i18n';

export * from './loading';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiInlineEditButtons props renders InlineEdit buttons 1`] = `
<div
class="euiFlexItem euiInlineEditButtons testClass1 testClass2 emotion-euiFlexItem-growZero"
>
<div
class="euiFormRow"
id="generated-id-row"
>
<div
class="euiFormRow__fieldWrapper"
>
<button
aria-label="Save edit"
class="euiButtonIcon euiButtonIcon--medium emotion-euiButtonIcon-base-success"
id="generated-id"
type="button"
>
<span
aria-hidden="true"
class="euiButtonIcon__icon"
color="inherit"
data-euiicon-type="check"
/>
</button>
</div>
</div>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiInlineEditText props renders as text 1`] = `
<div
aria-label="aria-label"
class="euiInlineEditText testClass1 testClass2"
data-test-subj="test subject string"
>
<div
class="euiInlineEditForm"
>
<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>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiInlineEditTitle props renders as title 1`] = `
<div
aria-label="aria-label"
class="euiInlineEditTitle testClass1 testClass2"
data-test-subj="test subject string"
>
<div
class="euiInlineEditForm"
>
<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>
</div>
`;
13 changes: 13 additions & 0 deletions src/components/inline_edit/index.ts
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';
Loading