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

[8.x] Fix various EuiFormControlLayout usages (#192779) #193925

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
EuiFlyoutBody,
EuiFlyoutFooter,
EuiFlyoutHeader,
EuiFormControlLayout,
EuiFormRow,
EuiSwitch,
EuiTextArea,
Expand Down Expand Up @@ -128,48 +127,46 @@ export const SavedBookEditor = ({
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiFormControlLayout>
<EuiFormRow
label={i18n.translate('embeddableExamples.savedBook.editor.authorLabel', {
defaultMessage: 'Author',
})}
>
<EuiFieldText
value={authorName ?? ''}
onChange={(e) => attributesManager.authorName.next(e.target.value)}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate('embeddableExamples.savedBook.editor.titleLabel', {
defaultMessage: 'Title',
})}
>
<EuiFieldText
value={bookTitle ?? ''}
onChange={(e) => attributesManager.bookTitle.next(e.target.value)}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate('embeddableExamples.savedBook.editor.pagesLabel', {
defaultMessage: 'Number of pages',
})}
>
<EuiFieldNumber
value={numberOfPages ?? ''}
onChange={(e) => attributesManager.numberOfPages.next(+e.target.value)}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate('embeddableExamples.savedBook.editor.synopsisLabel', {
defaultMessage: 'Synopsis',
})}
>
<EuiTextArea
value={synopsis ?? ''}
onChange={(e) => attributesManager.bookSynopsis.next(e.target.value)}
/>
</EuiFormRow>
</EuiFormControlLayout>
<EuiFormRow
label={i18n.translate('embeddableExamples.savedBook.editor.authorLabel', {
defaultMessage: 'Author',
})}
>
<EuiFieldText
value={authorName ?? ''}
onChange={(e) => attributesManager.authorName.next(e.target.value)}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate('embeddableExamples.savedBook.editor.titleLabel', {
defaultMessage: 'Title',
})}
>
<EuiFieldText
value={bookTitle ?? ''}
onChange={(e) => attributesManager.bookTitle.next(e.target.value)}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate('embeddableExamples.savedBook.editor.pagesLabel', {
defaultMessage: 'Number of pages',
})}
>
<EuiFieldNumber
value={numberOfPages ?? ''}
onChange={(e) => attributesManager.numberOfPages.next(+e.target.value)}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate('embeddableExamples.savedBook.editor.synopsisLabel', {
defaultMessage: 'Synopsis',
})}
>
<EuiTextArea
value={synopsis ?? ''}
onChange={(e) => attributesManager.bookSynopsis.next(e.target.value)}
/>
</EuiFormRow>
</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup justifyContent="spaceBetween">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
margin-top: $euiSizeS;
}

.lnsConfigPanelNoPadding {
padding: 0;
}

