Skip to content

Commit

Permalink
Merge pull request #78 from gisce/separator-icon
Browse files Browse the repository at this point in the history
Add icon to separator widget
  • Loading branch information
mguellsegarra authored May 3, 2023
2 parents 3669753 + 34e9ae5 commit f0dbb00
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gisce/ooui",
"version": "0.18.1",
"version": "0.19.0",
"main": "./dist/ooui.umd.js",
"module": "./dist/ooui.es.js",
"types": "./dist/index.d.ts",
Expand Down
11 changes: 11 additions & 0 deletions src/Separator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@ class Separator extends Widget {
this._label = value;
}

_icon: string | null = null;
get icon(): string | null {
return this._icon;
}
set icon(value: string | null) {
this._icon = value;
}

constructor(props: any) {
super(props);

if (props) {
if (props.string) {
this._label = replaceEntities(props.string);
}
if (props.icon) {
this._icon = props.icon;
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/spec/Separator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@ describe("A Separator", () => {

expect(widget.label).toBe("Text");
});
it("can have an icon property", () => {
const widgetFactory = new WidgetFactory();
const props = {
string: "Text",
icon: "home"
};
const widget = widgetFactory.createWidget("separator", props);
expect(widget.icon).toEqual("home");
});
});

0 comments on commit f0dbb00

Please sign in to comment.