Catalog npm
Back to packageRELEASE DETAILS

1.0.5

npm

@0saw/foundation-media-query

Lightweight addon to suit your crazy frontend needs

foundationmatchmediamedia-query
Published7 May 2019
Direct dependencies0
Transitive dependenciesNot calculated

README

Current package documentation

Foundation Media Query

Small little nifty utility to help you work with foundation-sites media queries.

No dependencies. Except for foundation (Da-a-ah). Adds CustomEvent polyfill.

Usage

import mq from "@0saw/foundation-media-query";

document.addEventListener('breakpoint-change', breakpointEventListener);

function breakpointEventListener() {
    if (mq.is('large only')) {
        console.log("You've hit the right spot");
    }
}

You are not obligated to import mq to your scope. Instead you can use event.detail like so:

import "@0saw/foundation-media-query";

document.addEventListener('breakpoint-change', breakpointEventListener);

function breakpointEventListener(event) {
    let mq = event.detail;

    switch (mq.current) {
        case 'medium':
            alert("You've hit the right spot");
            break;
        case 'large':
            alert("Too far");
            break;
        default:
            break;
    }
}

API

mq object contains a few useful things.

Getters

  • mq.current - Gives you the name of current breakpoint
  • mq.currentFull - Gives you all of the breakpoint info that we have. (I.e mq.currentFull.matchMedia will give you matchMedia object. In case you want to do something naughty)
  • mq.landscape - Analog of CSS's (orientation: landscape)
  • mq.portrait - Pretty straight forward
  • mq.retina - DPI is at least 2x

Methods

  • mq.is - Allows you to quickly check current breakpoint
// Either true or false
mq.is('xlarge');

// Won't return true when next breakpoint is active. ([small -> medium] -> large)
mq.is('medium only');

// portrait/ladscape/retina
mq.is('portrait');

FAQ

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 0

Native requirements
0 direct targetsNot calculated transitive count
No declared dependencies in this collected response

Declarations describe requirements; they are not a resolved dependency graph.

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-5+GOpjQ+pDYZzgMffnEhqDUjVb6rDZd1CbFl98SrNzeexduvRSQtBDnrLsuvafMyhAW6JE+FPvz7XFHVv1u+YQ==",
  "shasum": "a1f1a7a484fa7a218a004541989b7642fdfb234d",
  "tarball": "https://registry.npmjs.org/@0saw/foundation-media-query/-/foundation-media-query-1.0.5.tgz",
  "fileCount": 24,
  "unpackedSize": 78338,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc0VjZCRA9TVsSAnZWagAAgtIP/RQx1Yc8UmTh/+GCHgs0\nV/6KxjhMHJ51mw7ZDVjKeQNvmtmFTQkKDzokGy0+gjHTKgXnsbaXXT1wPQkZ\nq4QYrgQk18k/QsAnnbYD4QbKvRFqkkLqk/N7KO4WDoVMHbxnR/4nMrix/Ljs\nmUxwTAiLE+wkLiGRMoEfkQQ2oS8DAD/MN1Oo2iEl+gsVz/7osoNaOKSYAS7Y\nW5hBxKNXg+AWbiWJtBUmXIjacWuIMETS3I7jNSkuZbwSNSiPxzN2aAtsz8xi\n5584+jV7be49DWbdWH48EKj2eX2YnTn8mHMRtdd81jw1TTkj930yyEzJYBXi\nMKjNmK2WYF5jRMJWajN7LLnS0XI1sSZLG8tHfOIcYZ6pTJzEeyjVoyEO6yb/\n0n8KdXEDEZ28eM5yjF9XRGUWqeMXUAXxnmaxoxxwnVv8mp9irtVdVGy2A67U\nn9/mVDJxowHoe+BQxIq3T5tkzLhS183B2040M1ixT9OUj90DRbHonOCgIinU\nISA9yB5Cy7Ij9655107BNkkdpnm9nzP38QMmYKUr1gKX0bW2N31i5/pY+pkZ\nIS837TkFG9gaHDluG1zjg55gZuBb5EPD/6Mo/j2iDHT1g+VpPJvUpm18yo1f\nvZ86YcFXSYl8faM8SQsK8w0o18gzIiRCVLrhwigSTJwND0TlgLMTpGaQGR8o\n2p+P\r\n=zCIs\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQC5XP1UCGqAEoVWvNbo8Mt2DcFbdBVKI3kAInWT0gYVIQIgANiVYWWBJLGuGNd+EjRsbpZydXrJ/SWE6aWsCEz+85E="
    }
  ]
}

Repository

PENDING
0saw/foundation-media-query

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:15 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:44beb72e16de361008a9bc470cbccbbd92e693cb6a7fb2667e775901e45f5403

Other collected versions

1.0.68 May1.0.47 May1.0.37 May1.0.27 May1.0.15 Apr1.0.05 AprView all collected versions →