.lnsConfigPanelDate__label {
min-width: 56px; // makes both labels ("from" and "to") the same width
.lnsConfigPanelAnnotations__date .euiFormControlLayout__prepend {
min-width: $euiSize * 3.25; // makes both labels ("from" and "to") the same width
}

.lnsConfigPanelAnnotations__addButton {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@

import { i18n } from '@kbn/i18n';
import React from 'react';
import {
EuiFormRow,
EuiSwitch,
EuiText,
EuiFormControlLayout,
EuiFormLabel,
EuiDatePicker,
} from '@elastic/eui';
import { EuiFormRow, EuiSwitch, EuiText, EuiDatePicker } from '@elastic/eui';
import moment from 'moment';
import type {
PointInTimeEventAnnotationConfig,
Expand Down Expand Up @@ -107,36 +100,23 @@ export const ConfigPanelRangeDatePicker = ({
dataTestSubj?: string;
}) => {
return (
<EuiFormRow display="rowCompressed" fullWidth label={label} className="lnsRowCompressedMargin">
{prependLabel ? (
<EuiFormControlLayout
fullWidth
className="lnsConfigPanelNoPadding"
prepend={
<EuiFormLabel className="lnsConfigPanelDate__label">{prependLabel}</EuiFormLabel>
}
>
<EuiDatePicker
calendarClassName={calendarClassName}
fullWidth
showTimeSelect
selected={value}
onChange={onChange}
dateFormat="MMM D, YYYY @ HH:mm:ss.SSS"
data-test-subj={dataTestSubj}
/>
</EuiFormControlLayout>
) : (
<EuiDatePicker
calendarClassName={calendarClassName}
fullWidth
showTimeSelect
selected={value}
onChange={onChange}
dateFormat="MMM D, YYYY @ HH:mm:ss.SSS"
data-test-subj={dataTestSubj}
/>
)}
<EuiFormRow
display="rowCompressed"
fullWidth
label={label}
className="lnsConfigPanelAnnotations__date lnsRowCompressedMargin"
>
<EuiDatePicker
compressed
calendarClassName={calendarClassName}
fullWidth
showTimeSelect
selected={value}
onChange={onChange}
dateFormat="MMM D, YYYY @ HH:mm:ss.SSS"
data-test-subj={dataTestSubj}
prepend={prependLabel}
/>
</EuiFormRow>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
EuiContextMenuPanel,
EuiCopy,
EuiFieldText,
EuiFormControlLayout,
EuiHorizontalRule,
EuiPopover,
EuiSpacer,
Expand All @@ -29,12 +28,24 @@ export interface TokenFieldProps extends Omit<EuiFieldTextProps, 'append'> {
value: string;
}

export const TokenField: FunctionComponent<TokenFieldProps> = (props) => {
export const TokenField: FunctionComponent<TokenFieldProps> = ({ value, ...props }) => {
return (
<EuiFormControlLayout
<EuiFieldText
data-test-subj="apiKeyTokenField"
aria-label={i18n.translate('xpack.security.copyTokenField.tokenLabel', {
defaultMessage: 'Token',
})}
value={value}
style={{
fontFamily: euiThemeVars.euiCodeFontFamily,
fontSize: euiThemeVars.euiFontSizeXS,
backgroundColor: 'transparent',
}}
onFocus={(event) => event.currentTarget.select()}
readOnly
{...props}
append={
<EuiCopy textToCopy={props.value}>
<EuiCopy textToCopy={value}>
{(copyText) => (
<EuiButtonIcon
aria-label={i18n.translate('xpack.security.copyTokenField.copyButton', {
Expand All @@ -48,25 +59,7 @@ export const TokenField: FunctionComponent<TokenFieldProps> = (props) => {
)}
</EuiCopy>
}
style={{ backgroundColor: 'transparent' }}
readOnly
>
<EuiFieldText
data-test-subj="apiKeyTokenField"
controlOnly
aria-label={i18n.translate('xpack.security.copyTokenField.tokenLabel', {
defaultMessage: 'Token',
})}
value={props.value}
style={{
fontFamily: euiThemeVars.euiCodeFontFamily,
fontSize: euiThemeVars.euiFontSizeXS,
backgroundColor: 'transparent',
}}
onFocus={(event) => event.currentTarget.select()}
readOnly
/>
</EuiFormControlLayout>
/>
);
};

Expand Down Expand Up @@ -118,7 +111,7 @@ export const SelectableTokenField: FunctionComponent<SelectableTokenFieldProps>
closePopover={closePopover}
>
<EuiContextMenuPanel
initialFocusedItemIndex={selectedIndex * 2}
initialFocusedItemIndex={selectedIndex}
items={options.reduce<ReactElement[]>((items, option, i) => {
items.push(
<EuiContextMenuItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const AddDomainForm: React.FC = () => {
fullWidth
>
<EuiFieldText
controlOnly
autoFocus
value={addDomainFormInputValue}
onChange={(e) => setAddDomainFormInputValue(e.target.value)}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading