https://github.com/niksy/sass-scoped-media-query
Scope CSS styles and apply them only inside provided selector and media query pairs.
https://github.com/niksy/sass-scoped-media-query
Last synced: 3 days ago
JSON representation
Scope CSS styles and apply them only inside provided selector and media query pairs.
- Host: GitHub
- URL: https://github.com/niksy/sass-scoped-media-query
- Owner: niksy
- License: mit
- Created: 2016-08-21T08:45:34.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-23T11:15:41.000Z (about 1 year ago)
- Last Synced: 2025-02-15T06:49:51.446Z (9 months ago)
- Language: SCSS
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# sass-scoped-media-query
[![Build Status][ci-img]][ci]
Scope CSS styles and apply them only inside provided selector and media query
pairs.
"Hacky" workaround for
[element queries](https://www.filamentgroup.com/lab/element-query-workarounds.html).
## Install
```sh
npm install sass-scoped-media-query --save
```
## Usage
Input:
```scss
@use 'sass-scoped-media-query' as *;
@include scoped-media-query(('screen and (min-width: 500px)', '.jasper')) {
.gizmo {
color: #f00;
}
}
@include scoped-media-query(
('screen and (min-width: 500px)', '.gigi'),
('screen and (min-width: 1000px)', '.lola')
) {
.gunner {
font-family: 'Helvetica', sans-serif;
}
}
```
Output:
```css
@media screen and (min-width: 500px) {
.jasper .gizmo {
color: #f00;
}
}
@media screen and (min-width: 500px) {
.gigi .gunner {
font-family: 'Helvetica', sans-serif;
}
}
@media screen and (min-width: 1000px) {
.lola .gunner {
font-family: 'Helvetica', sans-serif;
}
}
```
## API
### mixin(mediaQuery)
Returns scoped CSS styles based on selector and media query pair.
#### mediaQuery
Type: `sass.types.List`
List of selector and media query pairs.
## Browser support
Works where [media queries](http://caniuse.com/#feat=css-mediaqueries) are
supported.
## References
- Originally based on
[Filament Group’s project](https://github.com/filamentgroup/scoped-media-query),
but completely refactored to be more flexible.
## License
MIT © [Ivan Nikolić](http://ivannikolic.com)
[ci]: https://travis-ci.org/niksy/sass-scoped-media-query
[ci-img]: https://img.shields.io/travis/niksy/sass-scoped-media-query.svg