File tree Expand file tree Collapse file tree 9 files changed +153
-6
lines changed Expand file tree Collapse file tree 9 files changed +153
-6
lines changed Original file line number Diff line number Diff line change 5
5
< title > Ruby.wasm Quickstart</ title >
6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
7
< script src ="browser.script.iife.js "> </ script >
8
+ < style >
9
+ .spinner {
10
+ border : 4px solid rgba (0 , 0 , 0 , 0.1 );
11
+ width : 40px ;
12
+ height : 40px ;
13
+ border-radius : 50% ;
14
+ border-left-color : # 09f ;
15
+ animation : spin 1s ease infinite;
16
+ }
17
+
18
+ @keyframes spin {
19
+ 0% {
20
+ transform : rotate (0deg );
21
+ }
22
+ 100% {
23
+ transform : rotate (360deg );
24
+ }
25
+ }
26
+ </ style >
8
27
< script type ="text/ruby ">
9
- require 'js'
28
+ require 'js'
10
29
# Create a canvas element
11
30
window = JS . global
12
31
document = window . document
32
+ document . getElementById ( "spinner" ) . style . display = "none"
33
+
13
34
14
35
canvas = document . createElement ( "canvas" )
15
36
87
108
</ head >
88
109
< body class ="main ">
89
110
< h3 >
90
- We are loading...
111
+ Canvas Example
91
112
</ h3 >
113
+ < div id ="spinner " class ="spinner "> </ div >
92
114
</ body >
93
115
</ html >
Original file line number Diff line number Diff line change 5
5
< title > Heartbeat Monitor Animation with Ruby.wasm</ title >
6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
7
< script src ="browser.script.iife.js "> </ script >
8
+ < style >
9
+ .spinner {
10
+ border : 4px solid rgba (0 , 0 , 0 , 0.1 );
11
+ width : 40px ;
12
+ height : 40px ;
13
+ border-radius : 50% ;
14
+ border-left-color : # 09f ;
15
+ animation : spin 1s ease infinite;
16
+ }
17
+
18
+ @keyframes spin {
19
+ 0% {
20
+ transform : rotate (0deg );
21
+ }
22
+ 100% {
23
+ transform : rotate (360deg );
24
+ }
25
+ }
26
+ </ style >
8
27
< script type ="text/ruby ">
9
28
require 'js'
10
29
Original file line number Diff line number Diff line change 21
21
margin : 20px ;
22
22
}
23
23
24
+ .spinner {
25
+ border : 4px solid rgba (0 , 0 , 0 , 0.1 );
26
+ width : 40px ;
27
+ height : 40px ;
28
+ border-radius : 50% ;
29
+ border-left-color : # 09f ;
30
+ animation : spin 1s ease infinite;
31
+ }
32
+
33
+ @keyframes spin {
34
+ 0% {
35
+ transform : rotate (0deg );
36
+ }
37
+ 100% {
38
+ transform : rotate (360deg );
39
+ }
40
+ }
24
41
</ style >
25
42
</ head >
26
43
< body >
27
44
< h1 > Ruby.wasm Quickstart</ h1 >
45
+ < div id ="spinner " class ="spinner "> </ div >
28
46
< script type ="text/ruby " data-eval ="async ">
29
47
require 'kramdown'
30
48
$window = JS . global
31
49
$d = $window . document
32
50
51
+ $d . getElementById ( "spinner" ) . style . display = "none"
52
+
33
53
$d . createElement ( "h2" ) . tap { | e |
34
54
e . innerText = "Examples"
35
55
$d . body . appendChild ( e )
@@ -39,7 +59,7 @@ <h1>Ruby.wasm Quickstart</h1>
39
59
div . classList . add ( "examples" )
40
60
$d . body . appendChild ( div )
41
61
}
42
- examples = % w ( heartbeat canvas kramdown require run - code shoppingList )
62
+ examples = % w ( run - code shoppingList require canvas heartbeat kramdown )
43
63
examples . each do | example |
44
64
$d . createElement ( "a" ) . tap { | link |
45
65
link . href = "#{example}.html"
@@ -61,7 +81,6 @@ <h1>Ruby.wasm Quickstart</h1>
61
81
$d . body . appendChild ( e )
62
82
}
63
83
end
64
-
65
84
</ script >
66
85
</ body >
67
86
</ html >
Original file line number Diff line number Diff line change 5
5
< title > Ruby.wasm Quickstart</ title >
6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
7
< script src ="browser.script.iife.js "> </ script >
8
+ < style >
9
+ .spinner {
10
+ border : 4px solid rgba (0 , 0 , 0 , 0.1 );
11
+ width : 40px ;
12
+ height : 40px ;
13
+ border-radius : 50% ;
14
+ border-left-color : # 09f ;
15
+ animation : spin 1s ease infinite;
16
+ }
17
+
18
+ @keyframes spin {
19
+ 0% {
20
+ transform : rotate (0deg );
21
+ }
22
+ 100% {
23
+ transform : rotate (360deg );
24
+ }
25
+ }
26
+ </ style >
8
27
< script type ="text/ruby ">
9
28
require 'js'
10
29
require 'kramdown'
18
37
MARKDOWN
19
38
20
39
div . innerHTML = Kramdown ::Document . new ( text ) . to_html
40
+ JS . global . document . getElementById ( "spinner" ) . style . display = "none"
21
41
JS . global . document . body . appendChild ( div )
22
42
</ script >
23
43
</ head >
24
44
< body class ="main ">
25
45
< h3 >
26
46
Kramdown Example
27
47
</ h3 >
48
+ < div id ="spinner " class ="spinner "> </ div >
28
49
</ body >
29
50
</ html >
Original file line number Diff line number Diff line change 5
5
< title > Multiple Files example</ title >
6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
7
< script src ="browser.script.iife.js "> </ script >
8
+ < style >
9
+ .spinner {
10
+ border : 4px solid rgba (0 , 0 , 0 , 0.1 );
11
+ width : 40px ;
12
+ height : 40px ;
13
+ border-radius : 50% ;
14
+ border-left-color : # 09f ;
15
+ animation : spin 1s ease infinite;
16
+ }
17
+
18
+ @keyframes spin {
19
+ 0% {
20
+ transform : rotate (0deg );
21
+ }
22
+ 100% {
23
+ transform : rotate (360deg );
24
+ }
25
+ }
26
+ .buttons {
27
+ display : none;
28
+ }
29
+ </ style >
8
30
</ head >
9
31
< body class ="main ">
10
32
< h3 >
11
33
Multiple Files Example
12
34
</ h3 >
35
+ < div id ="spinner " class ="spinner "> </ div >
13
36
< div class ="buttons ">
14
37
< button id ="hello "> Click me</ button >
15
38
</ div >
Original file line number Diff line number Diff line change @@ -9,4 +9,7 @@ def require_relative(path)
9
9
end
10
10
app_path = __FILE__
11
11
$0 = File ::basename ( app_path , ".rb" ) if app_path
12
- require_relative "require/second" # Here it should be relative to main.rb. Note: I will upstream the fix for this.
12
+ require_relative "require/second" # Here it should be relative to main.rb. Note: I will upstream the fix for this.
13
+
14
+ JS . global . document . getElementById ( "spinner" ) . style . display = "none"
15
+ JS . global . document . querySelector ( ".buttons" ) . style . display = "block"
Original file line number Diff line number Diff line change 13
13
white-space : pre-wrap;
14
14
margin-top : 20px ;
15
15
}
16
+ .spinner {
17
+ border : 4px solid rgba (0 , 0 , 0 , 0.1 );
18
+ width : 40px ;
19
+ height : 40px ;
20
+ border-radius : 50% ;
21
+ border-left-color : # 09f ;
22
+ animation : spin 1s ease infinite;
23
+ }
24
+
25
+ @keyframes spin {
26
+ 0% {
27
+ transform : rotate (0deg );
28
+ }
29
+ 100% {
30
+ transform : rotate (360deg );
31
+ }
32
+ }
16
33
</ style >
17
34
</ head >
18
35
< body >
19
36
< h1 > Code Runner</ h1 >
37
+ < div id ="spinner " class ="spinner "> </ div >
20
38
< textarea id ="ruby-code " rows ="10 " cols ="50 ">
21
39
document = JS.global.document
22
40
div = document.createElement("div")
Original file line number Diff line number Diff line change 7
7
indentUnit : 4
8
8
} )
9
9
10
+ JS . global . document . getElementById ( "spinner" ) . style . display = "none"
11
+
10
12
define_method :click_run_button do
11
13
code_area = JS . global . document . getElementById ( "ruby-code" )
12
14
@window . editor . save
Original file line number Diff line number Diff line change 45
45
: checked ~ label {
46
46
text-decoration : line-through;
47
47
}
48
+
49
+ .spinner {
50
+ border : 4px solid rgba (0 , 0 , 0 , 0.1 );
51
+ width : 40px ;
52
+ height : 40px ;
53
+ border-radius : 50% ;
54
+ border-left-color : # 09f ;
55
+ animation : spin 1s ease infinite;
56
+ }
57
+
58
+ @keyframes spin {
59
+ 0% {
60
+ transform : rotate (0deg );
61
+ }
62
+ 100% {
63
+ transform : rotate (360deg );
64
+ }
65
+ }
48
66
</ style >
49
67
</ head >
50
68
< body >
@@ -53,8 +71,10 @@ <h2>Shopping List</h2>
53
71
< input type ="text " id ="new-item " placeholder ="Add new item " />
54
72
< button id ="add-item "> Add</ button >
55
73
< ul class ="shopping-list " id ="shopping-list "> </ ul >
56
-
74
+ < div id ="spinner " class ="spinner "> </ div >
75
+
57
76
< script type ="text/ruby " data-eval ="async ">
77
+ JS . global . document . getElementById ( "spinner" ) . style . display = "none"
58
78
require "json"
59
79
@document = JS . global . document
60
80
@list = @document . getElementById ( "shopping-list" )
You can’t perform that action at this time.
0 commit comments