Skip to content

Commit b804a50

Browse files
committed
Remove mention of decorators and root elements from the README
1 parent 658b630 commit b804a50

File tree

1 file changed

+19
-191
lines changed

1 file changed

+19
-191
lines changed

README.md

Lines changed: 19 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ Ember-flavored support for [CSS Modules](https://github.com/css-modules/css-modu
44

55
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.
66

7-
* [Installation](#installation)
8-
* [What and Why?](#what-and-why)
9-
* [Usage](#usage)
10-
* [Simple Example](#simple-example)
11-
* ["Classic" Structure Applications](#classic-structure-applications)
12-
* [Styling Reuse](#styling-reuse)
13-
* [Programmatic Styles Access](#programmatic-styles-access)
14-
* [Global Classes](#global-classes)
15-
* [Values](#values)
16-
* [Usage in Addons](#usage-in-addons)
17-
* [Plugins](#plugins)
18-
* [Advanced Configuration](#advanced-configuration)
19-
* [Where to Specify Options](#where-to-specify-options)
20-
* [Scoped Name Generation](#scoped-name-generation)
21-
* [Source Maps](#source-maps)
22-
* [Ember Support](#ember-support)
7+
- [Installation](#installation)
8+
- [What and Why?](#what-and-why)
9+
- [Usage](#usage)
10+
- [Simple Example](#simple-example)
11+
- [Component Colocation Example](#component-colocation-example)
12+
- [Styling Reuse](#styling-reuse)
13+
- [Programmatic Styles Access](#programmatic-styles-access)
14+
- [Global Classes](#global-classes)
15+
- [Values](#values)
16+
- [Usage in Addons](#usage-in-addons)
17+
- [Plugins](#plugins)
18+
- [Advanced Configuration](#advanced-configuration)
19+
- [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)
2325

2426
## Installation
2527

@@ -53,27 +55,7 @@ With ember-css-modules, you define styles on a per-component (or -controller) ba
5355

5456
Similarly, if you were styling e.g. your application controller, you would place your styles alongside `controller.js` in `<podModulePrefix>/application/styles.css`.
5557

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:
61-
62-
```hbs
63-
{{! app/templates/components/my-component.hbs }}
64-
<div local-class="hello-class">Hello, world!</div>
65-
```
66-
67-
```css
68-
/* app/styles/components/my-component.css */
69-
.hello-class {
70-
font-weight: bold;
71-
}
72-
```
73-
74-
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
7759

7860
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:
7961

@@ -165,154 +147,6 @@ import styles from 'my-app-name/components/my-component/styles.css';
165147

166148
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.
167149

168-
### Applying Classes to a Component's Root Element
169-
170-
There is no root element, if you are using either of the following:
171-
172-
- [Glimmer components (`@glimmer/component`)](https://octane-guides-preview.emberjs.com/release/components/component-basics/)
173-
- [template-only components](https://github.com/emberjs/rfcs/blob/master/text/0278-template-only-components.md)
174-
- [tag-less components](https://api.emberjs.com/ember/3.9/classes/Component/properties/tagName?anchor=tagName)
175-
176-
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-
export default Ember.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:
191-
192-
```js
193-
export default Ember.Component.extend({
194-
localClassNameBindings: ['propA', 'propB:special', 'propC:yes:no'],
195-
propA: true,
196-
propB: true,
197-
propC: true
198-
});
199-
```
200-
201-
- 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:
212-
213-
```js
214-
import Component from '@ember/component';
215-
import { localClassNames } from 'ember-css-modules';
216-
217-
@localClassNames('my-component')
218-
export default class ExampleComponent extends Component {
219-
// your kickass code here
220-
}
221-
```
222-
223-
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:
224-
225-
```js
226-
import Component from '@ember/component';
227-
import { localClassNames } from 'ember-css-modules';
228-
229-
@localClassNames('my-component', 'make-it-pop', 'vibrant-colors')
230-
export default class ExampleComponent extends Component {
231-
// your sensational code here
232-
}
233-
```
234-
235-
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:
236-
237-
```js
238-
import Component from '@ember/component';
239-
import { localClassName } from 'ember-css-modules';
240-
241-
export default class ExampleComponent extends Component {
242-
@localClassName propA;
243-
@localClassName('special') propB;
244-
@localClassName('yes', 'no') propC;
245-
}
246-
```
247-
248-
- If `propA` is true, a local `prop-a` class will be applied. If it's false, no additional classes will be applied.
249-
- If `propB` is true, a local `special` class will be applied. If it's false, no additional classes will be applied.
250-
- If `propC` is true, a local `yes` class will be applied. If it's false, a local `no` class will be applied.
251-
252-
This is especially beautiful when combined with other decorators or computed properties:
253-
254-
```js
255-
import Component from '@ember/component';
256-
import { computed } from '@ember-decorators/object';
257-
import { notEmpty } from '@ember-decorators/object/computed';
258-
import { localClassName } from 'ember-css-modules';
259-
260-
export default class ExampleComponent extends Component {
261-
user; // provided as an attr to the component
262-
263-
@localClassName
264-
@notEmpty('user.lastName')
265-
hasLastName;
266-
267-
@localClassName('the-good-stuff', 'soda-pop')
268-
@computed('user.age')
269-
get isOldEnoughToDrink() {
270-
return this.user.age >= 21;
271-
}
272-
}
273-
```
274-
275-
- If the property `user.lastName` is not empty, a local `has-last-name` class will be applied.
276-
- If the user is at least of age `21`, a local `the-good-stuff` class is applied, otherwise a local `soda-pop` class is applied.
277-
278-
You can even return strings from computed properties or decorate string properties in order to set local classes in a fully dynamic fashion:
279-
280-
```js
281-
import Component from '@ember/component';
282-
import { computed } from '@ember-decorators/object';
283-
import { reads } from '@ember-decorators/object/computed';
284-
import { localClassName } from 'ember-css-modules';
285-
286-
export default class ExampleComponent extends Component {
287-
user; // provided as an attr to the component
288-
289-
@localClass somethingDynamic = 'hello-world';
290-
291-
@localClass
292-
@reads('user.favoriteColor')
293-
favoriteColor;
294-
295-
@localClass
296-
@computed('user.usedTechnologies.[]')
297-
get coolness() {
298-
const { usedTechnologies } = this.user;
299-
const coolTech = ['TypeScript', 'Ember.js', 'ember-css-modules'];
300-
const coolUsedTech = coolTech.filter(t => usedTechnologies.includes(t));
301-
302-
switch (coolUsedTech.length) {
303-
case 1: return 'cool';
304-
case 2: return 'pretty-rad'
305-
case 3: return 'rockstar';
306-
}
307-
308-
return null;
309-
}
310-
}
311-
```
312-
- The local `hello-world` class will be applied.
313-
- 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-
316150
### Global Classes
317151

318152
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: {
461295
## Ember Support
462296

463297
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`:
466-
467-
```js
468-
import 'ember-css-modules/extensions';
469-
```

0 commit comments

Comments
 (0)