-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSDiv.java
88 lines (71 loc) · 2.23 KB
/
GSDiv.java
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
package org.genericsystem.reactor.gs;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.gstag.HtmlDiv;
import org.genericsystem.reactor.gstag.HtmlH1;
import org.genericsystem.reactor.gstag.HtmlH2;
public class GSDiv extends HtmlDiv {
private final FlexDirection direction;
public GSDiv(Tag parent) {
this(parent, FlexDirection.COLUMN);
}
public GSDiv(Tag parent, FlexDirection direction) {
super(parent);
this.direction = direction;
addStyle("display", "flex");
addStyle("flex-direction", direction.toString());
addStyle("flex-wrap", "nowrap");
}
public FlexDirection getDirection() {
return direction;
}
public FlexDirection getReverseDirection() {
return getDirection().reverse();
}
public static class GenericColumn extends GSDiv {
public GenericColumn(Tag parent) {
super(parent, FlexDirection.COLUMN);
}
}
public static class TitledColumn extends GenericColumn {
protected final FlexDirection flexDirection; // For the content’s direction.
public TitledColumn(Tag parent, FlexDirection flexDirection) {
super(parent);
this.flexDirection = flexDirection;
titleHeader();
content();
}
protected void titleHeader() {
}
protected void content() {
}
}
public static class GenericRow extends GSDiv {
public GenericRow(Tag parent) {
super(parent, FlexDirection.ROW);
}
}
public static class GenericRowWrapper extends GSDiv {
public GenericRowWrapper(Tag parent, FlexDirection direction, Consumer<Tag> consumer) {
super(parent, direction);
addStyle("justify-content", "center");
consumer.accept(this);
}
public <T> GenericRowWrapper(Tag parent, FlexDirection direction, BiConsumer<Tag, T> consumer, T arg) {
super(parent, direction);
addStyle("justify-content", "center");
consumer.accept(this, arg);
}
}
public static class GenericH1Section extends GenericRowWrapper {
public GenericH1Section(Tag parent, String text) {
super(parent, FlexDirection.ROW, HtmlH1::new, text);
}
}
public static class GenericH2Section extends GenericRowWrapper {
public GenericH2Section(Tag parent, String text) {
super(parent, FlexDirection.ROW, HtmlH2::new, text);
}
}
}