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

[BUG] Fix the EuiRange prepend prop CSS #7678

Merged
merged 6 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -180,7 +180,7 @@ exports[`EuiRange props custom ticks should render 1`] = `

exports[`EuiRange props disabled should render 1`] = `
<div
class="euiRangeWrapper euiRange emotion-euiRangeWrapper-regular-euiRange"
class="euiRangeWrapper euiRange emotion-euiRangeWrapper-regular-disabled-euiRange"
>
<div
aria-hidden="false"
Expand Down
2 changes: 2 additions & 0 deletions src/components/form/range/range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ export class EuiRangeClass extends Component<
css={cssStyles}
fullWidth={fullWidth}
compressed={compressed}
disabled={disabled}
readOnly={readOnly}
>
{showLabels && (
<EuiRangeLabel side="min" disabled={disabled}>
Expand Down
16 changes: 15 additions & 1 deletion src/components/form/range/range_wrapper.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
*/

import { css } from '@emotion/react';
import { euiFormControlSize } from '../form.styles';
import { euiFormControlSize, euiFormVariables } from '../form.styles';
import { UseEuiTheme } from '../../../services';

export const euiRangeWrapperStyles = (euiThemeContext: UseEuiTheme) => {
const { backgroundColor, backgroundDisabledColor, backgroundReadOnlyColor } =
euiFormVariables(euiThemeContext);

return {
euiRangeWrapper: css`
display: flex;
Expand All @@ -20,6 +23,7 @@ export const euiRangeWrapperStyles = (euiThemeContext: UseEuiTheme) => {
/* There's no way to target the layout of the extra input, so we must
* use the descendant selector to allow the width to shrink. */
inline-size: auto;
background: ${backgroundColor};
}
`,
regular: css`
Expand All @@ -31,5 +35,15 @@ export const euiRangeWrapperStyles = (euiThemeContext: UseEuiTheme) => {
fullWidth: css`
max-inline-size: 100%;
`,
disabled: css`
> .euiFormControlLayout {
background: ${backgroundDisabledColor};
}
`,
readOnly: css`
&& > .euiFormControlLayout {
background: ${backgroundReadOnlyColor};
}
`,
};
};
9 changes: 8 additions & 1 deletion src/components/form/range/range_wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import { euiRangeWrapperStyles } from './range_wrapper.styles';
export interface EuiRangeWrapperProps
extends CommonProps,
HTMLAttributes<HTMLDivElement>,
Pick<_SharedRangeInputProps, 'fullWidth' | 'compressed'> {}
Pick<
_SharedRangeInputProps,
'fullWidth' | 'compressed' | 'disabled' | 'readOnly'
> {}

export const EuiRangeWrapper = forwardRef<HTMLDivElement, EuiRangeWrapperProps>(
(props, ref) => {
Expand All @@ -29,6 +32,8 @@ export const EuiRangeWrapper = forwardRef<HTMLDivElement, EuiRangeWrapperProps>(
className,
fullWidth = defaultFullWidth,
compressed,
disabled,
readOnly,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only added this change to the single EuiRange but tested it in all examples on the docs site. Wasn't able to get an EuiDualRange to show the prepend or append labels, but would be an easy add if I just missed something.

Copy link
Contributor

Choose a reason for hiding this comment

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

Lol I'm honestly still so confused why our single ranges even support append/prepend 🙈 Ah well, probably too much of a hassle to breaking change/remove it now

...rest
} = props;

Expand All @@ -41,6 +46,8 @@ export const EuiRangeWrapper = forwardRef<HTMLDivElement, EuiRangeWrapperProps>(
!compressed && styles.regular,
compressed && styles.compressed,
fullWidth && styles.fullWidth,
disabled && styles.disabled,
readOnly && styles.readOnly,
];

return (
Expand Down
Loading