forked from qiwi/pijma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: style fix, rewrite menu items with LinkControl
- Loading branch information
Sergey Yuferev
committed
Apr 16, 2019
1 parent
7778fd1
commit c6b0320
Showing
6 changed files
with
114 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 43 additions & 24 deletions
67
packages/mobile/src/horizontal-menu/HorizontalMenuItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,52 @@ | ||
import {styled} from '@qiwi/pijma-core' | ||
import {Card, LinkControl, Lnk, Typo} from '@qiwi/pijma-core' | ||
import React from 'react' | ||
|
||
export interface HorizontalMenuItemProps { | ||
active: boolean | ||
id: string | ||
href?: string | ||
target?: string | ||
reverse?: boolean | ||
onClick?: (e: React.MouseEvent) => void | ||
isLast?: boolean | ||
onClick?: () => void | ||
} | ||
|
||
export const HorizontalMenuItem = styled('a', { | ||
shouldForwardProp: prop => prop !== 'active', | ||
})<HorizontalMenuItemProps>(({active, theme}) => ({ | ||
cursor: 'pointer', | ||
fontFamily: theme.font.family, | ||
fontWeight: theme.font.weight.normal, | ||
fontSize: '16px', | ||
textDecoration: 'none', | ||
color: theme.color.black, | ||
flexShrink: 0, | ||
flexGrow: 0, | ||
whiteSpace: 'nowrap', | ||
paddingBottom: '4px', | ||
marginRight: '24px', | ||
borderBottomWidth: '4px', | ||
borderBottomStyle: 'solid', | ||
borderBottomColor: active ? theme.color.brand : 'transparent', | ||
'&:hover, &:active, &:focus': { | ||
textDecoration: 'none', | ||
borderBottomColor: theme.color.brand, | ||
}, | ||
})) | ||
const CardLink = Card.withComponent(Lnk) | ||
|
||
export const HorizontalMenuItem: React.FC<HorizontalMenuItemProps> = props => ( | ||
<LinkControl | ||
onClick={props.onClick} | ||
target={props.target} | ||
children={renderProps => ( | ||
<CardLink | ||
id={props.id} | ||
href={props.href} | ||
target={props.target} | ||
onClick={renderProps.onClick} | ||
onFocus={renderProps.onFocus} | ||
onBlur={renderProps.onBlur} | ||
onMouseEnter={renderProps.onMouseEnter} | ||
onMouseLeave={renderProps.onMouseLeave} | ||
onMouseUp={renderProps.onMouseUp} | ||
onMouseDown={renderProps.onMouseDown} | ||
cursor="pointer" | ||
mr={props.isLast ? 0 : 6} | ||
pb={1} | ||
bb={`4px solid ${ | ||
renderProps.hover || props.active ? '#ff8c00' : 'transparent' | ||
}`} | ||
children={ | ||
<Typo | ||
id={`${props.id}-text`} | ||
as="span" | ||
cursor="pointer" | ||
size={4} | ||
height={6} | ||
weight={500} | ||
children={props.children} | ||
/> | ||
} | ||
/> | ||
)} | ||
/> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,48 @@ | ||
import {styled} from '@qiwi/pijma-core' | ||
import {Card, LinkControl, Lnk, Typo} from '@qiwi/pijma-core' | ||
import React from 'react' | ||
|
||
export interface SelectMenuItemProps { | ||
id: string | ||
href?: string | ||
target?: string | ||
reverse?: boolean | ||
onClick?: (e: React.MouseEvent) => void | ||
onClick?: () => void | ||
} | ||
|
||
export const SelectMenuItem = styled('a')< | ||
SelectMenuItemProps | ||
>(({theme}) => ({ | ||
cursor: 'pointer', | ||
fontFamily: theme.font.family, | ||
fontWeight: theme.font.weight.normal, | ||
fontSize: '16px', | ||
textDecoration: 'none', | ||
color: theme.color.black, | ||
flexShrink: 0, | ||
flexGrow: 0, | ||
whiteSpace: 'nowrap', | ||
lineHeight: '21px', | ||
padding: '8px 16px', | ||
'&:hover, &:active, &:focus': { | ||
textDecoration: 'none', | ||
backgroundColor: theme.color.gray.lightest, | ||
}, | ||
})) | ||
const CardLink = Card.withComponent(Lnk) | ||
|
||
export const SelectMenuItem: React.FC<SelectMenuItemProps> = props => ( | ||
<LinkControl | ||
onClick={props.onClick} | ||
target={props.target} | ||
children={renderProps => ( | ||
<CardLink | ||
id={props.id} | ||
href={props.href} | ||
target={props.target} | ||
onClick={renderProps.onClick} | ||
onFocus={renderProps.onFocus} | ||
onBlur={renderProps.onBlur} | ||
onMouseEnter={renderProps.onMouseEnter} | ||
onMouseLeave={renderProps.onMouseLeave} | ||
onMouseUp={renderProps.onMouseUp} | ||
onMouseDown={renderProps.onMouseDown} | ||
cursor="pointer" | ||
px={4} | ||
py={2} | ||
bg={`${renderProps.hover ? '#f5f5f5' : 'transparent'}`} | ||
children={ | ||
<Typo | ||
id={`${props.id}-text`} | ||
weight={300} | ||
as="span" | ||
cursor="pointer" | ||
size={4} | ||
height={6} | ||
children={props.children} | ||
/> | ||
} | ||
/> | ||
)} | ||
/> | ||
) |