1
+ ///|
1
2
fn comp_container () -> @respo_node .RespoNode [ActionOp ] {
2
3
div (
3
4
class_name = str_spaced (
@@ -17,55 +18,104 @@ fn comp_container() -> @respo_node.RespoNode[ActionOp] {
17
18
),
18
19
[
19
20
text_node ("MoonBit is like Rust (Except that it has GC)" ),
20
- text_node ("Fork repo if you want to contribute." ),
21
+ @respo_node .a (
22
+ href = "https://github.com/fp-china/moonbit-is-like-rust" ,
23
+ target = Blank ,
24
+ inner_text = "Fork repo if you want to contribute." ,
25
+ ),
21
26
],
22
27
),
23
28
div (
24
29
style = respo_style (background_color = RawString ("#eee" )),
25
30
[
26
31
div (
27
- style = respo_style (max_width = Px (1400 ), margin = Auto ),
32
+ class_name = style_section ,
33
+ [
34
+ div (
35
+ class_name = style_section_inner ,
36
+ [
37
+ comp_section ("BASICS" ),
38
+ comp_topic ("Hello World" ),
39
+ comp_compare (
40
+ "println(\" Hello, World!\" )" , "println!(\" Hello, World!\" );" ,
41
+ ),
42
+ comp_topic ("Variables And Constants" ),
43
+ comp_compare (mbt_variable , rs_variable ),
44
+ comp_topic ("Explicit Types" ),
45
+ comp_compare (mbt_explict_type , rs_explict_type ),
46
+ comp_topic ("Type Coercion" ),
47
+ comp_compare (mbt_type_coercion , rs_type_coercion ),
48
+ comp_topic ("String Interpolation" ),
49
+ comp_compare (
50
+ mbt_string_interpolation , rs_string_interpolation ,
51
+ ),
52
+ comp_topic ("Range Operator" ),
53
+ comp_compare (mbt_range_operator , rs_range_operator ),
54
+ ],
55
+ ),
56
+ ],
57
+ ),
58
+ div (
59
+ class_name = style_section ,
60
+ [
61
+ div (
62
+ class_name = style_section_inner ,
63
+ [
64
+ comp_section ("COLLECTIONS" ),
65
+ comp_topic ("Arrays" ),
66
+ comp_compare (mbt_arrays , rs_arrays ),
67
+ comp_topic ("Maps" ),
68
+ comp_compare (mbt_maps , rs_maps ),
69
+ ],
70
+ ),
71
+ ],
72
+ ),
73
+ div (
74
+ class_name = style_section ,
75
+ [
76
+ div (
77
+ class_name = style_section_inner ,
78
+ [
79
+ comp_section ("FUNCTIONS" ),
80
+ comp_topic ("Functions" ),
81
+ comp_compare (mbt_functions , rs_functions ),
82
+ comp_topic ("Tuple Return" ),
83
+ comp_compare (mbt_tuple_return , rs_tuple_return ),
84
+ comp_topic ("Function Type" ),
85
+ comp_compare (mbt_function_type , rs_function_type ),
86
+ comp_topic ("HsahMap" ),
87
+ comp_compare (mbt_hashmap , rs_hashmap ),
88
+ comp_topic ("Named Arguments" ),
89
+ comp_compare (mbt_named_arguments , rs_named_arguments ),
90
+ ],
91
+ ),
92
+ ],
93
+ ),
94
+ div (
95
+ class_name = style_section ,
28
96
[
29
- comp_section ("BASICS" ),
30
- comp_topic ("Hello World" ),
31
- comp_compare (
32
- "println(\" Hello, World!\" )" , "println!(\" Hello, World!\" );" ,
97
+ div (
98
+ class_name = style_section_inner ,
99
+ [
100
+ comp_section ("TRAITS" ),
101
+ comp_topic ("Methods" ),
102
+ comp_compare (mbt_struct_methods , rs_struct_methods ),
103
+ comp_topic ("Trait Objects" ),
104
+ comp_compare (mbt_trait_objects , rs_trait_objects ),
105
+ comp_topic ("Default Implementation" ),
106
+ comp_compare (mbt_default_trait_impl , rs_default_trait_impl ),
107
+ ],
33
108
),
34
- comp_topic ("Variables And Constants" ),
35
- comp_compare (mbt_variable , rs_variable ),
36
- comp_topic ("Explicit Types" ),
37
- comp_topic ("Type Coercion" ),
38
- comp_topic ("String Interpolation" ),
39
- comp_topic ("Range Operator" ),
40
- comp_topic ("Inclusive Range Operator" ),
41
- comp_section ("COLLECTIONS" ),
42
- comp_topic ("Arrays" ),
43
- comp_topic ("Maps" ),
44
- comp_topic ("Empty Collections" ),
45
- comp_section ("FUNCTIONS" ),
46
- comp_topic ("Functions" ),
47
- comp_topic ("Tuple Return" ),
48
- comp_topic ("Variable Number Of Arguments" ),
49
- comp_topic ("Function Type" ),
50
- comp_topic ("Map" ),
51
- comp_topic ("Sort" ),
52
- comp_topic ("Named Arguments" ),
53
- comp_section ("TRAITS" ),
54
- comp_topic ("Declaration" ),
55
- comp_topic ("Usage" ),
56
- comp_topic ("Default Implementation" ),
57
- comp_topic ("Downcasting" ),
58
- comp_topic ("Protocol" ),
59
- comp_topic ("Extensions" ),
60
- @respo_node .space (height = 200 ),
61
109
],
62
110
),
111
+ @respo_node .space (height = 400 ),
63
112
],
64
113
),
65
114
],
66
115
)
67
116
}
68
117
118
+ ///|
69
119
fn comp_section (title : String ) -> @respo_node .RespoNode [ActionOp ] {
70
120
div (
71
121
class_name = str_spaced ([]),
@@ -81,6 +131,7 @@ fn comp_section(title : String) -> @respo_node.RespoNode[ActionOp] {
81
131
)
82
132
}
83
133
134
+ ///|
84
135
fn comp_topic (title : String ) -> @respo_node .RespoNode [ActionOp ] {
85
136
div (
86
137
class_name = str_spaced ([@respo .ui_center]),
@@ -95,12 +146,13 @@ fn comp_topic(title : String) -> @respo_node.RespoNode[ActionOp] {
95
146
)
96
147
}
97
148
149
+ ///|
98
150
fn comp_compare (
99
151
mbt_code : String ,
100
152
rs_code : String
101
153
) -> @respo_node .RespoNode [ActionOp ] {
102
154
div (
103
- class_name = str_spaced ([ @respo .ui_row]),
155
+ class_name = "ui-compare-by-width" , // Respo does not support media query yet
104
156
style = respo_style (padding = Px (12 )),
105
157
[
106
158
div (
@@ -122,7 +174,7 @@ fn comp_compare(
122
174
)
123
175
}
124
176
125
- /// a custom style for code block
177
+ ///| a custom style for code block
126
178
fn code_block [T ](
127
179
class_name ? : String ,
128
180
style ? : @respo_node .RespoStyle ,
@@ -142,11 +194,13 @@ fn code_block[T](
142
194
)
143
195
}
144
196
197
+ ///|
145
198
fn str_some_spaced (arr : Array [String? ]) -> String {
146
199
arr .filter (fn (x ) { not (x .is_empty ()) }).map (fn (x ) { x .unwrap () })
147
200
|> String ::concat (separator = " " )
148
201
}
149
202
203
+ ///|
150
204
let style_code_block : String = declare_static_style (
151
205
[
152
206
(
@@ -158,12 +212,14 @@ let style_code_block : String = declare_static_style(
158
212
border_radius = 4 ,
159
213
line_height = Em (1.6 ),
160
214
font_size = 13 ,
215
+ overflow = Auto ,
161
216
),
162
217
),
163
218
("pre&" , respo_style (margin = Px (0 ))),
164
219
],
165
220
)
166
221
222
+ ///|
167
223
let style_lang_name : String = declare_static_style (
168
224
[
169
225
(
@@ -177,3 +233,34 @@ let style_lang_name : String = declare_static_style(
177
233
),
178
234
],
179
235
)
236
+
237
+ ///|
238
+ let style_section : String = declare_static_style (
239
+ [
240
+ ("&" , respo_style (background_color = White )),
241
+ // set code color
242
+ ("& .\{ style_code_block } " , respo_style (background_color = RawString ("#eee" ))),
243
+ // every 2nd of parent
244
+ ("&:nth-child(2n)" , respo_style (background_color = RawString ("#eee" ))),
245
+ // and code block has changed color too
246
+ (
247
+ "&:nth-child(2n) .\{ style_code_block } " ,
248
+ respo_style (background_color = White ),
249
+ ),
250
+ ],
251
+ )
252
+
253
+ ///|
254
+ let style_section_inner : String = declare_static_style (
255
+ [
256
+ (
257
+ "&" ,
258
+ respo_style (
259
+ max_width = Px (1400 ),
260
+ margin = Auto ,
261
+ padding_top = Px (60 ),
262
+ padding_bottom = Px (60 ),
263
+ ),
264
+ ),
265
+ ],
266
+ )
0 commit comments