# fruitmachine-media

> FruitMachine helper that allows different setup and teardown callbacks to be called based on media queries

Latest version **2.0.1** (published 2015-04-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install fruitmachine-media
pnpm add fruitmachine-media
yarn add fruitmachine-media
bun add fruitmachine-media
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2015-04-14 |
| First published | 2014-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Ada Edwards |
| Maintainers | ftlabs, adaroseedwards, georgecrawfordft, kornel |

## Links

- npm: https://www.npmjs.com/package/fruitmachine-media
- Repository: https://github.com/ftlabs/fruitmachine-media
- Issues: https://github.com/ftlabs/fruitmachine-media/issues
- npm.io page: https://npm.io/package/fruitmachine-media

## Recent versions

- 2.0.1 (latest) — 2015-04-14
- 2.0.0 — 2015-02-11
- 1.3.1 — 2014-12-10
- 1.3.0 — 2014-11-20
- 1.2.6 — 2014-07-08
- 1.2.3 — 2014-05-14
- 1.2.2 — 2014-05-12
- 1.2.1 — 2014-05-08
- 1.2.0 — 2014-05-07
- 1.1.1 — 2014-04-08
- 1.1.0 — 2014-03-25
- 1.0.0 — 2014-02-10

## README

# fruitmachine-media [![Build Status](https://travis-ci.org/ftlabs/fruitmachine-media.svg?branch=master)](https://travis-ci.org/ftlabs/fruitmachine-media)

FruitMachine helper that allows different setup and teardown callbacks to be called based on media queries.  If asychronous logic is needed to be run within a `teardown` or `setup` callback, return a promise.

## Example usage

```js
var fm = require('fruitmachine');

fm.define({
  name: 'passionfruit',

  template: function() {
    // Normal fruitmachine template method
  },

  helpers: [
    require('fruitmachine-media')
  ],

  media: {
    '(max-width: 699px), (max-height: 699px)': 'small',
    '(min-width: 700px) and (min-height: 700px)': 'large'
  },

  states: {
    small: {
      setup: function(options) {
        // Run small setup logic
      },
      teardown: function(options) {
        // Run small teardown logic
      }
    },
    large: {
      setup: function(options) {
        // Run large setup logic

        // If asychronous logic needs to be run:-
        //
        // var promise = new Promise();
        // doAsyncStuff(function() {
        //   promise.resolve();
        // });
        // return promise;
      },
      teardown: function(options) {
        // Run large teardown logic
      }
    }
  }
});
```

## License
Copyright (c) 2014 The Financial Times Limited
Licensed under the MIT license.

## Credits and collaboration

- **Wilson Page** - [@wilsonpage](http://github.com/wilsonpage)
- **Matt Andrews** - [@matthew-andrews](http://github.com/matthew-andrews)
- **Ada Rose Edwards** - [@adaroseedwards](http://github.com/adaroseedwards)

All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request.

---
_Source: https://npm.io/package/fruitmachine-media · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
