Skip to content

Commit 8200ee2

Browse files
committed
feat(Layout): add PopoverExample
1 parent bc66aec commit 8200ee2

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

example/js/Layout.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import DropdownsExample from './DropdownsExample';
44
import TetherExample from './TetherExample';
55
import TooltipExample from './TooltipExample';
66
import LabelsExample from './LabelsExample';
7+
import PopoverExample from './PopoverExample';
78

89
class Layout extends React.Component {
910
render() {
@@ -18,6 +19,7 @@ class Layout extends React.Component {
1819
<DropdownsExample/>
1920
<TetherExample/>
2021
<TooltipExample/>
22+
<PopoverExample/>
2123
<LabelsExample/>
2224
</div>
2325
</div>

example/js/PopoverExample.jsx

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/* eslint react/no-multi-comp: 0, react/prop-types: 0 */
2+
3+
import React from 'react';
4+
import { Button, Popover, PopoverTitle, PopoverContent } from 'lib/index';
5+
6+
class PopoverItem extends React.Component {
7+
constructor(props) {
8+
super(props);
9+
10+
this.toggle = this.toggle.bind(this);
11+
this.state = {
12+
popoverOpen: false
13+
};
14+
}
15+
16+
toggle() {
17+
this.setState({
18+
popoverOpen: !this.state.popoverOpen
19+
});
20+
}
21+
22+
render() {
23+
return (
24+
<Button className="m-r-1" color="secondary" id={'Popover-' + this.props.item.id} onClick={this.toggle}>
25+
{this.props.item.text}
26+
<Popover placement={this.props.item.placement} isOpen={this.state.popoverOpen} target={'Popover-' + this.props.item.id} toggle={this.toggle}>
27+
<PopoverTitle>Popover Title</PopoverTitle>
28+
<PopoverContent>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</PopoverContent>
29+
</Popover>
30+
</Button>
31+
);
32+
}
33+
}
34+
35+
class PopoverExample extends React.Component {
36+
constructor(props) {
37+
super(props);
38+
39+
this.state = {
40+
popovers: [
41+
{
42+
id: 0,
43+
placement: 'top',
44+
text: 'Top'
45+
},
46+
{
47+
id: 1,
48+
placement: 'bottom',
49+
text: 'Bottom'
50+
},
51+
{
52+
id: 3,
53+
placement: 'left',
54+
text: 'Left'
55+
},
56+
{
57+
id: 2,
58+
placement: 'right',
59+
text: 'Right'
60+
}
61+
]
62+
};
63+
}
64+
65+
render() {
66+
return (
67+
<div>
68+
<h3>Popovers</h3>
69+
<hr/>
70+
<p>
71+
{ this.state.popovers.map((popover) => {
72+
return (
73+
<PopoverItem key={popover.id} item={popover} />
74+
);
75+
})}
76+
</p>
77+
<hr/>
78+
</div>
79+
);
80+
}
81+
}
82+
83+
export default PopoverExample;

0 commit comments

Comments
 (0)