Skip to content

Commit

Permalink
feat(image): allow to hide controls
Browse files Browse the repository at this point in the history
  • Loading branch information
ecarreras committed Nov 22, 2024
1 parent 70bd1b6 commit f96de62
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 f96de62

Please sign in to comment.