This repository has been archived by the owner on Oct 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hyperloopjs-helloworld.html
79 lines (60 loc) · 2.23 KB
/
hyperloopjs-helloworld.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>HyperloopJS-helloworld</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<!-- React and JQuery -->
<script src="https://unpkg.com/react@15/dist/react.min.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Opal and Hyperloop -->
<script src="https://rawgit.com/ruby-hyperloop/hyperloop-js/master/opal-compiler.min.js"></script>
<script src="https://rawgit.com/ruby-hyperloop/hyperloop-js/master/hyperloop.min.js"></script>
</head>
<body>
<div id="example"></div>
<script type="text/ruby">
class Helloworld < Hyperloop::Component
state show_field: false
state field_value: ""
render(DIV) do
show_button
DIV(class: 'formdiv') do
show_input
H1 { "#{state.field_value}" }
end if state.show_field
end
def show_button
BUTTON(class: 'btn btn-info') do
state.show_field ? "Click to hide HelloWorld input field" : "Click to show HelloWorld input field"
end.on(:click) { mutate.show_field !state.show_field }
end
def show_input
H4 do
SPAN {'Please type '}
SPAN(class: 'colored') {'Hello World'}
SPAN {' in the input field below :'}
BR {}
SPAN{'Or anything you want (^̮^)'}
end
INPUT(type: :text, class: 'form-control').on(:change) do |e|
mutate.field_value e.target.value
end
end
def show_text
H1 { "#{state.field_value}" }
end
end
</script>
<div class="hyperloophelloword">
<img src="hyperloop-logo-medium-white.png">
<h3>The complete isomorphic ruby framework</h3>
<br>
<div data-hyperloop-mount="Helloworld"
data-name="">
</div>
</div>
</body>
</html>