-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
129 lines (118 loc) · 3.41 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Rust + WebAssembly Example</title>
<style>
.wasm-greetings {
position: relative;
height: 140px;
width: 240px;
padding: 20px;
background-color: #fff;
border-radius: 4px;
color: #333;
-webkit-box-shadow: 0px 0px 60px 5px rgba(0, 0, 0, 0.4);
box-shadow: 0px 0px 60px 5px rgba(0, 0, 0, 0.4);
}
.wasm-greetings:after {
position: absolute;
content: "";
right: -10px;
bottom: 18px;
width: 0;
height: 0;
border-left: 0px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #1a044e;
}
.wasm-greetings p {
text-align: center;
font-size: 20px;
font-weight: bold;
letter-spacing: 4px;
line-height: 28px;
}
.wasm-greetings input {
position: absolute;
bottom: 30px;
border: none;
border-bottom: 1px solid #d4d4d4;
padding: 10px;
width: 82%;
background: transparent;
-webkit-transition: all 0.25s ease;
transition: all 0.25s ease;
}
.wasm-greetings input:focus {
outline: none;
border-bottom: 1px solid #0d095e;
font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS",
"sans-serif";
}
.wasm-greetings .submit-btn {
position: absolute;
border-radius: 30px;
border-bottom-right-radius: 0;
border-top-right-radius: 0;
background-color: #0f0092;
color: #fff;
padding: 12px 25px;
display: inline-block;
font-size: 12px;
font-weight: bold;
letter-spacing: 5px;
right: -10px;
bottom: -20px;
cursor: pointer;
-webkit-transition: all 0.25s ease;
transition: all 0.25s ease;
-webkit-box-shadow: -5px 6px 20px 0px rgba(26, 26, 26, 0.4);
box-shadow: -5px 6px 20px 0px rgba(26, 26, 26, 0.4);
}
.wasm-greetings .submit-btn:hover {
background-color: #07013d;
-webkit-box-shadow: -5px 6px 20px 0px rgba(88, 88, 88, 0.569);
box-shadow: -5px 6px 20px 0px rgba(88, 88, 88, 0.569);
}
</style>
<script type="module">
import init, {
greetings,
get_message_len,
} from "./pkg/rust_wasm_greetings.js";
async function run() {
await init();
const input = document.getElementById("input");
const button = document.getElementById("button");
const lengthPlaceholder = document.getElementById("message-len");
button.addEventListener("click", () => {
const nameLength = get_message_len(input.value);
lengthPlaceholder.innerHTML = nameLength;
greetings(input.value);
});
}
run();
</script>
</head>
<body>
<div style="padding-left: 50%">
<div class="wasm-greetings">
<p>GREETINGS</p>
<input
id="input"
placeholder="Your name"
class="wasm-greetings-input"
name="name"
type="text"
/>
<br />
<div id="button" class="submit-btn">SUBMIT</div>
</div>
<div>
<p>Message Length: <span id="message-len"></span></p>
</div>
</div>
<script src="./pkg/rust_wasm_greetings_bg.wasm"></script>
</body>
</html>