@@ -31,7 +31,7 @@ import {
3131 ADMIN_AUTH_URL ,
3232 PUBLIC_APP_EDITOR_URL ,
3333} from "constants/routesURL" ;
34- import React from "react" ;
34+ import React , { useMemo } from "react" ;
3535import { createRoot } from "react-dom/client" ;
3636import { Helmet } from "react-helmet" ;
3737import { connect , Provider } from "react-redux" ;
@@ -63,6 +63,7 @@ import { packageMetaReadyAction, setLowcoderCompsLoading } from "./redux/reduxAc
6363import { fetchBrandingSetting } from "./redux/reduxActions/enterpriseActions" ;
6464import { EnterpriseProvider } from "./util/context/EnterpriseContext" ;
6565import { SimpleSubscriptionContextProvider } from "./util/context/SimpleSubscriptionContext" ;
66+ import { getBrandingSetting } from "./redux/selectors/enterpriseSelectors" ;
6667
6768const LazyUserAuthComp = React . lazy ( ( ) => import ( "pages/userAuth" ) ) ;
6869const LazyInviteLanding = React . lazy ( ( ) => import ( "pages/common/inviteLanding" ) ) ;
@@ -75,18 +76,33 @@ const LazyApplicationHome = React.lazy(() => import("pages/ApplicationV2"));
7576const LazyDebugComp = React . lazy ( ( ) => import ( "./debug" ) ) ;
7677const LazyDebugNewComp = React . lazy ( ( ) => import ( "./debugNew" ) ) ;
7778
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+ } ) ;
90106
91107type AppIndexProps = {
92108 isFetchUserFinished : boolean ;
@@ -106,6 +122,7 @@ type AppIndexProps = {
106122 favicon : string ;
107123 brandName : string ;
108124 uiLanguage : string ;
125+ brandingFontFamily ?: string ;
109126} ;
110127
111128class AppIndex extends React . Component < AppIndexProps , any > {
@@ -156,7 +173,7 @@ class AppIndex extends React.Component<AppIndexProps, any> {
156173 localStorage . setItem ( 'lowcoder_uiLanguage' , this . props . uiLanguage ) ;
157174
158175 return (
159- < Wrapper language = { this . props . uiLanguage } >
176+ < Wrapper language = { this . props . uiLanguage } fontFamily = { this . props . brandingFontFamily } >
160177 < Helmet >
161178 { < title > { this . props . brandName } </ title > }
162179 { < link rel = "icon" href = { this . props . favicon } /> }
@@ -281,7 +298,8 @@ class AppIndex extends React.Component<AppIndexProps, any> {
281298 href = { window . location . href }
282299 media = "(aspect-ratio: 1280/720)"
283300 /> ,
284-
301+ ] }
302+ { ( ( isLowCoderDomain || isLocalhost ) && ! Boolean ( this . props . brandingFontFamily ) ) && [
285303 < link
286304 key = "preconnect-googleapis"
287305 rel = "preconnect"
@@ -299,6 +317,24 @@ class AppIndex extends React.Component<AppIndexProps, any> {
299317 rel = "stylesheet"
300318 />
301319 ] }
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+ ] }
302338 </ Helmet >
303339 < SystemWarning />
304340 < Router history = { history } >
@@ -449,6 +485,7 @@ const mapStateToProps = (state: AppState) => ({
449485 : favicon ,
450486 brandName : getBrandingConfig ( state ) ?. brandName ?? trans ( "productName" ) ,
451487 uiLanguage : state . ui . users . user . uiLanguage ,
488+ brandingFontFamily : getBrandingSetting ( state ) ?. config_set ?. font ,
452489} ) ;
453490
454491const mapDispatchToProps = ( dispatch : any ) => ( {
0 commit comments