aboutsummaryrefslogtreecommitdiffstats
path: root/demo/react-demo-embed.html
blob: e14a7c4d65e82e05328c26d21b9a1ae8f1df0752 (plain)
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
<!doctype html>
<html>

<head>
  <title>vaadin-grid Code Examples - React Integration</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <script src="../../webcomponentsjs/webcomponents-lite.js"></script>

  <script src="js_dependencies/react.min.js"></script>
  <script src="js_dependencies/JSXTransformer.js"></script>

  <link rel="import" href="common.html">

  <style>
    body {
      padding: 0;
      margin: 0;
      font-family: 'Helvetica Neue', Helvetica, Arial, 'Microsoft YaHei New', 'Microsoft Yahei', SimSun, STXihei, sans-serif;
    }

    img.user-image {
      position: absolute;
      bottom: 0px;
      right: 0px;
      max-width: 33%;
      max-height: 33%;
    }
  </style>
</head>

<body style="padding: 0; margin: 0;">
  <div id="reactdemo"></div>

  <script>
    (function wait() {
      // Wait for the polyfilled browsers to finish importing needed resources
      if (!document.querySelector('link[href$="vaadin-grid.html"]') || !window.getJSON) {
        return setTimeout(wait, 50);
      }
      // Want to avoid maintaining the React demo source in 2 places so we'll
      // evaluate the jsx code in react.html manually here
      var xhr = new XMLHttpRequest();
      xhr.onreadystatechange = function() {
        if (xhr.readyState == XMLHttpRequest.DONE) {
          if (xhr.status == 200) {
            var text = xhr.responseText;
            var scriptTag = '<script type="text/jsx">';
            var start = text.indexOf(scriptTag) + scriptTag.length;
            var end = text.indexOf('<\/script>', start);
            HTMLImports.whenReady(function() {
              JSXTransformer.exec(text.substr(start, end - start));
            });
          }
        }
      };
      xhr.open('GET', 'react.html', true);
      xhr.send();
    })();
  </script>

</body>
</html>