Skip to content

Commit

Permalink
Merge pull request #29 from mediamonks/feature/add-additional-mediaqu…
Browse files Browse the repository at this point in the history
…ery-hover

Add additional mediaquery hover mixin
  • Loading branch information
tworrisb authored Nov 8, 2023
2 parents 84255f4 + 9738efe commit fd7ca97
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions utils/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ $minimumFluidSizeViewportWidth: 480px !default;
$maximumFluidSizeViewportWidth: 1440px !default;
$useRem: true !default;
$useClamp: true !default;
$extraHoverMediaQuerySelector: '(pointer:fine)' !default;
31 changes: 20 additions & 11 deletions utils/mixin/_hover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@
* Uses the hover mixin with an optional extra selector (like '$:focus-visible')
*
* @param $extraSelector:string (optional) = an extra selector that can have the same styles as a hover (for mobile/active state)
* @param $extraMediaQuery:string (optional) = an extra media query selector that can for example prevent issues on Samsung devices ( https://www.ctrl.blog/entry/css-media-hover-samsung.html )
*/
@mixin hover($extraSelector: null) {
@media (hover: hover) {
&:hover {
@content;
}
}
@mixin hoverAdjusted($extraSelector: null, $extraMediaQuery: $extraHoverMediaQuerySelector) {
@if $extraMediaQuery {
@media (hover: hover) and #{$extraMediaQuery} {
&:hover {
@content;
}
}
} @else {
@media (hover: hover) {
&:hover {
@content;
}
}
}

@if $extraSelector {
#{$extraSelector} {
@content;
}
}
@if $extraSelector {
#{$extraSelector} {
@content;
}
}
}

0 comments on commit fd7ca97

Please sign in to comment.