Skip to content

Commit c828e82

Browse files
committed
Add batch of new elements
1 parent 9c82c37 commit c828e82

File tree

13 files changed

+229
-17
lines changed

13 files changed

+229
-17
lines changed

src/main/kotlin/org/celtric/kotlin/html/_building_blocks.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ operator fun List<Node>.plus(nodes: List<Node>): List<Node> = ((this as List<Any
9898
typealias Attributes = Map<String, Any?>
9999

100100
private fun Attributes.renderAttributes(prefix: String = "") =
101-
filter { it.value != null }
101+
filter { it.value != null && it.value != false }
102102
.map { Pair(it.key, if (it.value is Boolean) "" else "=\"${it.value}\"") }
103103
.joinToString("") { (key, value) -> " " + prefix + key + value }
104104

src/main/kotlin/org/celtric/kotlin/html/canvas.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fun canvas(
1616
// Content
1717
content: () -> Any
1818
) = BlockElement("canvas", content(), AllAttributes(mapOf(
19-
"width" to width.toString(),
20-
"height" to height.toString(),
19+
"width" to width,
20+
"height" to height,
2121
"class" to css,
2222
"id" to id
2323
), other, data))

src/main/kotlin/org/celtric/kotlin/html/embed.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ fun embed(
1717
) = EmptyBlockElement("embed", AllAttributes(mapOf(
1818
"type" to type,
1919
"src" to src,
20-
"width" to width.toString(),
21-
"height" to height.toString(),
20+
"width" to width,
21+
"height" to height,
2222
"class" to css,
2323
"id" to id
2424
), other, data))
Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
11
package org.celtric.kotlin.html
22

3-
// TODO
3+
fun form(
4+
// Optional
5+
action: String? = null,
6+
method: String? = null,
7+
acceptCharset: String? = null,
8+
autocomplete: String? = null,
9+
enctype: String? = null,
10+
name: String? = null,
11+
novalidate : Boolean = false,
12+
target: String? = null,
13+
14+
// Global
15+
css: String? = null,
16+
id: String? = null,
17+
18+
// Custom
19+
other: Attributes = emptyMap(),
20+
data: Attributes = emptyMap(),
21+
22+
// Content
23+
content: () -> Any
24+
) = BlockElement("form", content(), AllAttributes(mapOf(
25+
"action" to action,
26+
"method" to method,
27+
"accept-charset" to acceptCharset,
28+
"autocomplete" to autocomplete,
29+
"enctype" to enctype,
30+
"name" to name,
31+
"novalidate " to novalidate ,
32+
"target" to target,
33+
"class" to css,
34+
"id" to id
35+
), other, data))
Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,65 @@
11
package org.celtric.kotlin.html
22

3-
// TODO
3+
fun input(
4+
// Mandatory
5+
type: String,
6+
7+
// Optional
8+
accept: String? = null,
9+
autocomplete: String? = null,
10+
autofocus: Boolean = false,
11+
capture: Boolean = false,
12+
checked: Boolean = false,
13+
disabled: Boolean = false,
14+
list: String? = null,
15+
max: String? = null,
16+
maxlength: Int? = null,
17+
min: String? = null,
18+
minlength: Int? = null,
19+
multiple: Boolean = false,
20+
name: String? = null,
21+
pattern: String? = null,
22+
placeholder: String? = null,
23+
readonly: Boolean = false,
24+
required: Boolean = false,
25+
size: Int? = null,
26+
step: String? = null,
27+
value: String? = null,
28+
29+
// Global
30+
css: String? = null,
31+
id: String? = null,
32+
title: String? = null,
33+
34+
// Custom
35+
other: Attributes = emptyMap(),
36+
data: Attributes = emptyMap(),
37+
38+
// Content
39+
content: () -> Any
40+
) = EmptyBlockElement("input", AllAttributes(mapOf(
41+
"type" to type,
42+
"accept" to accept,
43+
"autocomplete" to autocomplete,
44+
"autofocus" to autofocus,
45+
"capture" to capture,
46+
"checked" to checked,
47+
"disabled" to disabled,
48+
"list" to list,
49+
"max" to max,
50+
"maxlength" to maxlength,
51+
"min" to min,
52+
"minlength" to minlength,
53+
"multiple" to multiple,
54+
"name" to name,
55+
"pattern" to pattern,
56+
"placeholder" to placeholder,
57+
"readonly" to readonly,
58+
"required" to required,
59+
"size" to size,
60+
"step" to step,
61+
"value" to value,
62+
"class" to css,
63+
"id" to id,
64+
"title" to title
65+
), other, data))

src/main/kotlin/org/celtric/kotlin/html/ol.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fun ol(
1818
content: () -> Any
1919
) = BlockElement("ol", content(), AllAttributes(mapOf(
2020
"type" to type,
21-
"start" to start.toString(),
21+
"start" to start,
2222
"reversed" to reversed,
2323
"class" to css,
2424
"id" to id
Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
11
package org.celtric.kotlin.html
22

3-
// TODO
3+
fun script(
4+
// Optional
5+
type: String? = null,
6+
src: String? = null,
7+
async: Boolean = false,
8+
crossorigin: String? = null,
9+
defer: Boolean = false,
10+
11+
// Global
12+
css: String? = null,
13+
id: String? = null,
14+
15+
// Custom
16+
other: Attributes = emptyMap(),
17+
data: Attributes = emptyMap(),
18+
19+
// Content
20+
content: () -> Any
21+
) = BlockElement("script", content(), AllAttributes(mapOf(
22+
"type" to type,
23+
"src" to src,
24+
"async" to async,
25+
"crossorigin" to crossorigin,
26+
"defer" to defer,
27+
"class" to css,
28+
"id" to id
29+
), other, data))
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
11
package org.celtric.kotlin.html
22

3-
// TODO
3+
fun select(
4+
// Optional
5+
autofocus: Boolean = false,
6+
disabled: Boolean = false,
7+
multiple: Boolean = false,
8+
name: String? = null,
9+
required: Boolean = false,
10+
size: Int? = null,
11+
12+
// Global
13+
css: String? = null,
14+
id: String? = null,
15+
16+
// Custom
17+
other: Attributes = emptyMap(),
18+
data: Attributes = emptyMap(),
19+
20+
// Content
21+
content: () -> Any
22+
) = BlockElement("select", content(), AllAttributes(mapOf(
23+
"autofocus" to autofocus,
24+
"disabled" to disabled,
25+
"multiple" to multiple,
26+
"name" to name,
27+
"required" to required,
28+
"size" to size,
29+
"class" to css,
30+
"id" to id
31+
), other, data))
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
package org.celtric.kotlin.html
22

3-
// TODO
3+
fun style(
4+
// Optional
5+
type: String? = null,
6+
media: String? = null,
7+
nonce: String? = null,
8+
title: String? = null,
9+
10+
// Custom
11+
other: Attributes = emptyMap(),
12+
data: Attributes = emptyMap(),
13+
14+
// Content
15+
content: () -> Any
16+
) = BlockElement("style", content(), AllAttributes(mapOf(
17+
"type" to type,
18+
"media" to media,
19+
"nonce" to nonce,
20+
"title" to title
21+
), other, data))

src/main/kotlin/org/celtric/kotlin/html/td.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ fun td(
1717
// Content
1818
content: () -> Any
1919
) = BlockElement("td", content(), AllAttributes(mapOf(
20-
"colspan" to colspan?.toString(),
21-
"rowspan" to rowspan?.toString(),
20+
"colspan" to colspan,
21+
"rowspan" to rowspan,
2222
"class" to css,
2323
"id" to id,
2424
"title" to title

0 commit comments

Comments
 (0)