Skip to content

Commit

Permalink
Merge pull request #137 from gisce/feature/image-hide-controls
Browse files Browse the repository at this point in the history
Allow to hide controls in Image component
  • Loading branch information
ecarreras authored Nov 25, 2024
2 parents 70bd1b6 + f96de62 commit 98987ce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import Field from "./Field";
/**
* Image base64 field
*/
class Image extends Field {}
class Image extends Field {
get showControls(): boolean {
return this.parsedWidgetProps?.showControls ?? true;
}
}

export default Image;
19 changes: 19 additions & 0 deletions src/spec/Image.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, it, expect } from "vitest";
import Image from "../Image";

describe("Image", () => {
it("should have showControls property to true as default", () => {
const props = {};
const image = new Image(props);
expect(image.showControls).toBe(true);
});
it("should have showControls property to false", () => {
const props = {
widget_props: {
showControls: false,
},
};
const image = new Image(props);
expect(image.showControls).toBe(false);
});
});

0 comments on commit 98987ce

Please sign in to comment.