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

Commit 8e9be8e

Browse files
committed
chore: Merge branch 'header/router' into dev
2 parents 5aa9d1a + 72f0e04 commit 8e9be8e

File tree

10 files changed

+60
-26
lines changed

10 files changed

+60
-26
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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ 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>
14-
<SiteLink>首页</SiteLink>
15+
<SiteLink testid="header-home-link">首页</SiteLink>
1516
</Link>
1617
<DotDivider space={splitMargin} />
1718
<Link href="/communities" prefetch passHref>
18-
<SiteLink>社区</SiteLink>
19+
<SiteLink
20+
active={mainPath === 'communities'}
21+
testid="header-communities-link"
22+
>
23+
社区
24+
</SiteLink>
1925
</Link>
2026
<DotDivider space={splitMargin} />
2127
<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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ export const Wrapper = styled.div`
1313
export const DotDivider = styled(DotDividerBase)`
1414
background-color: ${theme('banner.desc')};
1515
`
16-
export const SiteLink = styled.a`
16+
export const SiteLink = styled.a.attrs(props => ({
17+
'data-testid': props.testid,
18+
}))`
1719
color: ${theme('banner.desc')};
20+
background: ${({ active }) =>
21+
active ? theme('banner.numberHoverBg') : 'transparent'};
22+
padding: ${({ active }) => (active ? '5px 3px 3px 3px' : '0')};
23+
border-bottom: ${({ active }) => (active ? '2px solid' : 'none')};
24+
border-bottom-color: ${({ active }) =>
25+
active ? theme('tabs.headerActive') : ''};
26+
1827
cursor: pointer;
1928
&:hover {
2029
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,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
describe('communities page layout', () => {
3+
// beforeEach(() => {
4+
before(() => {
5+
cy.visit('/communities')
6+
})
7+
8+
it('basic layout', () => {
9+
cy.id('header').should('be.visible')
10+
11+
cy.id('header-search').should('be.visible')
12+
cy.id('header-search-icon').should('be.visible')
13+
14+
cy.id('sidebar').should('be.visible')
15+
16+
cy.id('communities-banner').should('be.visible')
17+
cy.id('footer').should('be.visible')
18+
})
19+
20+
it('communities link should be highlight', () => {
21+
cy.id('header-communities-link')
22+
.should('not.have.css', 'background', 'transparent')
23+
.and('have.css', 'padding', '5px 3px 3px')
24+
})
25+
})
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
describe('basic layout', () => {
1+
describe('home page layout', () => {
22
// beforeEach(() => {
33
before(() => {
44
cy.visit('/home/posts')
55
})
66

77
it('basic layout shoud be visible', () => {
88
cy.id('header').should('be.visible')
9+
cy.id('header-search').should('be.visible')
10+
cy.id('header-search-icon').should('be.visible')
11+
912
cy.id('sidebar').should('be.visible')
1013

1114
cy.id('community-banner').should('be.visible')
@@ -14,18 +17,10 @@ describe('basic layout', () => {
1417
cy.id('footer').should('be.visible')
1518
})
1619

17-
it('header content', () => {
18-
cy.id('header-search').should('be.visible')
19-
cy.id('header-search-icon').should('be.visible')
20-
})
21-
22-
it('communities page', () => {
23-
cy.visit('/communities')
24-
cy.id('header-search').should('be.visible')
25-
cy.id('header-search-icon').should('be.visible')
26-
27-
cy.id('communities-banner').should('be.visible')
28-
29-
cy.id('footer').should('be.visible')
20+
it('home link should not be highlight', () => {
21+
cy.id('header-home-link')
22+
// .should('have.css', 'background')
23+
// .should('not.have.css', 'border-bottom')
24+
.and('not.have.css', 'padding', '5px 3px 3px 3px')
3025
})
3126
})

0 commit comments

Comments
 (0)