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

Commit e91e271

Browse files
committed
refactor(header): add highlighter for non 'home' routes
1 parent 5aa9d1a commit e91e271

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

components/Navigator/BriefView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import MainEntries from './MainEntries'
2121

2222
const CommunityLogoHolder = `${ICON_CMD}/community_logo_holder.svg`
2323

24-
const BriefView = ({ community }) => (
24+
const BriefView = ({ community, curRoute }) => (
2525
<Wrapper>
2626
<Popover
2727
placement="bottomLeft"
@@ -44,7 +44,7 @@ const BriefView = ({ community }) => (
4444
</Popover>
4545
<Breadcrumbs>
4646
<BetaLogo src={`${ICON_CMD}/beta.svg`} />
47-
<MainEntries />
47+
<MainEntries curRoute={curRoute} />
4848
</Breadcrumbs>
4949
</Wrapper>
5050
)

components/Navigator/DigestView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414

1515
import MainEntries from './MainEntries'
1616

17-
const DigestView = () => (
17+
const DigestView = ({ curRoute }) => (
1818
<Breadcrumbs>
1919
<Logo />
2020
<Popover
@@ -31,7 +31,7 @@ const DigestView = () => (
3131
<LogoText href="/home/posts">coderplanets</LogoText>
3232
</Popover>
3333
<BetaLogo src={`${ICON_CMD}/beta.svg`} />
34-
<MainEntries />
34+
<MainEntries curRoute={curRoute} />
3535
</Breadcrumbs>
3636
)
3737

components/Navigator/MainEntries.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import DiscussLinker from '@components/DiscussLinker'
88
import { Wrapper, DotDivider, SiteLink } from './styles/main_entries'
99

1010
const splitMargin = '8px'
11-
const MainEntries = () => (
11+
12+
const MainEntries = ({ curRoute: { mainPath } }) => (
1213
<Wrapper>
1314
<Link href="/home/posts" prefetch passHref>
1415
<SiteLink>首页</SiteLink>
1516
</Link>
1617
<DotDivider space={splitMargin} />
1718
<Link href="/communities" prefetch passHref>
18-
<SiteLink>社区</SiteLink>
19+
<SiteLink active={mainPath === 'communities'}>社区</SiteLink>
1920
</Link>
2021
<DotDivider space={splitMargin} />
2122
<Popover

components/Navigator/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ const Navigator = ({ curCommunity, layout, curRoute }) => {
2424
R.contains(mainPath, [ROUTE.USER, ROUTE.COMMUNITIES]) ||
2525
R.contains(subPath, [ROUTE.POST, ROUTE.JOB, ROUTE.VIDEO, ROUTE.REPO])
2626
) {
27-
return <DigestView />
27+
return <DigestView curRoute={curRoute} />
2828
}
2929

3030
return (
3131
<React.Fragment>
3232
{layout === C11N.DIGEST ? (
33-
<DigestView />
33+
<DigestView curRoute={curRoute} />
3434
) : (
35-
<BriefView community={curCommunity} />
35+
<BriefView community={curCommunity} curRoute={curRoute} />
3636
)}
3737
</React.Fragment>
3838
)

components/Navigator/styles/main_entries.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ export const DotDivider = styled(DotDividerBase)`
1515
`
1616
export const SiteLink = styled.a`
1717
color: ${theme('banner.desc')};
18+
background: ${({ active }) =>
19+
active ? theme('banner.numberHoverBg') : 'transparent'};
20+
padding: ${({ active }) => (active ? '5px 3px 3px 3px' : '0')};
21+
border-bottom: ${({ active }) => (active ? '2px solid' : 'none')};
22+
border-bottom-color: ${({ active }) =>
23+
active ? theme('tabs.headerActive') : ''};
24+
1825
cursor: pointer;
1926
&:hover {
2027
text-decoration: underline;

containers/Header/styles/header.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export const InnerWrapper = styled.div`
2929
export const RouterWrapper = styled.div`
3030
${cs.flexGrow('align-center')};
3131
height: 100%;
32-
margin-top: 1px;
3332
`
3433
export const HeaderSearchIcon = styled(HeaderSearchSVG).attrs(props => ({
3534
'data-testid': props.testid,

0 commit comments

Comments
 (0)