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

Commit 19b93c3

Browse files
authored
style(avatar): Inset shadow for advatar (#997)
* style(avatar): add inner shadow, closes #996 * refactor(theme): re-org avatar scope
1 parent e234b93 commit 19b93c3

File tree

27 files changed

+165
-42
lines changed

27 files changed

+165
-42
lines changed

src/components/ImgFallback/Avatar.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const Avatar = ({
2323
right,
2424
top,
2525
bottom,
26+
quote,
2627
}) => {
2728
const name = user?.nickname
2829
const sliceCount = size > 32 ? 2 : 1
@@ -36,6 +37,7 @@ const Avatar = ({
3637
right={right}
3738
top={top}
3839
bottom={bottom}
40+
quote={quote}
3941
>
4042
<Name size={size}>{name.slice(0, sliceCount)}</Name>
4143
</Wrapper>
@@ -53,6 +55,7 @@ Avatar.propTypes = {
5355
right: T.number,
5456
top: T.number,
5557
bottom: T.number,
58+
quote: T.bool,
5659
}
5760

5861
Avatar.defaultProps = {
@@ -66,6 +69,7 @@ Avatar.defaultProps = {
6669
right: 0,
6770
top: 0,
6871
bottom: 0,
72+
quote: false,
6973
}
7074

7175
export default React.memo(Avatar)

src/components/ImgFallback/styles/avatar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ export const Wrapper = styled.div.attrs((props) => ({
1111
color: ${theme('thread.articleTitle')};
1212
width: ${({ size }) => `${size}px`};
1313
height: ${({ size }) => `${size}px`};
14-
background: #074857;
14+
background: ${theme('avatar.fallbackBg')};
1515
border-radius: 100%;
1616
1717
margin-top: ${({ top }) => `${top}px`};
1818
margin-bottom: ${({ bottom }) => `${bottom}px`};
1919
margin-left: ${({ left }) => `${left}px`};
2020
margin-right: ${({ right }) => `${right}px`};
21+
22+
border: ${({ quote }) => (quote ? '2px solid' : 'none')};
23+
border-color: ${({ quote }) => (quote ? theme('avatar.quote') : 'none')};
2124
`
2225
export const Name = styled.div`
2326
font-family: 'Audiowide', cursive;

src/components/ImgFallback/styles/metric/avatar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const getFontSize = (size) => {
66
return '14px'
77
}
88

9-
if (size >= 38 && size < 50) {
9+
if (size >= 36 && size < 50) {
1010
return '14px' // two letters
1111
}
1212

src/components/JobItem/styles/list_view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const TagsWrapper = styled.div`
2727
export const CompanyLogo = styled(Img)`
2828
${css.size(45)};
2929
border-radius: 5px;
30-
opacity: ${theme('avatarOpacity')};
30+
opacity: ${theme('avatar.opacity')};
3131
`
3232
export const Brief = styled.div`
3333
${css.flex('align-center')};

src/components/PostItem/styles/digest_view/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const AvatarWrapper = styled.div`
1313
export const Avatar = styled(Img)`
1414
${css.circle(36)};
1515
fill: ${theme('thread.articleTitle')};
16-
opacity: ${theme('avatarOpacity')};
16+
opacity: ${theme('avatar.opacity')};
1717
margin-top: 2px;
1818
`
1919
export const SmallAvatar = styled(Avatar)`

src/components/PostItem/styles/list_view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const AvatarWrapper = styled.div`
2121
export const Avatar = styled(Img)`
2222
${css.circle(36)};
2323
fill: ${theme('thread.articleTitle')};
24-
opacity: ${theme('avatarOpacity')};
24+
opacity: ${theme('avatar.opacity')};
2525
margin-top: 2px;
2626
2727
${css.media.mobile`${css.circle(34)}`};

src/components/PostItem/styles/mobile_view/header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const AvatarWrapper = styled.div`
1717
export const Avatar = styled(Img)`
1818
${css.circle(16)};
1919
fill: ${theme('thread.articleTitle')};
20-
opacity: ${theme('avatarOpacity')};
20+
opacity: ${theme('avatar.opacity')};
2121
margin-right: 8px;
2222
`
2323
export const AuthorInfo = styled.div`

src/components/TheAvatar/PostItemAvatar.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,29 @@ import React from 'react'
22

33
// import { ICON } from '@/config'
44
import ImgFallback from '@/components/ImgFallback'
5-
import { Wrapper, Avatar, QuoteAvatar } from './styles/post_item_avatar'
5+
import {
6+
Wrapper,
7+
InnerShadow,
8+
QuoteShadow,
9+
Avatar,
10+
QuoteAvatar,
11+
} from './styles/post_item_avatar'
612

713
const PostItemAvatar = ({ user, onSelect }) => {
814
return (
915
<Wrapper onClick={() => onSelect(user)}>
1016
{user.login === 'mydearxym' ? (
1117
<QuoteAvatar
1218
src={user.avatar}
13-
fallback={<ImgFallback user={user} size={38} top={2} />}
19+
fallback={<ImgFallback user={user} size={36} top={2} quote />}
1420
/>
1521
) : (
1622
<Avatar
1723
src={user.avatar}
18-
fallback={<ImgFallback user={user} size={38} top={2} />}
24+
fallback={<ImgFallback user={user} size={38} top={-1} left={-1} />}
1925
/>
2026
)}
27+
{user.login === 'mydearxym' ? <QuoteShadow /> : <InnerShadow />}
2128
{/* <Tail src={`${ICON}/shape/tail.svg`} /> */}
2229
</Wrapper>
2330
)

src/components/TheAvatar/styles/article_author_avatar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const Wrapper = styled.div.attrs((props) => ({
1515
export const Avatar = styled(Img)`
1616
${css.circle(36)};
1717
fill: ${theme('thread.articleTitle')};
18-
opacity: ${theme('avatarOpacity')};
18+
opacity: ${theme('avatar.opacity')};
1919
`
2020
export const Tail = styled(TailBase)`
2121
${Wrapper}:hover & {

src/components/TheAvatar/styles/post_item_avatar.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,33 @@ export const Wrapper = styled.div.attrs((props) => ({
99
'data-test-id': props.testId,
1010
}))`
1111
cursor: pointer;
12-
/* border: 1px solid tomato; */
13-
${css.size(36)};
12+
${css.circle(38)};
1413
position: relative;
14+
margin-top: 2px;
15+
`
16+
export const InnerShadow = styled.div`
17+
position: absolute;
18+
${css.circle(38)};
19+
top: -1px;
20+
left: -1px;
21+
box-shadow: ${theme('avatar.shadow')};
22+
z-index: 2;
23+
`
24+
export const QuoteShadow = styled(InnerShadow)`
25+
${css.circle(34)};
26+
top: 2px;
27+
left: 2px;
28+
box-shadow: ${theme('avatar.quoteShadow')};
1529
`
1630
export const Avatar = styled(Img)`
1731
${css.circle(36)};
1832
fill: ${theme('thread.articleTitle')};
19-
opacity: ${theme('avatarOpacity')};
20-
margin-top: 2px;
33+
opacity: ${theme('avatar.opacity')};
2134
`
2235
export const QuoteAvatar = styled(Avatar)`
2336
${css.circle(38)};
2437
border: 2px solid;
25-
border-color: #217470;
38+
border-color: ${theme('avatar.quote')};
2639
`
2740
export const Tail = styled(TailBase)`
2841
${Wrapper}:hover & {

0 commit comments

Comments
 (0)