forked from yuristrelets/react-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialog.js
More file actions
74 lines (63 loc) · 1.71 KB
/
dialog.js
File metadata and controls
74 lines (63 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import React, { PropTypes } from 'react';
import Button from '../../components/button';
import Dialog from '../../components/dialog';
class DialogTest extends React.Component {
state = {
active: false
};
handleToggle = () => {
this.setState({
active: !this.state.active
});
};
actions = [
{ label: 'Disagree', primary: true, onClick: this.handleToggle },
{ label: 'Agree', primary: true, onClick: this.handleToggle }
];
render () {
return (
<section>
<h5>Dialog</h5>
<p>lorem ipsum...</p>
<Button label='Show Dialog' raised primary onClick={this.handleToggle} />
<ContextComponent>
<Dialog
actions={this.actions}
active={this.state.active}
title="Use Google's location service?"
onOverlayClick={this.handleToggle}
onEscKeyDown={this.handleToggle}
>
<p>Let Google help apps <strong>determine location</strong>. This means sending anonymous location data to Google, even when no apps are running.</p>
<DialogChild />
</Dialog>
</ContextComponent>
</section>
);
}
}
class ContextComponent extends React.Component {
static propTypes = {
children: PropTypes.any
};
static childContextTypes = {
message: PropTypes.string
}
getChildContext () {
return {
message: 'Hi, I\'m the top container'
};
}
render () {
return this.props.children;
}
}
class DialogChild extends React.Component {
static contextTypes = {
message: PropTypes.string
}
render () {
return <p>This message comes from a parent: <strong>{this.context.message}</strong></p>;
}
}
export default DialogTest;