Skip to content

Commit 053f8d2

Browse files
authored
Merge pull request #356 from BeAPI/feature/hover-no-touch
Refactor hover no touch
2 parents 1c9b106 + 2c6cdd8 commit 053f8d2

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

src/scss/02-tools/_m-hover-prevent-touch.scss

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/scss/02-tools/_m-hover.scss

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
@use "sass:list";
22

3-
/// Add active, focus and hover pseudo selectors to element
4-
///
5-
/// @param {string||list} $additionalSelectors
6-
/// List of additional selectors
7-
@mixin hover($additionalSelectors: null) {
3+
/**
4+
* Add active, focus and hover pseudo selectors to element
5+
* @param {string||list} $additionalSelectors
6+
* List of additional selectors
7+
*
8+
* @param {boolean} $onlyNoTouch
9+
* The hover style will only work when the user is using a tool device like a mouse or a trackpad.
10+
* https://defensivecss.dev/tip/hover-media/
11+
* https://developer.mozilla.org/fr/docs/Web/CSS/@media/hover
12+
*/
13+
@mixin hover($onlyNoTouch: null, $additionalSelectors: null) {
814
$selectors: "&:hover", "&:active", "&:focus";
915

1016
@if ($additionalSelectors) {
@@ -16,7 +22,15 @@
1622
}
1723
}
1824

19-
#{$selectors} {
20-
@content;
25+
@if $onlyNoTouch {
26+
@media (hover: hover) {
27+
#{$selectors} {
28+
@content;
29+
}
30+
}
31+
} @else {
32+
#{$selectors} {
33+
@content;
34+
}
2135
}
2236
}

src/scss/02-tools/tools.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
@import "./m-editor-only";
2525
@import "./m-heading";
2626
@import "./m-hover";
27-
@import "./m-hover-prevent-touch";
2827
@import "./m-line-clamp";
2928
@import "./m-placeholder-media";
3029
@import "./m-radio-custom";

0 commit comments

Comments
 (0)