Skip to content

Commit

Permalink
More CSS tweaks
Browse files Browse the repository at this point in the history
- Fix `disabled`+`invalid` to hide invalid underline (transparent)

- tweak `euiFormControlDefaultShadow` to allow more granular CSS
  - it's possible I should just rewrite this whole mixin at this point? :|

- Update delimited styles to smoothly transition background color for disabled/readonly bgs (to match the inputs)
  • Loading branch information
cee-chen committed Aug 13, 2024
1 parent 78c1c29 commit f2d8e9f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
5 changes: 1 addition & 4 deletions packages/eui/src/components/form/form.styles.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ describe('euiFormControlStyles', () => {
-webkit-text-fill-color: #98A2B3;
background-color: #eef1f7;
cursor: not-allowed;
--euiFormControlStateColor: transparent;
&::-webkit-input-placeholder {
Expand Down Expand Up @@ -186,11 +187,8 @@ describe('euiFormControlStyles', () => {
border: none;
box-shadow: inset 0 0 0 1px rgba(32,38,47,0.1);
background-color: #f9fbfd;
background-repeat: no-repeat;
background-size: 0% 100%;
Expand All @@ -200,7 +198,6 @@ describe('euiFormControlStyles', () => {
transparent 2px,
transparent 100%
);
@media screen and (prefers-reduced-motion: no-preference) {
transition:
background-image 150ms ease-in,
Expand Down
24 changes: 20 additions & 4 deletions packages/eui/src/components/form/form.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,14 @@ export const euiFormControlDefaultShadow = (
{
withBorder = true,
withBackground = true,
}: { withBorder?: boolean; withBackground?: boolean } = {}
withBackgroundColor = withBackground,
withBackgroundAnimation = withBackground,
}: {
withBorder?: boolean;
withBackground?: boolean;
withBackgroundColor?: boolean;
withBackgroundAnimation?: boolean;
} = {}
) => {
const { euiTheme } = euiThemeContext;
const form = euiFormVariables(euiThemeContext);
Expand All @@ -243,10 +250,13 @@ export const euiFormControlDefaultShadow = (
const border = `
border: none;
box-shadow: inset 0 0 0 ${euiTheme.border.width.thin} ${form.borderColor};
`;
`.trim();

const backgroundGradient = `
const backgroundColor = `
background-color: ${form.backgroundColor};
`.trim();

const backgroundGradient = `
background-repeat: no-repeat;
background-size: 0% 100%;
background-image: linear-gradient(to top,
Expand All @@ -255,17 +265,22 @@ export const euiFormControlDefaultShadow = (
transparent ${euiTheme.border.width.thick},
transparent 100%
);
`.trim();

const backgroundAnimation = `
${euiCanAnimate} {
transition:
background-image ${form.animationTiming},
background-size ${form.animationTiming},
background-color ${form.animationTiming};
}`;
}
`.trim();

return `
${withBorder ? border : ''}
${withBackgroundColor ? backgroundColor : ''}
${withBackground ? backgroundGradient : ''}
${withBackgroundAnimation ? backgroundAnimation : ''}
`;
};

Expand Down Expand Up @@ -297,6 +312,7 @@ export const euiFormControlDisabledStyles = (euiThemeContext: UseEuiTheme) => {
-webkit-text-fill-color: ${form.controlDisabledColor};
background-color: ${form.backgroundDisabledColor};
cursor: not-allowed;
--euiFormControlStateColor: transparent;
${euiPlaceholderPerBrowser(`
color: ${form.controlDisabledColor};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ export const euiFormControlLayoutDelimitedStyles = (
euiThemeContext: UseEuiTheme
) => {
return {
// Appended onto existing `euiFormControlLayout` styles
delimited: css``,
// Appended onto existing `euiFormControlLayout` styles
delimited: css(
// Transition smoothly between disabled/readOnly background color changes
euiFormControlDefaultShadow(euiThemeContext, {
withBorder: false,
withBackground: false,
withBackgroundAnimation: true,
})
),
disabled: css(euiFormControlDisabledStyles(euiThemeContext)),
readOnly: css(euiFormControlReadOnlyStyles(euiThemeContext)),

Expand All @@ -32,7 +39,11 @@ export const euiFormControlLayoutDelimitedStyles = (
display: flex;
`,
invalid: css(
euiFormControlDefaultShadow(euiThemeContext, { withBorder: false }),
euiFormControlDefaultShadow(euiThemeContext, {
withBorder: false,
withBackgroundColor: false,
withBackgroundAnimation: false,
}),
euiFormControlInvalidStyles(euiThemeContext)
),
},
Expand Down

0 comments on commit f2d8e9f

Please sign in to comment.