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

Migrate UI Framework source into Kibana. #9192

Merged
merged 5 commits into from
Dec 13, 2016

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Nov 22, 2016

Addresses #8867

When we make changes to our UI by adding new components to the UI Framework, our dev process will look like this:

  1. Run Kibana with npm start.
  2. Run the UI Framework dev server with npm run uiFramework:start.
  3. Check it out on localhost:8080.
  4. Add a new component to the UI Framework.
  5. Integrate it into Kibana and test it out in the Kibana UI.
  6. Create examples in the UI Framework and check them out in the browser.
  7. Submit PR like normal.

Changes

  • Add dependencies to package.json.
  • Add task for building UI Framework docs and serving locally.
  • Import UI Framework scss from autoload/styles.js instead of importing the CSS in base.less.

FAQ

I see React and Redux are now dependencies. Are we using them in Kibana?

No, they're only used to build the UI Framework documentation site. They make it really easy to add examples of new components. If anybody thinks we should use a different set of tools, suggestions and PRs are welcome!

Why are we using SCSS? We're already using LESS.

SCSS has better mixins, value interpolation, control directives, and other features. We can migrate all of our LESS to SCSS eventually, so we'll only be using one preprocessor.

- Add dependencies to package.json.
- Add task for building UI Framework docs and serving locally.
- Import UI Framework scss from autoload/styles.js instead of importing the CSS in base.less.
@cjcenizal cjcenizal force-pushed the 8867/feature/absorb-ui-framework branch from 40a96e5 to de3f34f Compare November 22, 2016 22:34
@spalger spalger self-assigned this Nov 22, 2016
Copy link
Contributor

@w33ble w33ble left a comment

Choose a reason for hiding this comment

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

quick comment and a question

@@ -62,7 +62,8 @@
"makelogs": "makelogs",
"mocha": "mocha",
"mocha:debug": "mocha --debug-brk",
"sterilize": "grunt sterilize"
"sterilize": "grunt sterilize",
"uiFramework:start": "./node_modules/.bin/webpack-dev-server --config src/ui_framework/webpack.config.js --hot --inline --content-base src/ui_framework/public/"
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need ./node_modules/.bin/when running npm scripts, the node_modules/.bin is included in the path by default in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks man!

"npm": "3.10.8",
"numeral": "1.5.3",
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 numeral has caused us some issues in the past, though I suspect your use is probably fine. Curious what you're using it for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I don't think it's actually being used anywhere. Thanks for catching this, I'll remove it.

@cjcenizal cjcenizal added Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. release_note:enhancement v5.2.0 v6.0.0 labels Nov 22, 2016
@tylersmalley tylersmalley self-assigned this Dec 5, 2016
@spalger
Copy link
Contributor

spalger commented Dec 5, 2016

What do you think about unifying source related to the ui framework's doc site in src/ui_framework/doc_site? public directories have additional meaning/baggage that doesn't/shouldn't apply here, and I was initially caught off-guard by the webpack.config.js file.

I'm thinking:

src/ui_framework
  components/
    local_nav/
      index.scss
    index.scss
  doc_site/
    src/
      actions/
      components/
      ...
      index.html
    build/
      // webpack output target
    webpack.config.js

@cjcenizal
Copy link
Contributor Author

@spalger That's a really good idea. I'll implement your suggestion. Out of curiosity, what are the additional meanings/baggage you associate with the public dir and where/how did you form that understanding of it? (Trying to educate myself.)

@w33ble
Copy link
Contributor

w33ble commented Dec 5, 2016

