ember-scoped-css 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -5
- package/dist/cjs/all-Cl5IZZ-T.cjs +1539 -0
- package/dist/cjs/all.cjs +1 -1
- package/dist/cjs/babel.cjs +1 -1
- package/dist/cjs/rollup.cjs +1 -1
- package/dist/cjs/vite.cjs +1 -1
- package/dist/runtime/test-support.js +5 -0
- package/dist/runtime/test-support.js.map +1 -1
- package/package.json +1 -1
- package/src/build/babel-plugin.js +1 -5
- package/src/build/babel-plugin.test.ts +113 -0
- package/src/lib/renameClass.js +5 -0
- package/src/template-lint/plugin.js +74 -6
- package/dist/cjs/all-DJjr6YEx.cjs +0 -1534
package/README.md
CHANGED
|
@@ -496,20 +496,27 @@ const Outer = <template>
|
|
|
496
496
|
|
|
497
497
|
### Passing classes as arguments to a component
|
|
498
498
|
|
|
499
|
-
There is a `scopedClass` helper that you can use to pass a class name as an argument to a component. The helper takes a class name and returns
|
|
499
|
+
There is a `scopedClass` helper that you can use to pass a class name as an argument to a component. The helper takes a class name — or a space-separated list of class names — and returns the scoped equivalent. `scopedClass` helper is replaced at build time so there is no performance hit when running the app.
|
|
500
500
|
|
|
501
501
|
```gjs
|
|
502
502
|
import { scopedClass } from 'ember-scoped-css';
|
|
503
503
|
|
|
504
504
|
<template>
|
|
505
505
|
<OtherComponent @internalClass={{scopedClass 'hello-class'}} />
|
|
506
|
-
<OtherComponent @internalClass={{
|
|
507
|
-
<OtherComponent
|
|
508
|
-
@internalClass={{concat (scopedClass 'hello-class') ' other-class'}}
|
|
509
|
-
/>
|
|
506
|
+
<OtherComponent @internalClass={{scopedClass 'hello-class other-class'}} />
|
|
507
|
+
<OtherComponent @internalClass="{{scopedClass 'hello-class'}} global-class" />
|
|
510
508
|
</template>
|
|
511
509
|
```
|
|
512
510
|
|
|
511
|
+
Every class in the argument is scoped, so
|
|
512
|
+
```hbs
|
|
513
|
+
<div class={{scopedClass 'hello-class other-class'}}>
|
|
514
|
+
```
|
|
515
|
+
is equivalent to
|
|
516
|
+
```hbs
|
|
517
|
+
<div class="{{scopedClass 'hello-class'}} {{scopedClass 'other-class'}}">
|
|
518
|
+
```
|
|
519
|
+
|
|
513
520
|
## Testing
|
|
514
521
|
|
|
515
522
|
As classes are renamed during the build process you can't directly verify if classes are present in your tests. To solve this problem you can use the `scopedClass` function from the `ember-scoped-css/test-support` module. The function takes the class names and path to the CSS file where are the classes defined and returns the scoped class names.
|