Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niksy/regex-css-media-query
Regular expression for CSS media query.
https://github.com/niksy/regex-css-media-query
Last synced: about 2 months ago
JSON representation
Regular expression for CSS media query.
- Host: GitHub
- URL: https://github.com/niksy/regex-css-media-query
- Owner: niksy
- License: mit
- Created: 2016-11-20T09:00:43.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-20T09:07:47.000Z (about 8 years ago)
- Last Synced: 2024-10-30T02:01:33.952Z (about 2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# regex-css-media-query
[![Build Status][ci-img]][ci]
Regular expression for CSS media query.
## Install
```sh
npm install regex-css-media-query --save
```## Usage
```js
const reCssMediaQuery = require('regex-css-media-query');console.log(reCssMediaQuery().test('screen and (min-width: 500px) and (max-width: 800px)'));
// trueconsole.log(reCssMediaQuery({ strict: false }).test('all and (elvis: chase) and (sasha: tucker)'));
// true
```## API
### reCssMediaQuery(opts)
Returns: `RegExp`
Returns regular expression for checking if given query is valid CSS media query.
#### opts
Type: `Object`
#### strict
Type: `Boolean`
Default: `true`If true, regular expression will use valid standard values when evaluation expression:
* [media types][media-types]
* [media features and corresponding discrete values][media-features]
* [length][css-length-units] and [resolution][css-resolution-units] units for number values## Acknowledgments
* [Initial CSS media query regular expression](https://github.com/weblinc/media-match/blob/master/media.match.js#L25)
## License
MIT © [Ivan Nikolić](http://ivannikolic.com)
[ci]: https://travis-ci.org/niksy/regex-css-media-query
[ci-img]: https://img.shields.io/travis/niksy/regex-css-media-query.svg
[media-types]: https://www.w3.org/TR/mediaqueries-4/#media-types
[media-features]: https://www.w3.org/TR/mediaqueries-4/#mf-dimensions
[css-length-units]: https://www.w3.org/TR/css3-values/#length-value
[css-resolution-units]: https://www.w3.org/TR/css3-values/#resolution-value