# parlor

> A collection of tools for creating React and Next.js apps

Latest version **0.1.5** (published 2018-11-13) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install parlor
pnpm add parlor
yarn add parlor
bun add parlor
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2018-11-13 |
| First published | 2018-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 19 |
| Unpacked size | 18.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | David Sinclair |
| Maintainers | sikhote |

## Links

- npm: https://www.npmjs.com/package/parlor
- Homepage: https://github.com/sikhote/parlor
- npm.io page: https://npm.io/package/parlor

## Dependencies (19)

- [eslint](https://npm.io/package/eslint.md) 4.19.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [express](https://npm.io/package/express.md) ^4.16.4
- [prettier](https://npm.io/package/prettier.md) 1.14.2
- [@babel/cli](https://npm.io/package/@babel/cli.md) ^7.1.2
- [path-match](https://npm.io/package/path-match.md) ^1.2.4
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.1.2
- [query-parse](https://npm.io/package/query-parse.md) 2.0.0
- [babel-eslint](https://npm.io/package/babel-eslint.md) 8.0.1
- [app-root-path](https://npm.io/package/app-root-path.md) ^2.1.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.1.0
- [eslint-plugin-react](https://npm.io/package/eslint-plugin-react.md) ^7.4.0
- [eslint-config-airbnb](https://npm.io/package/eslint-config-airbnb.md) 16.1.0
- [eslint-plugin-import](https://npm.io/package/eslint-plugin-import.md) 2.11.0
- [eslint-config-prettier](https://npm.io/package/eslint-config-prettier.md) 2.8.0
- [eslint-plugin-jsx-a11y](https://npm.io/package/eslint-plugin-jsx-a11y.md) 6.0.2
- [express-history-api-fallback](https://npm.io/package/express-history-api-fallback.md) ^2.2.1
- [@babel/plugin-proposal-class-properties](https://npm.io/package/@babel/plugin-proposal-class-properties.md) ^7.1.0
- [@babel/plugin-proposal-object-rest-spread](https://npm.io/package/@babel/plugin-proposal-object-rest-spread.md) ^7.0.0

## Recent versions

- 0.1.5 (latest) — 2018-11-13
- 0.1.3 — 2018-11-13
- 0.1.2 — 2018-11-12
- 0.1.1 — 2018-11-04
- 0.1.0 — 2018-11-04
- 0.0.17 — 2018-10-25
- 0.0.16 — 2018-10-25
- 0.0.15 — 2018-10-25
- 0.0.14 — 2018-10-25
- 0.0.13 — 2018-10-24
- 0.0.12 — 2018-10-24
- 0.0.11 — 2018-10-24
- 0.0.10 — 2018-10-24
- 0.0.9 — 2018-10-24
- 0.0.8 — 2018-10-24
- … 7 more at https://npm.io/package/parlor/versions

## README

[![NPM version](https://img.shields.io/npm/v/parlor.svg)](https://www.npmjs.com/package/parlor)
[![CircleCI Build Status](https://img.shields.io/circleci/project/github/sikhote/parlor/master.svg?label=CircleCI)](https://circleci.com/gh/sikhote/parlor)
[![Dependency Status](https://david-dm.org/sikhote/parlor.svg)](https://david-dm.org/sikhote/parlor)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Blazing Fast](https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg)](https://twitter.com/acdlite/status/974390255393505280)

# parlor
A collection of tools for creating [React](https://github.com/facebook/react/) and [Next.js](https://github.com/zeit/next.js/) apps.

## install
`yarn add parlor` or `npm i -S parlor`

## usage
Detailed examples can be found at the [interplay.app](https://github.com/sikhote/interplay.app) repository.

### syncRouting
Sync some routing on a single page app within `_app.js` of a Next app.
```
...
import { syncRouting } from 'parlor';
import { matches, pages } from '../lib/routing';
...

class ReduxApp extends NextApp {
  state = {
    synced: false,
  };
  ...
  componentDidMount() {
    syncRouting(matches, pages, () => this.setState({ synced: true }));
  }
  ...
}
```

### getCurrentPath
Get the current browser path in a cross-platform friendly way. Defaults to an empty string.
```
import { getCurrentPath } from 'parlor';
const currentPath = getCurrentPath();
```

### getLocale
Get the current locale in a cross-platform friendly way. Defaults to `en`.
```
import { getLocale } from 'parlor';
const locale = getLocale();
```

### matchesGenerator
Generates matches that can be used for determining if a path matches a valid route.
```
const { matchesGenerator } = require('parlor');
exports.matches = matchesGenerator('/:page/:alpha');
```

### next-server
A replacement for `server.js` within a Next app that always renders the root page.
```
$ node node_modules/parlor/dist/next-server.js
```

### spa-server-maker
Use to generate an SPA server that serves the `build` directory's `index.html` and static files. This is useful when running a server for E2E tests using [Nightwatch.js](http://nightwatchjs.org/).
```
const spaServerMaker = require('parlor/dist/spa-server-maker.js');
const appRoot = require('app-root-path');

const server = spaServerMaker(done, appRoot.toString());
server.close();
```

### spa-server
Starts an SPA server using `spa-server-maker`.
```
$ node node_modules/parlor/dist/spa-server.js
```

### get-dimensions
Gets the window dimensions. If not on browser, returns `0` for each dimension.
```
import { getDimensions } from 'parlor';
const { width, height } = getDimensions();
```

### dimensions-change-throttler
Function that can be used to throttle the window resize callback. Truthfully, it could be used to throttle anything.
```
import { dimensionsChangeThrottler } from 'parlor';

...
  onDimensionsChange() {
		throttledOnDimensionsChange(() => this.setState(getDimensions()));
	}
```

### DimensionsContext
Context provider for dimensions of page. Recommended to be used with some sort of throttling.
```
import { DimensionsContext } from 'parlor';

const App = () => (
  <DimensionsContext.Provider value={{ height, width }}>
    ...
  </DimensionsContext.Provider>
);

const SomeComponent = () => (
  <DimensionsContext.Consumer>
    {({ width }) => (
      ...
    )}
  </DimensionsContext.Consumer>
);
```

## requirements
- [Node 8 LTS](https://nodejs.org/)
- [Yarn 1.9.4](https://yarnpkg.com/)
- Peer dependencies: `next`, `react`

## commands
- `yarn` to install NPM packages
- `yarn prettier` to clean code
- `yarn eslint` to check code is clean
- `yarn ci` to run all continuous integration tests
- `yarn babel` to convert code from `src` to `dist`
- `yarn publisher` - to convert code and then start publishing

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