bem-components
is a library of blocks providing ready-made form controls and some other blocks.
It contains base realizations of blocks that are abstracted from the design. Few optional design themes are available.
You can use any way you are familiar with to include this library into your project.
E.g. you can use bem-tools
or ENB
.
- Desktop:
- Firefox 30+
- Chrome last 2 versions
- Safari 6.0+
- Opera 12.1+
- Internet Explorer 9+
- Touch-pad:
- Android 4+
- iOS 5+
- Touch-phone:
- Android 4+
- iOS 6+
- Windows Phone 8+ (Internet Explorer 10+)
common.blocks
— suited for any devices and browsersdesktop.blocks
— should be used for desktop browserstouch.blocks
— implement some touch-platforms specifics
- attach
- button
- checkbox
- checkbox-group
- control
- control-group
- dropdown
- icon
- image
- input
- link
- menu
- menu-item
- popup
- radio
- radio-group
- select
- spin
- textarea
- z-index-group
You can check the changelog at the changelog page.
Migartion guide is here.
- Get the source code:
$ git clone git://github.com/bem/bem-components.git
$ cd bem-components
- Install the dependencies:
$ npm install
You need export PATH=./node_modules/.bin:$PATH
or any alternative way to run locally-installed ENB
.
Install all necessary libraries:
$ bower install
Build and run tests and examples:
$ npm run build-all
Run development server:
$ enb server
Check the code-style:
$ npm run lint
- Create an issue with a proper description.
- Decide which version needs your changes.
- Create a feature branch with an issue number and a version (
issues/<issue_number>@v<version_number>
) based on a version branch. For example, for an issue #42 and a version 2:git checkout -b issues/42@v2
. If you need changes for several versions, each of them has to have a feature branch. - Commit changes (you can test your changes running
npm test
) and push.Rebase
your branch on a corresponding version branch if needed. - Create a pull request from your feature branch; or several pull requests if you changed several versions.
- Link your pull request with an issue number any way you like. For example, leave a comment with the issue number.
- Wait for your pull request and the issue to be closed ;-)
To run JS unit tests use npm run test-specs
command. You may also specify the target, e.g. enb make specs desktop.specs/input
to run just input
tests.
All tests will be run automatically using Travis on each pull request.
We use gemini for layout testing.
Tests for each block are stored in a separate file block-name.gemini.js
in a directory gemini/
. All tests could be executed manually or automatically using Travis. We use SauceLabs service as a Selenium Grid.
Use OpenSauce account in SauceLabs and Sauce Connect utility to run tests locally.
Developers of BEM team could use bem-components
account (we do not publish login and password because of the limit for three concurrent browsers launch; it is much more efficiently to use different free accounts for manual testing).
For tests execution you need the following:
- Set up environment variables (
SAUCE_USERNAME
andSAUCE_ACCESS_KEY
). - Run
sc
utility (SauceConnect) and wait for a tunnel initialization. - Run the tests using
npm run gemini
. - To collect new versions of the screenshots use
npm run gemini-gather
.
In case you write new tests for local usage, you can run your own Selenium Server or PhantomJS with WebDriver server. For this:
- Install and run selenium-server or phantomjs.
- Correct
gridUrl
option tohttp://localhost:4444/
in.gemini.yml
file. - Run tests (see above).
Detailed description of gemini
work with different types of backends find here.
NB You have to commit screenshots to the repository from SauceLabs to avoid minor differencies in fonts rendering.
Befor commit some new or modified pattern you have to:
- Check the validity. If in doubt, use Araxis Merge utility or something like this to see the difference between two versions of the pattern.
- Compress them using ImageOptim utility (this is the most effective tool for images compression for May 2014).
Build tools for the library allow you to build and run tests on BEMHTML and BH block templates.
To add a test for a block, you need to add a directory named [block name].tmpl-specs
on your definition level. All test files will be stored in it.
Each test consists of a pair of files implemented in following technologies: BEMJSON and HTML. Each block could have more then one pair of such files. You could give any name to the file. But the file names (without extensions) within the one pair for one test must coincide. For example, 10-default.bemjson.js and 10-default.html.
For each block:
- BEMJSON file contains an example for a block;
- HTML file contains standard HTML-code – a block sample.
Block sample in HTML is a block implementation result that becomes available after applying a template to the BEMJSON example.
desktop.blocks
└── myblocks
├── myblock.bemhtml.js
├── myblock.bh.js
├── ...
└── myblock.tmpl-specs
├── 10-default.bemjson.js
├── 10-default.html
├── 20-advanced.bemjson.js
└── 20-advanced.html
To run tests for templates use:
enb make tmpl-specs
or npm run test-tmpls
To run tests for required definition level use:
enb make tmpl-specs desktop.tmpl-specs
To run tests for a specific block use:
enb make tmpl-specs desktop.tmpl-specs/button
If build procedure is successful, tests will be run automatically. After that you will see all test results.
If the result of applying the template does not match with the block sample in HTML, then you will see errors in the log with description of the difference from the block sample.
All tests will be run automatically using Travis for each pull request.