@@ -6,30 +6,45 @@ import cssVars from "css-vars-ponyfill";
6
6
import { IInputs } from "../generated/ManifestTypes" ;
7
7
8
8
export function useCalendarColors ( pcfContext : ComponentFramework . Context < IInputs > , eventHeaderFormat : string ) {
9
- const eventDefaultBackgroundColor = Color (
10
- isHexColor ( pcfContext . parameters . eventDefaultColor ?. raw || "" )
11
- ? ( pcfContext . parameters . eventDefaultColor . raw as string )
12
- : CalendarUtils . DEFAULT_EVENT_COLOR
9
+
10
+ const [ eventDefaultBackgroundColor , setEventDefaultBackgroundColor ] = useState < Color > (
11
+ Color (
12
+ isHexColor ( pcfContext . parameters . eventDefaultColor ?. raw || "" )
13
+ ? ( pcfContext . parameters . eventDefaultColor . raw as string )
14
+ : CalendarUtils . DEFAULT_EVENT_COLOR
15
+ )
13
16
) ;
14
- const calendarTodayBackgroundColor = Color (
15
- isHexColor ( pcfContext . parameters . calendarTodayBackgroundColor ?. raw || "" )
16
- ? ( pcfContext . parameters . calendarTodayBackgroundColor . raw as string )
17
- : CalendarUtils . DEFAULT_TODAY_BACKGROUND_COLOR
17
+
18
+ const [ calendarTodayBackgroundColor , setCalendarTodayBackgroundColor ] = useState < Color > (
19
+ Color (
20
+ isHexColor ( pcfContext . parameters . calendarTodayBackgroundColor ?. raw || "" )
21
+ ? ( pcfContext . parameters . calendarTodayBackgroundColor . raw as string )
22
+ : CalendarUtils . DEFAULT_TODAY_BACKGROUND_COLOR
23
+ )
18
24
) ;
19
- const calendarTextColor = Color (
20
- isHexColor ( pcfContext . parameters . calendarTextColor ?. raw || "" )
21
- ? ( pcfContext . parameters . calendarTextColor . raw as string )
22
- : CalendarUtils . DEFAULT_TEXT_COLOR
25
+
26
+ const [ calendarTextColor , setCalendarTextColor ] = useState < Color > (
27
+ Color (
28
+ isHexColor ( pcfContext . parameters . calendarTextColor ?. raw || "" )
29
+ ? ( pcfContext . parameters . calendarTextColor . raw as string )
30
+ : CalendarUtils . DEFAULT_TEXT_COLOR
31
+ )
23
32
) ;
24
- const calendarBorderColor = Color (
25
- isHexColor ( pcfContext . parameters . calendarBorderColor ?. raw || "" )
26
- ? ( pcfContext . parameters . calendarBorderColor . raw as string )
27
- : CalendarUtils . DEFAULT_BORDER_COLOR
33
+
34
+ const [ calendarBorderColor , setCalendarBorderColor ] = useState < Color > (
35
+ Color (
36
+ isHexColor ( pcfContext . parameters . calendarBorderColor ?. raw || "" )
37
+ ? ( pcfContext . parameters . calendarBorderColor . raw as string )
38
+ : CalendarUtils . DEFAULT_BORDER_COLOR
39
+ )
28
40
) ;
29
- const calendarTimeBarBackgroundColor = Color (
30
- isHexColor ( pcfContext . parameters . calendarTimeBarBackgroundColor ?. raw || "" )
31
- ? ( pcfContext . parameters . calendarTimeBarBackgroundColor . raw as string )
32
- : CalendarUtils . DEFAULT_TIMEBAR_BACKGROUND_COLOR
41
+
42
+ const [ calendarTimeBarBackgroundColor , setCalendarTimeBarBackgroundColor ] = useState < Color > (
43
+ Color (
44
+ isHexColor ( pcfContext . parameters . calendarTimeBarBackgroundColor ?. raw || "" )
45
+ ? ( pcfContext . parameters . calendarTimeBarBackgroundColor . raw as string )
46
+ : CalendarUtils . DEFAULT_TIMEBAR_BACKGROUND_COLOR
47
+ )
33
48
) ;
34
49
35
50
const [ weekendColor , setWeekendColor ] = useState < string > (
@@ -38,6 +53,56 @@ export function useCalendarColors(pcfContext: ComponentFramework.Context<IInputs
38
53
: CalendarUtils . DEFAULT_WEEKEND_BACKGROUND_COLOR
39
54
) ;
40
55
56
+ useEffect ( ( ) => {
57
+ setEventDefaultBackgroundColor (
58
+ Color (
59
+ isHexColor ( pcfContext . parameters . eventDefaultColor ?. raw || "" )
60
+ ? ( pcfContext . parameters . eventDefaultColor . raw as string )
61
+ : CalendarUtils . DEFAULT_EVENT_COLOR
62
+ )
63
+ ) ;
64
+ } , [ pcfContext . parameters . eventDefaultColor ?. raw ] ) ;
65
+
66
+ useEffect ( ( ) => {
67
+ setCalendarTodayBackgroundColor (
68
+ Color (
69
+ isHexColor ( pcfContext . parameters . calendarTodayBackgroundColor ?. raw || "" )
70
+ ? ( pcfContext . parameters . calendarTodayBackgroundColor . raw as string )
71
+ : CalendarUtils . DEFAULT_TODAY_BACKGROUND_COLOR
72
+ )
73
+ ) ;
74
+ } , [ pcfContext . parameters . calendarTodayBackgroundColor ?. raw ] ) ;
75
+
76
+ useEffect ( ( ) => {
77
+ setCalendarTextColor (
78
+ Color (
79
+ isHexColor ( pcfContext . parameters . calendarTextColor ?. raw || "" )
80
+ ? ( pcfContext . parameters . calendarTextColor . raw as string )
81
+ : CalendarUtils . DEFAULT_TEXT_COLOR
82
+ )
83
+ ) ;
84
+ } , [ pcfContext . parameters . calendarTextColor ?. raw ] ) ;
85
+
86
+ useEffect ( ( ) => {
87
+ setCalendarBorderColor (
88
+ Color (
89
+ isHexColor ( pcfContext . parameters . calendarBorderColor ?. raw || "" )
90
+ ? ( pcfContext . parameters . calendarBorderColor . raw as string )
91
+ : CalendarUtils . DEFAULT_BORDER_COLOR
92
+ )
93
+ ) ;
94
+ } , [ pcfContext . parameters . calendarBorderColor ?. raw ] ) ;
95
+
96
+ useEffect ( ( ) => {
97
+ setCalendarTimeBarBackgroundColor (
98
+ Color (
99
+ isHexColor ( pcfContext . parameters . calendarTimeBarBackgroundColor ?. raw || "" )
100
+ ? ( pcfContext . parameters . calendarTimeBarBackgroundColor . raw as string )
101
+ : CalendarUtils . DEFAULT_TIMEBAR_BACKGROUND_COLOR
102
+ )
103
+ ) ;
104
+ } , [ pcfContext . parameters . calendarTimeBarBackgroundColor ?. raw ] ) ;
105
+
41
106
useEffect ( ( ) => {
42
107
const color = isHexColor ( pcfContext . parameters . weekendBackgroundColor ?. raw || "" )
43
108
? pcfContext . parameters . weekendBackgroundColor . raw !
0 commit comments