Skip to content

Commit

Permalink
Merge pull request #219 from Aylie-Chou/1-feature-header-v2
Browse files Browse the repository at this point in the history
fix(universal-header): fix ui defect
  • Loading branch information
Aylie-Chou authored Oct 8, 2021
2 parents 0f674a0 + a1592da commit 84f2051
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
3 changes: 3 additions & 0 deletions packages/universal-header/src/components/action-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const ActionContainer = styled.div`
transition: opacity 0.1s;
transition-delay: 300ms;
opacity: ${props => (props.isActive ? 1 : 0)};
pointer-events: ${props => (props.isActive ? 'auto' : 'none')};
margin: ${props => arrayToCssShorthand(styles.itemMargin[props.direction])};
width: 100%;
Expand All @@ -84,9 +85,11 @@ const ActionContainer = styled.div`
font-size: ${styles.fontSize.desktop};
font-weight: ${fonts.weight.bold};
${mq.tabletOnly`
cursor: default;
font-size: ${props => styles.fontSize.tablet[props.direction]};
`}
${mq.mobileOnly`
cursor: default;
font-size: ${props => styles.fontSize.mobile[props.direction]};
`}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/universal-header/src/components/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import fonts from '../constants/fonts'
import DropDownMenu from './drop-down-menu'
import Link from './customized-link'
// @twreporter
import mq from '@twreporter/core/lib/utils/media-query'
import { arrayToCssShorthand } from '@twreporter/core/lib/utils/css'
// lodash
import get from 'lodash/get'
Expand Down Expand Up @@ -115,7 +116,6 @@ const ListItem = styled.li`
height: 100%;
font-size: ${fonts.size.base};
letter-spacing: 0.5px;
cursor: pointer;
margin: ${arrayToCssShorthand(styles.itemMargin.desktop)};
flex: 1;
text-shadow: ${props => props.textShadow};
Expand Down Expand Up @@ -149,6 +149,9 @@ const ListItem = styled.li`
background-color: ${props => props.hoverBgColor};
color: ${props => props.hoverFontColor};
}
${mq.tabletAndBelow`
cursor: default;
`}
}
`

Expand Down
47 changes: 23 additions & 24 deletions packages/universal-header/src/components/hamburger-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const IconContainer = styled.div`
margin-right: 17px;
a {
display: flex;
cursor: default;
}
${mq.tabletOnly`
Expand All @@ -55,7 +56,7 @@ const IconsContainer = styled.div`
`

const Login = ({ callback }) => {
const handleLogin = (releaseBranch) => {
const handleLogin = releaseBranch => {
const redirectURL = window.location.href
const query = querystring.stringify({
destination: redirectURL,
Expand All @@ -73,11 +74,11 @@ const Login = ({ callback }) => {
<IconContainer>
<HeaderContext.Consumer>
{({ releaseBranch, theme }) => {
const [LogInIcon] = themeUtils.selectHamburgerServiceIcons(theme).login
const [LogInIcon] = themeUtils.selectHamburgerServiceIcons(
theme
).login
return (
<Link
onClick={e => handleClick(e, releaseBranch)}
>
<Link onClick={e => handleClick(e, releaseBranch)}>
<LogInIcon />
</Link>
)
Expand All @@ -96,7 +97,7 @@ Login.defaultProps = {
}

const Logout = ({ callback }) => {
const handleLogout = (releaseBranch) => {
const handleLogout = releaseBranch => {
const redirectURL = window.location.href
const query = querystring.stringify({
destination: redirectURL,
Expand All @@ -114,11 +115,11 @@ const Logout = ({ callback }) => {
<IconContainer>
<HeaderContext.Consumer>
{({ releaseBranch, theme }) => {
const [LogOutIcon] = themeUtils.selectHamburgerServiceIcons(theme).logout
const [LogOutIcon] = themeUtils.selectHamburgerServiceIcons(
theme
).logout
return (
<Link
onClick={e => handleClick(e, releaseBranch)}
>
<Link onClick={e => handleClick(e, releaseBranch)}>
<LogOutIcon />
</Link>
)
Expand All @@ -141,11 +142,10 @@ const Search = ({ callback }) => {
<IconContainer>
<HeaderContext.Consumer>
{({ releaseBranch, isLinkExternal, theme }) => {
const [SearchIcon] = themeUtils.selectHamburgerServiceIcons(theme).search
const link = linkUtils.getSearchLink(
isLinkExternal,
releaseBranch
)
const [SearchIcon] = themeUtils.selectHamburgerServiceIcons(
theme
).search
const link = linkUtils.getSearchLink(isLinkExternal, releaseBranch)
return (
<Link {...link} onClick={callback}>
<SearchIcon />
Expand All @@ -170,11 +170,10 @@ const Bookmark = ({ callback }) => {
<IconContainer>
<HeaderContext.Consumer>
{({ releaseBranch, isLinkExternal, theme }) => {
const [BookmarkIcon] = themeUtils.selectHamburgerServiceIcons(theme).bookmark
const link = linkUtils.getBookmarksLink(
isLinkExternal,
releaseBranch
)
const [BookmarkIcon] = themeUtils.selectHamburgerServiceIcons(
theme
).bookmark
const link = linkUtils.getBookmarksLink(isLinkExternal, releaseBranch)
return (
<Link {...link} onClick={callback}>
<BookmarkIcon />
Expand All @@ -195,9 +194,9 @@ Bookmark.defaultProps = {
}

const HamburgerService = ({ services, callback }) => {
const _prepareIconJsx = (service) => {
const _prepareIconJsx = service => {
const serviceKey = service.key
switch(serviceKey) {
switch (serviceKey) {
case 'login':
return <Login callback={callback} key={serviceKey} />
case 'logout':
Expand All @@ -207,7 +206,7 @@ const HamburgerService = ({ services, callback }) => {
case 'bookmarks':
return <Bookmark callback={callback} key={serviceKey} />
default:
return null;
return null
}
}

Expand All @@ -217,7 +216,7 @@ const HamburgerService = ({ services, callback }) => {
const { borderColor } = themeUtils.selectHamburgerServiceTheme(theme)
return (
<IconsContainer borderColor={borderColor}>
{ _.map(services, service => _prepareIconJsx(service)) }
{_.map(services, service => _prepareIconJsx(service))}
</IconsContainer>
)
}}
Expand Down
11 changes: 10 additions & 1 deletion packages/universal-header/src/components/mobile-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const styles = {
mobile: [24], // px
tablet: [24, 30, 24, 50], // px
},
hamburgerPadding: {
mobile: [24], // px
tablet: [24, 30], // px
},
logoHeight: {
mobile: 26, // px
tablet: 40, // px
Expand Down Expand Up @@ -125,7 +129,12 @@ const HamburgerContainer = styled.div`

const Hamburger = styled.div`
display: flex;
cursor: pointer;
position: absolute;
right: 0;
padding: ${arrayToCssShorthand(styles.hamburgerPadding.mobile)};
${mq.tabletOnly`
padding: ${arrayToCssShorthand(styles.hamburgerPadding.tablet)};
`}
`

export default class MobileHeader extends React.PureComponent {
Expand Down
1 change: 1 addition & 0 deletions packages/universal-header/src/components/slogan.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const SloganContainer = styled.div`
font-family: ${fonts.family.serif};
display: flex;
align-items: center;
cursor: default;
`

const Slogan = ({ themeFunction }) => {
Expand Down

0 comments on commit 84f2051

Please sign in to comment.