Skip to content

Commit

Permalink
Document support for individual properties
Browse files Browse the repository at this point in the history
  • Loading branch information
wheeyls committed Aug 4, 2019
1 parent 2042a43 commit 0b71470
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ We start with a file that has been marked up with `@only` directives:
```css
/* _component.scss */

.button { background: blue; }
.button {
background: blue;
@only(ie) { content: 'ie only'; }
}

@only(medium) {
@media(min-width: 500px) {
Expand All @@ -36,15 +39,13 @@ Then we call the `@onlyRender` directive at the top of each file to specify what

#### By name
```css
/* medium.scss */
@onlyRender(medium);
/* ie.scss */
@onlyRender(ie);
@import 'component'; // inlines the css
```
```css
/* medium.css */
@media(min-width: 500px) {
.button { background: green; }
}
/* ie.css */
.button { content: 'ie only'; }
```

#### Multiple names
Expand All @@ -58,6 +59,7 @@ Then we call the `@onlyRender` directive at the top of each file to specify what
@media(min-width: 500px) {
.button { background: green; }
}

@media(min-width: 900px) {
.button { background: red; }
}
Expand All @@ -82,10 +84,15 @@ Then we call the `@onlyRender` directive at the top of each file to specify what
```
```css
/* app.css */
.button { background: blue; }
.button {
background: blue;
content: 'ie only';
}

@media(min-width: 500px) {
.button { background: green; }
}

@media(min-width: 900px) {
.button { background: red; }
}
Expand Down
16 changes: 16 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ describe('with root directive', function() {
return run('@onlyRender(:root); @only(small) { a { } }', '', {});
});

it('keeps @only declarations', function() {
return run(
'@onlyRender(:root); a { border: 1; @only(small) { border: 0; } }',
'a { border: 1 }',
{}
);
});

it('keeps other rules', function() {
return run(
'@onlyRender(:root); @only(small) { a { } } b { color: blue; }',
Expand Down Expand Up @@ -47,6 +55,14 @@ describe('with a named directive', function() {
return run('@onlyRender(small); @only(small) { a { } }', ' a { }', {});
});

it('keeps @only declarations', function() {
return run(
'@onlyRender(small); a { border: 1; @only(small) { border: 0; } }',
'a { border: 0 }',
{}
);
});

it('keeps nested @ rules', function() {
return run(
'@onlyRender(small); @only(small) { @media(print) { a { } } }',
Expand Down

0 comments on commit 0b71470

Please sign in to comment.