@@ -2,13 +2,14 @@ import * as WebFont from 'webfontloader';
2
2
import { Global } from '@emotion/react' ;
3
3
import { MantineProvider } from '@mantine/core' ;
4
4
import { Notifications } from '@mantine/notifications' ;
5
+ import { generateColors } from '@mantine/colors-generator' ;
5
6
import { useEffect , useState , PropsWithChildren , useMemo } from 'react' ;
6
7
7
8
import { ApiService } from '@api' ;
8
9
import { Provider } from '../Provider' ;
9
10
import { MessageHandlerDataType } from '@types' ;
11
+ import { ParentWindow , deepMerge } from '@util' ;
10
12
import { WIDGET_TEXTS , isObject } from '@impler/client' ;
11
- import { generateShades , ParentWindow , deepMerge } from '@util' ;
12
13
import { API_URL , colors , mantineConfig , variables } from '@config' ;
13
14
import { IWidgetShowPayload , WidgetEventTypesEnum } from '@impler/shared' ;
14
15
@@ -47,6 +48,7 @@ export function Container({ children }: PropsWithChildren<{}>) {
47
48
if ( data . value . accessToken ) {
48
49
api . setAuthorizationToken ( data . value . accessToken ) ;
49
50
}
51
+ console . log ( data . value . primaryColor || colors . primary ) ;
50
52
setShowWidget ( true ) ;
51
53
setSecondaryPayload ( {
52
54
accessToken : data . value . accessToken ,
@@ -88,13 +90,18 @@ export function Container({ children }: PropsWithChildren<{}>) {
88
90
}
89
91
90
92
const primaryColor = secondaryPayload . appearance ?. primaryColor ?? secondaryPayload . primaryColor ?? colors . primary ;
93
+ console . log (
94
+ primaryColor ,
95
+ secondaryPayload ?. colorScheme ,
96
+ secondaryPayload . appearance ?. widget ?. backgroundColor ?? colors . white
97
+ ) ;
91
98
const primaryButtonConfig = secondaryPayload . appearance ?. primaryButtonConfig ;
92
99
const secondaryButtonConfig = secondaryPayload . appearance ?. secondaryButtonConfig ;
93
100
94
101
const primaryColorShades = useMemo (
95
102
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
96
103
// @ts -ignore
97
- ( ) => generateShades ( primaryColor ) ,
104
+ ( ) => generateColors ( primaryColor ) ,
98
105
[ primaryColor ]
99
106
) ;
100
107
@@ -128,54 +135,56 @@ export function Container({ children }: PropsWithChildren<{}>) {
128
135
borderRadius : '10px' ,
129
136
} ,
130
137
131
- ...( secondaryPayload ?. colorScheme && {
132
- ':root' : {
133
- colorScheme : secondaryPayload . colorScheme ,
138
+ ':root' : {
139
+ ...( secondaryPayload ?. colorScheme
140
+ ? {
141
+ colorScheme : secondaryPayload . colorScheme ,
142
+ }
143
+ : { } ) ,
134
144
135
- //common
136
- '--border-radius' : secondaryPayload . appearance ?. borderRadius || '0.25rem' ,
137
- '--label-color' : '#868e96' ,
138
- '--error-color' : '#f03e3e' ,
139
- '--border-color' : colors . lightDeem ,
140
- '--background-color' : secondaryPayload . appearance ?. widget ?. backgroundColor ?? colors . white ,
145
+ //common
146
+ '--border-radius' : secondaryPayload . appearance ?. borderRadius || '0.25rem' ,
147
+ '--label-color' : '#868e96' ,
148
+ '--error-color' : '#f03e3e' ,
149
+ '--border-color' : colors . lightDeem ,
150
+ '--background-color' : secondaryPayload . appearance ?. widget ?. backgroundColor ?? colors . white ,
141
151
142
- // stepper
143
- '--stepper-background' : '#f1f3f5' ,
144
- '--stepper-completed-background' : colors . success ,
145
- '--stepper-progress-background' : '#f1f3f5' ,
146
- '--stepper-icon-color' : '#495057' ,
147
- '--stepper-icon-progress-color' : '#495057' ,
148
- '--stepper-icon-completed-color' : colors . white ,
149
- '--stepper-border-color' : '#f1f3f5' ,
150
- '--stepper-completed-border-color' : colors . success ,
151
- '--stepper-progress-border-color' : primaryColor ,
152
- '--stepper-border-radius' : '0px' ,
153
- '--stepper-color' : '#666' ,
152
+ // stepper
153
+ '--stepper-background' : '#f1f3f5' ,
154
+ '--stepper-completed-background' : colors . success ,
155
+ '--stepper-progress-background' : '#f1f3f5' ,
156
+ '--stepper-icon-color' : '#495057' ,
157
+ '--stepper-icon-progress-color' : '#495057' ,
158
+ '--stepper-icon-completed-color' : colors . white ,
159
+ '--stepper-border-color' : '#f1f3f5' ,
160
+ '--stepper-completed-border-color' : colors . success ,
161
+ '--stepper-progress-border-color' : primaryColor ,
162
+ '--stepper-border-radius' : '0px' ,
163
+ '--stepper-color' : '#666' ,
154
164
155
- // button
165
+ // button
156
166
157
- //Primary Button Variables
158
- '--button-primary-color' : primaryButtonConfig ?. textColor ?? colors . white ,
159
- '--button-primary-background' : primaryButtonConfig ?. backgroundColor ?? primaryColor ,
160
- '--button-primary-background-hover' : primaryButtonConfig ?. hoverBackground ?? primaryColorShades ?. [ 6 ] ,
161
- '--button-primary-border-color' : primaryButtonConfig ?. borderColor ?? 'transparent' ,
162
- '--button-primary-border-hover' : primaryButtonConfig ?. hoverBorderColor ?? 'transparent' ,
163
- '--button-primary-shadow' : primaryButtonConfig ?. buttonShadow ?? 'none' ,
167
+ //Primary Button Variables
168
+ '--button-primary-color' : primaryButtonConfig ?. textColor ?? colors . white ,
169
+ '--button-primary-background' : primaryButtonConfig ?. backgroundColor ?? primaryColor ,
170
+ '--button-primary-background-hover' : primaryButtonConfig ?. hoverBackground ?? primaryColorShades ?. [ 7 ] ,
171
+ '--button-primary-border-color' : primaryButtonConfig ?. borderColor ?? 'transparent' ,
172
+ '--button-primary-border-hover' : primaryButtonConfig ?. hoverBorderColor ?? 'transparent' ,
173
+ '--button-primary-shadow' : primaryButtonConfig ?. buttonShadow ?? 'none' ,
164
174
165
- // Secondary Button Variables
166
- '--button-secondary-color' : secondaryButtonConfig ?. textColor ?? primaryColor ,
167
- '--button-secondary-background' : secondaryButtonConfig ?. backgroundColor ?? colors . white ,
168
- '--button-secondary-background-hover' : secondaryButtonConfig ?. hoverBackground ?? primaryColorShades ?. [ 0 ] ,
169
- '--button-secondary-border-color' : secondaryButtonConfig ?. borderColor ?? primaryColor ,
170
- '--button-secondary-border-hover' : secondaryButtonConfig ?. hoverBorderColor ?? primaryColor ,
171
- '--button-secondary-shadow' : secondaryButtonConfig ?. buttonShadow ?? 'none' ,
175
+ // Secondary Button Variables
176
+ '--button-secondary-color' : secondaryButtonConfig ?. textColor ?? primaryColor ,
177
+ '--button-secondary-background' : secondaryButtonConfig ?. backgroundColor ?? colors . white ,
178
+ '--button-secondary-background-hover' : secondaryButtonConfig ?. hoverBackground ?? primaryColorShades ?. [ 0 ] ,
179
+ '--button-secondary-border-color' : secondaryButtonConfig ?. borderColor ?? primaryColor ,
180
+ '--button-secondary-border-hover' : secondaryButtonConfig ?. hoverBorderColor ?? primaryColor ,
181
+ '--button-secondary-shadow' : secondaryButtonConfig ?. buttonShadow ?? 'none' ,
172
182
173
- // counts
174
- '--counts-background' : '#f1f3f5' ,
175
- '--counts-border-radius' : '2rem' ,
176
- '--counts-active-background' : '#ffffff' ,
177
- } ,
178
- } ) ,
183
+ // counts
184
+ '--counts-background' : '#f1f3f5' ,
185
+ '--counts-border-radius' : '2rem' ,
186
+ '--counts-active-background' : '#ffffff' ,
187
+ } ,
179
188
'.tippy-box[data-theme~="custom"]' : {
180
189
color : 'black' ,
181
190
backgroundColor : 'white' ,
0 commit comments