Skip to content

Commit a5c6843

Browse files
author
FalkWolsky
committed
Update for Better User Profile Display
1 parent e0890db commit a5c6843

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ server/api-service/lowcoder-server/src/main/resources/application-lowcoder.yml
1414
server/api-service/lowcoder-server/src/main/resources/application-debug.yaml
1515
.vscode/settings.json
1616
.vscode/launch.json
17+
server/api-service/lowcoder-server/src/main/resources/application-dev-localhost.yaml

client/packages/lowcoder/src/pages/ApplicationV2/UserProfileLayout.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,19 @@ const StyleProfileContent = styled.div`
130130
}
131131
`;
132132

133-
const StyleAvatar = styled(Avatar)`
134-
position: relative;
135-
border: 3px solid #eee;
133+
const StyleAvatar = styled(Avatar)`
134+
position: relative;
135+
border: 3px solid #eee;
136+
color: #fff;
137+
display: flex;
138+
align-items: center;
139+
justify-content: center;
140+
font-weight: bold;
141+
background-color: #0093E9;
142+
background-image: linear-gradient(160deg, #0093E9 0%, #80D0C7 100%);
143+
.ant-avatar-string {
144+
font-size: 2em;
145+
}
136146
`;
137147

138148
const TextMuted = styled.div`
@@ -151,6 +161,11 @@ export interface UserProfileLayoutProps {
151161
breadcrumb?: UserProfileBreadcrumbType[];
152162
}
153163

164+
const getInitials = (name: string) => {
165+
const initials = name.split(' ').map(word => word[0]).join('');
166+
return initials.toUpperCase();
167+
};
168+
154169
export function UserProfileLayout(props: UserProfileLayoutProps) {
155170

156171
const { breadcrumb = []} = props;
@@ -233,7 +248,13 @@ export function UserProfileLayout(props: UserProfileLayoutProps) {
233248
<StyleProfileContent>
234249
<Row gutter={[24, 24]} style={{ display: 'flex', alignItems: 'end' }}>
235250
<Col lg={4}>
236-
<StyleAvatar src={<img src={user.avatarUrl ? fullAvatarUrl(user.avatarUrl) : `https://eu.ui-avatars.com/api/?name=${user.username}&size=250`} alt="avatar" />} shape="square" size={120} />
251+
{user.avatarUrl ? (
252+
<StyleAvatar src={fullAvatarUrl(user.avatarUrl)} shape="square" size={120} />
253+
) : (
254+
<StyleAvatar shape="square" size={120}>
255+
{getInitials(user.username)}
256+
</StyleAvatar>
257+
)}
237258
</Col>
238259
<Col lg={20}>
239260
<Space style={{paddingLeft : "80px"}}>

client/packages/lowcoder/src/pages/common/profileImage.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export const ImgWrapper = styled.div<{
1616
border: 1px solid rgba(0, 0, 0, 0.1);
1717
justify-content: center;
1818
cursor: default;
19-
background-color: ${(props) => props.$backgroundColor};
19+
background-color: #0093E9;
20+
background-image: linear-gradient(160deg, #0093E9 0%, #80D0C7 100%);
2021
2122
& span {
2223
color: #ffffff;
@@ -52,13 +53,13 @@ export default function ProfileImage(props: {
5253
const [hasErrorLoadingImage, setHasErrorLoadingImage] = useState(false);
5354
const sourceUrl = fullAvatarUrl(props.source);
5455
const shouldRenderImage = (sourceUrl || props.svg) && !hasErrorLoadingImage;
55-
const backgroundColor = shouldRenderImage ? "transparent" : initialsAndColorCode[1];
56+
// const backgroundColor = shouldRenderImage ? "transparent" : initialsAndColorCode[1];
5657

5758
return (
5859
<ImgWrapper
5960
$fontSize={props.fontSize}
6061
style={props.style}
61-
$backgroundColor={backgroundColor}
62+
// $backgroundColor={backgroundColor}
6263
className={props.className}
6364
$side={props.side}
6465
title={props.userName}

client/packages/lowcoder/src/pages/setting/permission/styledComponents.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import ReactJson from "react-json-view";
2222
import { StyledLink } from "pages/common/styledComponent";
2323
import _ from "lodash";
2424
import { Avatar, Card, List } from "antd";
25+
import { fullAvatarUrl } from "util/urlUtils";
2526

2627
export const StyledTable = styled(AntdTable)`
2728
.ant-table-cell {
@@ -435,9 +436,9 @@ export function UserDetailPopup(props: { userId: string; title: string }) {
435436
style={{ width: "90%", borderRadius: 8, margin: "0 auto" }}
436437
cover={
437438
<div style={{ display: 'flex', justifyContent: 'center', padding: 20 }}>
438-
<Avatar
439+
<Avatar
439440
size={100}
440-
src={userInfo.avatarUrl || ''}
441+
src={userInfo.avatarUrl ? fullAvatarUrl(userInfo.avatarUrl) : ''}
441442
alt={userInfo.name || ''}
442443
/>
443444
</div>

0 commit comments

Comments
 (0)