meticulous-ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +27 -0
- package/src/colors/index.js +3 -0
- package/src/components/Icons/ChevronLeft/ChevronLeft.jsx +28 -0
- package/src/components/Icons/ChevronLeft/index.js +3 -0
- package/src/components/Icons/ChevronRight/ChevronRight.jsx +28 -0
- package/src/components/Icons/ChevronRight/index.js +3 -0
- package/src/components/Pagination/Pagination.jsx +76 -0
- package/src/components/Pagination/helpers.jsx +21 -0
- package/src/components/Pagination/index.js +3 -0
- package/src/components/Pagination/styles.js +50 -0
- package/src/index.js +3 -0
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "meticulous-ui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A clean, modern React component library built with Vite (ESM)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"src"
|
|
9
|
+
],
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
12
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
13
|
+
"styled-components": "^6.0.0"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"lint": "eslint .",
|
|
17
|
+
"build": "vite build"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"react",
|
|
21
|
+
"components",
|
|
22
|
+
"ui",
|
|
23
|
+
"meticulous-ui"
|
|
24
|
+
],
|
|
25
|
+
"author": "Your Name",
|
|
26
|
+
"license": "MIT"
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
// constants
|
|
5
|
+
import { GREY } from '../../../colors';
|
|
6
|
+
|
|
7
|
+
const Image = styled.img`
|
|
8
|
+
display: inline-block;
|
|
9
|
+
vertical-align: middle;
|
|
10
|
+
fill: ${({ color }) => color};
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
const ChevronLeft = (props) => {
|
|
14
|
+
const {color, size} = props;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Image
|
|
18
|
+
{...props}
|
|
19
|
+
color={color || GREY}
|
|
20
|
+
src="https://www.svgrepo.com/show/533659/chevron-left.svg"
|
|
21
|
+
alt="Chevron Left"
|
|
22
|
+
width={size}
|
|
23
|
+
height={size}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default ChevronLeft;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
// constants
|
|
5
|
+
import { GREY } from '../../../colors';
|
|
6
|
+
|
|
7
|
+
const Image = styled.img`
|
|
8
|
+
display: inline-block;
|
|
9
|
+
vertical-align: middle;
|
|
10
|
+
fill: ${({ color }) => color};
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
const ChevronRight = (props) => {
|
|
14
|
+
const {color, size} = props;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Image
|
|
18
|
+
{...props}
|
|
19
|
+
color={color || GREY}
|
|
20
|
+
src="https://www.svgrepo.com/show/533661/chevron-right.svg"
|
|
21
|
+
alt="Chevron Right"
|
|
22
|
+
width={size}
|
|
23
|
+
height={size}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default ChevronRight;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import _range from 'lodash-es/range';
|
|
3
|
+
|
|
4
|
+
// helpers
|
|
5
|
+
import { renderThreeDots, renderPageNum } from './helpers.jsx';
|
|
6
|
+
|
|
7
|
+
// styles
|
|
8
|
+
import { AllPages, ClickableChevronLeft, ClickableChevronRight } from './styles';
|
|
9
|
+
|
|
10
|
+
const Pagination = ({ pageNumber, setPageNumber, totalPages }) => {
|
|
11
|
+
const setPrevPage = () => {
|
|
12
|
+
if (pageNumber > 1) {
|
|
13
|
+
setPageNumber(pageNumber - 1);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const setNextPage = () => {
|
|
18
|
+
if (pageNumber < totalPages) {
|
|
19
|
+
setPageNumber(pageNumber + 1);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
if (totalPages <= 7) {
|
|
24
|
+
return (
|
|
25
|
+
<AllPages>
|
|
26
|
+
<ClickableChevronLeft onClick={setPrevPage} />
|
|
27
|
+
{_range(1, totalPages + 1).map(renderPageNum(pageNumber, setPageNumber))}
|
|
28
|
+
<ClickableChevronRight onClick={setPrevPage} />
|
|
29
|
+
</AllPages>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (
|
|
34
|
+
totalPages < 10 ||
|
|
35
|
+
pageNumber < 4 ||
|
|
36
|
+
(pageNumber > totalPages - 3 && pageNumber <= totalPages)
|
|
37
|
+
) {
|
|
38
|
+
return (
|
|
39
|
+
<AllPages>
|
|
40
|
+
<ClickableChevronLeft
|
|
41
|
+
size={20}
|
|
42
|
+
onClick={setPrevPage}
|
|
43
|
+
/>
|
|
44
|
+
{_range(1, 5).map(renderPageNum(pageNumber, setPageNumber))}
|
|
45
|
+
{renderThreeDots()}
|
|
46
|
+
{[totalPages - 3, totalPages - 2, totalPages - 1, totalPages].map(
|
|
47
|
+
renderPageNum(pageNumber, setPageNumber)
|
|
48
|
+
)}
|
|
49
|
+
<ClickableChevronRight
|
|
50
|
+
size={20}
|
|
51
|
+
onClick={setNextPage}
|
|
52
|
+
/>
|
|
53
|
+
</AllPages>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<AllPages>
|
|
59
|
+
<ClickableChevronLeft
|
|
60
|
+
size={20}
|
|
61
|
+
onClick={setPrevPage}
|
|
62
|
+
/>
|
|
63
|
+
{_range(1, 3).map(renderPageNum(pageNumber, setPageNumber))}
|
|
64
|
+
{renderThreeDots()}
|
|
65
|
+
{[pageNumber - 1, pageNumber, pageNumber + 1].map(renderPageNum(pageNumber, setPageNumber))}
|
|
66
|
+
{renderThreeDots()}
|
|
67
|
+
{[totalPages - 1, totalPages].map(renderPageNum(pageNumber, setPageNumber))}
|
|
68
|
+
<ClickableChevronRight
|
|
69
|
+
size={20}
|
|
70
|
+
onClick={setNextPage}
|
|
71
|
+
/>
|
|
72
|
+
</AllPages>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default Pagination;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Page, P } from './styles';
|
|
2
|
+
|
|
3
|
+
export const renderPageNum = (selected, setPageNumber) => (page) => {
|
|
4
|
+
const clickHandler = () => {
|
|
5
|
+
setPageNumber(page);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<Page data-testid={selected === page ? "current-page" : `test-${page}`} isSelected={selected === page} onClick={clickHandler}>
|
|
10
|
+
{page}
|
|
11
|
+
</Page>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const renderThreeDots = () => (
|
|
16
|
+
<>
|
|
17
|
+
<P>.</P>
|
|
18
|
+
<P>.</P>
|
|
19
|
+
<P>.</P>
|
|
20
|
+
</>
|
|
21
|
+
);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
// Icons
|
|
5
|
+
import ChevronLeft from '../Icons/ChevronLeft';
|
|
6
|
+
import ChevronRight from '../Icons/ChevronRight';
|
|
7
|
+
|
|
8
|
+
// constants
|
|
9
|
+
import { GREY, TEAL, WHITE } from '../../colors';
|
|
10
|
+
|
|
11
|
+
export const AllPages = styled.div`
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: 0.6rem;
|
|
16
|
+
min-width: 175rem;
|
|
17
|
+
width: 175rem;
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
export const Page = styled.div`
|
|
21
|
+
height: 3rem;
|
|
22
|
+
width: 3rem;
|
|
23
|
+
border-radius: 50%;
|
|
24
|
+
padding-top: 0.6rem;
|
|
25
|
+
text-align: center;
|
|
26
|
+
font-size: 1.4rem;
|
|
27
|
+
${({ isSelected }) =>
|
|
28
|
+
isSelected
|
|
29
|
+
? css`
|
|
30
|
+
cursor: auto;
|
|
31
|
+
color: ${WHITE};
|
|
32
|
+
background-color: ${TEAL};
|
|
33
|
+
`
|
|
34
|
+
: css`
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
color: ${GREY};
|
|
37
|
+
`}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
export const P = styled.p`
|
|
41
|
+
color: ${GREY};
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export const ClickableChevronLeft = styled(ChevronLeft)`
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
export const ClickableChevronRight = styled(ChevronRight)`
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
`;
|
package/src/index.js
ADDED