Skip to content

Commit

Permalink
refactor(antd): wrap BackTop and classnames
Browse files Browse the repository at this point in the history
issue #699
  • Loading branch information
sabertazimi committed Apr 28, 2022
1 parent ba28983 commit ea82cc2
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 14 deletions.
2 changes: 1 addition & 1 deletion components/Article/ArticleHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
} from '@ant-design/icons';
import { Slide } from '@components/Motion';
import { IconTag, LinkTag } from '@components/Tags';
import { classNames } from '@components/utils';
import { siteConfig } from '@config';
import type { PostMeta } from '@types';
import classNames from 'classnames';

interface Props {
post: PostMeta;
Expand Down
2 changes: 1 addition & 1 deletion components/Article/ArticleNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
import FlexContainer from '@components/FlexContainer';
import Link from '@components/Link';
import { Bounce } from '@components/Motion';
import { classNames } from '@components/utils';
import type { PostMeta } from '@types';
import classNames from 'classnames';

interface Props {
prevPost: PostMeta['prevPost'];
Expand Down
2 changes: 1 addition & 1 deletion components/Article/ArticleToc.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CloseOutlined, MenuFoldOutlined } from '@ant-design/icons';
import { classNames } from '@components/utils';
import { Button, Drawer } from 'antd';
import classNames from 'classnames';
import { useCallback, useState } from 'react';
import styles from './ArticleToc.module.css';

Expand Down
10 changes: 10 additions & 0 deletions components/BackTop/BackTop.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { render } from '@testing-library/react';
import BackTop from './BackTop';

describe('BackTop', () => {
test('should render correctly (snapshot)', () => {
const { container } = render(<BackTop />);

expect(container).toMatchSnapshot();
});
});
5 changes: 5 additions & 0 deletions components/BackTop/BackTop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BackTop as AntBackTop } from 'antd';

const BackTop = () => <AntBackTop />;

export default BackTop;
9 changes: 9 additions & 0 deletions components/BackTop/__snapshots__/BackTop.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`BackTop should render correctly (snapshot) 1`] = `
<div>
<div
class="ant-back-top"
/>
</div>
`;
1 change: 1 addition & 0 deletions components/BackTop/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './BackTop';
2 changes: 1 addition & 1 deletion components/Header/DesktopNav.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Link from '@components/Link';
import PostsSearchBar from '@components/PostsSearchBar';
import { classNames } from '@components/utils';
import { routes } from '@config';
import logo from '@images/logo-full.png';
import type { PostMeta } from '@types';
import { Menu } from 'antd';
import classNames from 'classnames';
import Image from 'next/image';

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion components/LandingNav/LandingNav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Close, Hamburger } from '@components/Icons';
import { classNames } from '@components/utils';
import { routes as defaultRoutes } from '@config';
import type { Route } from '@types';
import classNames from 'classnames';
import { motion } from 'framer-motion';
import { useCallback, useState } from 'react';
import LandingNavLink from './LandingNavLink';
Expand Down
2 changes: 1 addition & 1 deletion components/LandingNav/LandingNavLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from '@components/Link';
import { Bounce } from '@components/Motion';
import { classNames } from '@components/utils';
import { Tooltip } from 'antd';
import classNames from 'classnames';
import type { ReactNode } from 'react';

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion components/Motion/Bounce.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from 'classnames';
import { classNames } from '@components/utils';
import { motion } from 'framer-motion';
import type { ReactNode } from 'react';

Expand Down
2 changes: 1 addition & 1 deletion components/NotFoundResult/NotFoundResult.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from '@components/Link';
import { classNames } from '@components/utils';
import { Result } from 'antd';
import classNames from 'classnames';

interface Props {
title?: string;
Expand Down
2 changes: 1 addition & 1 deletion components/PostsGrid/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import Container from '@components/Container';
import Link from '@components/Link';
import { Slide } from '@components/Motion';
import { IconTag, LinkTag } from '@components/Tags';
import { classNames } from '@components/utils';
import type { PostMeta } from '@types';
import { Button, Skeleton, Typography } from 'antd';
import classNames from 'classnames';

interface Props {
post: PostMeta;
Expand Down
2 changes: 1 addition & 1 deletion components/Tags/LinkTag.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Link from '@components/Link';
import { classNames } from '@components/utils';
import { getColorByName } from '@config';
import type { Tag } from '@types';
import { Tag as AntTag } from 'antd';
import classNames from 'classnames';

interface Props {
tag?: Tag;
Expand Down
2 changes: 1 addition & 1 deletion components/TypingTitle/TypingTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { classNames } from '@components/utils';
import { siteConfig } from '@config';
import { useTypingEffect } from '@hooks';
import classNames from 'classnames';
import { useRef } from 'react';

interface Props {
Expand Down
1 change: 1 addition & 0 deletions components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as Article } from './Article';
export { default as BackTop } from './BackTop';
export { default as BooksGrid } from './BooksGrid';
export { default as Container } from './Container';
export { default as Divider } from './Divider';
Expand Down
3 changes: 3 additions & 0 deletions components/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import classNames from 'classnames';

export { classNames };
2 changes: 1 addition & 1 deletion layouts/LandingLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MetaHeader } from '@components';
import { classNames } from '@components/utils';
import landingImage from '@images/landing.jpg';
import classNames from 'classnames';
import type { ReactNode } from 'react';

interface Props {
Expand Down
3 changes: 1 addition & 2 deletions layouts/PostLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Container, Footer, Header, MetaHeader } from '@components';
import { BackTop, Container, Footer, Header, MetaHeader } from '@components';
import type { PostMeta } from '@types';
import { BackTop } from 'antd';
import type { ReactNode } from 'react';

interface Props {
Expand Down

0 comments on commit ea82cc2

Please sign in to comment.