This addon gives you access to several helpful components and mixins that can be used to compliment the Bootstrap3 Grid System.
You must have Bootstrap 3.x installed in your Ember application.
Feel free to use the
ember-cli-bootstrap3-sass
addon to setup Bootstrap if you haven't already done so.
This addon supplied the following components:
twbs-clearfix
- used for responsive column resets at the end of an each loop
...and the following mixins:
Viewport
- imported asimport Viewport as 'ember-cli-bootstrap3-grid/mixins/viewport'
Further information about these items can be found in the Usage section below.
- Ember >= 1.13.0
- Ember CLI
The following will install this addon:
$ ember install ember-cli-bootstrap3-grid
As mentioned you must install some version of Bootstrap3 in your Ember application should you want this to work.
When working through the Ember upgrade process, I recommend
invoking the ember install ember-cli-bootstrap3-grid
command once
you are done to get the latest version of the addon.
Ever wanted an efficient way to render those
<div class="clearfix"></div>
for responsive column resets?
Use this component in your each-loop.
columnCount
- the number of columns that are being rendered in the grid. Required Default:1
index
- the loop index. Requiredvisible-all
- render the clearfix element for all screen sizes. Defaultfalse
visible-lg
- render the element for large size screens only. Defaultfalse
visible-md
- render the element for medium size screens only. Defaultfalse
visible-sm
- render the element for small size screens only. Defaultfalse
visible-xs
- render the element for extra-small size screens only. Defaultfalse
Inside the following loop three columns are being rendered for sizes sm/md/lg. To create the clearfix-div(s) it would usually take considerable conditional logic. Instead use this component the following way:
<div class="row">
{{#each itemList as |item index|}}
<div class="col-sm-4">
Some Item Column
</div>
{{twbs-clearfix columnCount=3 index=index visible-sm=true visible-md=true visible-lg=true}}
{{/each}}
</div>
... the {{twbs-clearfix ...}}
in the above example will render the
clearfix after every third column:
<div class="ember-view clearfix visible-sm-block visible-md-block visible-lg-block"></div>
Here's another example where you may need multiple clearfix resets:
<div class="row">
{{#each itemList as |item index|}}
<div class="col-sm-6 col-md-4 col-lg-3">
Some Item Column
</div>
{{twbs-clearfix columnCount=2 index=index visible-sm=true}}
{{twbs-clearfix columnCount=3 index=index visible-md=true}}
{{twbs-clearfix columnCount=4 index=index visible-lg=true}}
{{/each}}
</div>
... the {{twbs-clearfix ...}}
components in the above example will
render the clearfix for small displays every second column, and for
medium displays every third column, and for large displays every
fourth column.
Here's an example where you may need clearfix resets EVERY three columns:
<div class="row">
{{#each itemList as |item index|}}
<div class="col-xs-4">
Some Item Column
</div>
{{twbs-clearfix columnCount=3 index=index visible-all=true}}
{{/each}}
</div>
... the {{twbs-clearfix ...}}
in the above example will render the
clearfix after every third column for all sizes:
<div class="ember-view clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
A mixin that captures the width of the browser viewport on resizes and offers several helpful queries to determine the size.
Include the viewport in your Component (or Controller, but don't use controllers!) and then mix it:
import Viewport from 'ember-cli-bootstrap3-grid/mixins/viewport';
// or in a component
export default Ember.Component.extend(Viewport, { ... });
...and then use the properties listed below inside both your js or hbs template.
lg?
-true
when viewport is 1200px or wider,false
otherwise.md?
-true
when viewport is 992px to 1199px,false
otherwise.notLg?
- compliment tolg?
.notMd?
- compliment tomd?
.notSm?
- compliment tosm?
.notXs?
- compliment toxs?
.sm?
-true
when viewport is 768px to 991px,false
otherwise.xs?
-true
when viewport is smaller than 768px,false
otherwise.
git clone [email protected]:cybertoothca/ember-cli-bootstrap3-grid.git
npm install
ember server
- Visit your app at http://localhost:4200.
npm run lint:js
npm run lint:js -- --fix
npm test
(Runsember try:testall
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit http://ember-cli.com/.
- From the command line at the root of this project run the
npm link
command to link this addon within your local node repository. - From the other Ember project that you wish to test this addon
in, execute the following command:
npm link ember-cli-bootstrap3-grid
. - Now in that same other Ember project, you should go into the
package.json
and add the ember addon with the version *. It will look something like this:"ember-cli-bootstrap3-grid": "*"
. Now when/if you executenpm install
on this other project it will know to look for the linked addon rather than fetch it from the central repository.
- Remove the addon from your local node repository with the following
command (that can be run anywhere):
npm uninstall -g ember-cli-bootstrap3-grid
- Remove the reference to the
ember-cli-bootstrap3-grid
in your other project'spackage.json
. - Run an
npm prune
from the root of your other project's command line.
This project is licensed under the MIT License.