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

Commit 7a666f0

Browse files
authored
feat(layout): simple layout mainly for digest (#1297)
* refactor: rm the expand desc staff * refactor(layout): basic simple layout UI * refactor(simple-layout): add route tab function * refactor(layout): rm the holy grail layout
1 parent c9072e7 commit 7a666f0

File tree

74 files changed

+477
-946
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+477
-946
lines changed

src/containers/content/CommunityContent/HolyGrailLayout.tsx

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/containers/content/CommunityContent/index.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
*/
44

55
import { FC, Fragment } from 'react'
6-
import { isMobile } from 'react-device-detect'
76

8-
import { C11N } from '@/constant'
97
import { bond } from '@/utils/mobx'
108

119
import ClassicLayout from './ClassicLayout'
12-
import HolyGrailLayout from './HolyGrailLayout'
1310

1411
import type { TStore } from './store'
1512
import { useInit } from './logic'
@@ -21,20 +18,11 @@ type TProps = {
2118
const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
2219
useInit(store)
2320

24-
const { curThread, curCommunity, c11n, subscribedCommunitiesData } = store
25-
const isClassicLayout = isMobile || c11n.bannerLayout === C11N.CLASSIC
21+
const { curThread } = store
2622

2723
return (
2824
<Fragment>
29-
{isClassicLayout ? (
30-
<ClassicLayout thread={curThread} />
31-
) : (
32-
<HolyGrailLayout
33-
thread={curThread}
34-
community={curCommunity}
35-
subscribedCommunities={subscribedCommunitiesData}
36-
/>
37-
)}
25+
<ClassicLayout thread={curThread} />
3826
</Fragment>
3927
)
4028
}

src/containers/content/CommunityContent/styles/holy_grail_layout.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/containers/digest/CommunityDigest/ClassicLayout/CommunityBrief.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import type { TCommunity } from '@/spec'
55
import { ICON_CMD } from '@/config'
66
import { HCN, NON_FILL_COMMUNITY } from '@/constant'
77

8-
// import ExpandTexts from '../ExpandTexts'
9-
// import SocialList from '../SocialList'
10-
118
import CommunityJoinSign from '@/widgets/CommunityJoinSign'
129

1310
import {
@@ -26,12 +23,11 @@ const CommunityLogoHolder = `${ICON_CMD}/community_logo_holder.svg`
2623

2724
type TProps = {
2825
community: TCommunity
29-
descExpand: boolean
3026
}
3127

32-
const CommunityBrief: FC<TProps> = ({ community, descExpand }) => {
28+
const CommunityBrief: FC<TProps> = ({ community }) => {
3329
return (
34-
<Wrapper descExpand={descExpand}>
30+
<Wrapper>
3531
<LogoWrapper>
3632
{community.logo ? (
3733
<Logo
@@ -45,7 +41,7 @@ const CommunityBrief: FC<TProps> = ({ community, descExpand }) => {
4541
</LogoWrapper>
4642
<CommunityInfo>
4743
<TitleWrapper>
48-
<Title descExpand={descExpand}>
44+
<Title>
4945
<TitleText>{community.title}</TitleText>
5046
{community.raw !== HCN && (
5147
<CommunityJoinSign
@@ -56,9 +52,6 @@ const CommunityBrief: FC<TProps> = ({ community, descExpand }) => {
5652
)}
5753
</Title>
5854
</TitleWrapper>
59-
{/* <Desc>{community.desc}</Desc> */}
60-
{/* <ExpandTexts descExpand={descExpand} desc={community.desc} /> */}
61-
{/* {community.raw !== HCN && <SocialList />} */}
6255
</CommunityInfo>
6356
</Wrapper>
6457
)

src/containers/digest/CommunityDigest/ClassicLayout/index.tsx

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { FC, memo } from 'react'
22
import { isMobile } from 'react-device-detect'
33

4-
import type { TC11NLayout, TThread, TCommunity, TMetric } from '@/spec'
4+
import type { TThread, TCommunity, TMetric } from '@/spec'
55
import { EVENT } from '@/constant'
66
import { send } from '@/utils/helper'
77

88
import TabBar from '@/widgets/TabBar'
99
import ViewportTracker from '@/widgets/ViewportTracker'
10-
// import CommunityStatesPad from '@/widgets/CommunityStatesPad'
1110

1211
import CommunityBrief from './CommunityBrief'
1312
import AccountUnit from './AccountUnit'
@@ -27,53 +26,24 @@ import { setViewport } from '../logic'
2726

2827
type TProps = {
2928
community: TCommunity
30-
realtimeVisitors: number
31-
descExpand: boolean
3229
activeThread: TThread
33-
layout: TC11NLayout
3430
metric: TMetric
3531
}
3632

37-
const ClassicLayout: FC<TProps> = ({
38-
community,
39-
realtimeVisitors,
40-
descExpand,
41-
activeThread,
42-
layout,
43-
metric,
44-
}) => {
33+
const ClassicLayout: FC<TProps> = ({ community, activeThread, metric }) => {
4534
return (
46-
<Wrapper
47-
testid="community-digest"
48-
descExpand={descExpand}
49-
// noSocial={contains(community.raw, NON_STANDARD_COMMUNITIES)}
50-
noSocial
51-
isMobile={isMobile}
52-
>
53-
<InnerWrapper
54-
metric={metric}
55-
descExpand={descExpand}
56-
// noSocial={contains(community.raw, NON_STANDARD_COMMUNITIES)}
57-
noSocial
58-
isMobile={isMobile}
59-
>
60-
<BannerContentWrapper descExpand={descExpand}>
35+
<Wrapper testid="community-digest" isMobile={isMobile}>
36+
<InnerWrapper metric={metric} isMobile={isMobile}>
37+
<BannerContentWrapper>
6138
<CommunityBaseInfo>
62-
<CommunityBrief community={community} descExpand={descExpand} />
39+
<CommunityBrief community={community} />
6340
<AccountUnit />
64-
{/* <CommunityStatesPad
65-
community={community}
66-
onShowEditorList={onShowEditorList}
67-
onShowSubscriberList={onShowSubscriberList}
68-
realtimeVisitors={realtimeVisitors}
69-
/> */}
7041
</CommunityBaseInfo>
7142
<TabBarWrapper>
7243
<TabBar
7344
source={community.threads}
7445
onChange={(data) => send(EVENT.COMMUNITY_THREAD_CHANGE, { data })}
7546
active={activeThread}
76-
layout={layout}
7747
communityRaw={community.raw}
7848
/>
7949
</TabBarWrapper>

src/containers/digest/CommunityDigest/ExpandTexts.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { FC, memo } from 'react'
2+
3+
import {
4+
Wrapper,
5+
Avatar,
6+
NotifyIcon,
7+
SubscribeButton,
8+
SubText,
9+
// SearchIcon,
10+
} from '../styles/simple_layout/account_unit'
11+
import { mockUsers } from '@/utils/mock'
12+
// import { onShowEditorList, onShowSubscriberList, setViewport } from '../logic'
13+
14+
const AccountUnit: FC = () => {
15+
// return <Wrapper>登入 / 注册</Wrapper>
16+
return (
17+
<Wrapper>
18+
<SubscribeButton type="primary" ghost size="small">
19+
<SubText>订阅</SubText>
20+
</SubscribeButton>
21+
22+
<NotifyIcon />
23+
<Avatar src={`${mockUsers(1)[0].avatar}`} />
24+
</Wrapper>
25+
)
26+
}
27+
28+
export default memo(AccountUnit)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { FC, memo } from 'react'
2+
import { contains } from 'ramda'
3+
4+
import type { TCommunity } from '@/spec'
5+
import { ICON_CMD } from '@/config'
6+
import { HCN, NON_FILL_COMMUNITY } from '@/constant'
7+
8+
import CommunityJoinSign from '@/widgets/CommunityJoinSign'
9+
10+
import {
11+
Wrapper,
12+
Logo,
13+
LogoWrapper,
14+
CommunityInfo,
15+
TitleWrapper,
16+
Title,
17+
TitleText,
18+
LogoHolder,
19+
} from '../styles/simple_layout/community_brief'
20+
import { subscribeCommunity, unsubscribeCommunity } from '../logic'
21+
22+
const CommunityLogoHolder = `${ICON_CMD}/community_logo_holder.svg`
23+
24+
type TProps = {
25+
community: TCommunity
26+
}
27+
28+
const CommunityBrief: FC<TProps> = ({ community }) => {
29+
return (
30+
<Wrapper>
31+
<LogoWrapper>
32+
{community.logo ? (
33+
<Logo
34+
noFill={contains(community.raw, NON_FILL_COMMUNITY)}
35+
src={community.logo}
36+
raw={community.raw}
37+
/>
38+
) : (
39+
<LogoHolder src={CommunityLogoHolder} />
40+
)}
41+
</LogoWrapper>
42+
<CommunityInfo>
43+
<TitleWrapper>
44+
<Title>
45+
<TitleText>{community.title}</TitleText>
46+
{community.raw !== HCN && (
47+
<CommunityJoinSign
48+
onFollow={() => subscribeCommunity(community.id)}
49+
onUndoFollow={() => unsubscribeCommunity(community.id)}
50+
hasFollowed={community.viewerHasSubscribed}
51+
/>
52+
)}
53+
</Title>
54+
</TitleWrapper>
55+
</CommunityInfo>
56+
</Wrapper>
57+
)
58+
}
59+
60+
export default memo(CommunityBrief)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { FC, memo } from 'react'
2+
3+
import type { TCommunityThread, TThread } from '@/spec'
4+
import { Wrapper, Title } from '../styles/simple_layout/thread_tab'
5+
6+
type TProps = {
7+
threads: TCommunityThread[]
8+
active: string
9+
onChange: (thread: TThread) => void
10+
}
11+
12+
const ThreadTab: FC<TProps> = ({ active, threads, onChange }) => {
13+
return (
14+
<Wrapper>
15+
{threads.map((item) => (
16+
<Title
17+
key={item.raw}
18+
$active={active === item.raw}
19+
onClick={() => onChange(item.raw)}
20+
>
21+
{item.title}
22+
</Title>
23+
))}
24+
</Wrapper>
25+
)
26+
}
27+
28+
export default memo(ThreadTab)

0 commit comments

Comments
 (0)