Skip to content

Commit ec64ef3

Browse files
committed
Improves touch-only mixin.
1 parent ef72067 commit ec64ef3

File tree

4 files changed

+182
-7
lines changed

4 files changed

+182
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"rwd"
1010
],
1111
"homepage": "https://www.github.com/deviscoding/responsive",
12-
"version": "1.0.4",
12+
"version": "1.0.5",
1313
"authors": [
1414
{
1515
"name": "Aaron M Jones",

composer.lock

Lines changed: 109 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scss/_rwd-mixins.scss

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,49 @@
1616
}
1717
}
1818

19-
// Wraps the given content in a media query targeting
20-
// devices without a 'fine' pointing device. On Firefox
21-
// browsers, this may include all touch devices.
22-
@mixin only-touch() {
23-
@media #{media-condition("touch")} {
19+
// Encloses the content in a media query intended for devices reporting 'pointer:coarse'.
20+
// Works with poly-pointer polyfill.
21+
//
22+
// Any additional media queries given will be appended to each of the necessary queries.
23+
//
24+
// @param {List|String} $and - Additional media queries to add.
25+
@mixin only-touch($and: null) {
26+
27+
$joiner: unquote(" and ");
28+
$suffix: "";
29+
30+
@if $and != null {
31+
@if type-of($and) == "list" {
32+
@each $item in $and {
33+
// Get Surrounded by Parenthesis if Needed
34+
$tItem: parenthesis($item, true);
35+
// Add The ' and '
36+
$suffix: #{$suffix}#{$joiner}#{$tItem};
37+
}
38+
} @else {
39+
$suffix: #{$joiner}#{parenthesis($and,true)};
40+
}
41+
}
42+
43+
// Get the Touch Conditions from Conditions Map
44+
$touch-conditions: ();
45+
@if(map-has-key($condition-map,"touch")) {
46+
$touch-conditions: map-get($condition-map,"touch");
47+
} @else {
48+
@error "You must have a 'touch' key in your $conditions-map.";
49+
}
50+
51+
// Put it all together, separated by ,'s. This could be done inline in the output, but that generates
52+
// inspection errors in many SASS inspectors, so avoiding it here.
53+
$query: "";
54+
$sep: unquote(", ");
55+
@each $part in $touch-conditions {
56+
$tPart: unquote(quote($part));
57+
$query: if(str-length($query) > 0, #{$query}#{$sep}#{$part}#{$suffix}, #{$part}#{$suffix});
58+
}
59+
60+
// Output
61+
@media #{$query} {
2462
@content;
2563
}
2664
}
@@ -121,4 +159,28 @@
121159
#{_target("ie 11")} {
122160
@content;
123161
}
162+
}
163+
164+
@mixin only-android() {
165+
#{_target("android")} {
166+
@content;
167+
}
168+
}
169+
170+
@mixin only-ios() {
171+
#{_target("ios")} {
172+
@content;
173+
}
174+
}
175+
176+
@mixin only-mac() {
177+
#{_target("mac")} {
178+
@content;
179+
}
180+
}
181+
182+
@mixin only-windows() {
183+
#{_target("windows")} {
184+
@content;
185+
}
124186
}

scss/_rwd-variables.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
$enable-framework: false;
2+
$enable-framework: false !default;
33

44
// region //////////////////////////////////////////////// Breakpoints
55

@@ -36,13 +36,17 @@ $condition-map: (
3636
$target-feature: (
3737
"fallback" : '.fallback',
3838
"baseline" : '.baseline',
39+
"ios" : '.ios',
40+
"android" : '.android'
3941
);
4042

4143
// User-Agent Based Targets (requires d.js)
4244
$target-user-agent: (
4345
"ie" : "Trident",
4446
"edge" : "Edge",
4547
"safari" : "Version",
48+
"windows" : "Windows NT",
49+
"mac" : "Macintosh"
4650
);
4751

4852
// endregion ///////////////////////////////////////////// End Targeting Maps

0 commit comments

Comments
 (0)