Skip to content

Commit

Permalink
Merge pull request #10 from MailOnline/feat/various-3
Browse files Browse the repository at this point in the history
Feat/various 3
  • Loading branch information
streamich authored Jan 29, 2018
2 parents 1822f83 + dcdbe0c commit c6b5453
Show file tree
Hide file tree
Showing 120 changed files with 4,203 additions and 473 deletions.
89 changes: 53 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

[![][npm-badge]][npm-url] [![][travis-badge]][travis-url]

React standard library, must-have toolbox for any React project.
React standard library — must-have toolbox for any React project.

- Collection of React sensors, FaCCs, HOCs, context providers, dummies, and [other goodies](#contents).
- Isomorphic - all components work in browser and on server (and some in `react-native`).
- Collection of React sensors, FaCCs, render props, HOCs, context providers, dummies, and [other goodies](#contents).
- *Isomorphic* - all components work in browser and on server (and some in `react-native`).
- See [demos](https://mailonline.github.io/libreact/) and [docs](#contents).

## Installation
Expand All @@ -28,52 +28,69 @@ const MyComponent = mock();

## Contents

- Dummies
- [`mock()`](./docs/mock.md)
- [`loadable()`](./docs/loadable.md)
- [`lazy()`](./docs/lazy.md)
- [`delayed()`](./docs/delayed.md)
- [`invert()`](./docs/invert.md)
- Sensors
- [Introduction](./docs/Introduction.md)
- [Dummies](./docs/Dummies.md)
- [`mock()`](./docs/mock.md) and [`loadable()`](./docs/loadable.md)
- [`lazy()`](./docs/lazy.md), [`delayed()`](./docs/delayed.md), and [`viewport()`](./docs/viewport.md)
- [Inversion](./docs/Inversion.md)
- [`invert()`](./docs/invert.md) and [`<Inverted>`](./docs/invert.md#inverted)
- [`<State>`](./docs/State.md) and [`withState()`](./docs/State.md#withstate-hoc)
- [`<Toggle>`](./docs/Toggle.md), [`withToggle()`](./docs/Toggle.md#withtoggle-hoc), and [`@withToggle`](./docs/Toggle.md#withtoggle-decorator)
- [`<Flipflop>`](./docs/Flipflop.md), [`withFlipflop()`](./docs/Flipflop.md#withflipflop-hoc), and [`@withFlipflop`](./docs/Flipflop.md#withflipflop-decorator)
- [`<Value>`](./docs/Value.md), [`withValue()`](./docs/Value.md#withvalue-hoc), and [`@withValue`](./docs/Value.md#withvalue-decorator)
- [`<Counter>`](./docs/Counter.md), [`withCounter()`](./docs/Counter.md#withcounter-hoc) and [`@withCounter`](./docs/Counter.md#withcounter-decorator)
- [`<List>`](./docs/List.md), [`withList()`](./docs/List.md#withlist-hoc), and [`@withList`](./docs/List.md#withlist-decorator)
- [`<Map>`](./docs/Map.md), [`withMap()`](./docs/Map.md#withmap-hoc), and [`@withMap`](./docs/Map.md#withmap-decorator)
- [Context](./docs/Context.md)
- [`<Provider>`](./docs/Provider.md#provider), [`<Consumer>`](./docs/Provider.md#consumer), [`withContext()`](./docs/Provider.md#withcontext), and `@withContext`
- [`<Theme>`](./docs/theme.md#theme), [`<Themed>`](./docs/theme.md#themed), [`withTheme()`](./docs/theme.md#withtheme), and `@withTheme`
- `<CssVars>`
- [`<Router>`](./docs/route.md#router), [`<Route>`](./docs/route.md#route), [`withRoute()`](./docs/route.md#withroute), `@withRoute`, `go()`, and `<Go>`
- [`<Translations>`](./docs/translate.md#translations), [`<Translate>`](./docs/translate.md#translate-or-t), [`<T>`](./docs/translate.md#translate-or-t), [`withT()`](./docs/translate.md#witht-hoc), and [`@withT`](./docs/translate.md#witht-decorator)
- [Sensors](./docs/Sensors.md)
- [`<BatterySensor>`](./docs/BatterySensor.md), [`withBattery()`](./docs/BatterySensor.md#withbattery), and [`@withBattery`](./docs/BatterySensor.md#withbattery-1)
- [`<GeoLocationSensor>`](./docs/GeoLocationSensor.md), [`withGeoLocation()`](./docs/GeoLocationSensor.md#withgeolocation-hoc), and [`@withGeoLocation`](./docs/GeoLocationSensor.md#withgeolocation-decorator)
- [`<HoverSensor>`](./docs/HoverSensor.md), [`withHover()`](./docs/HoverSensor.md#withhover-hoc), and [`@withHover`](./docs/HoverSensor.md#withhover-decorator)
- [`<MediaDeviceSensor>`](./docs/MediaDeviceSensor.md), [`withMediaDevices()`](./docs/MediaDeviceSensor.md#withmediadevices), and [`@withMediaDevices`](./docs/MediaDeviceSensor.md#withmediadevices-1)
- [`<MediaSensor>`](./docs/MediaSensor.md), [`withMedia()`](./docs/MediaSensor.md#withmedia), and [`@withMedia`](./docs/MediaSensor.md#withmedia-1)
- [`<NetworkSensor>`](./docs/NetworkSensor.md) and [`withNetwork()`](./docs/NetworkSensor.md#withnetwork)
- [`<LightSensor>`](./docs/LightSensor.md)
- [`<LocationSensor>`](./docs/LocationSensor.md)
- [`<OrientationSensor>`](./docs/OrientationSensor.md) and [`withOrientation()`](./docs/OrientationSensor.md#withorientation)
- [`<MotionSensor>`](./docs/MotionSensor.md), [`withMotion()`](./docs/MotionSensor.md#withmotion-hoc), and [`@withMotion`](./docs/MotionSensor.md#withmotion-decorator)
- [`<MouseSensor>`](./docs/MouseSensor.md), [`withMouse()`](./docs/MouseSensor.md#withmouse-hoc), and [`@withMouse`](./docs/MouseSensor.md#withmouse-decorator)
- [`<NetworkSensor>`](./docs/NetworkSensor.md), [`withNetwork()`](./docs/NetworkSensor.md#withnetwork-hoc), and [`@withNetwork`](./docs/NetworkSensor.md#withnetwork-decorator)
- [`<LightSensor>`](./docs/LightSensor.md), [`withLight()`](./docs/LightSensor.md#withlight-hoc), and [`@withLight`](./docs/LightSensor.md#withlight-decorator)
- [`<LocationSensor>`](./docs/LocationSensor.md), [`withLocation()`](./docs/LocationSensor.md#withlocation-hoc), and [`@withLocation`](./docs/LocationSensor.md#withlocation-decora)
- [`<OrientationSensor>`](./docs/OrientationSensor.md), [`withOrientation()`](./docs/OrientationSensor.md#withorientation-hoc), and [`@withOrientation`](./docs/OrientationSensor.md#withorientation-decorator)
- [`<ScrollSensor>`](./docs/ScrollSensor.md)
- [`<SizeSensor>`](./docs/SizeSensor.md)
- [`<ViewportSensor>`](./docs/ViewportSensor.md), [`<ViewportScrollSensor>`](./docs/ViewportSensor.md#viewportscrollsensor), and [`<ViewportObserverSensor>`](./docs/ViewportSensor.md#viewportobserversensor)
- [`<WidthSensor>`](./docs/WidthSensor.md)
- [`<WindowScrollSensor>`](./docs/WindowScrollSensor.md)
- [`<WindowSizeSensor>`](./docs/WindowSizeSensor.md)
- [`<SizeSensor>`](./docs/SizeSensor.md), [`withSize()`](./docs/SizeSensor.md#withsize-hoc), and [`@withSize`](./docs/SizeSensor.md#withsize-decorator)
- [`<WidthSensor>`](./docs/WidthSensor.md), [`withWidth()`](./docs/WidthSensor.md#withwidth-hoc-and-withwidth-decorator), and [`@withWidth`](./docs/WidthSensor.md#withwidth-hoc-and-withwidth-decorator)
- [`<ViewportSensor>`](./docs/ViewportSensor.md), [`withViewport()`](./docs/ViewportSensor.md#withviewport-hoc), and [`@withViewport`](./docs/ViewportSensor.md#withviewport-decorator)
- [`<ViewportScrollSensor>`](./docs/ViewportSensor.md#viewportscrollsensor) and [`<ViewportObserverSensor>`](./docs/ViewportSensor.md#viewportobserversensor)
- [`<WindowScrollSensor>`](./docs/WindowScrollSensor.md), [`withWindowScroll()`](./docs/WindowScrollSensor.md#withwindowscroll-hoc), and [`@withWindowScroll`](./docs/WindowScrollSensor.md#withwindowscroll-decorator)
- [`<WindowSizeSensor>`](./docs/WindowSizeSensor.md), [`withWindowSize()`](./docs/WindowSizeSensor.md#withwindowsize-hoc), and [`@withWindowSize`](./docs/WindowSizeSensor.md#withwindowsize-decorator)
- `ActiveSensor`, `withActive()`, and `@withActive`
- `FocusSensor`, `withFocus()`, and `@withFocus`
- Generators
- [`<Alert>`](./docs/Alert.md)
- [`<Audio>`](./docs/Audio.md), [`<Video>`](./docs/Video.md), and `<Media>`
- [`<LocalStorage>`](./docs/LocalStorage.md)
- `<Redirect>`
- [`<Speak>`](./docs/Speak.md)
- [`<Vibrate>`](./docs/Vibrate.md)
- Context
- [`<Provider>`](./docs/context.md#provider), [`<Consumer>`](./docs/context.md#consumer), [`withContext()`](./docs/context.md#withcontext), and `@withContext`
- [`<Theme>`](./docs/theme.md#theme), [`<Themed>`](./docs/theme.md#themed), [`withTheme()`](./docs/theme.md#withtheme), and `@withTheme`
- `<CssVars>`
- [`<Router>`](./docs/route.md#router), [`<Route>`](./docs/route.md#route), [`go()`](./docs/route.md#go), [`withRoute()`](./docs/route.md#withroute), and `@withRoute`
- CSS resets
- [`<CssResetEricMeyer>`](./docs/reset/CssResetEricMeyer.md)
- [`<CssResetEricMeyerCondensed>`](./docs/reset/CssResetEricMeyerCondensed.md)
- [`<CssResetMinimalistic>`](./docs/reset/CssResetMinimalistic.md)
- [`<CssResetMinimalistic2>`](./docs/reset/CssResetMinimalistic2.md)
- [`<CssResetMinimalistic3>`](./docs/reset/CssResetMinimalistic3.md)
- [`<LocalStorage>`](./docs/LocalStorage.md), `<SessionStorage>`, `<IndexedDb>`
- [`<Speak>`](./docs/Speak.md), [`<Vibrate>`](./docs/Vibrate.md), [`<Alert>`](./docs/Alert.md), `<Prompt>`, `<Confirm>`
- [`go()`](./docs/route.md#go), `<Redirect>`, `<Link>`, [`<Sms>`](./docs/Sms.md), [`<Mailto>`](./docs/Mailto.md), and `<Tel>`
- [`<FullScreen>`](./docs/FullScreen.md)
- UI
- `<Overlay>`
- [CSS resets](./docs/CSS-resets.md)
- [`<CssResetEricMeyer>`](./docs/reset/CssResetEricMeyer.md) and [`<CssResetEricMeyerCondensed>`](./docs/reset/CssResetEricMeyerCondensed.md)
- [`<CssResetMinimalistic>`](./docs/reset/CssResetMinimalistic.md), [`<CssResetMinimalistic2>`](./docs/reset/CssResetMinimalistic2.md), and [`<CssResetMinimalistic3>`](./docs/reset/CssResetMinimalistic3.md)
- [`<CssResetPoorMan>`](./docs/reset/CssResetPoorMan.md)
- [`<CssResetShaunInman>`](./docs/reset/CssResetShaunInman.md)
- [`<CssResetSiolon>`](./docs/reset/CssResetSiolon.md)
- [`<CssResetTantek>`](./docs/reset/CssResetTantek.md)
- [`<CssResetUniversal>`](./docs/reset/CssResetUniversal.md)
- [`<CssResetYahoo>`](./docs/reset/CssResetYahoo.md)
- Other
- [`<Resolve>`](./docs/Resolve.md)
- [`<Resolve>`](./docs/Resolve.md), `<Fetch>`
- [`getDisplayName()`](./docs/getDisplayName.md)
- `<BrowserOnly>`, `<ServerOnly>`, and `<Environment>`
- `<Locales>`
- `<Draggable>`, `<Droppable>`, `<Parallax>`, `<Pin>`


## License
Expand Down
30 changes: 30 additions & 0 deletions docs/CSS-resets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# CSS Resets

CSS reset components `<CssReset*>` provide a handy way to include CSS reset in your app.
You simply need to render the css reset component somewhere in your JSX tree for it to take effect.

```jsx
import CssResetEricMeyer from 'libreact/lib/reset/CssResetEricMeyer';

const App = () =>
<div>
<CssResetEricMeyer />
{ /* ... */ }
</div>
```

When you un-mount a CSS reset component it will also remove the CSS automatically.

Below is a list of included CSS resets.

- [`<CssResetEricMeyer>`](./reset/CssResetEricMeyer.md)
- [`<CssResetEricMeyerCondensed>`](./reset/CssResetEricMeyerCondensed.md)
- [`<CssResetMinimalistic>`](./reset/CssResetMinimalistic.md)
- [`<CssResetMinimalistic2>`](./reset/CssResetMinimalistic2.md)
- [`<CssResetMinimalistic3>`](./reset/CssResetMinimalistic3.md)
- [`<CssResetPoorMan>`](./reset/CssResetPoorMan.md)
- [`<CssResetShaunInman>`](./reset/CssResetShaunInman.md)
- [`<CssResetSiolon>`](./reset/CssResetSiolon.md)
- [`<CssResetTantek>`](./reset/CssResetTantek.md)
- [`<CssResetUniversal>`](./reset/CssResetUniversal.md)
- [`<CssResetYahoo>`](./reset/CssResetYahoo.md)
101 changes: 101 additions & 0 deletions docs/Counter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# `<Counter>`

Allows you to keep a state of a counter value. Is similar to [`<Value>`](./Value.md) but its
value is cast to `number` and you have an extra `inc(by = 1)` method that will increment your counter.

## Usage

```jsx
import {Counter} from 'libreact/lib/Counter';

<Counter>{({value, set, inc}) =>
<div onClick={() => inc(2))} onDoubleClick={() => set(0)}>
{value}
<div>
}</Counter>
```

## Props

Signature

```ts
interface ICounterProps {
init?: number;
}
```

, where

- `init` - optional, number, default value.


## `withCounter()` HOC

HOC that merges `counter` prop into enhanced component's props.

```jsx
import {withCounter} from 'libreact/lib/Counter';

const MyCompWithCounter = withCounter(MyComp);
```

You can overwrite the injected prop name

```js
const MyCompWithCounter = withCounter(MyComp, 'foobar');
```

Or simply merge the whole object into your props

```js
const MyCompWithCounter = withCounter(MyComp, '');
```

Set default value

```js
const MyCompWithCounter = withCounter(MyComp, '', -123);
```



## `@withCounter` decorator

React stateful component decorator that adds `counter` prop.

```js
import {withCounter} from 'libreact/lib/Counter';

@withCounter
class MyComp extends Component {

}
```

Specify different prop name

```js
@withCounter('foobar')
class MyComp extends Component {

}
```

or merge the the whole object into props

```js
@withCounter('')
class MyComp extends Component {

}
```

set starting value

```js
@withCounter('', 123)
class MyComp extends Component {

}
```
16 changes: 16 additions & 0 deletions docs/Dummies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Dummies

Dummies are empty *"shell"* components that don't contain the actual implementation.

However, those dummies can be used as real React components and they will re-render
automatically once they get implemented.

Essentially you can create dummies, which will not add any size to your bundle, use them,
but implement them with real components only later when necessary.

- [`mock()`](./mock.md) - dummy that can be implemented using `.implement()` method.
- [`loadable()`](./loadable.md) - dummy that can be loaded using `.load()` method.
- [`lazy()`](./lazy.md) - like `loadable()`, but also loads automatically when rendered for the first time.
- [`delayed()`](./delayed.md) - like `lazy()`, but its loading can be delayed.
- [`viewport()`](./viewport.md) - postpones component's rendering until it is visible
in viewport at least once.
83 changes: 83 additions & 0 deletions docs/Flipflop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# `<Flipflop>`

Similar to [`<Toggle>`](./Toggle.md) but allows to flip the state only once using the `flip` method. Repeated calls to `flip`
will have no effect. To flop the state back again, use `flop` method.

## Usage

```jsx
import {Flipflop} from 'libreact/lib/Flipflop';

<Flipflop>{({on, flip, flop}) =>
<div onClick={flip}>{on ? 'ON' : 'OFF'}</div>
}</Flipflop>
```

## Props

Signature

```ts
interface IFlipflopProps {
init?: boolean;
}
```

, where

- `init` - optional, boolean, initial state of the flipflop.


## `withFlipflop()` HOC

HOC that merges `flipflop` prop into enhanced component's props.

```jsx
import {withFlipflop} from 'libreact/lib/Flipflop';

const MyCompWithFlipflop = withFlipflop(MyComp);
```

You can overwrite the injected prop name

```js
const MyCompWithFlipflop = withFlipflop(MyComp, 'foobar');
```

Or simply merge the whole object into your props

```js
const MyCompWithFlipflop = withFlipflop(MyComp, '');
```


## `@withFlipflop` decorator

React stateful component decorator that adds `flipflop` prop.

```js
import {withFlipflop} from 'libreact/lib/Flipflop';

@withFlipflop
class MyComp extends Component {

}
```

Specify different prop name

```js
@withFlipflop('foobar')
class MyComp extends Component {

}
```

or merge the the whole object into props

```js
@withFlipflop('')
class MyComp extends Component {

}
```
37 changes: 37 additions & 0 deletions docs/FullScreen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# `<FullScreen>`

Displays child elements full-screen.

## Usage

```jsx
import {FullScreen} from 'libreact/lib/FullScreen';

<FullScreen on={on}>
Hello world!
</FullScreen>
```

## Props

Props have the following signature

```ts
interface IFullScreenProps {
on: boolean;
video?: HTMLVideoElement;
innerRef?: (el) => void;
onClose?: () => void;
tag?: keyof React.ReactHTML;
}
```

, where

- `on` - required, boolean, whether to display element in full screen or inline.
- `video` - optional, DOM video element to try to display that video in full screen using alternative `.webkitEnterFullscreen()`
available only on `HTMLVideoElement`. That way video element will get displayed full screen. Only used when regular full screen
API is not available.
- `innerRef` - optional, callback that receives the root element reference.
- `onClose` - optional, callback, called when full screen is exited.
- `tag` - optional, string, specifying tag name to use for root element, defaults to `div`.
Loading

0 comments on commit c6b5453

Please sign in to comment.