diff --git a/src/components/ArticleCard/Date.tsx b/src/components/ArticleCard/Date.tsx new file mode 100644 index 00000000..754e4714 --- /dev/null +++ b/src/components/ArticleCard/Date.tsx @@ -0,0 +1,14 @@ +import * as React from 'react' +import { dateFormat } from '../../lib/date' + +export const Date: React.FC<{ children: string }> = ({ children }) => ( +

+ + {dateFormat(children)} +

+) diff --git a/src/components/ArticleCard/index.tsx b/src/components/ArticleCard/index.tsx index b414bd07..f5bff60d 100644 --- a/src/components/ArticleCard/index.tsx +++ b/src/components/ArticleCard/index.tsx @@ -1,10 +1,6 @@ -import React from 'react' +import * as React from 'react' import cx from 'classnames' -import { dateFormat } from '../../lib/date' - -const Date = ({ children }) => ( -

{dateFormat(children)}

-) +import { Date } from './Date' interface IImage { alt: string @@ -75,11 +71,6 @@ export const ArticleCard: React.FC = ({ article, ...props }) padding: .75em 1em; } - .ArticleCard .date { - color: #ccc; - font-size: small; - } - .ArticleCard:hover img { width: 105%; height: 105%; @@ -128,7 +119,9 @@ export const ArticleCard: React.FC = ({ article, ...props }) {article.title} {!article.date ? null : ( - {article.date} + + {article.date} + )} diff --git a/src/lib/date.js b/src/lib/date.js deleted file mode 100644 index 126af346..00000000 --- a/src/lib/date.js +++ /dev/null @@ -1,18 +0,0 @@ -const moment = require('moment') -moment.locale('ru') - -/** - * - * Date -> DD.MM.YYYY - * - * @param date - */ -exports.dateFormat = date => moment(date).format('L') - -/** - * - * Date -> Unix time - * - * @param date - */ -exports.timestamp = date => date.getTime() diff --git a/src/lib/date.ts b/src/lib/date.ts new file mode 100644 index 00000000..1a2cbede --- /dev/null +++ b/src/lib/date.ts @@ -0,0 +1,18 @@ +import moment from 'moment' +moment.locale('ru') + +/** + * + * Date -> DD.MM.YYYY + * + * @param date + */ +export const dateFormat = (date: string) => moment(date).format('L') + +/** + * + * Date -> Unix time + * + * @param date + */ +export const timestamp = (date: Date) => date.getTime()