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

Machine learning convert Less to Scss #23387

Closed
wants to merge 17 commits into from

Conversation

snide
Copy link
Contributor

@snide snide commented Sep 21, 2018

This PR removes the LESS files for the Machine Learning plugin and replaces them with Sass.

Process taken

  1. The src/core_plugins/machine_learning/index.js file was updated to build x-pack/plugins/ml/public/index.scss into a css file.
    • That index file imports styling_constants.scss from ui/public/styles in Kibana. This a placeholder file that includes all theming and invisible sass globals from EUI.
    • Any sass files under that line can now use the functions, mixins and variables from EUI. Although the theme is hardcoded, it will be relatively easy to switch themes based on this import later.
  2. All Less files in the x-pack/plugins/ml/public/... directory were replaced with sass counterparts.
    • The sass files now live with separated _index.scss and _component_names.scss files next to the components or views they live next to.
    • The Less files were then deleted entirely.
    • The new sass files use EUI variables whenever possible. The most important being color and sizing variables.
    • The selectors were all changed to match EUI's BEM formatting. This means the html/js templating was touched as well.
    • Additionally, a three-letter prefix mch was added to all selectors to namespace them and avoid conflicts.

ML css / design layer cleanup plan of attack

  1. THIS PR: Convert ML Less to Sass
    • Straight conversion, try not to touch the template layer, don't focus on design
    • Introduce EUI variables where easy, but avoid anything major. Hex values and pixels still remain in spots.
    • Don't focus on selectors. Use #ml-app to sandbox.
  2. PR 2: Introduce BEM naming
    • Replace selectors across ML, prefix everything to avoid conflicts. Remove sandboxing.
  3. PR 3: Focus on css code duplication / eui overwriting
    • Remove all the copy/paste CSS and try to cut the footprint down
    • Remove and replace the EUI overwrites with something less brittle
  4. PR 3+: Design
    • Potentially do a similar reskinning like we did with canvas. Likely a large project.
    • Could be done in pieces as pages are converted to React so design team can step in to help

Major visual changes

I went ahead and made the job list table act similar to our other selections so that it didn't have the awkward gap to the left of the search area. Later, we should do a pass to use the button dropdown pattern to deal with sections + actions.

image

@snide snide force-pushed the sass/machine_learning branch 2 times, most recently from 0ed7362 to 22d7b10 Compare September 25, 2018 16:58
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@snide snide force-pushed the sass/machine_learning branch from 22d7b10 to 3f75189 Compare September 26, 2018 04:37
@snide
Copy link
Contributor Author

snide commented Sep 26, 2018

@peteharverson @walterra @jgowdyelastic

I'm sure there are plenty of breaks in here still, but at this point I could prolly use a visual review so I can start fixing things. Takes screens of whatever you notice and I'll do another pass.

Note that I'm really trying NOT to touch layouts or designs too much. This is really just a base run to get the code workable so it has some level of variable scoping. Colors will be be slightly different in places, and in many cases this fixes a lot of color contrast accessibility issues in ML, but if something looks really off, it's likely a mistake on my part.

I don't think much of the chart coloring should change (other than the grays) and I've introduced a small ML specific variable layer into the sass so things are at least consistent till my team can do more work in here.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@peteharverson
Copy link
Contributor

For the most part this is looking great @snide! I have taken a first quick(ish) run through all the pages, and the only areas which have significant breaks are the Single and Multi-metric job wizards. Some issues on other pages, but those are all fairly minor I think.

I have saved a bunch of screenshots from my review - will be in contact to point you at the doc.

@peteharverson peteharverson added :ml Feature:Anomaly Detection ML anomaly detection Feature:ml-results legacy - do not use labels Sep 26, 2018
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui

@snide snide force-pushed the sass/machine_learning branch from a3dab88 to e848718 Compare September 27, 2018 02:27
@snide
Copy link
Contributor Author

snide commented Sep 27, 2018

OK @peteharverson. Think I got most everything from your list. Have some small issues around the bootstrap autocomplete placeholders, but I think we're close to what master looks like now.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@peteharverson
Copy link
Contributor

Tested your latest fixes @snide. Getting very close to master I think. I am still seeing the issue with the layout of the top card in the Population Job wizard. I have also added one extra item to the end of the doc related to the z-index of the severity control in relation to the job picker in the Anomaly Explorer which I fixed recently in #23189.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@snide snide force-pushed the sass/machine_learning branch from d166a7a to 27a4805 Compare September 27, 2018 21:49
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@snide snide requested a review from cchaos September 27, 2018 23:32
@snide
Copy link
Contributor Author

snide commented Sep 27, 2018

