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
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ selenium
*.swp
*.swo
*.out
src/ui_framework/doc_site/build/*.js*
23 changes: 21 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"makelogs": "makelogs",
"mocha": "mocha",
"mocha:debug": "mocha --debug-brk",
"sterilize": "grunt sterilize"
"sterilize": "grunt sterilize",
"uiFramework:start": "webpack-dev-server --config src/ui_framework/doc_site/webpack.config.js --hot --inline --content-base src/ui_framework/doc_site/build"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -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.

"babel-runtime": "5.8.38",
"bluebird": "2.9.34",
"body-parser": "1.12.0",
Expand Down Expand Up @@ -171,6 +173,8 @@
"cheerio": "0.22.0",
"chokidar": "1.6.0",
"chromedriver": "2.24.1",
"classnames": "2.2.5",
"del": "1.2.1",
"elasticdump": "2.1.1",
"eslint": "1.10.3",
"eslint-plugin-mocha": "1.1.0",
Expand All @@ -190,6 +194,9 @@
"gruntify-eslint": "1.0.1",
"gulp-sourcemaps": "1.7.3",
"handlebars": "4.0.5",
"highlight.js": "9.0.0",
"history": "2.1.1",
"html-loader": "0.4.3",
"husky": "0.8.1",
"image-diff": "1.6.0",
"intern": "3.2.3",
Expand All @@ -201,6 +208,7 @@
"karma-ie-launcher": "0.2.0",
"karma-mocha": "0.2.0",
"karma-safari-launcher": "0.1.1",
"keymirror": "0.1.1",
"license-checker": "5.1.2",
"load-grunt-config": "0.19.2",
"makelogs": "3.0.2",
Expand All @@ -209,15 +217,26 @@
"murmurhash3js": "3.0.1",
"ncp": "2.0.0",
"nock": "8.0.0",
"node-sass": "3.8.0",
"npm": "3.10.8",
"portscanner": "1.0.0",
"proxyquire": "1.7.10",
"react": "15.2.0",
"react-addons-test-utils": "15.2.0",
"react-dom": "15.2.0",
"react-redux": "4.4.5",
"react-router": "2.0.0",
"react-router-redux": "4.0.4",
"redux": "3.0.0",
"redux-thunk": "0.1.0",
"sass-loader": "4.0.0",
"simple-git": "1.37.0",
"sinon": "1.17.2",
"source-map": "0.5.6",
"source-map-support": "0.2.10",
"supertest": "1.2.0",
"supertest-as-promised": "2.0.2"
"supertest-as-promised": "2.0.2",
"webpack-dev-server": "1.14.1"
},
"engines": {
"node": "6.9.0",
Expand Down
4 changes: 4 additions & 0 deletions src/optimize/base_optimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
  )
}

},
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style', `css${mapQ}`) },
{ test: /\.jade$/, loader: 'jade' },
{ test: /\.json$/, loader: 'json' },
Expand Down
4 changes: 4 additions & 0 deletions src/ui/public/autoload/styles.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
// Kibana UI Framework
require('../../../ui_framework/components/index.scss');

// All Kibana styles inside of the /styles dir
const context = require.context('../styles', false, /[\/\\](?!mixins|variables|_|\.)[^\/\\]+\.less/);
context.keys().forEach(key => context(key));
3 changes: 0 additions & 3 deletions src/ui/public/styles/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
@import (reference) "./variables";
@import (reference) "~ui/styles/bootstrap/bootstrap";

// Kibana UI Framework
@import (less) "~@elastic/kibana-ui-framework/dist/framework.css";

html,
body {
.flex-parent();
Expand Down
57 changes: 57 additions & 0 deletions src/ui_framework/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Kibana UI Framework

## 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.


## What is this?

The UI Framework provides you with UI components you can quickly use to build UIs, as well as interactive examples which document how they're supposed to be used. These UI components are currently only implemented in CSS and markup, but eventually they'll grow to involve JS as well.

When you build a UI using this framework (e.g. a plugin's UI), you can rest assured it will fit into the overall Kibana UI.

## Benefits

### Dynamic, interactive documentation

By having a "living style guide", we relieve our designers of the burden of creating and maintaining static style guides. This also makes it easier for our engineers to translate mockups, prototypes, and wireframes into products.

### Copy-pasteable UI

Engineers can copy and paste sample code into their projects to quickly get reliable, consistent results.

### Remove CSS from the day-to-day

The CSS portion of this framework means engineers don't need to spend mental cycles. These cycles can be spent on the things critical to the identity of the specific project they're working on, like architecture and business logic.

Once this framework also provides JS components, engineers won't even need to _see_ CSS -- it will be encapsulated behind the JS components' interfaces.

### More UI tests === fewer UI bugs

By covering our UI components with great unit tests and having those tests live within the framework itself, we can rest assured that our UI layer is tested and remove some of that burden from out integration/end-to-end tests.

## Why not just use Bootstrap?

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?

recognizable. When the CSS reaches that point, it's time to take ownership over it and build
your own framework.

We also gain the ability to fix some of the common issues with third-party CSS frameworks:

* They have non-semantic markup.
* They deeply nest their selectors.

For a more in-depth analysis of the problems with Bootstrap (and similar frameworks), check out this article and the links it has at the bottom: ["Bootstrap Bankruptcy"](http://www.matthewcopeland.me/blog/2013/11/04/bootstrap-bankruptcy/).

## 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!

* [Smaato React UI Framework](http://smaato.github.io/ui-framework/#/modal)
* [Lonely Planet Style Guide](http://rizzo.lonelyplanet.com/styleguide/design-elements/colours)
* [MailChimp Patterns Library](http://ux.mailchimp.com/patterns)
* [Salesforce Lightning Design System](https://www.lightningdesignsystem.com/)
* [Refills](http://refills.bourbon.io/)
* [Formstone](https://formstone.it/)
27 changes: 27 additions & 0 deletions src/ui_framework/components/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Normal colors
$textColor: #2d2d2d;
$buttonTextColor: #ffffff;
$buttonBackgroundColor: #9c9c9c;
$linkColor: #328CAA;
$linkColor-isHover: #105A73;
$inputTextColor: $textColor;
$inputBackgroundColor: #ffffff;
$inputBorderColor: $inputBackgroundColor;

// Dark theme colors
$textColor--darkTheme: #cecece;
$buttonTextColor--darkTheme: #ffffff;
$buttonBackgroundColor--darkTheme: #777777;
$linkColor--darkTheme: #b7e2ea;
$linkColor-isHover--darkTheme: #def2f6;
$inputTextColor--darkTheme: $textColor--darkTheme;
$inputBackgroundColor--darkTheme: #444444;
$inputBorderColor--darkTheme: $inputBackgroundColor--darkTheme;

@mixin darkTheme() {
.theme-dark & {
@content;
}
}

@import "local_nav/index";
48 changes: 48 additions & 0 deletions src/ui_framework/components/local_nav/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Normal colors
$localNavTextColor: $textColor;
$localNavBackgroundColor: #e4e4e4;
$localNavButtonTextColor: #5a5a5a;
$localNavButtonTextColor-isHover: #000000;
$localNavButtonBackgroundColor: transparent;
$localNavButtonBackgroundColor-isHover: rgba(#000000, 0.1);
$localNavButtonBackgroundColor-isSelected: #f6f6f6;
$localNavBreadcrumbDelimiterColor: #5a5a5a;
$localSearchBackgroundColor: #ffffff;
$localSearchBorderColor-isInvalid: #e74C3c;
$localDropdownBackgroundColor: $localNavButtonBackgroundColor-isSelected;
$localDropdownFormNoteTextColor: #737373;
$localTabTextColor: $localNavButtonTextColor;
$localTabTextColor-isHover: $localNavButtonTextColor-isHover;
$localTabTextColor-isSelected: $localNavButtonTextColor-isHover;

// Dark theme colors
$localNavTextColor--darkTheme: $textColor--darkTheme;
$localNavBackgroundColor--darkTheme: #333333;
$localNavButtonTextColor--darkTheme: #dedede;
$localNavButtonTextColor-isHover--darkTheme: #ffffff;
$localNavButtonBackgroundColor-isHover--darkTheme: #000000;
$localNavButtonBackgroundColor-isSelected--darkTheme: #525252;
$localNavBreadcrumbDelimiterColor--darkTheme: #a5a5a5;
$localSearchBackgroundColor--darkTheme: #4e4e4e;
$localSearchBorderColor-isInvalid--darkTheme: #ff6758;
$localDropdownBackgroundColor--darkTheme: $localNavButtonBackgroundColor-isSelected--darkTheme;
$localDropdownFormNoteTextColor--darkTheme: #a2a2a2;
$localDropdownWarningTextColor--darkTheme: $textColor--darkTheme;
$localDropdownWarningBackgroundColor--darkTheme: #636363;
$localTabTextColor--darkTheme: $localNavButtonTextColor--darkTheme;
$localTabTextColor-isHover--darkTheme: $localNavButtonTextColor-isHover--darkTheme;
$localTabTextColor-isSelected--darkTheme: $localNavButtonTextColor-isHover--darkTheme;

// Spacing
$localNavSideSpacing: 10px;

// Font size
$localNavFontSizeNormal: 14px;

@import "local_breadcrumbs";
@import "local_dropdown";
@import "local_menu";
@import "local_nav";
@import "local_search";
@import "local_tabs";
@import "local_title";
58 changes: 58 additions & 0 deletions src/ui_framework/components/local_nav/_local_breadcrumbs.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

/**
* 1. Breadcrumbs are placed in the top-left corner and need to be bumped over
* a bit.
*/
.localBreadcrumbs {
display: flex;
align-items: center;
height: 100%;
padding-left: $localNavSideSpacing; /* 1 */
}

.localBreadcrumb {
& + & {
margin-left: 6px;

&:before {
content: '/';
user-select: none;
margin-right: 4px;
color: $localNavBreadcrumbDelimiterColor;

@include darkTheme {
color: $localNavBreadcrumbDelimiterColor--darkTheme;
}
}
}

&:last-child {
.localBreadcrumb__link {
pointer-events: none;
color: $localNavTextColor;

@include darkTheme {
color: $localNavTextColor--darkTheme;
}
}
}

}

.localBreadcrumb__link {
font-size: $localNavFontSizeNormal;
color: #5a5a5a;
text-decoration: none;

&:hover {
text-decoration: underline;
}

@include darkTheme {
color: $localNavButtonTextColor--darkTheme;
}
}

.localBreadcrumb__emphasis {
font-weight: 700;
}
Loading