@@ -3,6 +3,10 @@ import { RecordConstructorToView } from "lowcoder-core";
3
3
import { styleControl } from "comps/controls/styleControl" ;
4
4
import _ from "lodash" ;
5
5
import {
6
+ avatarContainerStyle ,
7
+ AvatarContainerStyleType ,
8
+ avatarLabelStyle ,
9
+ AvatarLabelStyleType ,
6
10
AvatarStyle ,
7
11
AvatarStyleType ,
8
12
} from "comps/controls/styleControlConstants" ;
@@ -37,13 +41,20 @@ const AvatarWrapper = styled(Avatar) <AvatarProps & { $cursorPointer?: boolean,
37
41
cursor: ${ ( props ) => props . $cursorPointer ? 'pointer' : '' } ;
38
42
` ;
39
43
40
- const Wrapper = styled . div < { iconSize : number , labelPosition : string } > `
44
+ const Wrapper = styled . div < { iconSize : number , labelPosition : string , $style : AvatarContainerStyleType } > `
41
45
display: flex;
42
46
width: 100%;
43
47
height: 100%;
44
- padding: 0px;
45
48
align-items: center;
46
49
flex-direction: ${ ( props ) => props . labelPosition === 'left' ? 'row' : 'row-reverse' } ;
50
+ ${ ( props ) => {
51
+ return (
52
+ props . $style && {
53
+ ...props . $style ,
54
+ borderRadius : props . $style . radius ,
55
+ }
56
+ ) ;
57
+ } }
47
58
`
48
59
49
60
const LabelWrapper = styled . div < { iconSize : number , alignmentPosition : string } > `
@@ -55,20 +66,47 @@ flex-direction: column;
55
66
justify-content: flex-end;
56
67
align-items: ${ ( props ) => props . alignmentPosition === 'left' ? 'flex-start' : 'flex-end' } ;
57
68
`
58
- const LabelSpan = styled . span < { color : string } > `
69
+ const LabelSpan = styled . span < { $style : AvatarLabelStyleType } > `
59
70
max-width: 100%;
60
71
overflow: hidden;
61
72
text-overflow: ellipsis;
62
73
white-space: nowrap;
63
- font-weight: bold;
64
- color: ${ ( props ) => props . color } ;
74
+ font-weight: ${ props => props . $style . textWeight } ;
75
+ border-radius: ${ props => props . $style . radius } ;
76
+ font-size: ${ props => props . $style . textSize } ;
77
+ rotate: ${ props => props . $style . rotation } ;
78
+ text-transform: ${ props => props . $style . textTransform } ;
79
+ color: ${ props => props . $style . text } ;
80
+ border: ${ props => props . $style . border } ;
81
+ border-style: ${ props => props . $style . borderStyle } ;
82
+ border-width: ${ props => props . $style . borderWidth } ;
83
+ font-family: ${ props => props . $style . fontFamily } ;
84
+ font-style: ${ props => props . $style . fontStyle } ;
85
+ margin: ${ props => props . $style . margin } ;
86
+ padding: ${ props => props . $style . padding } ;
87
+ background: ${ props => props . $style . background } ;
88
+ text-decoration: ${ props => props . $style . textDecoration } ;
65
89
`
66
- const CaptionSpan = styled . span < { color : string } > `
90
+ const CaptionSpan = styled . span < { $style : AvatarLabelStyleType } > `
67
91
max-width: 100%;
68
92
overflow: hidden;
69
93
text-overflow: ellipsis;
70
94
white-space: nowrap;
71
- color: ${ ( props ) => props . color } ;
95
+ font-weight: ${ props => props . $style . textWeight } ;
96
+ border-radius: ${ props => props . $style . radius } ;
97
+ font-size: ${ props => props . $style . textSize } ;
98
+ rotate: ${ props => props . $style . rotation } ;
99
+ text-transform: ${ props => props . $style . textTransform } ;
100
+ color: ${ props => props . $style . text } ;
101
+ border: ${ props => props . $style . border } ;
102
+ border-style: ${ props => props . $style . borderStyle } ;
103
+ border-width: ${ props => props . $style . borderWidth } ;
104
+ font-family: ${ props => props . $style . fontFamily } ;
105
+ font-style: ${ props => props . $style . fontStyle } ;
106
+ margin: ${ props => props . $style . margin } ;
107
+ padding: ${ props => props . $style . padding } ;
108
+ background: ${ props => props . $style . background } ;
109
+ text-decoration: ${ props => props . $style . textDecoration } ;
72
110
`
73
111
const EventOptions = [ clickEvent ] as const ;
74
112
const sharpOptions = [
@@ -82,7 +120,10 @@ const sideOptions = [
82
120
] as const ;
83
121
84
122
const childrenMap = {
85
- style : styleControl ( AvatarStyle ) ,
123
+ style : styleControl ( avatarContainerStyle ) ,
124
+ avatarStyle : styleControl ( AvatarStyle ) ,
125
+ labelStyle : styleControl ( avatarLabelStyle ) ,
126
+ captionStyle : styleControl ( avatarLabelStyle ) ,
86
127
icon : withDefault ( IconControl , "/icon:solid/user" ) ,
87
128
iconSize : withDefault ( NumberControl , 40 ) ,
88
129
onEvent : eventHandlerControl ( EventOptions ) ,
@@ -127,7 +168,7 @@ const AvatarView = (props: RecordConstructorToView<typeof childrenMap>) => {
127
168
disabled = { ! props . enableDropdownMenu }
128
169
dropdownRender = { ( ) => menu }
129
170
>
130
- < Wrapper iconSize = { props . iconSize } labelPosition = { props . labelPosition } >
171
+ < Wrapper iconSize = { props . iconSize } labelPosition = { props . labelPosition } $style = { props . style } >
131
172
< Badge
132
173
count = { props . badgeCount . value }
133
174
dot = { props . badgeType === 'dot' }
@@ -140,7 +181,7 @@ const AvatarView = (props: RecordConstructorToView<typeof childrenMap>) => {
140
181
size = { iconSize }
141
182
icon = { title . value !== '' ? null : props . icon }
142
183
shape = { shape }
143
- $style = { props . style }
184
+ $style = { props . avatarStyle }
144
185
src = { src . value }
145
186
// $cursorPointer={eventsCount > 0}
146
187
onClick = { ( ) => props . onEvent ( "click" ) }
@@ -149,8 +190,8 @@ const AvatarView = (props: RecordConstructorToView<typeof childrenMap>) => {
149
190
</ AvatarWrapper >
150
191
</ Badge >
151
192
< LabelWrapper iconSize = { props . iconSize } alignmentPosition = { props . alignmentPosition } >
152
- < LabelSpan color = { props . style . label } > { props . avatarLabel . value } </ LabelSpan >
153
- < CaptionSpan color = { props . style . caption } > { props . avatarCatption . value } </ CaptionSpan >
193
+ < LabelSpan $style = { props . labelStyle } > { props . avatarLabel . value } </ LabelSpan >
194
+ < CaptionSpan $style = { props . captionStyle } > { props . avatarCatption . value } </ CaptionSpan >
154
195
</ LabelWrapper >
155
196
</ Wrapper >
156
197
</ Dropdown >
@@ -220,6 +261,15 @@ let AvatarBasicComp = (function () {
220
261
< Section name = { sectionNames . style } >
221
262
{ children . style . getPropertyView ( ) }
222
263
</ Section >
264
+ < Section name = { sectionNames . avatarStyle } >
265
+ { children . avatarStyle . getPropertyView ( ) }
266
+ </ Section >
267
+ < Section name = { sectionNames . labelStyle } >
268
+ { children . labelStyle . getPropertyView ( ) }
269
+ </ Section >
270
+ < Section name = { sectionNames . captionStyle } >
271
+ { children . captionStyle . getPropertyView ( ) }
272
+ </ Section >
223
273
</ >
224
274
) )
225
275
. build ( ) ;
0 commit comments