1 | :toc: macro
|
2 | :toc-title:
|
3 | :toclevels: 99
|
4 |
|
5 | # react-popover
|
6 |
|
7 | image:https://travis-ci.org/littlebits/react-popover.svg?branch=master["Build Status", link="https://travis-ci.org/littlebits/react-popover"]
|
8 |
|
9 |
|
10 | toc::[]
|
11 |
|
12 |
|
13 |
|
14 | ## Installation
|
15 |
|
16 | ```
|
17 | npm install --save react-popover
|
18 | ```
|
19 |
|
20 |
|
21 |
|
22 | ## Demos
|
23 |
|
24 | * link:https://littlebits.github.io/react-popover/build/playground.html[Playground]
|
25 | * link:https://littlebits.github.io/react-popover/build/rows.html[Rows]
|
26 | * link:https://littlebits.github.io/react-popover/build/jsx.html[Using JSX]
|
27 |
|
28 | To run demos locally execute `npm start`. If you do not see logs in the console refresh the browser once (https://github.com/littlebits/react-popover/issues/35).
|
29 |
|
30 |
|
31 |
|
32 | ## API
|
33 |
|
34 | ### `export default` `Popover(props, target)`
|
35 |
|
36 | #### `props :: {...}`
|
37 |
|
38 | ---
|
39 |
|
40 | ##### `body :: Node | Array Node`
|
41 | The `popover` content. Content is rooted (becomes children of) `.Popover-body` and thus `body` can be a single `node` _or an array of `nodes`_.
|
42 |
|
43 | ---
|
44 |
|
45 | ##### `isOpen :: Boolean`
|
46 | Determines Whether or not the popover is rendered.
|
47 |
|
48 | ---
|
49 |
|
50 | ##### `preferPlace :: Enum String | Null`
|
51 | Sets a ***preference*** of where to position the Popover. Only useful to specify placement in case of multiple available fits. Defaults to `null`. Valid values are:
|
52 |
|
53 | `above | right | below | left` :: Prefer an explicit side.
|
54 | `row | column` :: Prefer an orientation.
|
55 | `start | end` :: Prefer an order.
|
56 | `null` :: No preference, automatic resolution. This is the default.
|
57 |
|
58 | ---
|
59 |
|
60 | ##### `place :: String | Null`
|
61 | Like `preferPlace` except that the given place is a ***requirement***. The resolver becomes scoped or disabled. It is scoped if the `place` is an `orientation` or `order` but disabled if it is a `side`. For example `place: "row"` scopes the resolver to `above` or `below` placement but `place: "above"` removes any need for the resolver.
|
62 |
|
63 | ---
|
64 |
|
65 | ##### `onOuterAction :: (Event) -> Void`
|
66 | A callback function executed every time the user does an action (`mousedown` or `touchstart`) outside the DOM tree of both `Popover` and `Target`. A canonical use-case is to automatically close the Popover on any external user action.
|
67 |
|
68 | ---
|
69 |
|
70 | ##### `refreshIntervalMs :: Number | Falsey`
|
71 | The polling speed (AKA time between each poll) in milliseconds for checking if a layout refresh is required. This polling is required because it is the only robust way to track the position of a target in the DOM. Defaults to `200`. Set to a falsey value to disable.
|
72 |
|
73 | ---
|
74 |
|
75 | #### `enterExitTransitionDurationMs :: Number | Falsey`
|
76 | The amount of time in milliseconds that it takes to complete the enter and exit animation. Defaults to '500'.
|
77 |
|
78 | ---
|
79 |
|
80 | #### `tipSize :: Number`
|
81 | Defines the size of the tip pointer. Use .01 to disable tip. Defaults to '7'.
|
82 |
|
83 | ---
|
84 |
|
85 | ##### Standard
|
86 |
|
87 | * Properties like `className` and `style`.
|
88 |
|
89 |
|
90 | ---
|
91 |
|
92 | #### `target :: React Element`
|
93 |
|
94 | - The React Element that this popover will orient itself around. `target` `rendering tree` is unaffected. `Popover` _will_ become its `owner`.
|
95 |
|
96 |
|