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

[Emotion] Convert EuiFormControlLayoutDelimited (2/3) #7957

Merged
merged 21 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
39c8497
[docs] Clean up EuiFormControlLayoutDelimited example
cee-chen Aug 9, 2024
18d507f
DRY out repeated border/border-radius styles by adding new prop
cee-chen Aug 11, 2024
5dfc86c
Set up basic delimited styles
cee-chen Aug 11, 2024
3eab24a
Allowing passing styles directly to `.euiFormControlLayout__childrenW…
cee-chen Aug 11, 2024
f41ff68
Set up invalid styles
cee-chen Aug 11, 2024
43edc3e
Replace fullWidth CSS with React context
cee-chen Aug 11, 2024
800ab9b
Convert delimiter styles to Emotion
cee-chen Aug 11, 2024
dfe0d36
Convert `.euiFormControlLayoutDelimited__input` styles
cee-chen Aug 11, 2024
2091371
Delete Sass files
cee-chen Aug 11, 2024
8631903
[EuiDatePicker] Fix styles that were relying on direct usage of `.eui…
cee-chen Aug 11, 2024
7ae705a
[EuiDatePickerRange] Fix regressed disabled background styles
cee-chen Aug 11, 2024
92ff1ef
[EuiSuperDatePicker] Fix quick select only styling + remove now-unnec…
cee-chen Aug 11, 2024
25e35da
[EuiDualRange] Fix broken CSS selector
cee-chen Aug 11, 2024
4903635
[VRT] Update screenshots and add new permutations story
cee-chen Aug 11, 2024
fc74c1c
[tests] `shouldRenderCustomStyles`
cee-chen Aug 11, 2024
6bd72d5
Enhance `cloneElementWithCss` to allow prepending cloned CSS as oppos…
cee-chen Aug 12, 2024
25e2db7
changelog
cee-chen Aug 12, 2024
7424d0d
Tweak EuiFieldNumber's browser stepper UI to follow EUI's color mode
cee-chen Aug 13, 2024
78c1c29
[PR feedback] Tweak delimited playground to pass invalid/disabled/rea…
cee-chen Aug 13, 2024
f2d8e9f
More CSS tweaks
cee-chen Aug 13, 2024
4216c21
Fix border-radius regression/lapse
cee-chen Aug 13, 2024
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 @@ -3,7 +3,7 @@
exports[`EuiFormControlLayoutDelimited is rendered 1`] = `
<div
aria-label="aria-label"
class="euiFormControlLayout euiFormControlLayoutDelimited testClass1 testClass2 emotion-euiFormControlLayout-group-euiTestCss"
class="euiFormControlLayout euiFormControlLayoutDelimited testClass1 testClass2 emotion-euiFormControlLayout-group-delimited-euiTestCss"
data-test-subj="test subject string"
>
<div
Expand Down Expand Up @@ -34,7 +34,7 @@ exports[`EuiFormControlLayoutDelimited is rendered 1`] = `

exports[`EuiFormControlLayoutDelimited props delimiter is rendered as a node 1`] = `
<div
class="euiFormControlLayout euiFormControlLayoutDelimited emotion-euiFormControlLayout-group"
class="euiFormControlLayout euiFormControlLayoutDelimited emotion-euiFormControlLayout-group-delimited"
>
<div
class="euiFormControlLayout__childrenWrapper emotion-euiFormControlLayout__childrenWrapper-inGroup-prependOnly-appendOnly"
Expand Down Expand Up @@ -62,7 +62,7 @@ exports[`EuiFormControlLayoutDelimited props delimiter is rendered as a node 1`]

exports[`EuiFormControlLayoutDelimited props delimiter is rendered as a string 1`] = `
<div
class="euiFormControlLayout euiFormControlLayoutDelimited emotion-euiFormControlLayout-group"
class="euiFormControlLayout euiFormControlLayoutDelimited emotion-euiFormControlLayout-group-delimited"
>
<div
class="euiFormControlLayout__childrenWrapper emotion-euiFormControlLayout__childrenWrapper-inGroup-prependOnly-appendOnly"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,6 @@
max-width: none;
}

// Target when the euiFormControlLayout is disabled without specifying the full class name in case it ever changes
&[class*='-isDisabled'] {
@include euiFormControlDisabledStyle;

.euiFormControlLayout__childrenWrapper {
background-color: $euiFormBackgroundDisabledColor;
}
}

// Target when the euiFormControlLayout is readOnly without specifying the full class name in case it ever changes
&[class*='-readOnly'] {
@include euiFormControlReadOnlyStyle;

.euiFormControlLayout__childrenWrapper {
background-color: $euiFormBackgroundReadOnlyColor;
}
}

&--isInvalid .euiFormControlLayout__childrenWrapper {
@include euiFormControlInvalidStyle;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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';
import {
euiFormControlDisabledStyles,
euiFormControlReadOnlyStyles,
} from '../form.styles';

export const euiFormControlLayoutDelimitedStyles = (
euiThemeContext: UseEuiTheme
) => {
return {
// Appended onto existing `euiFormControlLayout` styles
delimited: css``,
disabled: css(euiFormControlDisabledStyles(euiThemeContext)),
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
readOnly: css(euiFormControlReadOnlyStyles(euiThemeContext)),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import React, {
} from 'react';
import classNames from 'classnames';

import { useEuiMemoizedStyles } from '../../../services';
import { useEuiI18n } from '../../i18n';
import { EuiIcon } from '../../icon';
import { EuiText } from '../../text';
Expand All @@ -22,6 +23,7 @@ import {
EuiFormControlLayout,
EuiFormControlLayoutProps,
} from './form_control_layout';
import { euiFormControlLayoutDelimitedStyles } from './form_control_layout_delimited.styles';

export type EuiFormControlLayoutDelimitedProps =
Partial<EuiFormControlLayoutProps> & {
Expand Down Expand Up @@ -51,9 +53,17 @@ export const EuiFormControlLayoutDelimited: FunctionComponent<
'euiFormControlLayoutDelimited--isInvalid': showInvalidState,
});

const styles = useEuiMemoizedStyles(euiFormControlLayoutDelimitedStyles);
const cssStyles = [
styles.delimited,
rest.isDisabled && styles.disabled,
rest.readOnly && styles.readOnly,
];

return (
<EuiFormControlLayout
isDelimited
css={cssStyles}
className={classes}
iconsPosition="static"
{...rest}
Expand Down