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

Import space selector styles #64656

Merged
merged 7 commits into from
May 4, 2020
Merged

Conversation

legrego
Copy link
Member

@legrego legrego commented Apr 28, 2020

Summary

#61011 cleaned up legacy imports, but in the process ended up breaking the style of the space selector ui:

image

The space selector screen was incorrectly relying on legacy styles, rather than importing its own set of styles. This PR adds that import to correct the display:

image

@legrego legrego added Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.8.0 labels Apr 28, 2020
@legrego legrego requested a review from a team as a code owner April 28, 2020 14:29
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

Copy link
Contributor

@jportner jportner 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, LGTM

@legrego legrego requested a review from a team as a code owner April 29, 2020 12:11
@@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import './nav_control.scss';
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem like the appropriate file to import this from. This file is for a popover, but the nav_control.scss file contains styles for the whole page?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call, I think the nav_control component is likely the best place to do this import

@@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import './_index.scss';
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this index file still need to be imported in this sass file anymore?

@import './space_selector/index';

Copy link
Member Author

Choose a reason for hiding this comment

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

I suspect not, this is what got us into trouble in the first place 😄

Comment on lines -1 to -2
@import './components/index';
@import './nav_control';
Copy link
Contributor

Choose a reason for hiding this comment

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

This was actually still the correct structure. Imports should happen in a single file.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was trying to follow the advice outlined here: #64511 (review)

The top-level import is the nav_control.scss file, which itself contains the single import for this view. Am I thinking about this the wrong way?

Copy link
Contributor

Choose a reason for hiding this comment

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

We try to follow the pattern that individual component_name.scss files should not import lower level components. Only index.scss should import multiple files, or a full plugin's worth of files. This helps us understand the underlying structure SASS structure without having to open each file to know what is importing what.

Yes it is correct that now we can import each component's file into it's corresponding .tsx file. However, it should be using only one of these import techniques and not a combination of both:

  1. One index.scss manifest file that imports individual component _component.scss files, and gets itself imported in the topmost component as import './index.scss'
  2. Every component has a corresponding component.scss file that is imported directly by the component's component.tsx file. Meaning, lower level component SASS files like nav_control/components/spaces_description.scss should be imported inside nav_control/components/spaces_description.tsx. And not at the top level nav_control.scss.

I know we're in a weird transition phase right now, which is why it's all that more important that we either stick to the ole _index.scss manifest if you need to ensure all styles are imported by a top level component, or fully switch to the more modular import structure where each JS component imports its own SCSS file.

Copy link
Contributor

Choose a reason for hiding this comment

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

@legrego I created a PR for you to show the new import structure for the modularized technique. legrego#24

Copy link
Member Author

Choose a reason for hiding this comment

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

@cchaos thanks for the explanation, that helped clarify things for me. Thanks also for the PR, that was a nice surprise!

@legrego
Copy link
Member Author

legrego commented May 4, 2020

@elasticmachine merge upstream

@legrego legrego requested a review from cchaos May 4, 2020 14:49
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.

Tested this PR locally on chrome. 👍

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@legrego legrego merged commit fb79865 into elastic:master May 4, 2020
@legrego legrego deleted the spaces/selector-css-fix branch May 4, 2020 23:56
legrego added a commit to legrego/kibana that referenced this pull request May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants