]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
docs: improve MediaQuery JS documentation & add only/down modifiers
authorNicolas Coden <nicolas@ncoden.fr>
Sat, 11 Aug 2018 22:06:52 +0000 (00:06 +0200)
committerDaniel Ruf <mac1@daniel-ruf.de>
Sun, 17 Nov 2019 15:49:47 +0000 (16:49 +0100)
docs/pages/media-queries.md

index f7ef9070c7bf7111c2e57b0d123e18edf0453428..1fbebdd8220eed4315e860cf0be5f5106912de4e 100644 (file)
@@ -197,22 +197,24 @@ Get the name of the current breakpoint with `MediaQuery.current`.
 Foundation.MediaQuery.current // => 'small', 'medium', etc.
 ```
 
-To see if the screen is currently a certain breakpoint or larger, use `MediaQuery.atLeast`.
-
+You can use `MediaQuery.is()` to check the breakpoint the screen is at.
 ```js
-if (Foundation.MediaQuery.atLeast('medium')) {
-  // True if medium or large
-  // False if small
-}
+Foundation.MediaQuery.is('medium') // => True for "medium" or wider
 ```
 
-To see if the screen is currently a certain breakpoint, use `MediaQuery.is`.
-
+You can also use the `up` (default), `only` and `down` modifiers like in Sass, or use the equivalent `MediaQuery.atLeast()`, `MediaQuery.only()` and `MediaQuery.upTo()`.
 ```js
-if (Foundation.MediaQuery.is('small only')) {
-  // True if small
-  // False if medium or large
-}
+// ↑ True for "medium" or wider (by default)
+Foundation.MediaQuery.is('medium up');
+Foundation.MediaQuery.atLeast('medium');
+
+// → True for "medium" only
+Foundation.MediaQuery.is('medium only');
+Foundation.MediaQuery.only('medium');
+
+// ↓ True for "medium" or smaller
+Foundation.MediaQuery.is('medium down');
+Foundation.MediaQuery.upTo('medium');
 ```
 
 To get the media query of a breakpoint, use `MediaQuery.get`.