Skip to content
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] SCSS migration Home plugin #214859

Merged

Conversation

paulinashakirova
Copy link
Contributor

@paulinashakirova paulinashakirova commented Mar 17, 2025

Summary

This PR is a part of a Replace SCSS with CSS-in-JS epic.

  • rewriting styles using @emotion/react
  • updating tests

@paulinashakirova paulinashakirova added release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) labels Mar 17, 2025
@paulinashakirova paulinashakirova self-assigned this Mar 17, 2025
import { METRIC_TYPE } from '@kbn/analytics';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';
import { fullScreenGraphicsMixinStyles } from '../kibanaFullScreenGraphicsMixin';
Copy link
Contributor Author

@paulinashakirova paulinashakirova Mar 18, 2025

Choose a reason for hiding this comment

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

This is a locally defined "mixin" that can potentially be defined and imported from a core-app where there .scss mixin used to be.

/**
* Shows a full-screen welcome page that gives helpful quick links to beginners.
*/
export class Welcome extends React.Component<Props> {
private services = getServices();
export const Welcome: React.FC<WelcomeProps> = ({ urlBasePath, onSkip }: WelcomeProps) => {
Copy link
Contributor Author

@paulinashakirova paulinashakirova Mar 18, 2025

Choose a reason for hiding this comment

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

This change is a bit tricky - I can revert if it's better so as to not mix oranges and apples...

I refactored this component class->function because I wanted to use useEuiShadow, though if it's out of scope and I should look for an alternative approach - i ll do so 😊

Number(useEuiTheme().euiTheme.levels.navigation),
useEuiTheme()
),
]}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also not sure if there is a better approach to "calling" these mixin styles than this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'd probably get a lint error here for rules of hook, lets invoke the useEuiTheme hook outside of the render and pass the value we want to the mixin

@paulinashakirova paulinashakirova changed the title Home plugin scss to emotion [SharedUX] Home plugin scss to emotion migration Mar 18, 2025
Copy link
Contributor

@eokoneyo eokoneyo left a comment

Choose a reason for hiding this comment

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

First pass of review from reading through, I've pointed out some things we could improve, will test locally in a bit

Comment on lines 56 to 72
<EuiButton
fill
css={({ euiTheme }: UseEuiTheme) =>
css({
marginRight: euiTheme.size.s,
})
}
onClick={onConfirm}
>
<FormattedMessage id="home.tryButtonLabel" defaultMessage="Add integrations" />
</EuiButton>
<EuiButtonEmpty
className="homWelcome__footerAction"
css={({ euiTheme }: UseEuiTheme) =>
css({
marginRight: euiTheme.size.s,
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We could consolidate these two definitions into a single declaration that are then referenced for brevity, also it means only one style will be generated instead of two. Maybe something like so;

Suggested change
<EuiButton
fill
css={({ euiTheme }: UseEuiTheme) =>
css({
marginRight: euiTheme.size.s,
})
}
onClick={onConfirm}
>
<FormattedMessage id="home.tryButtonLabel" defaultMessage="Add integrations" />
</EuiButton>
<EuiButtonEmpty
className="homWelcome__footerAction"
css={({ euiTheme }: UseEuiTheme) =>
css({
marginRight: euiTheme.size.s,
})
}
const footerAction = useCallback(({ euiTheme }: UseEuiTheme) => {
return css({
marginRight: euiTheme.size.s,
})
}, [euiTheme]);
...
<EuiButtonEmpty fill css={footerAction} ...

>
<EuiScreenReaderOnly>
<h2 id="homSolutions__title">
<h2 id="homeSolutions__title">
Copy link
Contributor

Choose a reason for hiding this comment

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

I fear these changes might increase the scope of this PR, especially if these ids are used in either ftr or functional tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yesss, I checked with those tests and updated accordingly 😊

Number(useEuiTheme().euiTheme.levels.navigation),
useEuiTheme()
),
]}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'd probably get a lint error here for rules of hook, lets invoke the useEuiTheme hook outside of the render and pass the value we want to the mixin

backgroundColor: euiTheme.euiTheme.colors.backgroundBasePlain,
opacity: 0,
overflow: 'auto',
animation: `${fullScreenGraphicsFadeIn} ${euiTheme.euiTheme.animation.extraSlow} ${euiTheme.euiTheme.animation.resistance} 0s forwards`,
Copy link
Contributor

Choose a reason for hiding this comment

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

We typically want to wrap animation declarations within the canAnimate helper util from eui, see here

@elasticmachine
Copy link
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #12 / X-Pack Accessibility Tests - Group 1 Kibana Home Accessibility Kibana overview page meets a11y requirements
  • [job] [logs] FTR Configs #12 / X-Pack Accessibility Tests - Group 1 Kibana Home Accessibility Kibana overview page meets a11y requirements

History

cc @paulinashakirova

@@ -30,7 +30,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(event.properties.target).to.be.an('array');
const targets = event.properties.target as string[];
expect(targets.includes('DIV')).to.be(true);
expect(targets.includes('class=homWelcome')).to.be(true);
Copy link
Contributor Author

@paulinashakirova paulinashakirova Mar 19, 2025

Choose a reason for hiding this comment

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

I removed this class name as it is no longer used in the code.

@paulinashakirova paulinashakirova marked this pull request as ready for review March 19, 2025 16:40
@paulinashakirova paulinashakirova requested review from a team as code owners March 19, 2025 16:40
@paulinashakirova paulinashakirova requested review from a team as code owners March 19, 2025 16:40
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

Copy link
Contributor

@SoniaSanzV SoniaSanzV left a comment

Choose a reason for hiding this comment

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

kibana management changes lgtm :)

@paulinashakirova paulinashakirova changed the title [SharedUX] Home plugin scss to emotion migration [SharedUX] SCSS migration Home plugin Mar 21, 2025
@ryankeairns
Copy link
Contributor

@paulinashakirova I recently updated the login page to use the same svgs... is it technically possible to reuse those from core versus duplicating them in this plugin directory?

The are here: https://github.com/elastic/kibana/tree/main/src/core/public/styles/core_app/images

Copy link
Contributor

@eokoneyo eokoneyo left a comment

Choose a reason for hiding this comment

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

Tested locally, changes LGTM. well done!

@paulinashakirova
Copy link
Contributor Author

@paulinashakirova I recently updated the login page to use the same svgs... is it technically possible to reuse those from core versus duplicating them in this plugin directory?

The are here: https://github.com/elastic/kibana/tree/main/src/core/public/styles/core_app/images

@ryankeairns
What do you think about this way?
3b5e9d8

Copy link
Contributor

@ryankeairns ryankeairns 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 change!

@ryankeairns
Copy link
Contributor

Oh, also, you can then remove the .svg files from this PR then, correct?

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

Core changes LGTM

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
core 398 402 +4
home 211 193 -18
total -14

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
home 117.6KB 108.1KB -9.5KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 431.1KB 432.1KB +990.0B
home 12.3KB 12.4KB +40.0B
total +1.0KB
Unknown metric groups

miscellaneous assets size

id before after diff
core 0.0B 1.1MB ⚠️ +1.1MB
home 1.3MB 206.8KB -1.1MB
total -0.0B

History

cc @paulinashakirova

@paulinashakirova paulinashakirova merged commit 27ca807 into elastic:main Mar 25, 2025
9 checks passed
@paulinashakirova paulinashakirova deleted the home-plugin-scss-to-emotion branch March 25, 2025 18:13
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.0

https://github.com/elastic/kibana/actions/runs/14067089588

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
9.0 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 214859

Questions ?

Please refer to the Backport tool documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants