-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SharedUX] Replace SCSS with Emotion, Round 1 #199885
[SharedUX] Replace SCSS with Emotion, Round 1 #199885
Conversation
0c39420
to
d3fe030
Compare
.euiHeaderSectionItem .euiButtonEmpty__text { | ||
// stop global header buttons from jumping during loading state | ||
display: flex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not port these styles over, because I do not see the global header buttons jumping around during loading state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added this in a recent PR. See if you notice it when throttling your browser... in particular, the spaces button (loading rectangle) would jump up and right in a flash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked locally, and it looks like the jump is there if this is excluded.
CleanShot.2024-11-13.at.10.03.40.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ryankeairns! I restored these styles in 8e4cd1d. I will try to improve my test method
@@ -71,6 +72,7 @@ Array [ | |||
aria-hidden="true" | |||
aria-labelledby="elasticMark" | |||
class="chrHeaderLogo__mark" | |||
css="You have tried to stringify object returned from \`css\` function. It isn't supposed to be used directly (e.g. as value of the \`className\` prop), but rather handed to emotion so it can handle it (e.g. as value of \`css\` prop)." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, it is normal to see this message in a snapshot file when the component uses a css
prop that gets an object returned from the css
function.
@@ -102,11 +119,12 @@ export function HeaderLogo({ href, navigateToApp, loadingCount$, ...observables | |||
<img | |||
src={customizedLogo} | |||
className="chrHeaderLogo__mark" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we left these className in here because it's targeted some test files, what do you think about swapping this for testIds especially that it wont be apparent to some other person much later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eokoneyo thanks for taking a look at this. I would prefer to leave this as it is. It will help this PR, and others like it, to avoid ballooning the refactoring into something larger than it needs to be. Changing this code could impact other code owners as well, and then add the need for more teams to review.
Edit: let me think more about this. One of the class names is used as a selector for production code. That probably isn't the best practice and there should be a more acceptable way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bb45851 replaced a className with a testId, since it was only needed for a test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heyy @tsullivan , @eokoneyo ,
Just curious from investigations perspective, I agree that tests should target test-id
s but is there a downside of keeping classNames
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@logeekal The downside of using classNames for non-style purposes is that classNames are not a public contract, so they shouldn't be used for other things.
As we're replacing CSS/SASS with Emotion, for thoroughness, the typical followup will be to remove the className from the DOM, for thoroughness. We could break integrations if we fail to realize that some place in the repo is using that className as a selector in production code.
Relevant: 24f6977
@eokoneyo fully removing the class names had minimal effects. Can you re-review? |
If it still applies, if class names are referenced in tests, convert to |
That part of the description is outdated. I will update. See also the thread here: #199885 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
investigations LGTM 🚀 . Thanks for answering all our queries.
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
History
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Starting backport for target branches: 8.x |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Part of elastic/kibana-team#1082 Selects certain Sass files to replace with styles declared with Emotion. This PR does not include any changes that would be noticeable by end-users. It changes the internals to use a different technology for styling components. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]> (cherry picked from commit d86896b)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary Part of elastic/kibana-team#1082 Selects certain Sass files to replace with styles declared with Emotion. This PR does not include any changes that would be noticeable by end-users. It changes the internals to use a different technology for styling components. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. ## References 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]>
## Summary Part of elastic/kibana-team#1082 Selects certain Sass files to replace with styles declared with Emotion. This PR does not include any changes that would be noticeable by end-users. It changes the internals to use a different technology for styling components. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. ## References 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]>
# Backport This will backport the following commits from `main` to `8.x`: - [[SharedUX] Replace Sass with Emotion, Round 1 (#199885)](#199885) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Tim Sullivan","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-04T17:39:22Z","message":"[SharedUX] Replace Sass with Emotion, Round 1 (#199885)\n\n## Summary\r\n\r\nPart of https://github.com/elastic/kibana-team/issues/1082\r\n\r\nSelects certain Sass files to replace with styles declared with Emotion.\r\nThis PR does not include any changes that would be noticeable by\r\nend-users. It changes the internals to use a different technology for\r\nstyling components.\r\n\r\n~~Some `className` attributes have been kept, because they are\r\nreferenced in JS and tests.~~ Update: all classNames that are no longer\r\nneeded for styling purposes have been removed.\r\n* If the className was needed for tests, it has been replaced with a\r\ntest-subj.\r\n* If the className was used as a selector in production code, it has\r\nbeen replaced with alternative JS.\r\n\r\n## References\r\n1. https://emotion.sh/docs/globals\r\n2. https://emotion.sh/docs/best-practices\r\n3.\r\nhttps://github.com/elastic/eui/discussions/6828#discussioncomment-10825360\r\n\r\n---------\r\n\r\nCo-authored-by: Jatin Kathuria <[email protected]>","sha":"d86896bac0bbc5ed48b43e695e0a73c55b21450c","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport missing","v9.0.0","backport:prev-minor"],"number":199885,"url":"https://github.com/elastic/kibana/pull/199885","mergeCommit":{"message":"[SharedUX] Replace Sass with Emotion, Round 1 (#199885)\n\n## Summary\r\n\r\nPart of https://github.com/elastic/kibana-team/issues/1082\r\n\r\nSelects certain Sass files to replace with styles declared with Emotion.\r\nThis PR does not include any changes that would be noticeable by\r\nend-users. It changes the internals to use a different technology for\r\nstyling components.\r\n\r\n~~Some `className` attributes have been kept, because they are\r\nreferenced in JS and tests.~~ Update: all classNames that are no longer\r\nneeded for styling purposes have been removed.\r\n* If the className was needed for tests, it has been replaced with a\r\ntest-subj.\r\n* If the className was used as a selector in production code, it has\r\nbeen replaced with alternative JS.\r\n\r\n## References\r\n1. https://emotion.sh/docs/globals\r\n2. https://emotion.sh/docs/best-practices\r\n3.\r\nhttps://github.com/elastic/eui/discussions/6828#discussioncomment-10825360\r\n\r\n---------\r\n\r\nCo-authored-by: Jatin Kathuria <[email protected]>","sha":"d86896bac0bbc5ed48b43e695e0a73c55b21450c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199885","number":199885,"mergeCommit":{"message":"[SharedUX] Replace Sass with Emotion, Round 1 (#199885)\n\n## Summary\r\n\r\nPart of https://github.com/elastic/kibana-team/issues/1082\r\n\r\nSelects certain Sass files to replace with styles declared with Emotion.\r\nThis PR does not include any changes that would be noticeable by\r\nend-users. It changes the internals to use a different technology for\r\nstyling components.\r\n\r\n~~Some `className` attributes have been kept, because they are\r\nreferenced in JS and tests.~~ Update: all classNames that are no longer\r\nneeded for styling purposes have been removed.\r\n* If the className was needed for tests, it has been replaced with a\r\ntest-subj.\r\n* If the className was used as a selector in production code, it has\r\nbeen replaced with alternative JS.\r\n\r\n## References\r\n1. https://emotion.sh/docs/globals\r\n2. https://emotion.sh/docs/best-practices\r\n3.\r\nhttps://github.com/elastic/eui/discussions/6828#discussioncomment-10825360\r\n\r\n---------\r\n\r\nCo-authored-by: Jatin Kathuria <[email protected]>","sha":"d86896bac0bbc5ed48b43e695e0a73c55b21450c"}}]}] BACKPORT-->
## Summary Part of elastic/kibana-team#1082 Selects certain Sass files to replace with styles declared with Emotion. This PR does not include any changes that would be noticeable by end-users. It changes the internals to use a different technology for styling components. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. ## References 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]>
## Summary Part of elastic/kibana-team#1082 Selects certain Sass files to replace with styles declared with Emotion. This PR does not include any changes that would be noticeable by end-users. It changes the internals to use a different technology for styling components. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. ## References 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]>
## Summary Part of elastic/kibana-team#1082 Selects certain Sass files to replace with styles declared with Emotion. This PR does not include any changes that would be noticeable by end-users. It changes the internals to use a different technology for styling components. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. ## References 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]>
Pinging @elastic/appex-sharedux (Team:SharedUX) |
Summary
Part of https://github.com/elastic/kibana-team/issues/1082
Selects certain Sass files to replace with styles declared with Emotion. This PR does not include any changes that would be noticeable by end-users. It changes the internals to use a different technology for styling components.
SomeUpdate: all classNames that are no longer needed for styling purposes have been removed.className
attributes have been kept, because they are referenced in JS and tests.References