Skip to content

Commit c6d9bbc

Browse files
feat(date-time-picker-web): add icon SVG and update structure mode layout
1 parent 46c5087 commit c6d9bbc

File tree

3 files changed

+41
-33
lines changed

3 files changed

+41
-33
lines changed

packages/pluggableWidgets/date-time-picker-web/src/DateTimePicker.editorConfig.ts

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import { hidePropertiesIn, Properties } from "@mendix/pluggable-widgets-tools";
22
import {
33
container,
44
ContainerProps,
5-
dropzone,
5+
rowLayout,
66
structurePreviewPalette,
7-
StructurePreviewProps
7+
StructurePreviewProps,
8+
svgImage
89
} from "@mendix/widget-plugin-platform/preview/structure-preview-api";
910
import { DateTimePickerPreviewProps } from "../typings/DateTimePickerProps";
11+
import IconSVG from "./assets/close.svg";
12+
const IconSVGDark = IconSVG.replace('fill="#000000"', 'fill="#FFFFFF"');
1013

1114
export function getProperties(values: DateTimePickerPreviewProps, defaultProperties: Properties): Properties {
1215
if (values.type !== "date" && values.type !== "range") {
@@ -25,14 +28,6 @@ export function getProperties(values: DateTimePickerPreviewProps, defaultPropert
2528
hidePropertiesIn(defaultProperties, values, ["endDateAttribute"]);
2629
}
2730

28-
if (values.showLabel === false) {
29-
hidePropertiesIn(defaultProperties, values, ["label"]);
30-
}
31-
32-
if (values.editable !== "conditionally") {
33-
hidePropertiesIn(defaultProperties, values, ["editabilityCondition"]);
34-
}
35-
3631
if (values.validationType !== "custom") {
3732
hidePropertiesIn(defaultProperties, values, ["customValidation"]);
3833
}
@@ -43,7 +38,7 @@ export function getProperties(values: DateTimePickerPreviewProps, defaultPropert
4338
export function getPreview(values: DateTimePickerPreviewProps, isDarkMode: boolean): StructurePreviewProps {
4439
const palette = structurePreviewPalette[isDarkMode ? "dark" : "light"];
4540
const structurePreviewChildren: StructurePreviewProps[] = [];
46-
let dropdownPreviewChildren: StructurePreviewProps[] = [];
41+
// let dropdownPreviewChildren: StructurePreviewProps[] = [];
4742
let readOnly = values.readOnly;
4843

4944
if (structurePreviewChildren.length === 0) {
@@ -54,27 +49,33 @@ export function getPreview(values: DateTimePickerPreviewProps, isDarkMode: boole
5449
});
5550
}
5651

57-
return {
58-
type: "Container",
59-
children: [
60-
{
61-
type: "RowLayout",
62-
columnSize: "grow",
63-
borders: true,
64-
borderWidth: 1,
65-
borderRadius: 2,
66-
backgroundColor: readOnly ? palette.background.containerDisabled : palette.background.container,
67-
children: [
68-
{
69-
type: "Container",
70-
grow: 1,
71-
padding: 4,
72-
children: structurePreviewChildren
73-
},
74-
container({ grow: 0, padding: 4 })()
75-
]
76-
},
77-
...dropdownPreviewChildren
52+
return container()(
53+
rowLayout({
54+
columnSize: "grow",
55+
borders: true,
56+
borderWidth: 1,
57+
borderRadius: 2,
58+
backgroundColor: readOnly ? palette.background.containerDisabled : palette.background.container
59+
})(
60+
container({
61+
grow: 1,
62+
padding: 4
63+
})(...structurePreviewChildren),
64+
getIconPreview(isDarkMode)
65+
)
66+
);
67+
}
68+
69+
function getIconPreview(isDarkMode: boolean): ContainerProps {
70+
return container({
71+
grow: 0,
72+
padding: 4
73+
})(
74+
...[
75+
container({ padding: 1 })(),
76+
svgImage({ width: 16, height: 16 })(
77+
decodeURIComponent((isDarkMode ? IconSVGDark : IconSVG).replace("data:image/svg+xml,", ""))
78+
)
7879
]
79-
};
80+
);
8081
}
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "*.svg" {
2+
const content: string;
3+
export = content;
4+
}

0 commit comments

Comments
 (0)