In the context of plugins, public is kind of magic, and it has special rules for import. You can see this in Kibana too, where we have src/ui/public/**, and you require things as ui/**, but it's really reaching into the public path. I'm guessing that's the baggage @spalger was referring to.

@cjcenizal
Copy link
Contributor Author

@w33ble Ah OK yeah, that makes sense in the context of Kibana. I was wondering if there was a broader convention beyond Kibana I wasn't familiar with.

@cjcenizal
Copy link
Contributor Author

@spalger Implemented your directory structure suggestion.

@w33ble Addressed your comments.

Copy link
Contributor

@w33ble w33ble left a comment

Choose a reason for hiding this comment

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

quick dependency question

@@ -91,6 +92,7 @@
"babel": "5.8.38",
"babel-core": "5.8.38",
"babel-loader": "5.3.2",
"babel-polyfill": "6.9.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be using some v5 of this plugin? Is it compatible with our current Babel 5 setup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch man, looks like this isn't needed at all since we're using 5, not 6.

@spalger spalger self-requested a review December 9, 2016 23:45
Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

This seems really close but I have a few quibbles. The major one that I didn't bring up in inline comments, because it's pretty wide-spread, is the use of default exports. It's a pretty new rules that we have choosen to follow, but I think it would be a good idea to update this code to that standard before merging it.

There's at least one typo it would have prevented :) (creatExample)

@@ -108,6 +108,10 @@ class BaseOptimizer {
`css${mapQ}!autoprefixer${mapQPre}{ "browsers": ["last 2 versions","> 5%"] }!less${mapQPre}dumpLineNumbers=comments`
)
},
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass'],
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably should be using the ExtractTextPlugin so the CSS is included synchronously, before the JS (which loads asynchronously):

{
  test: /\.scss$/,
  loader: ExtractTextPlugin.extract(
    'style',
    `css${mapQ}!autoprefixer${mapQPre}{ "browsers": ["last 2 versions","> 5%"] }!sass${mapQPre}`
  )
}


In short: we've outgrown it! Third-party CSS frameworks like Bootstrap and Foundation are designed
for a general audience, so they offer things we don't need and _don't_ offer things we _do_ need.
As a result, we've forced to override their styles until the original framework is no longer
Copy link
Contributor

Choose a reason for hiding this comment

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

we've been or we're?

GuideExample,
} from '../../components';

export default function creatExample(examples) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Misspelled createExample()


export default class GuideExample extends Component {

constructor(props, sections) {
Copy link
Contributor

@spalger spalger Dec 10, 2016

Choose a reason for hiding this comment

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

Seeing a second argument to the constructor of a component perplexed me at first (especially since the second argument that components normally take is context).

I wonder if it would be less confusing if this class was defined inside the createExample function, and the closure was used to give that example component it's sections/examples.

(I also think createExample() could use a bit more color in it's name)

export function createExampleComponent(sections) {
  return class ExampleCompoent extends Component {
    // ...
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you have a really interesting point, but I'd like to avoid too much re-architecting of how the docs site works within this PR -- I just want to focus on getting it integrated with Kibana for now, so we can unblock UI development. I'm totally open to refactoring it later though. :)


import ActionTypes from '../action_types';

export default {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's generally preferable to expose each value explicitly, rather than an object of named values.

ie.

export const openCodeViewer = slug => ({
  type: ActionTypes.OPEN_CODE_VIEWER,
  slug,
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here; good point but let's do this later.


export default class GuideCodeViewer extends Component {

constructor(props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary constructor, there are a few others

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same comment here... though I'm thinking once we add the linting rule for this, we can get rid of them all at once.

@@ -0,0 +1,21 @@

export * from './guide_code_viewer/guide_code_viewer.jsx';
Copy link
Contributor

@spalger spalger Dec 10, 2016

Choose a reason for hiding this comment

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

This file seems to be exporting too much. Also, just like all other imports these imports should not have extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same... can we do this later?

@@ -0,0 +1,12 @@

export * from './example/createExample';
Copy link
Contributor

Choose a reason for hiding this comment

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

Another example of what looks like over-exporting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same... can we do this later?

@cjcenizal
Copy link
Contributor Author

cjcenizal commented Dec 10, 2016

@spalger Can you take another look? I addressed a few of your comments but I'd like to address the majority of them in subsequent PRs. I'd like to keep this PR focused on integrating the UI Framework as it already exists, so we can unblock UI dev (I'm continuing to work on the existing UI Framework and the longer this PR is left unmerged the more difficult it will be to port the changes over).

@spalger
Copy link
Contributor

spalger commented Dec 10, 2016

Sounds good to me @cjcenizal

@w33ble
Copy link
Contributor

w33ble commented Dec 12, 2016

Code works as described. I run the commands, I get a running version of the framework. I'm not familiar with the vast majority of the stack here though, so I can't really give you considered input on that part.

I would like to say that I think it would be helpful to outline the conventions in the framework itself. Things like how you name classes with -- vs __, how to use scss variables correctly, how to organize files... basically all the rules around how the UI Framework works. Definitely in the running site, but perhaps also outlined in the top level readme.md file.

Copy link
Contributor

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

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

LGTM - as it's been discussed we're simply reviewing how this project is to be brought into Kibana and saving the code change for another day.

## Development

* Start development server `npm run uiFramework:start`.
* View docs on `http://localhost:8080/`.
Copy link
Contributor

Choose a reason for hiding this comment

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

8080 is a common, and the default port for webpack dev server. We will probably want to change this in the future to avoid collisions.


## Examples of other in-house UI frameworks

* [Ubiquiti CSS Framework](http://ubnt-css.herokuapp.com/#/app/popover)
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't you make this? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure did!

@cjcenizal cjcenizal merged commit 1e315d9 into elastic:master Dec 13, 2016
@cjcenizal cjcenizal deleted the 8867/feature/absorb-ui-framework branch December 13, 2016 01:54
cjcenizal added a commit that referenced this pull request Dec 13, 2016
Backports PR #9192

**Commit 1:**
Migrate UI Framework source into Kibana.
- Add dependencies to package.json.
- Add task for building UI Framework docs and serving locally.
- Import UI Framework scss from autoload/styles.js instead of importing the CSS in base.less.

* Original sha: de3f34f
* Authored by CJ Cenizal <[email protected]> on 2016-11-22T22:27:11Z

**Commit 2:**
Refactor UI Framework directory structure.

* Original sha: 4e54844
* Authored by CJ Cenizal <[email protected]> on 2016-12-05T23:03:01Z

**Commit 3:**
Remove babel-polyfill.

* Original sha: 43854bc
* Authored by CJ Cenizal <[email protected]> on 2016-12-05T23:47:42Z

**Commit 4:**
Fix typos and include SCSS synchronously.

* Original sha: fe5bab1
* Authored by CJ Cenizal <[email protected]> on 2016-12-10T00:33:17Z

**Commit 5:**
Update with latest changes to UI Framework.

* Original sha: a44140a
* Authored by CJ Cenizal <[email protected]> on 2016-12-13T01:47:09Z
cjcenizal pushed a commit that referenced this pull request Dec 13, 2016
Backports PR #9192

**Commit 1:**
Migrate UI Framework source into Kibana.
- Add dependencies to package.json.
- Add task for building UI Framework docs and serving locally.
- Import UI Framework scss from autoload/styles.js instead of importing the CSS in base.less.

* Original sha: de3f34f
* Authored by CJ Cenizal <[email protected]> on 2016-11-22T22:27:11Z

**Commit 2:**
Refactor UI Framework directory structure.

* Original sha: 4e54844
* Authored by CJ Cenizal <[email protected]> on 2016-12-05T23:03:01Z

**Commit 3:**
Remove babel-polyfill.

* Original sha: 43854bc
* Authored by CJ Cenizal <[email protected]> on 2016-12-05T23:47:42Z

**Commit 4:**
Fix typos and include SCSS synchronously.

* Original sha: fe5bab1
* Authored by CJ Cenizal <[email protected]> on 2016-12-10T00:33:17Z

**Commit 5:**
Update with latest changes to UI Framework.

* Original sha: a44140a
* Authored by CJ Cenizal <[email protected]> on 2016-12-13T01:47:09Z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:enhancement Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. v5.2.0 v6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants