-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mdx-typography): add basic typography support (#705)
issue #699
- Loading branch information
1 parent
972b5b6
commit 76e6143
Showing
10 changed files
with
228 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Typography } from 'antd'; | ||
|
||
interface Props {} | ||
|
||
const Anchor = (props: Props): JSX.Element => <Typography.Link {...props} />; | ||
|
||
export default Anchor; |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Typography } from 'antd'; | ||
import type { TitleProps } from 'antd/lib/typography/Title'; | ||
|
||
interface Props {} | ||
|
||
const Heading = (props: TitleProps): JSX.Element => ( | ||
<Typography.Title {...props} /> | ||
); | ||
|
||
const H1 = (props: Props): JSX.Element => <Heading {...props} level={1} />; | ||
|
||
const H2 = (props: Props): JSX.Element => <Heading {...props} level={2} />; | ||
|
||
const H3 = (props: Props): JSX.Element => <Heading {...props} level={3} />; | ||
|
||
const H4 = (props: Props): JSX.Element => <Heading {...props} level={4} />; | ||
|
||
const H5 = (props: Props): JSX.Element => <Heading {...props} level={5} />; | ||
|
||
const Headings = { | ||
h1: H1, | ||
h2: H2, | ||
h3: H3, | ||
h4: H4, | ||
h5: H5, | ||
h6: H5, | ||
}; | ||
|
||
export default Headings; |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { render } from '@testing-library/react'; | ||
import Anchor from './Anchor'; | ||
import Headings from './Headings'; | ||
import Paragraph from './Paragraph'; | ||
import Texts from './Texts'; | ||
|
||
describe('Anchor', () => { | ||
test('should render correctly (snapshot)', () => { | ||
const { container } = render(<Anchor />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('Paragraph', () => { | ||
test('should render correctly (snapshot)', () => { | ||
const { container } = render(<Paragraph />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('Headings', () => { | ||
test.each(Object.values(Headings))( | ||
'should render correctly (snapshot)', | ||
Heading => { | ||
const { container } = render(<Heading />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
} | ||
); | ||
}); | ||
|
||
describe('Texts', () => { | ||
test.each(Object.values(Texts))( | ||
'should render correctly (snapshot)', | ||
Text => { | ||
const { container } = render(<Text />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
} | ||
); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Typography } from 'antd'; | ||
|
||
interface Props {} | ||
|
||
const Paragraph = (props: Props): JSX.Element => ( | ||
<Typography.Paragraph {...props} /> | ||
); | ||
|
||
export default Paragraph; |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Typography } from 'antd'; | ||
import type { TextProps } from 'antd/lib/typography/Text'; | ||
|
||
interface Props {} | ||
|
||
const Text = (props: TextProps): JSX.Element => <Typography.Text {...props} />; | ||
|
||
const Strong = (props: Props): JSX.Element => <Text {...props} strong />; | ||
|
||
const Emphasis = (props: Props): JSX.Element => <Text {...props} italic />; | ||
|
||
const Delete = (props: Props): JSX.Element => <Text {...props} delete />; | ||
|
||
const Texts = { | ||
strong: Strong, | ||
em: Emphasis, | ||
del: Delete, | ||
}; | ||
|
||
export default Texts; |
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Anchor should render correctly (snapshot) 1`] = ` | ||
<div> | ||
<a | ||
class="ant-typography" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Headings should render correctly (snapshot) 1`] = ` | ||
<div> | ||
<h1 | ||
class="ant-typography" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Headings should render correctly (snapshot) 2`] = ` | ||
<div> | ||
<h2 | ||
class="ant-typography" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Headings should render correctly (snapshot) 3`] = ` | ||
<div> | ||
<h3 | ||
class="ant-typography" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Headings should render correctly (snapshot) 4`] = ` | ||
<div> | ||
<h4 | ||
class="ant-typography" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Headings should render correctly (snapshot) 5`] = ` | ||
<div> | ||
<h5 | ||
class="ant-typography" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Headings should render correctly (snapshot) 6`] = ` | ||
<div> | ||
<h5 | ||
class="ant-typography" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Paragraph should render correctly (snapshot) 1`] = ` | ||
<div> | ||
<div | ||
class="ant-typography" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Texts should render correctly (snapshot) 1`] = ` | ||
<div> | ||
<span | ||
class="ant-typography" | ||
> | ||
<strong /> | ||
</span> | ||
</div> | ||
`; | ||
|
||
exports[`Texts should render correctly (snapshot) 2`] = ` | ||
<div> | ||
<span | ||
class="ant-typography" | ||
> | ||
<i /> | ||
</span> | ||
</div> | ||
`; | ||
|
||
exports[`Texts should render correctly (snapshot) 3`] = ` | ||
<div> | ||
<span | ||
class="ant-typography" | ||
> | ||
<del /> | ||
</span> | ||
</div> | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Anchor from './Anchor'; | ||
import Headings from './Headings'; | ||
import Paragraph from './Paragraph'; | ||
import Texts from './Texts'; | ||
|
||
const MDXComponents = { | ||
a: Anchor, | ||
p: Paragraph, | ||
...Headings, | ||
...Texts, | ||
}; | ||
|
||
export default MDXComponents; |
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
76e6143
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
blog – ./
blog-sabertaz.vercel.app
blog.tazimi.dev
blog-git-main-sabertaz.vercel.app