Skip to content

Commit

Permalink
refactor: small SCSS and code style refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorrusakov committed Oct 10, 2023
1 parent 766a3d0 commit 0895385
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 28 deletions.
34 changes: 18 additions & 16 deletions src/Pagination/DefaultPagination.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
import React, { useContext } from 'react';
import { useMediaQuery } from 'react-responsive';
import PaginationContext from './PaginationContext';
import PreviousPageButton from './subcomponents/PreviousPageButton';
import NextPageButton from './subcomponents/NextPageButton';
import PageOfCountButton from './subcomponents/PageOfCountButton';
import breakpoints from '../utils/breakpoints';
import { ELLIPSIS } from './constants';
import Ellipsis from './subcomponents/Ellipsis';
import {
PreviousPageButton,
NextPageButton,
PageOfCountButton,
PageButton,
Ellipsis,
} from './subcomponents';
import breakpoints from '../utils/breakpoints';
import newId from '../utils/newId';
import PageButton from './subcomponents/PageButton';

export default function DefaultPagination() {
return (
<ul className="pagination">
<PreviousPageButton />
<PaginationPages />
<NextPageButton />
</ul>
);
}

function PaginationPages() {
const { displayPages } = useContext(PaginationContext);
Expand All @@ -39,3 +31,13 @@ function PaginationPages() {
</>
);
}

export default function DefaultPagination() {
return (
<ul className="pagination">
<PreviousPageButton />
<PaginationPages />
<NextPageButton />
</ul>
);
}
3 changes: 1 addition & 2 deletions src/Pagination/MinimalPagination.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PreviousPageButton from './subcomponents/PreviousPageButton';
import NextPageButton from './subcomponents/NextPageButton';
import { PreviousPageButton, NextPageButton } from './subcomponents';

export default function MinimalPagination() {
return (
Expand Down
4 changes: 1 addition & 3 deletions src/Pagination/ReducedPagination.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import PreviousPageButton from './subcomponents/PreviousPageButton';
import NextPageButton from './subcomponents/NextPageButton';
import PaginationDropdown from './subcomponents/PaginationDropdown';
import { PreviousPageButton, NextPageButton, PaginationDropdown } from './subcomponents';

export default function ReducedPagination() {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/Pagination/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import MinimalPagination from './MinimalPagination';
import DefaultPagination from './DefaultPagination';
import { PaginationContextProvider } from './PaginationContext';
import { PAGINATION_VARIANTS } from './constants';
import PaginationScreenReaderText from './subcomponents/ScreenReaderComponent';
import { ScreenReaderText } from './subcomponents';

import { greaterThan } from '../utils/propTypes';
import { ChevronLeft, ChevronRight } from '../../icons';
Expand Down Expand Up @@ -43,7 +43,7 @@ function Pagination(props) {
'pagination-small': size !== PAGINATION_VARIANTS.default,
})}
>
<PaginationScreenReaderText />
<ScreenReaderText />
{renderPaginationComponent()}
</nav>
</PaginationContextProvider>
Expand Down
5 changes: 5 additions & 0 deletions src/Pagination/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
z-index: 4;
}

.page-of-count {
margin: 0 0.5rem;
border: 0;
}

.page-item {
&:first-child .page-link {
margin-left: 0;
Expand Down
9 changes: 4 additions & 5 deletions src/Pagination/subcomponents/PageOfCountButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ export default function PageOfCountButton() {
const label = getPageOfText();

return (
<li className={classNames(['page-item', 'disabled'])}>
<li className={classNames('page-item', 'disabled')}>
<span
className={classNames([
className={classNames(
'btn',
'page-link',
'mx-2',
'border-0',
])}
'page-of-count',
)}
aria-label={ariaLabel}
>
{label}
Expand Down
7 changes: 7 additions & 0 deletions src/Pagination/subcomponents/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export { default as Ellipsis } from './Ellipsis';
export { default as NextPageButton } from './NextPageButton';
export { default as PageButton } from './PageButton';
export { default as PageOfCountButton } from './PageOfCountButton';
export { default as PaginationDropdown } from './PaginationDropdown';
export { default as PreviousPageButton } from './PreviousPageButton';
export { default as ScreenReaderText } from './ScreenReaderText';

0 comments on commit 0895385

Please sign in to comment.