Giter Club home page Giter Club logo

ember-component-css's Introduction

ember-component-css Build Status

An Ember CLI addon which allows you to specify a component-specific style sheet inside of component pod directories

The announcement from EmberConf 2015 CSS is hard - EmberConf 2015

Installation

ember install ember-component-css

Usage

This addon allows you to specify a style sheet inside of your component's pod folder.

Rules defined in the style-sheet will automatically be namespaced with an autogenerated class. That autogenerated class will also be injected into your component's classNames property. This enables you to worry less about rules clashing across component styles.

For example, given this app/my-component/styles.css file:

& {  // ampersand refers to the component itself (parent selector)
  padding: 2px;
}
.urgent {
  color: red;
}

Your generated CSS output will look something like:

.my-component-a34fba {
  padding: 2px;
}
.my-component-a34fba .urgent {
  color: red;
}

A typical component invocation that looks like this:

{{my-component}}

will generated markup like:

<div class="my-component-a34fba"></div>

With Preprocessors

To use this addon with a CSS pre-processor, import pod-styles into your base stylesheet. (see your pre-processor docs)

// app/styles/app.scss
@import "pod-styles";
// app/styles/app.less
@import "pod-styles";
// app/styles/app.styl
@import 'pod-styles'

And that is it! The pod-styles file is generated during the build and will then be pulled into your other stylesheet to be processed like normal.

Note: If you are using more then one type of component style files (ie a .less file and a .scss file) then you will need to add the extension to the @import. Otherwise the extension can be left off.

Approved preprocessors:

Configuration

You can set the following configuration options in your config/environment.js file:

ENV['ember-component-css'] = {
  option: 'value'
}

namespacing(enabled)

Defaults to true. Set this option to false to disable the namespacing feature of Ember Component CSS.

ENV['ember-component-css'] = {
  namespacing: false
}

This changes the default behavior changes in two ways:

  1. The autogenerated component class is no longer added to your component's HTML
  2. Your pod CSS files are no longer are namespaced using the autogenerated component class.

ember-component-css's People

Contributors

ebryn avatar webark avatar trentmwillis avatar topaxi avatar dfreeman avatar cibernox avatar rwjblue avatar jeffhertzler avatar pavloo avatar hpstuff avatar ember-tomster avatar timgthomas avatar tiandavis avatar samselikoff avatar odoe avatar noxmwalsh avatar globegitter avatar buschtoens avatar ericschank avatar thedeeno avatar barneycarroll avatar indirect avatar twokul avatar

Watchers

James Cloos avatar  avatar

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.