Skip to content

Commit 1868e9a

Browse files
committed
feat: improve docs, add <LocationSensor> reference
1 parent f9e196c commit 1868e9a

File tree

3 files changed

+63
-14
lines changed

3 files changed

+63
-14
lines changed

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
# mol-fe-react
1+
# libreact
22

3-
React utility belt.
3+
React standard library.
44

5-
- Collection of React goodies
6-
- Isomorphic - all components work in browser and Node
5+
- Collection of React goodies necessary for every project.
6+
- Isomorphic - all components work in browser and Node.
77
- [See demos and docs](https://mailonline.github.io/mol-fe-react/)
88

99
## Installation
1010

1111
```shell
12-
npm install mol-fe-react --save
12+
npm install libreact --save
1313
```
1414

1515
## Usage
1616

1717
Import each utility individually to decrease your bundle size
1818

1919
```js
20-
import {mock} from 'mol-fe-react/lib/mock';
20+
import {mock} from 'libreact/lib/mock';
2121

2222
const MyComponent = mock();
2323
```
@@ -31,25 +31,27 @@ const MyComponent = mock();
3131
- [`delayed()`](./docs/delayed.md)
3232
- [`invert()`](./docs/invert.md)
3333
- Sensors
34+
- [`<BatterySensor>`](./docs/BatterySensor.md)
35+
- [`<MediaDeviceSensor>`](./docs/MediaDeviceSensor.md)
36+
- [`<MediaSensor>`](./docs/MediaSensor.md)
37+
- [`<NetworkSensor>`](./docs/NetworkSensor.md) and [`withNetwork()`](./docs/NetworkSensor.md#withnetwork)
38+
- [`<LightSensor>`](./docs/LightSensor.md)
39+
- [`<LocationSensor>`](./docs/LocationSensor.md)
3440
- [`<SizeSensor>`](./docs/SizeSensor.md)
35-
- [`<WidthSensor>`](./docs/WidthSensor.md)
3641
- [`<ScrollSensor>`](./docs/ScrollSensor.md)
37-
- [`<MediaSensor>`](./docs/MediaSensor.md)
42+
- [`<WidthSensor>`](./docs/WidthSensor.md)
3843
- [`<WindowSizeSensor>`](./docs/WindowSizeSensor.md)
3944
- [`<WindowScrollSensor>`](./docs/WindowScrollSensor.md)
40-
- [`<NetworkSensor>`](./docs/NetworkSensor.md) and [`withNetwork()`](./docs/NetworkSensor.md#withnetwork)
41-
- [`<BatterySensor>`](./docs/BatterySensor.md)
42-
- [`<LightSensor>`](./docs/LightSensor.md)
43-
- [`<MediaDeviceSensor>`](./docs/MediaDeviceSensor.md)
4445
- Generators
46+
- [`<Audio>`](./docs/Audio.md)
47+
- [`<LocalStorage>`](./docs/LocalStorage.md)
4548
- [`<Speak>`](./docs/Speak.md)
4649
- [`<Vibrate>`](./docs/Vibrate.md)
47-
- [`<LocalStorage>`](./docs/LocalStorage.md)
48-
- [`<Audio>`](./docs/Audio.md)
4950
- Context
5051
- [`<Provider>`](./docs/context.md#provider), [`<Consumer>`](./docs/context.md#consumer), and [`withContext()`](./docs/context.md#withcontext)
5152
- [`<Theme>`](./docs/theme.md#theme), [`<Themed>`](./docs/theme.md#themed), and [`withTheme()`](./docs/theme.md#withtheme)
5253
- `<CssVars>`
54+
- [`<Router>`](./docs/route.md#router), [`<Route>`](./docs/route.md#route), [`go()`](./docs/route.md#go), and [`withRoute()`](./docs/route.md#withroute)
5355
- CSS resets
5456
- [`<CssResetEricMeyer>`](./docs/reset/CssResetEricMeyer.md)
5557
- [`<CssResetEricMeyerCondensed>`](./docs/reset/CssResetEricMeyerCondensed.md)

docs/LocationSensor.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# `<LocationSensor>`
2+
3+
FaCC that uses [`Window.location`](https://developer.mozilla.org/en-US/docs/Web/API/Window/location) and
4+
[`Window.history`](https://developer.mozilla.org/en-US/docs/Web/API/Window/history) APIs to track
5+
page location and re-render on any changes.
6+
7+
## Usage
8+
9+
```jsx
10+
import {LocationSensor} from 'libreact/lib/LocationSensor';
11+
12+
<LocationSensor>{(location) =>
13+
<pre style={{fontFamily: 'monospace'}}>
14+
{JSON.stringify(location, null, 4)}
15+
</pre>
16+
}</LocationSensor>
17+
```
18+
19+
## Props
20+
21+
None.
22+
23+
## Reference
24+
25+
Returns location state object with the following signature
26+
27+
```ts
28+
interface ILocationSensorState {
29+
trigger: string;
30+
state?: any;
31+
length?: number;
32+
hash?: string;
33+
host?: string;
34+
hostname?: string;
35+
href?: string;
36+
origin?: string;
37+
pathname?: string;
38+
port?: string;
39+
protocol?: string;
40+
search?: string;
41+
}
42+
```

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export * from './ScrollSensor';
1515
export * from './WindowSizeSensor';
1616
export * from './WindowScrollSensor';
1717
export * from './LightSensor';
18+
export * from './LocationSensor';
1819

1920
// Generators
2021
export * from './Speak';
@@ -25,3 +26,7 @@ export * from './Audio';
2526
// Context
2627
export * from './context';
2728
export * from './theme';
29+
export * from './route';
30+
31+
// Other
32+
export * from './Resolve';

0 commit comments

Comments
 (0)