@@ -29,6 +29,7 @@ import {
29
29
RefreshLineIcon ,
30
30
ShadowIcon ,
31
31
OpacityIcon ,
32
+ LineHeightIcon
32
33
} from 'lowcoder-design' ;
33
34
import { useContext } from "react" ;
34
35
import styled from "styled-components" ;
@@ -74,6 +75,7 @@ import {
74
75
AnimationConfig ,
75
76
AnimationDelayConfig ,
76
77
AnimationDurationConfig ,
78
+ LineHeightConfig ,
77
79
78
80
79
81
} from "./styleControlConstants" ;
@@ -89,6 +91,12 @@ import { inputFieldComps } from "@lowcoder-ee/constants/compConstants";
89
91
function isSimpleColorConfig ( config : SingleColorConfig ) : config is SimpleColorConfig {
90
92
return config . hasOwnProperty ( "color" ) ;
91
93
}
94
+ function isLineHeightConfig ( config : SingleColorConfig ) : config is LineHeightConfig {
95
+ return config . hasOwnProperty ( "lineHeight" ) ;
96
+ }
97
+ function isTextSizeConfig ( config : SingleColorConfig ) : config is TextSizeConfig {
98
+ return config . hasOwnProperty ( "textSize" ) ;
99
+ }
92
100
93
101
function isDepColorConfig ( config : SingleColorConfig ) : config is DepColorConfig {
94
102
return config . hasOwnProperty ( "depName" ) || config . hasOwnProperty ( "depTheme" ) ;
@@ -157,9 +165,6 @@ function isFooterBackgroundImageOriginConfig(config: SingleColorConfig): config
157
165
return config . hasOwnProperty ( "footerBackgroundImageOrigin" ) ;
158
166
}
159
167
160
- function isTextSizeConfig ( config : SingleColorConfig ) : config is TextSizeConfig {
161
- return config . hasOwnProperty ( "textSize" ) ;
162
- }
163
168
164
169
function isTextWeightConfig ( config : SingleColorConfig ) : config is TextWeightConfig {
165
170
return config . hasOwnProperty ( "textWeight" ) ;
@@ -237,7 +242,12 @@ export type StyleConfigType<T extends readonly SingleColorConfig[]> = { [K in Na
237
242
function isEmptyColor ( color : string ) {
238
243
return _ . isEmpty ( color ) ;
239
244
}
240
-
245
+ function isEmptyLineHeight ( lineHeight : string ) {
246
+ return _ . isEmpty ( lineHeight ) ;
247
+ }
248
+ function isEmptyTextSize ( textSize : string ) {
249
+ return _ . isEmpty ( textSize ) ;
250
+ }
241
251
function isEmptyRadius ( radius : string ) {
242
252
return _ . isEmpty ( radius ) ;
243
253
}
@@ -293,9 +303,7 @@ function isEmptyFooterBackgroundImageOriginConfig(footerBackgroundImageOrigin: s
293
303
return _ . isEmpty ( footerBackgroundImageOrigin ) ;
294
304
}
295
305
296
- function isEmptyTextSize ( textSize : string ) {
297
- return _ . isEmpty ( textSize ) ;
298
- }
306
+
299
307
function isEmptyTextWeight ( textWeight : string ) {
300
308
return _ . isEmpty ( textWeight ) ;
301
309
}
@@ -375,6 +383,14 @@ function calcColors<ColorMap extends Record<string, string>>(
375
383
let res : Record < string , string > = { } ;
376
384
colorConfigs . forEach ( ( config ) => {
377
385
const name = config . name ;
386
+ if ( ! isEmptyLineHeight ( props [ name ] ) && isLineHeightConfig ( config ) ) {
387
+ res [ name ] = props [ name ] ;
388
+ return ;
389
+ }
390
+ if ( ! isEmptyTextSize ( props [ name ] ) && isTextSizeConfig ( config ) ) {
391
+ res [ name ] = props [ name ] ;
392
+ return ;
393
+ }
378
394
if ( ! isEmptyRadius ( props [ name ] ) && isRadiusConfig ( config ) ) {
379
395
res [ name ] = props [ name ] ;
380
396
return ;
@@ -448,10 +464,7 @@ function calcColors<ColorMap extends Record<string, string>>(
448
464
res [ name ] = props [ name ] ;
449
465
return ;
450
466
}
451
- if ( ! isEmptyTextSize ( props [ name ] ) && isTextSizeConfig ( config ) ) {
452
- res [ name ] = props [ name ] ;
453
- return ;
454
- }
467
+
455
468
if ( ! isEmptyTextWeight ( props [ name ] ) && isTextWeightConfig ( config ) ) {
456
469
res [ name ] = props [ name ] ;
457
470
return ;
@@ -633,6 +646,10 @@ function calcColors<ColorMap extends Record<string, string>>(
633
646
if ( isAnimationDurationConfig ( config ) ) {
634
647
res [ name ] = themeWithDefault [ config . animationDuration ] || '0s' ;
635
648
}
649
+ if ( isLineHeightConfig ( config ) ) {
650
+
651
+ res [ name ] = themeWithDefault [ config . lineHeight ] || '20px' ;
652
+ }
636
653
} ) ;
637
654
// The second pass calculates dep
638
655
colorConfigs . forEach ( ( config ) => {
@@ -743,6 +760,11 @@ const StyleContent = styled.div`
743
760
border-radius: 0 0 6px 6px;
744
761
}
745
762
` ;
763
+ const LineHeightPropIcon = styled ( LineHeightIcon ) `
764
+ margin: 0 8px 0 -3px;
765
+ padding: 3px;
766
+ color: #888;
767
+ ` ;
746
768
747
769
const MarginIcon = styled ( ExpandIcon ) ` margin: 0 8px 0 2px; color: #888` ;
748
770
const PaddingIcon = styled ( CompressIcon ) ` margin: 0 8px 0 2px; color: #888` ;
@@ -853,7 +875,8 @@ export function styleControl<T extends readonly SingleColorConfig[]>(
853
875
name === 'containerHeaderPadding' ||
854
876
name === 'containerSiderPadding' ||
855
877
name === 'containerFooterPadding' ||
856
- name === 'containerBodyPadding'
878
+ name === 'containerBodyPadding' ||
879
+ name === 'lineHeight'
857
880
) {
858
881
childrenMap [ name ] = StringControl ;
859
882
} else {
@@ -966,7 +989,8 @@ export function styleControl<T extends readonly SingleColorConfig[]>(
966
989
name === 'footerBackgroundImageRepeat' ||
967
990
name === 'footerBackgroundImageSize' ||
968
991
name === 'footerBackgroundImagePosition' ||
969
- name === 'footerBackgroundImageOrigin'
992
+ name === 'footerBackgroundImageOrigin' ||
993
+ name === 'lineHeight'
970
994
) {
971
995
children [ name ] ?. dispatchChangeValueAction ( '' ) ;
972
996
} else {
@@ -1299,6 +1323,14 @@ export function styleControl<T extends readonly SingleColorConfig[]>(
1299
1323
placeholder :
1300
1324
props [ name ] ,
1301
1325
} )
1326
+ : name === 'lineHeight' // Added lineHeight here
1327
+ ? (
1328
+ children [ name ] as InstanceType < typeof StringControl >
1329
+ ) . propertyView ( {
1330
+ label : config . label ,
1331
+ preInputNode : < LineHeightPropIcon title = "Line Height" /> ,
1332
+ placeholder : props [ name ] ,
1333
+ } )
1302
1334
: children [
1303
1335
name
1304
1336
] . propertyView ( {
@@ -1330,4 +1362,5 @@ export function useStyle<T extends readonly SingleColorConfig[]>(colorConfigs: T
1330
1362
props [ config . name as Names < T > ] = "" ;
1331
1363
} ) ;
1332
1364
return calcColors ( props , colorConfigs , theme ?. theme , bgColor ) ;
1365
+
1333
1366
}
0 commit comments