Skip to content

Commit

Permalink
Migrate UI Framework source into Kibana. (#9192)
Browse files Browse the repository at this point in the history
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.
- Refactor UI Framework directory structure.
- Remove babel-polyfill.
- Include SCSS synchronously.
  • Loading branch information
cjcenizal authored Dec 13, 2016
1 parent 10f7880 commit 1e315d9
Show file tree
Hide file tree
Showing 59 changed files with 2,648 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ selenium
*.swp
*.swo
*.out
src/ui_framework/doc_site/build/*.js*
22 changes: 20 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 @@ -173,6 +174,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": "3.11.1",
"eslint-plugin-mocha": "4.7.0",
Expand All @@ -191,6 +194,9 @@
"grunt-simple-mocha": "0.4.0",
"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 @@ -202,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.1.1",
Expand All @@ -210,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
7 changes: 7 additions & 0 deletions src/optimize/base_optimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ class BaseOptimizer {
`css${mapQ}!autoprefixer${mapQPre}{ "browsers": ["last 2 versions","> 5%"] }!less${mapQPre}dumpLineNumbers=comments`
)
},
{
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/`.

## 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 been forced to override their styles until the original framework is no longer
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)
* [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";
62 changes: 62 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,62 @@

/**
* 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 {
color: $localNavTextColor;
cursor: default;

&:hover {
text-decoration: none;
}

@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

0 comments on commit 1e315d9

Please sign in to comment.