Skip to content

Commit

Permalink
feat: add hover mixin (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
exdeniz authored and jescalan committed Nov 15, 2017
1 parent a176283 commit e45253b
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 0 deletions.
235 changes: 235 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ When the viewport is taller than it is wide, the styles in the block will take e
+mobile(orientation: portrait)
```

##### `+hover()`
The hover media feature is used to query the user’s ability to hover over elements on the page with the primary pointing device.


### PX to EM unit conversion

It is a popular opinion that using `em` units for media queries is a good practice, and [for good reason](http://blog.cloudfour.com/the-ems-have-it-proportional-media-queries-ftw/).
Expand Down
8 changes: 8 additions & 0 deletions rupture/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,11 @@ rupture-portrait(density = null, fallback-class = null)
{block}

portrait = rupture-portrait unless rupture-no-conflict


rupture-hover(density = null, orientation = null, fallback-class = null)
condition = "only screen and (hover: hover)";
@media ({condition})
{block}

hover = rupture-hover unless rupture-no-conflict
11 changes: 11 additions & 0 deletions test/fixtures/expected/hover.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.hello {
color: #f00;
}
@media (only screen and (hover: hover)) {
.hello {
color: #00f;
}
.hello:hover {
color: #f00;
}
}
7 changes: 7 additions & 0 deletions test/fixtures/hover.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.hello
color: red

+hover()
color: blue
&:hover
color: red
3 changes: 3 additions & 0 deletions test/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ describe 'basic', ->

it 'supports fallback classes', (done) ->
match_expected('fallback-classes.styl', done)

it 'hover', (done) ->
match_expected('hover.styl', done)

0 comments on commit e45253b

Please sign in to comment.