-
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
[ML] Migrate influencers list from SCSS to Emotion #200019
Merged
rbrtj
merged 3 commits into
elastic:main
from
rbrtj:influencers-list-scss-emotion-migrate
Nov 19, 2024
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
x-pack/plugins/ml/public/application/components/influencers_list/_index.scss
This file was deleted.
Oops, something went wrong.
109 changes: 0 additions & 109 deletions
109
x-pack/plugins/ml/public/application/components/influencers_list/_influencers_list.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
x-pack/plugins/ml/public/application/components/influencers_list/influencers_list_styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { css } from '@emotion/react'; | ||
import { useCurrentEuiThemeVars } from '@kbn/ml-kibana-theme'; | ||
import { mlColors } from '../../styles'; | ||
import { useMlKibana } from '../../contexts/kibana'; | ||
|
||
export const useInfluencersListStyles = () => { | ||
const { | ||
services: { theme }, | ||
} = useMlKibana(); | ||
const { euiTheme } = useCurrentEuiThemeVars(theme); | ||
|
||
return { | ||
influencersList: css({ | ||
lineHeight: 1.45, | ||
}), | ||
fieldLabel: css({ | ||
fontSize: euiTheme.euiFontSizeXS, | ||
textAlign: 'left', | ||
maxHeight: euiTheme.euiFontSizeS, | ||
maxWidth: 'calc(100% - 102px)', | ||
}), | ||
progress: css({ | ||
display: 'inline-block', | ||
width: 'calc(100% - 34px)', | ||
height: '22px', | ||
minWidth: '70px', | ||
marginBottom: 0, | ||
color: euiTheme.euiColorDarkShade, | ||
backgroundColor: 'transparent', | ||
}), | ||
progressBarHolder: (barScore: number) => | ||
css({ | ||
width: `${barScore}%`, | ||
display: 'inline-block', | ||
maxWidth: `calc(100% - 28px)`, | ||
}), | ||
progressBar: (severity: string) => | ||
css({ | ||
height: `calc(${euiTheme.euiSizeXS} / 2)`, | ||
marginTop: euiTheme.euiSizeM, | ||
textAlign: 'right', | ||
lineHeight: '18px', | ||
display: 'inline-block', | ||
transition: 'none', | ||
width: `100%`, | ||
backgroundColor: | ||
severity === 'critical' | ||
? mlColors.critical | ||
: severity === 'major' | ||
? mlColors.major | ||
: severity === 'minor' | ||
? mlColors.minor | ||
: mlColors.warning, | ||
}), | ||
scoreLabel: (severity: string) => | ||
css({ | ||
textAlign: 'center', | ||
lineHeight: '14px', | ||
whiteSpace: 'nowrap', | ||
fontSize: euiTheme.euiFontSizeXS, | ||
marginLeft: euiTheme.euiSizeXS, | ||
display: 'inline-block', | ||
borderColor: | ||
severity === 'critical' | ||
? mlColors.critical | ||
: severity === 'major' | ||
? mlColors.major | ||
: severity === 'minor' | ||
? mlColors.minor | ||
: mlColors.warning, | ||
}), | ||
totalScoreLabel: css({ | ||
width: euiTheme.euiSizeXL, | ||
verticalAlign: 'top', | ||
textAlign: 'center', | ||
color: euiTheme.euiColorDarkShade, | ||
fontSize: '11px', | ||
lineHeight: '14px', | ||
borderRadius: euiTheme.euiBorderRadius, | ||
padding: `calc(${euiTheme.euiSizeXS} / 2)`, | ||
display: 'inline-block', | ||
border: euiTheme.euiBorderThin, | ||
}), | ||
}; | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
As shown in your before / after screenshots, the total height of each influencer
div
has decreased slightly (looks like from 41 to 36px in my testing). On the plus side, this means less vertical whitespace. But on the downside, the progress bar now looks closer to the influencer below it than it's own text label.Do you know what is causing the change in total height? I couldn't track down the source of the change.
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 played a little bit more with the layout, but still can't find the cause.
One could be that top margin for the total score number is removed, though it's only about 2px.
It is kinda hard to catch, as initially, I couldn't get the layout correct. After some adjustments, I discovered that the progress bar had
float: left
applied from another file 🤔 . I aligned it more closely with the SCSS styles, but the height remains smaller. We could add some margin to separate it more from the next influencer.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'm happy to go with what you have now. The slightly compressed height is a win.