|
|
|
|
|
import * as React from 'react'; |
|
|
import { UserHoverProfile } from 'src/components/hoverProfile'; |
|
|
import { |
|
|
Container, |
|
|
MetaContainer, |
|
|
TextRow, |
|
|
MetaTitle, |
|
|
MetaSubtitle, |
|
|
Divider, |
|
|
MetaSubtitleText, |
|
|
MetaSubtitleLocked, |
|
|
MetaSubtitleWatercooler, |
|
|
MetaSubtitlePinned, |
|
|
} from './style'; |
|
|
import Timestamp from './timestamp'; |
|
|
import type { HeaderProps } from './index'; |
|
|
|
|
|
class Header extends React.Component<HeaderProps> { |
|
|
render() { |
|
|
const { |
|
|
active, |
|
|
viewContext, |
|
|
thread: { community, channel, id, watercooler, isLocked, author }, |
|
|
} = this.props; |
|
|
|
|
|
const isPinned = id === community.pinnedThreadId; |
|
|
|
|
|
return ( |
|
|
<Container active={active}> |
|
|
<MetaContainer> |
|
|
<TextRow> |
|
|
<MetaTitle active={active} to={`/${community.slug}`}> |
|
|
{community.name} |
|
|
</MetaTitle> |
|
|
|
|
|
<Divider>路</Divider> |
|
|
<Timestamp {...this.props} /> |
|
|
</TextRow> |
|
|
|
|
|
<TextRow> |
|
|
{viewContext === 'userProfileReplies' && ( |
|
|
<MetaSubtitleText> |
|
|
{author.user.username ? ( |
|
|
<UserHoverProfile username={author.user.username}> |
|
|
<MetaSubtitle |
|
|
active={active} |
|
|
to={`/users/${author.user.username}`} |
|
|
> |
|
|
By {author.user.name} |
|
|
</MetaSubtitle> |
|
|
</UserHoverProfile> |
|
|
) : ( |
|
|
<MetaSubtitleText active={active}> |
|
|
By {author.user.name} |
|
|
</MetaSubtitleText> |
|
|
)} |
|
|
|
|
|
<Divider>路</Divider> |
|
|
</MetaSubtitleText> |
|
|
)} |
|
|
|
|
|
<MetaSubtitle |
|
|
active={active} |
|
|
to={`/${community.slug}/${channel.slug}`} |
|
|
> |
|
|
# {channel.name} |
|
|
</MetaSubtitle> |
|
|
|
|
|
{watercooler && ( |
|
|
<MetaSubtitleWatercooler active={active}> |
|
|
<Divider>路</Divider> |
|
|
Watercooler |
|
|
</MetaSubtitleWatercooler> |
|
|
)} |
|
|
|
|
|
{isLocked && ( |
|
|
<MetaSubtitleLocked active={active}> |
|
|
<Divider>路</Divider> |
|
|
Locked |
|
|
</MetaSubtitleLocked> |
|
|
)} |
|
|
|
|
|
{isPinned && ( |
|
|
<MetaSubtitlePinned active={active}> |
|
|
<Divider>路</Divider> |
|
|
Pinned |
|
|
</MetaSubtitlePinned> |
|
|
)} |
|
|
</TextRow> |
|
|
</MetaContainer> |
|
|
</Container> |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
export default Header; |
|
|
|