Skip to content

Commit

Permalink
fix: TopicItem
Browse files Browse the repository at this point in the history
  • Loading branch information
Deturium committed Nov 22, 2018
1 parent c584078 commit fa02380
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/components/TopicList/TopicList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { css } from 'emotion'

import { List } from '@material-ui/core'

import TopicListItem from './TopicListItem'
import TopicListItem, { Place } from './TopicListItem'

import { ITopic } from '@cc98/api'

Expand All @@ -13,7 +13,7 @@ const list = css`

interface Props {
topics: ITopic[]
place?: 'inboard' | 'newtopic' | 'usercenter' | 'follow' | 'search'
place: Place
}

const TopicList: React.FunctionComponent<Props> = ({ topics, place }) => (
Expand Down
16 changes: 13 additions & 3 deletions src/components/TopicList/TopicListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ const Item = styled(ListItem)`
display: flex;
justify-content: space-between;
align-items: flex-end;
width: 100%;
`

const TitleArea = styled.div`
max-width: 80%;
flex-grow: 1;
`

const InfoArea = styled.div`
Expand All @@ -42,6 +44,7 @@ const SubTitle = styled(Typography)`
const Info = SubTitle

/**
* 布局:
* title info1
* subtitle info2
*/
Expand Down Expand Up @@ -73,9 +76,11 @@ export const TopicItem: React.FunctionComponent<ItemProps> = ({
</Item>
)

export type Place = 'inboard' | 'newtopic' | 'usercenter' | 'follow' | 'search' | 'hot'

interface Props {
data: ITopic
place?: 'inboard' | 'newtopic' | 'usercenter' | 'follow' | 'search'
place: Place
}

export default ({ data, place }: Props) => {
Expand All @@ -98,9 +103,15 @@ export default ({ data, place }: Props) => {
subtitle = boardName
break

case 'hot':
if (!boardName) {
getBoardName()
}
info1 = boardName
break

case 'newtopic':
info1 = dayjs(data.time).fromNow()

case 'follow':
case 'search':
if (!boardName) {
Expand All @@ -110,7 +121,6 @@ export default ({ data, place }: Props) => {
break

// case 'inboard':
// case undefined:
}

return (
Expand Down
6 changes: 3 additions & 3 deletions src/components/TopicList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import useInfList, { Service as InfService } from '@/hooks/useInfList'
import useFetcher, { Service as FinService } from '@/hooks/useFetcher'

import TopicList from './TopicList'
import { Place } from './TopicListItem'

import InfiniteList from '@/components/InfiniteList'
import LoadingCircle from '@/components/LoadingCircle'
Expand All @@ -12,8 +13,7 @@ import { ITopic } from '@cc98/api'

interface InfProps {
service: InfService<ITopic[]>
// TODO: remove
place?: 'inboard' | 'newtopic' | 'usercenter' | 'follow' | 'search'
place: Place
}

const InfTopicList: React.FunctionComponent<InfProps> = ({ service, place }) => {
Expand All @@ -30,7 +30,7 @@ const InfTopicList: React.FunctionComponent<InfProps> = ({ service, place }) =>
interface FinProps {
service: FinService<ITopic[]>
noLoading?: boolean
place?: 'inboard' | 'newtopic' | 'usercenter' | 'follow' | 'search'
place: Place
}

const FinTopicList: React.FunctionComponent<FinProps> = ({ service, noLoading, place }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Board/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default ({ id }: Props) => {

<Tags boardTags={boardTags} onChange={onTagChange} />

<FinTopicList service={() => getTopTopics(id)} place="inboard" />
<FinTopicList service={() => getTopTopics(id)} place="inboard" noLoading />

<InfTopicList
key={`${tagIDs[0]}-${tagIDs[1]}`}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/HotTopic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export default () => {

{current === 'day' && <HotTopicList service={getHotTopics} />}

{current === 'week' && <FinTopicList service={getWeeklyHotTopics} />}
{current === 'month' && <FinTopicList service={getMonthlyHotTopics} />}
{current === 'history' && <FinTopicList service={getHistoryHotTopics} />}
{current === 'week' && <FinTopicList service={getWeeklyHotTopics} place="hot" />}
{current === 'month' && <FinTopicList service={getMonthlyHotTopics} place="hot" />}
{current === 'history' && <FinTopicList service={getHistoryHotTopics} place="hot" />}
</>
)
}
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
* 版本号
*/

export default 'v0.14.11-alpha'
export default 'v0.14.12-alpha'
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"allowJs": false,
"target": "es6",
"jsx": "preserve",
"noEmitOnError": true,
"sourceMap": false,
"baseUrl": "./",
"rootDir": "src",
Expand Down

0 comments on commit fa02380

Please sign in to comment.