Skip to content

Commit

Permalink
Typograph texts
Browse files Browse the repository at this point in the history
  • Loading branch information
sashachabin committed Jul 4, 2023
1 parent 1283f16 commit 5615ba6
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 468 deletions.
10 changes: 6 additions & 4 deletions client/components/Articles/Article/Article.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import classNames from 'classnames/bind';
import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
import md from 'markdown-it';
import { ArticleProps } from './Article.types';
import Link from 'next/link';

import styles from './Article.module.css';
import t from 'utils/typograph';

const cn = classNames.bind(styles);

Expand All @@ -20,9 +21,10 @@ export function Article({ title, description }: ArticleProps) {
{title}
</h1>

<ReactMarkdown className={cn(styles.ArticleContent)}>
{description}
</ReactMarkdown>
<div
className={cn(styles.ArticleContent)}
dangerouslySetInnerHTML={{ __html: t(md().render(description)) }}
/>
</article>
)
}
5 changes: 3 additions & 2 deletions client/components/MainPage/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import classNames from 'classnames/bind';
import { CardProps } from './Card.types';

import styles from './Card.module.css';
import t from 'utils/typograph';

const cn = classNames.bind(styles);

Expand Down Expand Up @@ -41,11 +42,11 @@ export function Card({
} as React.CSSProperties}
>
{title && <div className={cn(styles.CardTitle, { [styles.CardTitle_Bg]: Boolean(titleBackground) })}>
{title}
{t(title)}
</div>}

{subtitle && <div className={cn(styles.CardSubtitle)}>
{subtitle}
{t(subtitle)}
</div>}

{button && <div className={cn(styles.CardButton)}>
Expand Down
5 changes: 3 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
"ekb": "^1.1.3",
"leaflet": "^1.9.2",
"lodash": "^4.17.21",
"markdown-it": "^13.0.1",
"prop-types": "^15.8.1",
"react-leaflet": "4.1.0",
"react-markdown": "^8.0.5",
"react-redux": "^8.0.7",
"redux": "^4.2.1",
"transport-common": "workspace:*"
"transport-common": "workspace:*",
"typograf": "^7.1.0"
},
"devDependencies": {
"@svgr/webpack": "^6.5.1",
Expand Down
34 changes: 34 additions & 0 deletions client/utils/typograph.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Typograf from 'typograf';

const tp = new Typograf({
locale: ['ru', 'en-US'],
});

const tpForAsideMenu = new Typograf({
locale: ['ru', 'en-US'],
});

tpForAsideMenu.disableRule([
'common/space/trimRight',
'common/space/trimLeft',
'common/space/delBeforePunctuation',
'common/space/afterPunctuation',
'common/nbsp/replaceNbsp',
'ru/optalign/comma',
'ru/punctuation/ano',
'ru/punctuation/exclamation',
'ru/punctuation/exclamationQuestion',
'ru/punctuation/hellipQuestion',
])

tp.disableRule([
'common/space/trimRight',
'common/space/trimLeft',
'common/space/delBeforePunctuation',
'common/space/afterPunctuation',
'common/nbsp/replaceNbsp',
]);

export default function t(text) {
return tp.execute(text);
};
Loading

1 comment on commit 5615ba6

@ekbdev
Copy link

@ekbdev ekbdev commented on 5615ba6 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for transport ready!

✅ Preview
https://transport-2hwx0p7n8-ekbdev.vercel.app
https://ekbdev-transport-feature-main-page-data.vercel.app

Built with commit 5615ba6.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.