You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,22 +4,24 @@ Ember-flavored support for [CSS Modules](https://github.com/css-modules/css-modu
4
4
5
5
If you have ideas or questions that aren't addressed here, try [#topic-css](https://discordapp.com/channels/480462759797063690/486013244667068436) on the Ember Discord Server.
-[Where to Specify Options](#where-to-specify-options)
20
+
-[Extensions in Module Paths](#extensions-in-module-paths)
21
+
-[Scoped Name Generation](#scoped-name-generation)
22
+
-[Source Maps](#source-maps)
23
+
-[Notes](#notes)
24
+
-[Ember Support](#ember-support)
23
25
24
26
## Installation
25
27
@@ -53,27 +55,7 @@ With ember-css-modules, you define styles on a per-component (or -controller) ba
53
55
54
56
Similarly, if you were styling e.g. your application controller, you would place your styles alongside `controller.js` in `<podModulePrefix>/application/styles.css`.
55
57
56
-
### "Classic" Structure Applications
57
-
58
-
In classic structure, all your modules are grouped by type rather than related functionality. Just like all your templates live in `app/templates` and all your routes live in `app/routes`, all your styles will live in `app/styles`. When determining where to put your CSS for a given controller or component, you should mirror the location of the corresponding template.
59
-
60
-
For example, the component given above in pod structure would look like this in classic structure:
Similarly, if you were styling e.g. your application controller, you would mirror the template at `app/templates/application.hbs` and put your CSS at `app/styles/application.css`.
75
-
76
-
### Component Colocation in Octane Applications
58
+
### Component Colocation Example
77
59
78
60
In Octane apps, where component templates can be colocated with their backing class, your styles module for a component takes the same name as the backing class and template files:
79
61
@@ -165,154 +147,6 @@ import styles from 'my-app-name/components/my-component/styles.css';
165
147
166
148
Note that the extension is **always** included for styles modules that are part of an Octane "colocated" component, to avoid a conflict with the import path for the component itself.
167
149
168
-
### Applying Classes to a Component's Root Element
169
-
170
-
There is no root element, if you are using either of the following:
In this case, you can ignore this complete section and just use the `local-class` attribute or helper.
177
-
178
-
#### Ember Object Model
179
-
180
-
Just like using [`classNames`](http://emberjs.com/api/classes/Ember.ClassNamesSupport.html#property_classNames) and [`classNameBindings`](http://emberjs.com/api/classes/Ember.ClassNamesSupport.html#property_classNameBindings) to set global classes on a component's root element, the `localClassNames` and `localClassNameBindings` properties allow you to set local classes on the root element.
181
-
182
-
For instance, to statically set a local `my-component` class on your component:
183
-
184
-
```js
185
-
exportdefaultEmber.Component.extend({
186
-
localClassNames:'my-component'
187
-
});
188
-
```
189
-
190
-
To dynamically set one or more classes on your component based on the boolean value of a given property:
- If `propA` is true, a local `prop-a` class will be applied. If it's false, no additional classes will be applied.
202
-
- If `propB` is true, a local `special` class will be applied. If it's false, no additional classes will be applied.
203
-
- If `propC` is true, a local `yes` class will be applied. If it's false, a local `no` class will be applied.
204
-
205
-
#### Native ES6 Class Syntax
206
-
207
-
The trusty Ember Object Model, that predates native ES6 class syntax, has served the community well over the years. But it's on its way out and you can already use the new native syntax in your apps today!
208
-
209
-
Instead of setting [`classNames`](http://emberjs.com/api/classes/Ember.ClassNamesSupport.html#property_classNames) and [`classNameBindings`](http://emberjs.com/api/classes/Ember.ClassNamesSupport.html#property_classNameBindings) properties, you would use [`@classNames`](http://ember-decorators.github.io/ember-decorators/latest/docs/api/modules/@ember-decorators/component#classNames) and [`@className`](http://ember-decorators.github.io/ember-decorators/latest/docs/api/modules/@ember-decorators/component#className) decorators from the amazing [ember-decorators addon](http://ember-decorators.github.io/ember-decorators/latest/). ember-css-modules provides the exact same decorators, but for local classes.
210
-
211
-
For instance, to statically set a local `my-component` class on your component, you use the `@localClassNames` decorator:
Just as with [`@classNames`](http://ember-decorators.github.io/ember-decorators/latest/docs/api/modules/@ember-decorators/component#classNames) you can pass as many classes as you like:
And just like you'd use [`@className`](http://ember-decorators.github.io/ember-decorators/latest/docs/api/modules/@ember-decorators/component#className) to dynamically toggle classes on your component based on the boolean value of a given property, you use `@localClassName` for local classes:
- If the property `user.favoriteColor` is `'red'`, a local `red` class will be applied.
314
-
- If the user uses all the cool technologies, the local `rockstar` class will be applied. If the user uses no cool technoloy, no further local class will be applied.
315
-
316
150
### Global Classes
317
151
318
152
Some libraries provide explicit class names as part of their public interface in order to allow customization of their look and feel. If, for example, you're wrapping such a library in a component, you need to be able to reference those unscoped class names in the context of your component styles. The `:global` pseudoselector allows for this:
@@ -461,9 +295,3 @@ sourcemaps: {
461
295
## Ember Support
462
296
463
297
This addon is tested against and expected to work with Ember's active [LTS releases](http://emberjs.com/blog/2016/02/25/announcing-embers-first-lts.html) as well as the current [release, beta, and canary](http://emberjs.com/builds/) builds.
464
-
465
-
Note that if you're using ember-css-modules with a version of Ember CLI prior to 2.13, you'll need to add the following to your `app.js`:
0 commit comments