Giter Site home page Giter Site logo

ember-body-class's Introduction

npm version Travis CI

ember-body-class

Easily add CSS classes on the <body>, including route names as well as loading and error states.

Compatibility

  • Ember.js v2.16 or above
  • Ember CLI v2.16 or above
  • Node.js v10 or above

Installation

ember install ember-body-class

Usage

  • npm run lint:hbs
  • npm run lint:js
  • npm run lint:js -- --fix

Route name classes

By default, all of your routes will include CSS class names. This works for the whole hierarchy, so if you have a route nested at application/dashboard/stats, then you'll end up with application, dashboard, stats, application-dashboard and application-dashboard-stats classes.

To disable this, see options below.

Loading & Error classes

Adding the loading and error classes requires you to include a mixin in your application route. Include it like this:

import Ember from 'ember';
import BodyClassMixin from 'ember-body-class/mixins/body-class';

export default Ember.Route.extend(BodyClassMixin, { });

Custom classes

All routes have a classNames attribute of type Array. If you wanted to add a class strawberry-jam to your route, it would look like this:

export default Ember.Route.extend({
  classNames: ["strawberry-jam"]
})

Options

You can disable route name classes being added in your environment.js like this.

ENV['ember-body-class'] = {
  includeRouteName: false
}

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.