Skip to content

Commit ea788ff

Browse files
refactor: update svgImage and image functions
1 parent 31895bf commit ea788ff

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

packages/pluggableWidgets/events-web/src/Events.editorConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function getPreview(values: EventsPreviewProps, isDarkMode: boolean): Str
3636
return rowLayout({ columnSize: "grow", borders: true, backgroundColor: palette.background.containerFill })(
3737
container()(),
3838
rowLayout({ grow: 2, padding: 8 })(
39-
svgImage(doc, 15, 15),
39+
svgImage({ width: 15, height: 15 })(doc),
4040
text({ fontColor: palette.text.primary, grow: 10 })(getCaption(eventsCount))
4141
),
4242
container()()

packages/pluggableWidgets/selection-helper-web/src/SelectionHelper.editorConfig.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export function getPreview(
3030
return container()(
3131
rowLayout({ columnSize: "grow" })(
3232
container({ grow: 1 })(
33-
svgImage(decodeURIComponent(CheckBoxIndeterminateSVG.replace("data:image/svg+xml,", "")), 24, 24)
33+
svgImage({ width: 24, height: 24 })(
34+
decodeURIComponent(CheckBoxIndeterminateSVG.replace("data:image/svg+xml,", ""))
35+
)
3436
),
3537
container({ grow: 100, padding: 3 })(text({ fontSize: 10 })(values.checkboxCaption))
3638
)

packages/shared/widget-plugin-platform/src/preview/structure-preview-api.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,28 @@ export interface ImageProps extends BaseStylingProps {
2626
height?: number; // sets a fixed maximum height
2727
}
2828

29-
export function svgImage(svgTextData: string, width?: number, height?: number): ImageProps {
30-
return {
31-
type: "Image",
32-
document: svgTextData,
33-
width,
34-
height
29+
interface ImageStyleProps extends BaseStylingProps {
30+
width?: number;
31+
height?: number;
32+
}
33+
34+
export function svgImage(style: ImageStyleProps): (document: string) => ImageProps {
35+
return (document: string) => {
36+
return {
37+
type: "Image",
38+
document,
39+
...style
40+
};
3541
};
3642
}
3743

38-
export function image(base64Data: string, width?: number, height?: number): ImageProps {
39-
return {
40-
type: "Image",
41-
data: base64Data,
42-
width,
43-
height
44+
export function image(style: ImageStyleProps): (data: string) => ImageProps {
45+
return (data: string) => {
46+
return {
47+
type: "Image",
48+
data,
49+
...style
50+
};
4451
};
4552
}
4653

0 commit comments

Comments
 (0)