Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit ea97947

Browse files
authored
feat(about-thread): admin style avatar (#1292)
1 parent 5eb8670 commit ea97947

File tree

5 files changed

+106
-27
lines changed

5 files changed

+106
-27
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { FC, memo } from 'react'
2+
3+
import type { TUser } from '@/spec'
4+
5+
import {
6+
Wrapper,
7+
AvatarWrapper,
8+
Avatar,
9+
BadgeWrapper,
10+
BadgeIcon,
11+
Info,
12+
Name,
13+
Bio,
14+
} from '../styles/members/admin_member'
15+
16+
type TProps = {
17+
user: TUser
18+
}
19+
20+
const AdminMember: FC<TProps> = ({ user }) => {
21+
return (
22+
<Wrapper>
23+
<AvatarWrapper>
24+
<Avatar src={user.avatar} />
25+
<BadgeWrapper>
26+
<BadgeIcon />
27+
</BadgeWrapper>
28+
</AvatarWrapper>
29+
<Info>
30+
<Name>{user.nickname}</Name>
31+
<Bio>{user.bio}</Bio>
32+
</Info>
33+
</Wrapper>
34+
)
35+
}
36+
37+
export default memo(AdminMember)

src/containers/thread/AboutThread/Members.tsx renamed to src/containers/thread/AboutThread/Members/index.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FC, memo } from 'react'
22

33
import { mockUsers } from '@/utils/mock'
4+
import AdminMember from './AdminMember'
45

56
import {
67
Wrapper,
@@ -10,12 +11,8 @@ import {
1011
Title,
1112
Row,
1213
Admin,
13-
AdminInfo,
14-
Name,
15-
Bio,
16-
AdminAvatar,
1714
NormalAvatar,
18-
} from './styles/members'
15+
} from '../styles/members'
1916

2017
const Members: FC = () => {
2118
return (
@@ -24,15 +21,10 @@ const Members: FC = () => {
2421
<Header>
2522
<Title>团队成员</Title>
2623
</Header>
27-
2824
<Row>
2925
{mockUsers(6).map((user) => (
3026
<Admin key={user.id}>
31-
<AdminAvatar src={user.avatar} />
32-
<AdminInfo>
33-
<Name>{user.nickname}</Name>
34-
<Bio>{user.bio}</Bio>
35-
</AdminInfo>
27+
<AdminMember user={user} />
3628
</Admin>
3729
))}
3830
</Row>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import styled from 'styled-components'
2+
3+
import css, { theme } from '@/utils/css'
4+
import Img from '@/Img'
5+
import AdminStarSVG from '@/icons/AdminStar'
6+
7+
export const Wrapper = styled.div`
8+
${css.flex('align-start')};
9+
`
10+
export const AvatarWrapper = styled.div`
11+
position: relative;
12+
`
13+
export const Avatar = styled(Img)`
14+
${css.circle(46)};
15+
margin-right: 10px;
16+
margin-bottom: 20px;
17+
border: 2px solid;
18+
border-color: ${theme('thread.articleTitle')};
19+
padding: 2px;
20+
`
21+
export const BadgeWrapper = styled.div`
22+
${css.circle(14)};
23+
${css.flex('align-both')};
24+
background: ${theme('thread.articleTitle')};
25+
padding: 1px;
26+
border: 2px solid white;
27+
position: absolute;
28+
right: 10px;
29+
bottom: 18px;
30+
z-index: 2;
31+
`
32+
export const Info = styled.div``
33+
export const Name = styled.div`
34+
color: ${theme('thread.articleTitle')};
35+
font-size: 14px;
36+
`
37+
export const Bio = styled.div`
38+
color: ${theme('thread.articleDigest')};
39+
font-size: 12px;
40+
${css.cutRest('100px')};
41+
`
42+
export const BadgeIcon = styled(AdminStarSVG)`
43+
${css.size(10)};
44+
fill: white;
45+
`

src/containers/thread/AboutThread/styles/members.ts renamed to src/containers/thread/AboutThread/styles/members/index.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import styled from 'styled-components'
22

33
import type { TTestable } from '@/spec'
44
import css, { theme } from '@/utils/css'
5-
import Img from '@/Img'
5+
6+
import { Avatar as AdminAvatar } from './admin_member'
67

78
export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({
89
'data-test-id': testid,
@@ -59,22 +60,8 @@ export const Admin = styled.div`
5960
${css.flex('align-start')};
6061
width: 33%;
6162
`
62-
export const AdminInfo = styled.div``
63-
export const Name = styled.div`
64-
color: ${theme('thread.articleTitle')};
65-
font-size: 14px;
66-
`
67-
export const Bio = styled.div`
68-
color: ${theme('thread.articleDigest')};
69-
font-size: 12px;
70-
${css.cutRest('100px')};
71-
`
72-
export const AdminAvatar = styled(Img)`
73-
${css.circle(46)};
74-
margin-right: 10px;
75-
margin-bottom: 20px;
76-
`
7763
export const NormalAvatar = styled(AdminAvatar)`
7864
${css.circle(30)};
7965
margin-bottom: 10px;
66+
border: none;
8067
`

src/widgets/Icons/AdminStar.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { memo, SVGProps } from 'react'
2+
3+
const AdminStar = (props: SVGProps<SVGSVGElement>) => {
4+
return (
5+
<svg
6+
className="icon"
7+
viewBox="0 0 1024 1024"
8+
xmlns="http://www.w3.org/2000/svg"
9+
width={200}
10+
height={200}
11+
{...props}
12+
>
13+
<path d="m908.1 353.1-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z" />
14+
</svg>
15+
)
16+
}
17+
18+
export default memo(AdminStar)

0 commit comments

Comments
 (0)