11import { Properties , hidePropertiesIn } from "@mendix/pluggable-widgets-tools" ;
2- import { EventsPreviewProps } from "../typings/EventsProps" ;
32import {
43 StructurePreviewProps ,
54 structurePreviewPalette
65} from "@mendix/widget-plugin-platform/preview/structure-preview-api" ;
6+ import { EventsPreviewProps } from "../typings/EventsProps" ;
77
8- import EventsPreviewSVG from "./assets/Events.icon.svg" ;
98import EventsPreviewSVGActive from "./assets/Events.icon.active.svg" ;
9+ import EventsPreviewSVG from "./assets/Events.icon.svg" ;
10+ import EventsPreviewDarkSVGActive from "./assets/Events.icon.dark.active.svg" ;
11+ import EventsPreviewDarkSVG from "./assets/Events.icon.dark.svg" ;
1012
1113export function getProperties (
1214 values : EventsPreviewProps ,
@@ -22,15 +24,16 @@ export function getPreview(values: EventsPreviewProps, isDarkMode: boolean): Str
2224 const eventsCount = Number ( ! ! values . onComponentLoad ) + Number ( ! ! values . onEventChange ) ;
2325
2426 const palette = structurePreviewPalette [ isDarkMode ? "dark" : "light" ] ;
25-
26- const variant = eventsCount > 0 ? EventsPreviewSVGActive : EventsPreviewSVG ;
27+ const activeSVG = isDarkMode ? EventsPreviewDarkSVGActive : EventsPreviewSVGActive ;
28+ const normalSVG = isDarkMode ? EventsPreviewDarkSVG : EventsPreviewSVG ;
29+ const variant = eventsCount > 0 ? activeSVG : normalSVG ;
2730 const doc = decodeURIComponent ( variant . replace ( "data:image/svg+xml," , "" ) ) ;
2831
2932 return {
3033 type : "RowLayout" ,
3134 columnSize : "grow" ,
3235 borders : true ,
33- backgroundColor : eventsCount <= 0 ? palette . background . container : palette . background . containerDisabled ,
36+ backgroundColor : palette . background . containerFill ,
3437 children : [
3538 {
3639 type : "Container"
@@ -49,7 +52,10 @@ export function getPreview(values: EventsPreviewProps, isDarkMode: boolean): Str
4952 } ,
5053 {
5154 type : "Text" ,
52- content : eventsCount <= 0 ? "[Configure events]" : `[${ eventsCount } ] Events` ,
55+ content :
56+ eventsCount <= 0
57+ ? "[Configure events]"
58+ : `[${ eventsCount } ] Event${ eventsCount > 1 ? "s" : "" } ` ,
5359 fontColor : palette . text . primary ,
5460 grow : 10
5561 }
@@ -65,5 +71,5 @@ export function getPreview(values: EventsPreviewProps, isDarkMode: boolean): Str
6571export function getCustomCaption ( values : EventsPreviewProps , _platform = "desktop" ) : string {
6672 const eventsCount = Number ( ! ! values . onComponentLoad ) + Number ( ! ! values . onEventChange ) ;
6773
68- return eventsCount <= 0 ? "[Configure events]" : `[${ eventsCount } ] Events ` ;
74+ return eventsCount <= 0 ? "[Configure events]" : `[${ eventsCount } ] Event ${ eventsCount > 1 ? "s" : "" } ` ;
6975}
0 commit comments