diff --git a/src/components/PageMeta/index.tsx b/src/components/PageMeta/index.tsx index d3c18f81..64cbe577 100644 --- a/src/components/PageMeta/index.tsx +++ b/src/components/PageMeta/index.tsx @@ -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 = props => ( -
- {!props.date ? null : ( -

Опубликовано {dateFormat(props.date)}

- )} +export const PageMeta: React.FC = props => { + const mobile = useMobile() + const center = mobile ? null : 'center' + const direction: Direction = mobile ? 'vertical' : 'horizontal' - {!(props.tags?.length) ? null : ( - - )} -
-) + return ( +
+ {!props.date ? null : ( +

Опубликовано {dateFormat(props.date)}

+ )} + + {!(props.tags?.length) ? null : ( + + )} +
+ ) +} diff --git a/src/components/PageMeta/styles.css b/src/components/PageMeta/styles.css index fa1c61b1..f90a3fbd 100644 --- a/src/components/PageMeta/styles.css +++ b/src/components/PageMeta/styles.css @@ -1,5 +1,8 @@ .pageMeta { display: flex; - align-items: center; justify-content: space-between; } + +.pageMeta.center { + align-items: center; +} diff --git a/src/components/TagList/index.tsx b/src/components/TagList/index.tsx index 3b72b3b8..a7483c88 100644 --- a/src/components/TagList/index.tsx +++ b/src/components/TagList/index.tsx @@ -1,10 +1,18 @@ import './styles.css' +import cx from 'classnames' import { ITag } from 'src/types' import { Button } from '../Button' -export const Tag: React.FC<{ href: string }> = props => ( -
  • +export type Direction = 'horizontal' | 'vertical' + +export type TagProps = { + href: string + direction: Direction +} + +export const Tag: React.FC = props => ( +