Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hiro0218/postcss-media-hover-any-hover

PostCSS plugin wraps selectors with :hover with at-media (hover: hover) block
https://github.com/hiro0218/postcss-media-hover-any-hover

postcss postcss-plugin

Last synced: 4 months ago
JSON representation

PostCSS plugin wraps selectors with :hover with at-media (hover: hover) block

Awesome Lists containing this project

README

        

## Install

```bash
npm i -D postcss-media-hover-any-hover
```

## Usage

Wrap `:hover` block with `@media (any-hover: hover)`.

```css
// Input
a {
&:hover {
text-decoration: underline;
}
}

// Output
a {
@media (any-hover: hover) {
&:hover {
text-decoration: underline;
}
}
}
```

`postcss.config.js`:

```js
const fs = require('fs');
const postcss = require('postcss');
const postcssMediaHoverAnyHover = require('postcss-media-hover-any-hover');

const css = fs.readFileSync('input.css', 'utf8');

const output = postcss().use(postcssMediaHoverAnyHover()).process(css).css;
```