Skip to content

Commit

Permalink
docs and warn
Browse files Browse the repository at this point in the history
  • Loading branch information
chu121su12 committed Oct 10, 2022
1 parent 2f83ff4 commit 811f073
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
22 changes: 22 additions & 0 deletions packages/preset-wind/README.md
Expand Up @@ -39,6 +39,28 @@ This preset uses `_` instead of `,` for respecting space in bracket syntax.

since some CSS rules require `,` as parts of the value, e.g. `grid-cols-[repeat(3,auto)]`

## Experimental Features

This preset includes experimental feature that may be changed in breaking ways at any time.

### Media Hover

Media hover addresses the [sticky hover](https://css-tricks.com/solving-sticky-hover-states-with-media-hover-hover/) problem where tapping target that includes hover style on mobile will persist that hover style until tapping elsewhere.

Since the regular `:hover` style most probably used so widely, the variant uses `@hover` syntax to distinguish it from the regular `hover` pseudo.

Example: `@hover-text-red`

Output:
```css
@media (hover: hover) and (pointer: fine) {
.\@hover-text-red:hover {
--un-text-opacity: 1;
color: rgba(248, 113, 113, var(--un-text-opacity));
}
}
```

## License

MIT License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)
12 changes: 8 additions & 4 deletions packages/preset-wind/src/variants/experimental.ts
@@ -1,9 +1,13 @@
import type { Variant } from '@unocss/core'
import { warnOnce } from '@unocss/core'
import { variantMatcher } from '@unocss/preset-mini/utils'

export const variantStickyHover: Variant[] = [
variantMatcher('@hover', input => ({
parent: `${input.parent ? `${input.parent} $$ ` : ''}@media (hover: hover) and (pointer: fine)`,
selector: `${input.selector || ''}:hover`,
})),
variantMatcher('@hover', (input) => {
warnOnce('The @hover variant is experimental and may be changed in breaking ways at any time.')
return {
parent: `${input.parent ? `${input.parent} $$ ` : ''}@media (hover: hover) and (pointer: fine)`,
selector: `${input.selector || ''}:hover`,
}
}),
]

0 comments on commit 811f073

Please sign in to comment.