[Emotion] Convert EuiFieldNumber, EuiFieldSearch, and EuiFieldPassword#7802
Conversation
+ bonus: we can now add the red underline for native invalid states!! hooray!
- class component, not a function component
- `::-ms-reveal` is still a thing! TIL
3b9769e to
4205ecf
Compare
|
Preview staging links for this PR:
|
💚 Build Succeeded
History
|
There was a problem hiding this comment.
I'm particularly looking for feedback on whether folks think the new euiFormControlStyles() JS mixin feels DRY enough compared to the previous Sass mixin or if they like that it's slightly more verbose but also more explicit.
Previously there were no options in the Sass mixin to exclude certain selectors etc, and I think this newer approach is more repetitive but easier to mix and match custom CSS per-component.
There was a problem hiding this comment.
I personally like the new euiFormControlStyles() way 👍
And when it comes to complex styles like forms, I think a bit more verbosity in defining the styles more specifically per usage is not a bad thing as - imho - it helps to understand what styles are added more explicitly.
E.g. redefining this following part might look unnecessary and could be dried out but it also:
a) makes more clear what's really used - it's being deliberate about what to use
b) shows that it's the default
c) provides the styles definition with the component instead of at a higher level
&:focus {
${formStyles.focus}
}
&:disabled {
${formStyles.disabled}
}
&[readOnly] {
${formStyles.readOnly}
}
&:autofill {
${formStyles.autoFill}
}There was a problem hiding this comment.
That was what I was thinking as well, thanks a million for your thoughts Lene! I think not defining the selectors also gives us more flexibility with them for one-offs, e.g. if we wanted :focus-visible as well as :focus for one specific selector, and so on and so forth.
There was a problem hiding this comment.
I personally like the new euiFormControlStyles() way 👍
And when it comes to complex styles like forms, I think a bit more verbosity in defining the styles more specifically per usage is not a bad thing as - imho - it helps to understand what styles are added more explicitly.
E.g. redefining this following part might look unnecessary and could be dried out but it also:
a) makes more clear what's really used - it's being deliberate about what to use
b) shows that it's the default
c) provides the styles definition with the component instead of at a higher level
&:focus {
${formStyles.focus}
}
&:disabled {
${formStyles.disabled}
}
&[readOnly] {
${formStyles.readOnly}
}
&:autofill {
${formStyles.autoFill}
}| } | ||
| `, | ||
|
|
||
| // Skip the css() on the default height to avoid generating a className |
There was a problem hiding this comment.
That's a helpful comment! ❤️
There was a problem hiding this comment.
It's a neat technique I can't believe I only just discovered this late into the conversion! 💀
| @@ -1,8 +0,0 @@ | |||
| .euiFieldNumber { | |||
| @include euiFormControlStyle; | |||
| @include euiFormControlWithIcon($isIconOptional: true, $side: 'left'); | |||
There was a problem hiding this comment.
Just to be sure it's expected currently: I noticed that the spacing changes slightly between icons and value. We changed the approach to position icons and calculate the affordance - so I assume this is expected? 🙂
Screen.Recording.2024-06-04.at.14.57.43.mov
There was a problem hiding this comment.
Responding to Tomasz as well here for comment threading.
EuiFieldSearch and EuiFieldPassword have a smaller icon padding now (see screenshot)
Expected/known change, that "decision" was made in #7770 when the CSS variable technique was adopted. I opted to greatly simplified the calculated logic over fussing with a few pixels or so, what I primarily care about is that text is rendering/cut off appropriately relative to the number of displayed icons.
All fields have very slightly darker backgrounds (#fbfcfd on main and #f9fbfd on this branch). I actually like that they're darker 🤔
Some amount of intentional-ish color changes are also being made in the Emotion conversions (mostly around borders/backgrounds). Some of that is the baseline color tokens were adjusted by Caroline at the beginning of the Emotion conversion, and some of that is intentionally reducing complex color calculations in favor of performance. In general unless something is failing color contrast checks or looks very obviously wrong/different to the naked eye, I'm not fussed about a slight color diffs.
There was a problem hiding this comment.
Actually, hm, I may have spoken too soon on that first paragraph. Now that I flip back and forth between the old and new I'm not sure I super love the direction the padding is offset in, so let me try to tweak the numbers a bit
There was a problem hiding this comment.
I can't get the numbers any better without some pretty ludicrous math. Going to leave it for now and maybe come back to it at the end of the conversion. The paddings are different but not broken looking, so IMO it's Good Enough 😅
There was a problem hiding this comment.
That seems reasonable to me too! 👍
mgadewoll
left a comment
There was a problem hiding this comment.
🚢 🐈⬛ Thanks for the additional clarifications! The changes look fine to me!
`v95.0.0-backport.0` ⏩ `v95.1.0-backport.0` This PR primarily concerns converting multiple common/building block form control components to Emotion (text, number, and search fields). This means that custom CSS or direct `className` usage of these form controls **should be manually QA'd** to ensure they still look the same before visually, with no regressions. _[Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_ --- ## [`v95.1.0`](https://github.com/elastic/eui/releases/v95.1.0) - Updated `EuiFormControlLayout` to automatically pass icon padding affordance down to child `input`s ([#7799](elastic/eui#7799)) **Bug fixes** - Fixed broken focus/invalid styling on compressed `EuiDatePickerRange`s ([#7770](elastic/eui#7770)) **CSS-in-JS conversions** - Converted `EuiFieldText` to Emotion ([#7770](elastic/eui#7770)) - Updated the autofill colors of Chrome (and other webkit browsers) to better match EUI's light and dark mode ([#7776](elastic/eui#7776)) - Converted `EuiFieldNumber` to Emotion ([#7802](elastic/eui#7802)) - Converted `EuiFieldSearch` to Emotion ([#7802](elastic/eui#7802)) - Converted `EuiFieldPassword` to Emotion ([#7802](elastic/eui#7802)) - Converted `EuiTextArea` to Emotion ([#7812](elastic/eui#7812)) - Converted `EuiSelect` to Emotion ([#7812](elastic/eui#7812)) - Converted `EuiSuperSelect` to Emotion ([#7812](elastic/eui#7812)) ## [`v95.1.0-backport.0`](https://github.com/elastic/eui/releases/v95.1.0-backport.0) **This is a backport release only intended for use by Kibana.** - Updated `EuiSteps` to support a new `titleSize="xxs"` style, which outputs the same title font size but smaller unnumbered step indicators ([#7813](elastic/eui#7813)) - Updated `EuiStepsHorizontal` to support a new `size="xs"` style, which outputs smaller unnumbered step indicators ([#7813](elastic/eui#7813)) - Updated `EuiStepNumber` to support new `titleSize="none"` which omits rendering step numbers, and will only render icons ([#7813](elastic/eui#7813))
`v95.0.0-backport.0` ⏩ `v95.1.0-backport.0` This PR primarily concerns converting multiple common/building block form control components to Emotion (text, number, and search fields). This means that custom CSS or direct `className` usage of these form controls **should be manually QA'd** to ensure they still look the same before visually, with no regressions. _[Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_ --- ## [`v95.1.0`](https://github.com/elastic/eui/releases/v95.1.0) - Updated `EuiFormControlLayout` to automatically pass icon padding affordance down to child `input`s ([elastic#7799](elastic/eui#7799)) **Bug fixes** - Fixed broken focus/invalid styling on compressed `EuiDatePickerRange`s ([elastic#7770](elastic/eui#7770)) **CSS-in-JS conversions** - Converted `EuiFieldText` to Emotion ([elastic#7770](elastic/eui#7770)) - Updated the autofill colors of Chrome (and other webkit browsers) to better match EUI's light and dark mode ([elastic#7776](elastic/eui#7776)) - Converted `EuiFieldNumber` to Emotion ([elastic#7802](elastic/eui#7802)) - Converted `EuiFieldSearch` to Emotion ([elastic#7802](elastic/eui#7802)) - Converted `EuiFieldPassword` to Emotion ([elastic#7802](elastic/eui#7802)) - Converted `EuiTextArea` to Emotion ([elastic#7812](elastic/eui#7812)) - Converted `EuiSelect` to Emotion ([elastic#7812](elastic/eui#7812)) - Converted `EuiSuperSelect` to Emotion ([elastic#7812](elastic/eui#7812)) ## [`v95.1.0-backport.0`](https://github.com/elastic/eui/releases/v95.1.0-backport.0) **This is a backport release only intended for use by Kibana.** - Updated `EuiSteps` to support a new `titleSize="xxs"` style, which outputs the same title font size but smaller unnumbered step indicators ([elastic#7813](elastic/eui#7813)) - Updated `EuiStepsHorizontal` to support a new `size="xs"` style, which outputs smaller unnumbered step indicators ([elastic#7813](elastic/eui#7813)) - Updated `EuiStepNumber` to support new `titleSize="none"` which omits rendering step numbers, and will only render icons ([elastic#7813](elastic/eui#7813))


Summary
Note
This PR merges into a feature branch.
QA
General checklist
- [ ] Checked for accessibility including keyboard-only and screenreader modesAdded orupdated jestand cypress tests- [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)