-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSSection.java
64 lines (52 loc) · 1.69 KB
/
GSSection.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
package org.genericsystem.reactor.gs;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.html.HtmlH1;
import org.genericsystem.reactor.model.GenericModel;
public class GSSection extends GSTag {
private final FlexDirection direction;
public GSSection(GSTag parent, FlexDirection direction) {
super(parent, "section");
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();
}
@Override
protected HtmlDomNode createNode(String parentId) {
return new HtmlDomNode(parentId);
}
public static class GenericColumn extends GSSection {
public GenericColumn(GSTag parent) {
super(parent, FlexDirection.COLUMN);
}
}
public static class GenericRow extends GSSection {
public GenericRow(GSTag parent) {
super(parent, FlexDirection.ROW);
}
}
public static class GenericRowWrapper extends GSSection {
public GenericRowWrapper(GSTag parent, FlexDirection direction, Consumer<Tag<?>> consumer) {
super(parent, direction);
addStyle("justify-content", "center");
consumer.accept(this);
}
public <T> GenericRowWrapper(GSTag parent, FlexDirection direction, BiConsumer<Tag<?>, T> consumer, T arg) {
super(parent, direction);
consumer.accept(this, arg);
}
}
public static class GenericH1Section extends GenericRowWrapper {
public GenericH1Section(GSTag parent, String text) {
super(parent, FlexDirection.ROW, HtmlH1<GenericModel>::new, text);
}
}
}