Skip to content

[Emotion] Convert EuiFieldNumber, EuiFieldSearch, and EuiFieldPassword#7802

Merged
cee-chen merged 6 commits intoelastic:emotion/formsfrom
cee-chen:emotion/field-number-password-search
Jun 4, 2024
Merged

[Emotion] Convert EuiFieldNumber, EuiFieldSearch, and EuiFieldPassword#7802
cee-chen merged 6 commits intoelastic:emotion/formsfrom
cee-chen:emotion/field-number-password-search

Conversation

@cee-chen
Copy link
Copy Markdown
Contributor

@cee-chen cee-chen commented May 30, 2024

Summary

Note

This PR merges into a feature branch.

QA

  • EuiFieldNumber
    • Docs and Storybook look the same as before with no regressions (particularly around icon padding)
    • Natively invalid inputs (e.g. set a max and then enter a value above that max) now display a red underline on the input instead of just the icon
  • EuiFieldSearch - docs and storybook look the same as before with no regressions
  • EuiFieldPassword - docs and storybook look the same as before with no regressions

General checklist

  • Browser QA
    • Checked in both light and dark modes
    • Checked in mobile
    • Checked in Chrome, Safari, Edge, and Firefox
      - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA - N/A
  • Code quality checklist
  • Release checklist
    • A changelog entry exists and is marked appropriately.
      - [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)
  • Designer checklist - N/A

cee-chen added 6 commits May 30, 2024 09:28
+ 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
@cee-chen cee-chen force-pushed the emotion/field-number-password-search branch from 3b9769e to 4205ecf Compare May 30, 2024 16:28
@kibanamachine
Copy link
Copy Markdown

Preview staging links for this PR:

@elasticmachine
Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

@cee-chen cee-chen marked this pull request as ready for review May 30, 2024 17:41
@cee-chen cee-chen requested a review from a team as a code owner May 30, 2024 17:41
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@mgadewoll mgadewoll Jun 4, 2024

Choose a reason for hiding this comment

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

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}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@tkajtoch tkajtoch self-requested a review June 3, 2024 13:43
@tkajtoch
Copy link
Copy Markdown
Member

tkajtoch commented Jun 4, 2024

  • EuiFieldSearch and EuiFieldPassword have a smaller icon padding now (see screenshot)
  • All fields have very slightly darker backgrounds (#fbfcfd on main and #f9fbfd on this branch). I actually like that they're darker 🤔

Other than these, the changes look great!

eui elastic co_
eui elastic co_pr_7802_

Copy link
Copy Markdown
Contributor

@mgadewoll mgadewoll Jun 4, 2024

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's a helpful comment! ❤️

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

@cee-chen cee-chen Jun 4, 2024

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That seems reasonable to me too! 👍

Copy link
Copy Markdown
Contributor

@mgadewoll mgadewoll left a comment

Choose a reason for hiding this comment

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

🚢 🐈‍⬛ Thanks for the additional clarifications! The changes look fine to me!

@cee-chen cee-chen merged commit bffd3f1 into elastic:emotion/forms Jun 4, 2024
@cee-chen cee-chen deleted the emotion/field-number-password-search branch June 4, 2024 16:18
Ikuni17 pushed a commit to elastic/kibana that referenced this pull request Jun 21, 2024
`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))
bhapas pushed a commit to bhapas/kibana that referenced this pull request Jun 24, 2024
`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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants