forked from autarc/react-htmltree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
115 lines (95 loc) · 2.63 KB
/
index.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<html>
<head>
<title>React HTMLTree</title>
<style>
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
border: 0;
margin: 0;
padding: 0;
}
html, body {
width: 100%;
height: 100%;
background-color: #292D31;
}
.wrapper {
padding-top: 50px;
max-width: 960px;
margin: 0 auto;
}
.title {
text-align: center;
color: #EEE;
}
.selector {
display: block;
font-size: 14px;
padding: 5px;
margin-bottom: 20px;
cursor: pointer;
}
.display {
overflow: auto;
padding: 20px;
background-color: #FFF;
}
</style>
</head>
<body>
<div class="wrapper">
<h1 class="title">React HTMLTree</h1>
<select class="selector" name="theme" id="themeselect">
<option value="chrome-devtools">Chrome DevTools</option>
<option value="firefox-devtools.light">Firefox DevTools - Light</option>
<option value="firefox-devtools.dark">Firefox DevTools - Dark</option>
</select>
<div class="display" id="root">
<!-- container for the HTMLTree -->
</div>
<!-- TODO: add custom style editor -->
</div>
<script src="../node_modules/react/dist/react.js"></script>
<script src="../node_modules/react-dom/dist/react-dom.js"></script>
<script src="../node_modules/react-dom/dist/react-dom-server.js"></script>
<script src="../dist/react-htmltree.js"></script>
<script>
var isChrome = window.navigator.userAgent.toLowerCase().indexOf('chrome') > -1
var themeselect = document.getElementById('themeselect')
themeselect.addEventListener('change', renderTree)
themeselect.value = isChrome ? 'chrome-devtools' : 'firefox-devtools.light'
renderTree()
function renderTree () {
ReactDOM.render(
React.createElement(ReactHTMLTree, {
source: document.documentElement,
theme: themeselect.value,
onSelect: function (element, component) {
console.log('ELEMENT:', element)
},
onExpand: function (element, component) {
var node = component.props.node.toJS()
console.log('EXPANDED:', !node.state.expanded)
},
// customRender: function (decorate, node) {
// return decorate(function (component) {
// if (node.depth > 3) {
// return React.DOM.div({
// children: component,
// style: {
// opacity: 0.9
// }
// })
// }
// })
// }
}),
document.getElementById('root')
)
}
</script>
</body>
</html>