[Security Solution][Detection Engine] EUI Tech Debt - Removes references to static EuiTheme variables#208820
Conversation
|
/ci |
|
Note to self: I think that 7b5441e was a mistake. That function should reference components that use the |
The EUI page header has some parent <p> somewhere, and we were incorrectly putting <div>s as children. This fixes that, along with a few necessary style changes (and updated snapshots).
This replaces static references to euiThemeVars to enable this behavior. I did away with some `margin` usage in favor of `EuiFlexGroup`'s `gutterSize` prop, as well as removing some manual `display: flex`s in favor of EuiFlexItem/Group. This also appears to fix some errors in the snapshot test related to this component. I'm not sure how those happened, but it appears specific to that test and not a production behavior.
While removing static references to euiThemeVars, I found that these manual styles weren't needed: * `&div:first-child` selector wasn't being applied * margins can be replaced with a different `gutterSize` prop * the eui-yScrollWithShadow was adding a shadow to a container that wasn't actually scrollable; when the extra margin above was removed, this caused the shadow to cover part of the border of the Exception item panels
We had negative-margin CSS to offset a 24px `gap` on our flex grouping. By reducing the `gap` to 8px, we no longer need to offset it.
Instead of adding bottom padding to each element in a container (the header of an individual exception list on its Shared Details page), we instead make the container a `FlexGroup` and add an analogous `gutterSize` prop (and `margin-bottom`) to it.
I forgot about the aforementioned weirdness in EUIPageHeader that necessitates everything being a span.
We were wrapping a `span` in a `div`, and then giving that div: 1. display: inline 2. margin-left: 4px Because the margin is so insignificant (there is already natural space after the previous element), I opted to just remove the div and its styles altogether.
The generated styles are equivalent.
…tCard This component exists as the inner item on the Shared Exception Lists page. Styles have been verified as equivalent.
* Defines a FieldSectionGroup component instead of applying the same styles to multiple identical EuiFieldGroup components * Replaces use of margin-top with a more appropriate `align-self` declaration
These were already fixed on the package version of this component, but the one that's still in the plugin was not updated, which I noticed while taking screenshots.
This ports the styles over from static generation with euiThemeVars to dynamic with useEuiTheme. I also simplified styles in a few ways, here: 1. Remove the JS conditions around applying styles, and porting to equivalent CSS 2. Removing unnecessary flex-basis CSS (which didn't work on the div it was being applied to) 3. Moving child `color` CSS to the parent, instead.
These tests were failing because they lacked the EUI Theme context when we were rendering these components which now require them (previously they were requiring a static object imported from elsewhere).
b4c12ab to
eb60210
Compare
|
/ci |
We don't really want to test the EuiThemeProvider, it's merely a consequence of the component's dependencies/how it's written. Calling the provider out as a wrapper better helps to show that relationship.
|
/ci |
|
Pinging @elastic/security-detection-engine (Team:Detection Engine) |
| */ | ||
| import React, { useState, useCallback } from 'react'; | ||
| import { css } from '@emotion/css'; | ||
| import styled from '@emotion/styled'; |
There was a problem hiding this comment.
shouldn't we avoid using styled components according to elastic/eui#6828 (comment) and give preference to @emotion/css or @emotion/react?
There was a problem hiding this comment.
@vitaliidm this is not the incompatible styled-components package but rather a variant of emotion's syntax. It's mentioned later in the comment you referenced:
As a simple first step in this transition, consider using @emotion/styled. This allows you to keep the familiar styled syntax while aligning with the Emotion ecosystem
It's unclear whether we'll need to change these in the future, but if so we can address them similarly/concurrently with the removal of remaining styled-components references.
There was a problem hiding this comment.
Yes, it's part of@emotion, but what got me curious - why the need to introduce styled in this file and couple of others?
We did not have styled-components here at all, so using it @emotion/styled as a transition step does not apply in this case.
In x-pack/solutions/security/plugins/security_solution/public/exceptions/pages/shared_lists/index.tsx for example, styled-components were replaced by @emotion/styled and I see why you did it there. It's in line with the eui-team guide.
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
cc @rylnd |
vitaliidm
left a comment
There was a problem hiding this comment.
Changes LGTM. Thanks for addressing tech debt
…ces to static EuiTheme variables (elastic#208820) ## Summary This PR is a followup to elastic#205990, which removed references to all of the deprecated/renamed EUI vars in preparation for 9.0. Here, we address some of the non-critical tech debt related to the EUI refresh, namely the [removal of static EUI tokens](elastic#199715 (comment)) from our codebase. I made every attempt not to change any styles in this PR, except to simplify CSS to produce an equivalent design. A common example of this was removing a static `margin` or `padding` declaration referencing `euiThemeVars.size*`, and swapping it with an equivalent `gutterSize` prop on the `EuiFlexGroup` container, or with an `align-self` or other equivalent flexbox directive. ## Screenshots of Areas Affected The majority of changes here involved the Exception List/Item pages. I've attached screenshots of their current layout for comparison/review: <details> <summary> <h3>Rule Exceptions Tab</h3> </summary> <kbd> <h3>Before</h3> <img width="1395" alt="Rule exceptions tab - before" src="https://github.com/user-attachments/assets/db7a5487-7df3-4a5f-b88e-90ab34784970" /> </kbd> <kbd> <h3>After</h3> <img width="1421" alt="Rule exceptions tab - after" src="https://github.com/user-attachments/assets/77cbdefc-cbec-4b9e-8436-197f2f2f6677" /> </kbd> </details> <details> <summary> <h3>Shared Exception Lists</h3> </summary> <kbd> <img width="1517" alt="Shared Exception Lists" src="https://github.com/user-attachments/assets/5448dd65-60f7-470c-bf7a-7af75bb914fa" /> </kbd> </details> <details> <summary> <h3>Shared Exception List Details</h3> </summary> <kbd> <img width="1517" alt="Shared Exception List Details" src="https://github.com/user-attachments/assets/6e03fef6-af58-40bb-98c5-188651a584cc" /> </kbd> </details> <details> <summary> <h3>Threshold Input</h3> </summary> <kbd> <img width="1046" alt="Threshold Input" src="https://github.com/user-attachments/assets/28738857-6bdf-404f-a790-a9f4e66ff27a" /> </kbd> </details> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Summary
This PR is a followup to #205990, which removed references to all of the deprecated/renamed EUI vars in preparation for 9.0. Here, we address some of the non-critical tech debt related to the EUI refresh, namely the removal of static EUI tokens from our codebase.
I made every attempt not to change any styles in this PR, except to simplify CSS to produce an equivalent design. A common example of this was removing a static
marginorpaddingdeclaration referencingeuiThemeVars.size*, and swapping it with an equivalentgutterSizeprop on theEuiFlexGroupcontainer, or with analign-selfor other equivalent flexbox directive.Screenshots of Areas Affected
The majority of changes here involved the Exception List/Item pages. I've attached screenshots of their current layout for comparison/review:
Rule Exceptions Tab
Before
After
Shared Exception Lists
Shared Exception List Details
Threshold Input
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:*label is applied per the guidelines