Skip to content

Commit 09ca08d

Browse files
authored
Merge pull request #22 from yjose/fix#20
Fix#20
2 parents f3a571a + 1fbd42c commit 09ca08d

File tree

4 files changed

+48
-10
lines changed

4 files changed

+48
-10
lines changed

src/Popup.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class Popup extends React.PureComponent {
3131
state = {
3232
isOpen: this.props.open || this.props.defaultOpen,
3333
modal: this.props.modal ? true : !this.props.trigger
34-
// we create this modal state because the popup can't be a tooltip if the trigger prop doesn't existe
34+
// we create this modal state because the popup can't be a tooltip if the trigger prop doesn't exist
3535
};
3636

3737
constructor(props) {
@@ -147,7 +147,7 @@ export default class Popup extends React.PureComponent {
147147
e.stopPropagation();
148148
}
149149
};
150-
if (!modal && on.indexOf("hover")>=0) {
150+
if (!modal && on.indexOf("hover") >= 0) {
151151
childrenElementProps.onMouseEnter = this.onMouseEnter;
152152
childrenElementProps.onMouseLeave = this.onMouseLeave;
153153
}
@@ -199,7 +199,7 @@ export default class Popup extends React.PureComponent {
199199
render() {
200200
const { overlayStyle, closeOnDocumentClick, on } = this.props;
201201
const { modal } = this.state;
202-
const overlay = this.state.isOpen && !(on.indexOf("hover")>=0);
202+
const overlay = this.state.isOpen && !(on.indexOf("hover") >= 0);
203203
const ovStyle = modal ? styles.overlay.modal : styles.overlay.tooltip;
204204
return [
205205
this.state.isOpen && (

stories/src/Controlledpopup.js renamed to stories/src/ControlledModal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from "react";
22
import Popup from "../../src/Popup";
33

4-
const ControlledPopup = () => {
4+
const ControlledModal = () => {
55
return (
66
<div>
7-
<ControlledPopupClass />
7+
<ControlledModalClass />
88
<div style={{ zIndex: "90" }}>
99
{" "}
1010
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo voluptas
@@ -15,9 +15,9 @@ const ControlledPopup = () => {
1515
);
1616
};
1717

18-
export default ControlledPopup;
18+
export default ControlledModal;
1919

20-
class ControlledPopupClass extends React.Component {
20+
class ControlledModalClass extends React.Component {
2121
constructor(props) {
2222
super(props);
2323
this.state = { open: false };

stories/src/ControlledTooltip.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from "react";
2+
import Popup from "../../src/Popup";
3+
4+
export default class ControlledPopup extends React.Component {
5+
constructor(props) {
6+
super(props);
7+
}
8+
9+
render() {
10+
return (
11+
<Popup
12+
trigger={<button className="button">Controlled Tooltip </button>}
13+
position="right center"
14+
//open={this.state.open}
15+
closeOnDocumentClick
16+
// onClose={this.closeModal}
17+
>
18+
{close => (
19+
<div className="modal">
20+
<a className="close" onClick={close}>
21+
&times; remove
22+
</a>
23+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae
24+
magni omnis delectus nemo, maxime molestiae dolorem numquam
25+
mollitia, voluptate ea, accusamus excepturi deleniti ratione
26+
sapiente! Laudantium, aperiam doloribus. Odit, aut.
27+
</div>
28+
)}
29+
</Popup>
30+
);
31+
}
32+
}

stories/src/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import PopupFuncStory from "./PopupFunc";
88
import PopupInputFocusStory from "./PopupInputFocus";
99
import ModalStory from "./Modal";
1010
import Menu from "./Menu";
11-
import ControlledPopup from "./Controlledpopup";
11+
import ControlledModal from "./ControlledModal";
12+
import ControlledTooltip from "./ControlledTooltip";
13+
1214
import CellTablePopupStory from "./CellTablePopup";
1315

1416
const storyProps = { text: "Parcel Storybook" };
@@ -33,8 +35,12 @@ export default [
3335
component: Centred(() => <button>Test without props</button>)
3436
},
3537
{
36-
name: "Controlled Popup Component", // without props
37-
component: Centred(ControlledPopup)
38+
name: "Controlled Modal Component", // without props
39+
component: Centred(ControlledModal)
40+
},
41+
{
42+
name: "Controlled Tooltip Component", // without props
43+
component: Centred(ControlledTooltip)
3844
},
3945
{
4046
name: "Menu Component", // without props

0 commit comments

Comments
 (0)