|
4 | 4 | <head>
|
5 | 5 | <meta charset="utf-8">
|
6 | 6 | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
7 |
| - <title>Reactrb-Express Demo</title> |
| 7 | + <title>Hyperloop JS Demo</title> |
| 8 | + |
| 9 | + <!-- React and JQuery --> |
| 10 | + <script src="https://unpkg.com/react@15/dist/react.min.js"></script> |
| 11 | + <script src="https://unpkg.com/react-dom@15/dist/react-dom.min.js"></script> |
8 | 12 | <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
|
9 |
| - <!-- |
10 |
| - <script src="https://rawgit.com/reactrb/reactrb-express/master/reactrb-express.js"></script> |
11 |
| - --> |
12 |
| - <script src="reactrb-express.min.js"></script> |
13 | 13 |
|
14 |
| - <!-- ruby scripts can be fetched from the server or other remote source --> |
15 |
| - <script type="text/ruby" src="clock.rb"></script> |
| 14 | + <!-- Opal and Hyperloop --> |
| 15 | + <script src="https://rawgit.com/ruby-hyperloop/hyperloop-js/master/opal-compiler.min.js"></script> |
| 16 | + <script src="https://rawgit.com/ruby-hyperloop/hyperloop-js/master/hyperloop.min.js"></script> |
16 | 17 |
|
17 |
| - <!-- or the ruby code can specified directly inline --> |
18 | 18 | <script type="text/ruby">
|
19 |
| - Element['#clock'].render do |
20 |
| - Clock format: 'The time is: %a, %e %b %Y %H:%M:%S %z' |
| 19 | + class SimpleComponent < Hyperloop::Component |
| 20 | + render(DIV) do |
| 21 | + BUTTON { 'Push the button' }.on(:click) do |
| 22 | + alert 'You did it!' |
| 23 | + end |
| 24 | + end |
21 | 25 | end
|
22 | 26 | </script>
|
23 |
| - |
24 | 27 | </head>
|
25 |
| - <body> |
26 |
| - <div id="clock"></div> |
27 |
| - <!-- |
28 | 28 |
|
29 |
| - instead of using Element[...].render to attach a top level component, you |
30 |
| - can specify the react component and parameters using data- tags: |
31 |
| -
|
32 |
| - <div data-reactrb-mount="Clock" |
33 |
| - data-format="The time is: %a, %e %b %Y %H:%M:%S %z"> |
| 29 | + <body> |
| 30 | + <div data-hyperloop-mount="SimpleComponent"> |
34 | 31 | </div>
|
35 |
| -
|
36 |
| - --> |
37 | 32 | </body>
|
38 | 33 | </html>
|
0 commit comments