cedro 0.1.5 → 0.1.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cedro",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "@types/node": "^20.4.4",
@@ -0,0 +1,49 @@
1
+ import "./styles/image.css";
2
+ import { Widget, WidgetTypes } from "./widget.ui";
3
+
4
+ export class Image extends Widget {
5
+ imageContainer: Widget;
6
+ image: Widget;
7
+ constructor(id: string, src: string = "", parent: Widget | null = null) {
8
+ super(id, "div", parent);
9
+
10
+ this.imageContainer = new Widget(id + ".imageContainer", "div", this);
11
+ this.imageContainer.addClass("WUIImageContainer");
12
+
13
+ this.image = new Widget(id + ".image", "img", this.imageContainer);
14
+ this.image.setType(WidgetTypes.CUSTOM);
15
+ this.image.getBody().setAttribute("src", src);
16
+ }
17
+
18
+ public render(): void {
19
+ super.render();
20
+
21
+ this.imageContainer.setX(0);
22
+ this.imageContainer.setY(0);
23
+ this.imageContainer.setWH(this.getW(), this.getH());
24
+ }
25
+
26
+ public fillWidth(): void {
27
+ this.image.addClass("WUIImageFillWidth");
28
+ }
29
+
30
+ public fillHeight(): void {
31
+ this.image.addClass("WUIImageFillHeight");
32
+ }
33
+
34
+ public setAlternateText(text: string): void {
35
+ this.image.getBody().setAttribute("alt", text);
36
+ }
37
+
38
+ public setImageUrl(url: string): void {
39
+ this.image.getBody().setAttribute("src", url);
40
+ }
41
+
42
+ public getImageUrl(): string | null {
43
+ return this.image.getBody().getAttribute("src");
44
+ }
45
+
46
+ public getAlternateText(): string | null {
47
+ return this.image.getBody().getAttribute("alt");
48
+ }
49
+ }
package/src/ui/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Accordion } from "./accordion";
1
+ import { Accordion } from "./accordion.ui";
2
2
  import { Button } from "./button.ui";
3
3
  import { ButtonColor } from "./buttonColor.ui";
4
4
  import { ButtonMenu } from "./buttonmenu.ui";
@@ -9,6 +9,7 @@ import { Dialog } from "./dialog";
9
9
  import { HPanel } from "./hpanel.ui";
10
10
  import { Icon } from "./Icon.ui";
11
11
  import { IconButton } from "./IconButton.ui";
12
+ import { Image } from "./image.ui";
12
13
  import { Label } from "./label.ui";
13
14
  import { Menu } from "./menu.ui";
14
15
  import { ProgressBar } from "./progressbar.ui";
@@ -37,6 +38,7 @@ export {
37
38
  Icon,
38
39
  IconButton,
39
40
  IconButtonMenu,
41
+ Image,
40
42
  Label,
41
43
  Menu,
42
44
  ProgressBar,
@@ -0,0 +1,19 @@
1
+ .WUIImageContainer {
2
+ position: absolute;
3
+ overflow: hidden;
4
+ display: flex;
5
+ align-items: center;
6
+ justify-content: center;
7
+ }
8
+
9
+ .WUIImageContainer img {
10
+ margin: auto;
11
+ }
12
+
13
+ .WUIImageFillWidth {
14
+ width: 100% !important;
15
+ }
16
+
17
+ .WUIImageFillHeight {
18
+ height: 100% !important;
19
+ }
File without changes