@@ -31,7 +31,7 @@ import {
31
31
ADMIN_AUTH_URL ,
32
32
PUBLIC_APP_EDITOR_URL ,
33
33
} from "constants/routesURL" ;
34
- import React from "react" ;
34
+ import React , { useMemo } from "react" ;
35
35
import { createRoot } from "react-dom/client" ;
36
36
import { Helmet } from "react-helmet" ;
37
37
import { connect , Provider } from "react-redux" ;
@@ -63,6 +63,7 @@ import { packageMetaReadyAction, setLowcoderCompsLoading } from "./redux/reduxAc
63
63
import { fetchBrandingSetting } from "./redux/reduxActions/enterpriseActions" ;
64
64
import { EnterpriseProvider } from "./util/context/EnterpriseContext" ;
65
65
import { SimpleSubscriptionContextProvider } from "./util/context/SimpleSubscriptionContext" ;
66
+ import { getBrandingSetting } from "./redux/selectors/enterpriseSelectors" ;
66
67
67
68
const LazyUserAuthComp = React . lazy ( ( ) => import ( "pages/userAuth" ) ) ;
68
69
const LazyInviteLanding = React . lazy ( ( ) => import ( "pages/common/inviteLanding" ) ) ;
@@ -75,18 +76,33 @@ const LazyApplicationHome = React.lazy(() => import("pages/ApplicationV2"));
75
76
const LazyDebugComp = React . lazy ( ( ) => import ( "./debug" ) ) ;
76
77
const LazyDebugNewComp = React . lazy ( ( ) => import ( "./debugNew" ) ) ;
77
78
78
- const Wrapper = ( props : { children : React . ReactNode , language : string } ) => (
79
- < ConfigProvider
80
- theme = { { hashed : false } }
81
- wave = { { disabled : true } }
82
- locale = { getAntdLocale ( props . language ) }
83
- >
84
- < App >
85
- < GlobalInstances />
86
- { props . children }
87
- </ App >
88
- </ ConfigProvider >
89
- ) ;
79
+ const Wrapper = React . memo ( ( props : {
80
+ children : React . ReactNode ,
81
+ language : string ,
82
+ fontFamily ?: string
83
+ } ) => {
84
+ const theme = useMemo ( ( ) => {
85
+ return {
86
+ hashed : false ,
87
+ token : {
88
+ fontFamily : `${ props . fontFamily ? props . fontFamily . split ( '+' ) . join ( ' ' ) : 'Roboto' } , sans-serif` ,
89
+ } ,
90
+ }
91
+ } , [ props . fontFamily ] ) ;
92
+
93
+ return (
94
+ < ConfigProvider
95
+ theme = { theme }
96
+ wave = { { disabled : true } }
97
+ locale = { getAntdLocale ( props . language ) }
98
+ >
99
+ < App >
100
+ < GlobalInstances />
101
+ { props . children }
102
+ </ App >
103
+ </ ConfigProvider >
104
+ ) ;
105
+ } ) ;
90
106
91
107
type AppIndexProps = {
92
108
isFetchUserFinished : boolean ;
@@ -106,6 +122,7 @@ type AppIndexProps = {
106
122
favicon : string ;
107
123
brandName : string ;
108
124
uiLanguage : string ;
125
+ brandingFontFamily ?: string ;
109
126
} ;
110
127
111
128
class AppIndex extends React . Component < AppIndexProps , any > {
@@ -156,7 +173,7 @@ class AppIndex extends React.Component<AppIndexProps, any> {
156
173
localStorage . setItem ( 'lowcoder_uiLanguage' , this . props . uiLanguage ) ;
157
174
158
175
return (
159
- < Wrapper language = { this . props . uiLanguage } >
176
+ < Wrapper language = { this . props . uiLanguage } fontFamily = { this . props . brandingFontFamily } >
160
177
< Helmet >
161
178
{ < title > { this . props . brandName } </ title > }
162
179
{ < link rel = "icon" href = { this . props . favicon } /> }
@@ -281,7 +298,8 @@ class AppIndex extends React.Component<AppIndexProps, any> {
281
298
href = { window . location . href }
282
299
media = "(aspect-ratio: 1280/720)"
283
300
/> ,
284
-
301
+ ] }
302
+ { ( ( isLowCoderDomain || isLocalhost ) && ! Boolean ( this . props . brandingFontFamily ) ) && [
285
303
< link
286
304
key = "preconnect-googleapis"
287
305
rel = "preconnect"
@@ -299,6 +317,24 @@ class AppIndex extends React.Component<AppIndexProps, any> {
299
317
rel = "stylesheet"
300
318
/>
301
319
] }
320
+ { Boolean ( this . props . brandingFontFamily ) && [
321
+ < link
322
+ key = "preconnect-googleapis"
323
+ rel = "preconnect"
324
+ href = "https://fonts.googleapis.com"
325
+ /> ,
326
+ < link
327
+ key = "preconnect-gstatic"
328
+ rel = "preconnect"
329
+ href = "https://fonts.gstatic.com"
330
+ crossOrigin = "anonymous"
331
+ /> ,
332
+ < link
333
+ key = { this . props . brandingFontFamily }
334
+ href = { `https://fonts.googleapis.com/css2?family=${ this . props . brandingFontFamily } &display=swap` }
335
+ rel = "stylesheet"
336
+ />
337
+ ] }
302
338
</ Helmet >
303
339
< SystemWarning />
304
340
< Router history = { history } >
@@ -449,6 +485,7 @@ const mapStateToProps = (state: AppState) => ({
449
485
: favicon ,
450
486
brandName : getBrandingConfig ( state ) ?. brandName ?? trans ( "productName" ) ,
451
487
uiLanguage : state . ui . users . user . uiLanguage ,
488
+ brandingFontFamily : getBrandingSetting ( state ) ?. config_set ?. font ,
452
489
} ) ;
453
490
454
491
const mapDispatchToProps = ( dispatch : any ) => ( {
0 commit comments