@cchaos I know this is a big blob to review so I don't expect a line by line review. The ML team covered most of the visual stuff so I'm pretty sure this looks pretty similar to how it used to. Can you do a quick scan of at least the sandboxing, sass importing and general structure of the code? Since ML is an app in transition, you'll often find folders with titles like old and new. Sometimes the component directories are in named component directories, and sometimes they are nested in other folders. I kept the organization similar to how it was, generally removing stuff like folder/styles/main.scss and replacing it with folder/_index.scss and folder/_folder.scss, using import chains as I went.

.ml-icon-severity-minor,
.ml-icon-severity-warning,
.ml-icon-severity-unknown {
text-shadow: 1px 1px 1px $euiColorLightestShade;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a note for review. I avoided touching shadows on this pass. A lot of ML uses text shadows and drops that I didn't have a quick 1 to 1 parallel for. Mostly I'd change the color to match against the EUI counterpart and then move forward. Rest can be handled on a 2nd pass.

Copy link
Contributor

Choose a reason for hiding this comment

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

This particular one looks like the EUI counterpart is significantly lighter. The original being #BBBBBB and this one equates to #F5F5F5, but I'm also not looking at it visually.

@snide snide changed the title [WIP] Machine learning convert Less to Scss Machine learning convert Less to Scss Sep 28, 2018
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@peteharverson
Copy link
Contributor

@snide I tested out the latest edits, and the layout of the top card in the Population wizard looks good. I have added a couple of extra items to the bottom of the doc - one for padding around the population wizard charts, and one for a suggestion to switch the border color used in the population wizards to euiColorLightShade.

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

So I just went through looking at the conversions, I didn't look at anything visually, so you can ignore what you may be "fixing".

Also here is a screenshot of what I found to be still existing .less files you may want to double-check.

image

.ml-icon-severity-minor,
.ml-icon-severity-warning,
.ml-icon-severity-unknown {
text-shadow: 1px 1px 1px $euiColorLightestShade;
Copy link
Contributor

Choose a reason for hiding this comment

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

This particular one looks like the EUI counterpart is significantly lighter. The original being #BBBBBB and this one equates to #F5F5F5, but I'm also not looking at it visually.


.centered-text {
text-align: center;
background-color: $euiBorderColor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think this is a bit bright on top of the dark tooltip background? Original color was: #95a5a6

@@ -18,28 +18,30 @@ ml-controls-select {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

$euiFontSizeXS?

text-decoration: none;
}

// SASSTODO: Needs more specific selectors
.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:active,
.dropdown-menu > li > a:focus {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move these up under the previous selector .dropdown-menu > li > a using &:hover, etc...

background-color: #F9F9F9;
background-color: $euiColorLightestShade;

// SASSTODO: Needs a proper selector
label {
font-weight: normal;
Copy link
Contributor

Choose a reason for hiding this comment

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

$euiFontWeightRegular


.form-controls, .charts-container {
margin: 0px;
margin-right: $euiSizeS;
Copy link
Contributor

Choose a reason for hiding this comment

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

Supposed to be negative, original: -10px


// SASSTODO: Proper selector
& > div {
border: $euiColorLightestShade;
Copy link
Contributor

Choose a reason for hiding this comment

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

$euiBorderThin


// SASSTODO: Proper selector
label {
font-weight: normal;
Copy link
Contributor

Choose a reason for hiding this comment

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

$euiFontWeightRegular

.events-list {
.actions-col {
width: 90px;
min-width: 90px;
}
.asterisk {
color: @kibanaRed1;
color: $euiColorDanger;
font-weight: bold;
Copy link
Contributor

Choose a reason for hiding this comment

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

$euiFontWeightBold

@import 'components/confirm_modal/index';
@import 'components/controls/index';
@import 'components/data_recognizer/index';
@import 'components/data_recognizer/index';
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate import

@import 'components/field_title_bar/index';
@import 'components/field_type_icon/index';
@import 'components/form_filter_input/index'; // SASSTODO: This file needs to be rewritten
@import 'components/form_filter_input/index'; // SASSTODO: This file needs to be rewritten
Copy link
Contributor

Choose a reason for hiding this comment

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

Another duplicate

@snide
Copy link
Contributor Author

snide commented Sep 29, 2018

OK. I think I got to all of the review feedback.

THANK YOU @cchaos for the detail on such a mighty PR. 🥇

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@snide
Copy link
Contributor Author

snide commented Oct 1, 2018

jenkins, test this

@elasticmachine
Copy link
Contributor

💔 Build Failed

@snide snide force-pushed the sass/machine_learning branch from 9a6cdb8 to b30be74 Compare October 5, 2018 03:24
@elasticmachine
Copy link
Contributor

💔 Build Failed

@snide
Copy link
Contributor Author

snide commented Nov 13, 2018

Replaced with #25574

@snide snide closed this Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Anomaly Detection ML anomaly detection Feature:ml-results legacy - do not use :ml
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants