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

Commit c6e5644

Browse files
authored
refactor(home): CommunityRecommends use text instead of logo (#1038)
1 parent 32628ff commit c6e5644

File tree

5 files changed

+87
-76
lines changed

5 files changed

+87
-76
lines changed

src/components/Cards/CommunityCard.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import React from 'react'
66

7+
import type { TCommunity } from '@/spec'
78
import { cutRest } from '@/utils'
89

910
import {
@@ -17,14 +18,7 @@ import {
1718
} from './styles/community_card'
1819

1920
type TProps = {
20-
item: {
21-
id: string
22-
logo: string
23-
title: string
24-
raw: string
25-
desc: string
26-
subscribersCount: number
27-
}
21+
item: TCommunity
2822
}
2923

3024
const CommunityCard: React.FC<TProps> = ({

src/components/PagedContents/CommunityRecommends.js

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import React from 'react'
2+
3+
import type { TCommunity } from '@/spec'
4+
5+
import Tooltip from '@/components/Tooltip'
6+
import CommunityCard from '@/components/Cards/CommunityCard'
7+
8+
import {
9+
Wrapper,
10+
Title,
11+
ListWrapper,
12+
Community,
13+
CommunityTitle,
14+
} from './styles/community_recommends'
15+
16+
const tmpItems = [
17+
{
18+
id: '1',
19+
title: 'elixir',
20+
raw: 'elixir',
21+
logo: 'https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/pl/elixir.png',
22+
desc:
23+
'maybe the most popular UI framework for web, maybe the most popular UI framework for web',
24+
subscribersCount: 100,
25+
},
26+
{
27+
id: '2',
28+
title: 'javascript',
29+
raw: 'javascript',
30+
logo:
31+
'https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/pl/javascript.png',
32+
desc:
33+
'maybe the most popular UI framework for web, maybe the most popular UI framework for web',
34+
subscribersCount: 100,
35+
},
36+
{
37+
id: '3',
38+
title: 'ruby',
39+
raw: 'ruby',
40+
logo: 'https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/pl/ruby.png',
41+
desc:
42+
'maybe the most popular UI framework for web, maybe the most popular UI framework for web',
43+
subscribersCount: 100,
44+
},
45+
{
46+
id: '4',
47+
title: 'clojure',
48+
raw: 'clojure',
49+
logo: 'https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/pl/clojure.png',
50+
desc:
51+
'maybe the most popular UI framework for web, maybe the most popular UI framework for web',
52+
subscribersCount: 100,
53+
},
54+
]
55+
56+
type TProps = {
57+
items?: TCommunity[]
58+
}
59+
60+
const CommunityRecommends: React.FC<TProps> = ({ items = tmpItems }) => {
61+
return (
62+
<Wrapper>
63+
<Title>热门社区</Title>
64+
<ListWrapper>
65+
{items.map((item) => (
66+
<Community key={item.id}>
67+
{/* @ts-ignore */}
68+
<Tooltip content={<CommunityCard item={item} />} placement="top">
69+
<CommunityTitle>{item.title}</CommunityTitle>
70+
</Tooltip>
71+
</Community>
72+
))}
73+
</ListWrapper>
74+
</Wrapper>
75+
)
76+
}
77+
78+
export default React.memo(CommunityRecommends)

src/components/PagedContents/styles/community_recommends.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import styled from 'styled-components'
22

3-
import Img from '@/Img'
43
import { css } from '@/utils'
54

65
export const Wrapper = styled.div`
@@ -13,8 +12,8 @@ export const Wrapper = styled.div`
1312
`
1413
export const Title = styled.div`
1514
font-size: 13px;
16-
margin-bottom: 4px;
17-
opacity: 0;
15+
margin-bottom: 6px;
16+
opacity: 0.8;
1817
1918
&:before {
2019
content: '- ';
@@ -40,7 +39,7 @@ export const ListWrapper = styled.div`
4039
`
4140
export const Community = styled.div`
4241
margin-right: 10px;
43-
opacity: 0.7;
42+
opacity: 0.9;
4443
4544
&:hover {
4645
cursor: pointer;
@@ -56,10 +55,6 @@ export const Community = styled.div`
5655
margin-right: 12px;
5756
`}
5857
`
59-
export const Logo = styled(Img)`
60-
${css.size(18)};
61-
62-
${css.media.mobile`
63-
${css.size(16)};
64-
`}
58+
export const CommunityTitle = styled.span`
59+
font-size: 14px;
6560
`

src/spec/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export type TCommunity = {
5757
title: string
5858
logo?: string
5959
raw: string
60-
color?: string
61-
index?: number
60+
subscribersCount?: number
61+
desc?: string
6262
}
6363

6464
export type TPagedCommunities = {

0 commit comments

Comments
 (0)