cedro 0.1.6 → 0.1.7
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/core/uid.ts +3 -0
- package/src/ui/container.ui.ts +33 -0
- package/src/ui/index.ts +5 -0
- package/src/ui/label.ui.ts +16 -20
package/package.json
CHANGED
package/src/core/uid.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OrientationTypes } from "src/types/orientation.type";
|
|
2
|
+
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
3
|
+
import { UID } from "../core/uid";
|
|
4
|
+
|
|
5
|
+
export type ContainerParams = {
|
|
6
|
+
orientation?: OrientationTypes;
|
|
7
|
+
parent?: Widget | null;
|
|
8
|
+
size?: number | null;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export class Container extends Widget {
|
|
12
|
+
constructor(params: ContainerParams) {
|
|
13
|
+
const { orientation = "horizontal", parent = null, size = null } = params;
|
|
14
|
+
|
|
15
|
+
super(UID(), "div", parent);
|
|
16
|
+
|
|
17
|
+
if (orientation === "horizontal") {
|
|
18
|
+
this.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
19
|
+
} else {
|
|
20
|
+
this.setAlign(WidgetAlignTypes.VERTICAL);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (size !== null) {
|
|
24
|
+
this.setFixedSize(size);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
this.setType(WidgetTypes.FILL);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function Spacer(): Container {
|
|
32
|
+
return new Container({});
|
|
33
|
+
}
|
package/src/ui/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ButtonColor } from "./buttonColor.ui";
|
|
|
4
4
|
import { ButtonMenu } from "./buttonmenu.ui";
|
|
5
5
|
import { ButtonStack } from "./buttonstack.ui";
|
|
6
6
|
import { Checkbox } from "./checkbox.ui";
|
|
7
|
+
import { Container, Spacer, ContainerParams } from "./container.ui";
|
|
7
8
|
import { WidgetAlignTypes, WidgetTypes, Widget } from "./widget.ui";
|
|
8
9
|
import { Dialog } from "./dialog";
|
|
9
10
|
import { HPanel } from "./hpanel.ui";
|
|
@@ -26,6 +27,8 @@ import { VPanel } from "./vpanel.ui";
|
|
|
26
27
|
import { createWidget } from "./widget.builder.ui";
|
|
27
28
|
import { IconButtonMenu } from "./iconButtonMenu.ui";
|
|
28
29
|
|
|
30
|
+
export type { ContainerParams };
|
|
31
|
+
|
|
29
32
|
export {
|
|
30
33
|
Accordion,
|
|
31
34
|
Button,
|
|
@@ -33,6 +36,7 @@ export {
|
|
|
33
36
|
ButtonMenu,
|
|
34
37
|
ButtonStack,
|
|
35
38
|
Checkbox,
|
|
39
|
+
Container,
|
|
36
40
|
Dialog,
|
|
37
41
|
HPanel,
|
|
38
42
|
Icon,
|
|
@@ -44,6 +48,7 @@ export {
|
|
|
44
48
|
ProgressBar,
|
|
45
49
|
RadioButton,
|
|
46
50
|
Select,
|
|
51
|
+
Spacer,
|
|
47
52
|
Switch,
|
|
48
53
|
Tabs,
|
|
49
54
|
TextArea,
|
package/src/ui/label.ui.ts
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
import { Colors } from "./colors.ui";
|
|
2
2
|
import { Widget } from "./widget.ui";
|
|
3
3
|
|
|
4
|
-
export type LabelVariants =
|
|
5
|
-
| "h1"
|
|
6
|
-
| "h2"
|
|
7
|
-
| "h3"
|
|
8
|
-
| "h4"
|
|
9
|
-
| "h5"
|
|
10
|
-
| "h6"
|
|
11
|
-
| "p"
|
|
12
|
-
| "span";
|
|
4
|
+
export type LabelVariants = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span";
|
|
13
5
|
|
|
14
6
|
export class Label extends Widget {
|
|
15
7
|
variant: LabelVariants;
|
|
16
8
|
color: Colors;
|
|
17
9
|
text: string;
|
|
18
10
|
|
|
19
|
-
constructor(
|
|
20
|
-
id: string,
|
|
21
|
-
variant: LabelVariants = "span",
|
|
22
|
-
parent: Widget | null = null
|
|
23
|
-
) {
|
|
11
|
+
constructor(id: string, variant: LabelVariants = "span", parent: Widget | null = null) {
|
|
24
12
|
super(id, variant, parent);
|
|
25
13
|
|
|
26
14
|
this.variant = variant;
|
|
@@ -34,28 +22,36 @@ export class Label extends Widget {
|
|
|
34
22
|
super.init();
|
|
35
23
|
}
|
|
36
24
|
|
|
37
|
-
|
|
25
|
+
public centerV(): void {
|
|
26
|
+
this.getBody().style.lineHeight = this.getH() + "px";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public centerH(): void {
|
|
30
|
+
this.getBody().style.textAlign = "center";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public setText(text: string): void {
|
|
38
34
|
this.text = text;
|
|
39
35
|
this.body.innerHTML = text;
|
|
40
36
|
}
|
|
41
37
|
|
|
42
|
-
setVariant(variant: LabelVariants = "span"): void {
|
|
38
|
+
public setVariant(variant: LabelVariants = "span"): void {
|
|
43
39
|
this.variant = variant;
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
setColor(color: Colors = "primary"): void {
|
|
42
|
+
public setColor(color: Colors = "primary"): void {
|
|
47
43
|
this.color = color;
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
getVariant(): LabelVariants {
|
|
46
|
+
public getVariant(): LabelVariants {
|
|
51
47
|
return this.variant;
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
getColor(): Colors {
|
|
50
|
+
public getColor(): Colors {
|
|
55
51
|
return this.color;
|
|
56
52
|
}
|
|
57
53
|
|
|
58
|
-
getText(): string {
|
|
54
|
+
public getText(): string {
|
|
59
55
|
return this.text;
|
|
60
56
|
}
|
|
61
57
|
}
|