cedro 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ui/container.ui.ts +6 -1
- package/src/ui/label.ui.ts +27 -2
package/package.json
CHANGED
package/src/ui/container.ui.ts
CHANGED
|
@@ -6,11 +6,12 @@ export type ContainerParams = {
|
|
|
6
6
|
orientation?: OrientationTypes;
|
|
7
7
|
parent?: Widget | null;
|
|
8
8
|
size?: number | null;
|
|
9
|
+
padding?: number | null;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export class Container extends Widget {
|
|
12
13
|
constructor(params: ContainerParams) {
|
|
13
|
-
const { orientation = "horizontal", parent = null, size = null } = params;
|
|
14
|
+
const { orientation = "horizontal", parent = null, size = null, padding = null } = params;
|
|
14
15
|
|
|
15
16
|
super(UID(), "div", parent);
|
|
16
17
|
|
|
@@ -24,6 +25,10 @@ export class Container extends Widget {
|
|
|
24
25
|
this.setFixedSize(size);
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
if (padding !== null) {
|
|
29
|
+
this.setPadding(padding);
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
this.setType(WidgetTypes.FILL);
|
|
28
33
|
}
|
|
29
34
|
}
|
package/src/ui/label.ui.ts
CHANGED
|
@@ -8,9 +8,15 @@ export class Label extends Widget {
|
|
|
8
8
|
color: Colors;
|
|
9
9
|
text: string;
|
|
10
10
|
|
|
11
|
+
isHCentered: boolean;
|
|
12
|
+
isVCentered: boolean;
|
|
13
|
+
|
|
11
14
|
constructor(id: string, variant: LabelVariants = "span", parent: Widget | null = null) {
|
|
12
15
|
super(id, variant, parent);
|
|
13
16
|
|
|
17
|
+
this.isHCentered = false;
|
|
18
|
+
this.isVCentered = false;
|
|
19
|
+
|
|
14
20
|
this.variant = variant;
|
|
15
21
|
this.color = "primary";
|
|
16
22
|
this.text = "";
|
|
@@ -22,11 +28,30 @@ export class Label extends Widget {
|
|
|
22
28
|
super.init();
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
public
|
|
31
|
+
public setHCentered(isHCentered: boolean = true): void {
|
|
32
|
+
this.isHCentered = isHCentered;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public setVCentered(isVCentered: boolean = true): void {
|
|
36
|
+
this.isVCentered = isVCentered;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public render(): void {
|
|
40
|
+
super.render();
|
|
41
|
+
|
|
42
|
+
if (this.isHCentered) {
|
|
43
|
+
this.centerH();
|
|
44
|
+
}
|
|
45
|
+
if (this.isVCentered) {
|
|
46
|
+
this.centerV();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private centerV(): void {
|
|
26
51
|
this.getBody().style.lineHeight = this.getH() + "px";
|
|
27
52
|
}
|
|
28
53
|
|
|
29
|
-
|
|
54
|
+
private centerH(): void {
|
|
30
55
|
this.getBody().style.textAlign = "center";
|
|
31
56
|
}
|
|
32
57
|
|