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

[K7] BEM mixin #12884

Merged
merged 5 commits into from
Jul 17, 2017
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
"@elastic/eslint-plugin-kibana-custom": "1.0.3",
"angular-mocks": "1.4.7",
"babel-eslint": "7.2.3",
"bemify": "0.1.4",
"chai": "3.5.0",
"chance": "1.0.6",
"cheerio": "0.22.0",
Expand Down
4 changes: 4 additions & 0 deletions style_guides/scss_style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Our style guide is an extension of [Sass Guidelines by Hugo Giraudel](https://sa
The Sass Guidelines site recommends using RBG and HSL values to format colors, but we're using
hex values.

### Bemify for namespacing

We use the [bemify](https://github.com/franzheidl/bemify) for namespacing the sass into a BEM format. We use `component`, `child`, `modifier` and `state` as our mixin names. We've adjusted the plugin's state mixin so that you need to write out the full selector (`@include state('is-happening')`).
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add an example to demonstrate how each mixin should be used? This should also help address some of @kjbekkelund's questions about why/what, if they occur to anyone else.


## Dealing with extends

Don't extend classes. The only time use should use an extend is when you are extending a placeholder. Even then, do it rarely and only for code maintainability.
15 changes: 15 additions & 0 deletions ui_framework/src/global_styling/mixins/_bemify.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Bemify lets us use mixins to define namespacing
// https://github.com/franzheidl/bemify

$state-prefix: null;

@import '../../../../node_modules/bemify/sass/_bemify';

@mixin state($state) {
@at-root {
&.#{$state} {
@content;
}
}
}

1 change: 1 addition & 0 deletions ui_framework/src/global_styling/mixins/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import 'bemify';
@import 'naming';
@import 'responsive';
@import 'typography';