-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
244 lines (211 loc) · 13.5 KB
/
index.html
File metadata and controls
244 lines (211 loc) · 13.5 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/ru51a4/rrender/dist/rrender.js"></script>
<!-- and it's easy to individually load additional languages -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/go.min.js"></script>
<meta charset="utf-8">
<link rel="icon" type="image/png" href="favicon.png" />
<title>rrender</title>
<script>hljs.highlightAll();</script>
<!-- Place this tag in your head or just before your close body tag. -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body>
<div class="container">
<header class="d-flex flex-wrap justify-content-center align-items-center py-3 mb-4 border-bottom">
<a href="#" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
<svg class="bi me-2" width="40" height="32">
<use xlink:href="#bootstrap"></use>
</svg>
<span class="fs-4">rrender <img style="width: 50px;" src="favicon.jpg"></span>
</a>
<!-- Place this tag where you want the button to render. -->
<a class="github-button" href="https://github.com/ru51a4/rrender"
data-color-scheme="no-preference: light; light: light; dark: dark;" data-icon="octicon-star"
data-size="large" data-show-count="true" aria-label="Star ru51a4/rrender on GitHub">Star</a>
</header>
</div>
<div class="container d-flex flex-column align-items-center">
<div class="row d-flex flex-column align-items-center">
<h2><a href="https://github.com/ru51a4/minimal_react">rrender</a> - framework for building user interfaces
</h2>
<br>
<br><span style="text-align: center;">https://cdn.jsdelivr.net/gh/ru51a4/rrender/dist/rrender.js</span>
<br>
<h3 class="d-flex justify-content-center">How does it work? - <a
href="https://github.com/ru51a4/programming-guide/blob/main/article/rrender.md">read online</a>
</h3>
</div>
<div class="mt-5 row d-flex justify-content-center" style="text-align: center;">
<h2>online demo:</h2>
<ul class="d-flex flex-column align-items-center">
<li>
<a href="./demo/todo/">todo app</a>
</li>
<li>
<a href="http://188.120.245.72:88/demo/iblockcms-frontend/">ajax-catalog</a>
</li>
<li>
<a href="http://188.120.245.72:3000/">chat-app</a>
</li>
</ul>
<br>
</div>
<div style="min-width: 100%;" class="row align-items-center">
<div class="col-6">
<pre>
<code class="language-js">
class component_todo extends component {
state = {
counter: 0,
todos: [
{ title: 'wash the dishes' },
{ title: 'cook lunch' },
{ title: 'cook dinner' }
],
};
body() {
return `
<div class="">
<ul>
<li r-for="todos">
<span r-bind="title"></span>
</li>
</uL>
<span r-bind="counter"></span>
<button class="btn-primary" r-click="increment">
+
</button>
</div>
`;
}
increment(){
this.state.counter++;
}
}
</code>
</pre>
</div>
<div class="col-6 main d-flex justify-content-center">
<todo />
</div>
</div>
<div class="row ">
<div class="d-flex flex-column align-items-center">
<h2>fast start:</h2>
<pre
style="font-family:monospace;color: rgb(68, 68, 68); background-color: rgb(243, 243, 243); font-weight: 400; "><html>
<span style="color: rgb(68, 68, 68); font-weight: 400;"><span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;"><<span style="color: rgba(68, 68, 68, 0.667); font-weight: 700;">script</span> <span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;">src</span>=<span style="color: rgb(136, 0, 0); font-weight: 400;">"https://cdn.jsdelivr.net/gh/ru51a4/rrender/dist/rrender.js"</span>></span><span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;"></<span style="color: rgba(68, 68, 68, 0.667); font-weight: 700;">script</span>></span></span>
<span style="color: rgb(68, 68, 68); font-weight: 400;"><span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;"><<span style="color: rgba(68, 68, 68, 0.667); font-weight: 700;">body</span>></span>
<span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;"><<span style="color: rgba(68, 68, 68, 0.667); font-weight: 700;">div</span> <span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;">class</span>=<span style="color: rgb(136, 0, 0); font-weight: 400;">"main"</span>></span>
<span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;"><<span style="color: rgba(68, 68, 68, 0.667); font-weight: 700;">hello</span> /></span>
<span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;"></<span style="color: rgba(68, 68, 68, 0.667); font-weight: 700;">div</span>></span>
<span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;"></<span style="color: rgba(68, 68, 68, 0.667); font-weight: 700;">body</span>></span></span>
<span style="color: rgb(68, 68, 68); font-weight: 400;"><span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;"><<span style="color: rgba(68, 68, 68, 0.667); font-weight: 700;">script</span>></span><span style="color: rgb(68, 68, 68); font-weight: 400;">
<span style="color: rgb(68, 68, 68); font-weight: 700;">class</span> <span style="color: rgb(136, 0, 0); font-weight: 700;">component_hello</span> <span style="color: rgb(68, 68, 68); font-weight: 700;">extends</span> <span style="color: rgb(136, 0, 0); font-weight: 700;">component</span> {
state = {
<span style="color: rgb(68, 68, 68); font-weight: 400;">variable</span>: <span style="color: rgb(136, 0, 0); font-weight: 400;">"hello"</span>,
<span style="color: rgb(68, 68, 68); font-weight: 400;">color</span>: <span style="color: rgb(136, 0, 0); font-weight: 400;">"red"</span>,
<span style="color: rgb(68, 68, 68); font-weight: 400;">cssColor</span>: <span style="color: rgb(68, 68, 68); font-weight: 400;">() =></span> {
<span style="color: rgb(68, 68, 68); font-weight: 700;">return</span> <span style="color: rgb(136, 0, 0); font-weight: 400;">'color:'</span> + <span style="color: rgb(171, 86, 86); font-weight: 400;">this</span>.<span style="color: rgb(68, 68, 68); font-weight: 400;">state</span>.<span style="color: rgb(68, 68, 68); font-weight: 400;">color</span> + <span style="color: rgb(136, 0, 0); font-weight: 400;">';'</span>
},
<span style="color: rgb(68, 68, 68); font-weight: 400;">time</span>: <span style="color: rgb(68, 68, 68); font-weight: 700;">new</span> <span style="color: rgb(136, 0, 0); font-weight: 700;">Date</span>().<span style="color: rgb(136, 0, 0); font-weight: 700;">toLocaleTimeString</span>(),
};
<span style="color: rgb(136, 0, 0); font-weight: 700;">body</span>(<span style="color: rgb(68, 68, 68); font-weight: 400;"></span>) {
<span style="color: rgb(68, 68, 68); font-weight: 700;">return</span> <span style="color: rgb(136, 0, 0); font-weight: 400;">`<div>
<span r-bind="variable"></span>
<span r-bind.style="cssColor">world</span>
<span r-bind="time"></span>
</div>`</span>;
}
<span style="color: rgb(136, 0, 0); font-weight: 700;">init</span>(<span style="color: rgb(68, 68, 68); font-weight: 400;"></span>) {
<span style="color: rgb(171, 86, 86); font-weight: 400;">this</span>.<span style="color: rgb(68, 68, 68); font-weight: 400;">timer</span> = <span style="color: rgb(57, 115, 0); font-weight: 400;">setInterval</span>(<span style="color: rgb(68, 68, 68); font-weight: 400;">() =></span> {
<span style="color: rgb(171, 86, 86); font-weight: 400;">this</span>.<span style="color: rgb(68, 68, 68); font-weight: 400;">state</span>.<span style="color: rgb(68, 68, 68); font-weight: 400;">time</span> = <span style="color: rgb(68, 68, 68); font-weight: 700;">new</span> <span style="color: rgb(136, 0, 0); font-weight: 700;">Date</span>().<span style="color: rgb(136, 0, 0); font-weight: 700;">toLocaleTimeString</span>();
<span style="color: rgb(171, 86, 86); font-weight: 400;">this</span>.<span style="color: rgb(136, 0, 0); font-weight: 700;">dirtyCheck</span>();
<span style="color: rgb(136, 0, 0); font-weight: 700;">Render</span>.<span style="color: rgb(136, 0, 0); font-weight: 700;">renderDom</span>();
}, <span style="color: rgb(136, 0, 0); font-weight: 400;">1000</span>);
}
<span style="color: rgb(136, 0, 0); font-weight: 700;">destroy</span>(<span style="color: rgb(68, 68, 68); font-weight: 400;"></span>) {
<span style="color: rgb(57, 115, 0); font-weight: 400;">clearInterval</span>(<span style="color: rgb(171, 86, 86); font-weight: 400;">this</span>.<span style="color: rgb(68, 68, 68); font-weight: 400;">timer</span>);
}
}
<span style="color: rgb(68, 68, 68); font-weight: 700;">var</span> components = [
{
<span style="color: rgb(68, 68, 68); font-weight: 400;">name</span>: <span style="color: rgb(136, 0, 0); font-weight: 400;">'hello'</span>,
<span style="color: rgb(68, 68, 68); font-weight: 400;">component</span>: component_hello
},
];
<span style="color: rgb(68, 68, 68); font-weight: 700;">var</span> <span style="color: rgb(136, 0, 0); font-weight: 700;">Render</span> = <span style="color: rgb(68, 68, 68); font-weight: 700;">new</span> <span style="color: rgb(136, 0, 0); font-weight: 700;">render</span>(<span style="color: rgb(171, 86, 86); font-weight: 400;">document</span>.<span style="color: rgb(136, 0, 0); font-weight: 700;">querySelector</span>(<span style="color: rgb(136, 0, 0); font-weight: 400;">".main"</span>), components);
<span style="color: rgb(68, 68, 68); font-weight: 700;">function</span> <span style="color: rgb(136, 0, 0); font-weight: 700;">main</span>(<span style="color: rgb(68, 68, 68); font-weight: 400;"></span>) {
<span style="color: rgb(136, 0, 0); font-weight: 700;">Render</span>.<span style="color: rgb(136, 0, 0); font-weight: 700;">renderDom</span>();
}
<span style="color: rgb(136, 0, 0); font-weight: 700;">main</span>();
</span><span style="color: rgba(68, 68, 68, 0.667); font-weight: 400;"></<span style="color: rgba(68, 68, 68, 0.667); font-weight: 700;">script</span>></span></span>
</html></pre>
</div>
</div>
<div style="width: 70%;">
<script src="https://giscus.app/client.js" data-repo="ru51a4/rrender" data-repo-id="R_kgDOKOgDCA"
data-category="Q&A" data-category-id="DIC_kwDOKOgDCM4C4boo" data-mapping="pathname" data-strict="0"
data-reactions-enabled="1" data-emit-metadata="0" data-input-position="bottom"
data-theme="preferred_color_scheme" data-lang="ru" crossorigin="anonymous" async>
</script>
</div>
<footer style="width: 100%; justify-content: space-around; margin-bottom: 10px;"
class="mt-5 pt-3 d-flex text-muted border-top">
<span>ru51a4 ©️ 2020 - 2025</span>
<span> disigned by <a href="https://vk.com/umarekawari">umarekawari</a></span>
</footer>
</div>
</body>
<script>
class component_todo extends component {
state = {
counter: 0,
todos: [
{ title: 'wash the dishes' },
{ title: 'cook lunch' },
{ title: 'cook dinner' }
],
};
body() {
return `
<div class="card" style="width: 18rem;">
<div class="card-body d-flex flex-column align-items-center">
<ul>
<li r-for="todos">
<span r-bind="title"></span>
</li>
</ul>
<div>
<span r-bind="counter"></span>
<button class="btn btn-primary" r-click="increment">+</button>
</div>
</div>
</div>
`
};
increment() {
this.state.counter++;
Render.renderDom();
}
}
var components = [
{
name: 'todo',
component: component_todo
},
];
Render = new render(document.querySelector(".main"), components);
function main() {
Render.renderDom();
Render.renderDom();
Render.renderDom();
}
main();
</script>
</html>