PageMeta and TagList mobile layout fix

This commit is contained in:
tmshv committed 2020-03-03 21:56:56 +03:00
1 parent faf9ee0f7c
commit 1767b65856
4 files changed
+52 -15

No files matched your search

+22 -11
View File
@@ -1,8 +1,10 @@
import './styles.css'
import cx from 'classnames'
import { dateFormat } from 'src/lib/date'
import { ITag } from 'src/types'
import { TagList } from '../TagList'
import { TagList, Direction } from '../TagList'
import { useMobile } from 'src/hooks/useMobile'
export type PageMetaProps = {
style?: React.CSSProperties
@@ -10,14 +12,23 @@ export type PageMetaProps = {
tags?: ITag[]
}
export const PageMeta: React.FC<PageMetaProps> = props => (
<header className={'pageMeta'} style={props.style}>
{!props.date ? null : (
<p className={'date'}>Опубликовано {dateFormat(props.date)}</p>
)}
export const PageMeta: React.FC<PageMetaProps> = props => {
const mobile = useMobile()
const center = mobile ? null : 'center'
const direction: Direction = mobile ? 'vertical' : 'horizontal'
{!(props.tags?.length) ? null : (
<TagList items={props.tags} />
)}
</header>
)
return (
<div className={cx('pageMeta', center)} style={props.style}>
{!props.date ? null : (
<p className={'date'}>Опубликовано {dateFormat(props.date)}</p>
)}
{!(props.tags?.length) ? null : (
<TagList
direction={direction}
items={props.tags}
/>
)}
</div>
)
}
+4 -1
View File
@@ -1,5 +1,8 @@
.pageMeta {
display: flex;
align-items: center;
justify-content: space-between;
}
.pageMeta.center {
align-items: center;
}