Skip to content

Commit 0453bb1

Browse files
fix: fix responsive components (#110)
1 parent 8640f85 commit 0453bb1

5 files changed

Lines changed: 25 additions & 14 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ lib/
1515
*.log
1616
.history/
1717
*storybook.log
18+
src/components/output.css

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"name": "@indec/react-commons",
3-
"version": "7.0.2",
3+
"version": "7.0.3",
44
"description": "Common reactjs components for apps",
55
"private": false,
66
"main": "index.js",
77
"exports": {
88
"./components": "./components/index.js",
99
"./Icons": "./components/Icons/index.js",
1010
"./hooks": "./hooks/index.js",
11-
"./utils": "./utils/index.js"
11+
"./utils": "./utils/index.js",
12+
"./assets": "./assets/index.js"
1213
},
1314
"scripts": {
1415
"start": "start-storybook -p 6006",

src/assets/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import footer from './footer.png';
2+
import logo from './logo.svg';
3+
import logoRight from './logoRight.png';
4+
5+
export {
6+
footer,
7+
logo,
8+
logoRight
9+
};

src/components/Pagination.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function Pagination({total = 0, perPage = 10, onChange = () => {}
2020

2121
const renderPageNumbers = () => {
2222
const pages = [];
23-
const maxVisible = 5;
23+
const maxVisible = window.innerWidth < 640 ? 3 : 5;
2424
let startPage = Math.max(1, safePage - Math.floor(maxVisible / 2));
2525
let endPage = Math.min(pagesCount, startPage + maxVisible - 1);
2626

@@ -34,7 +34,7 @@ export default function Pagination({total = 0, perPage = 10, onChange = () => {}
3434
type="button"
3535
key={1}
3636
onClick={() => onChange(1)}
37-
className="px-3 py-2 mx-1 text-sm rounded-md bg-white border border-gray-300 hover:bg-gray-50"
37+
className="px-2 sm:px-3 py-2 mx-0.5 sm:mx-1 text-xs sm:text-sm rounded-md bg-white border border-gray-300 hover:bg-gray-50 whitespace-nowrap"
3838
>
3939
1
4040
</button>
@@ -54,7 +54,7 @@ export default function Pagination({total = 0, perPage = 10, onChange = () => {}
5454
type="button"
5555
key={i}
5656
onClick={() => onChange(i)}
57-
className={`px-3 py-2 mx-1 text-sm rounded-md ${
57+
className={`px-2 sm:px-3 py-2 mx-0.5 sm:mx-1 text-xs sm:text-sm rounded-md whitespace-nowrap ${
5858
i === safePage
5959
? 'bg-blue-600 text-white border border-blue-600'
6060
: 'bg-white border border-gray-300 hover:bg-gray-50'
@@ -78,7 +78,7 @@ export default function Pagination({total = 0, perPage = 10, onChange = () => {}
7878
type="button"
7979
key={pagesCount}
8080
onClick={() => onChange(pagesCount)}
81-
className="px-3 py-2 mx-1 text-sm rounded-md bg-white border border-gray-300 hover:bg-gray-50"
81+
className="px-2 sm:px-3 py-2 mx-0.5 sm:mx-1 text-xs sm:text-sm rounded-md bg-white border border-gray-300 hover:bg-gray-50 whitespace-nowrap"
8282
>
8383
{pagesCount}
8484
</button>
@@ -90,13 +90,13 @@ export default function Pagination({total = 0, perPage = 10, onChange = () => {}
9090

9191
return (
9292
<>
93-
<div className="flex flex-col sm:flex-row justify-center items-center space-y-4 sm:space-y-0 sm:space-x-6 mt-6 flex-wrap">
94-
<div className="flex items-center space-x-2">
93+
<div className="flex flex-col sm:flex-row justify-center items-center space-y-4 sm:space-y-0 sm:space-x-6 mt-6 flex-wrap px-4">
94+
<div className="flex items-center space-x-1 sm:space-x-2 overflow-x-auto max-w-full">
9595
<button
9696
type="button"
9797
onClick={() => onChange(1)}
9898
disabled={safePage === 1}
99-
className="p-2 rounded-md bg-white border border-gray-300 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
99+
className="p-1.5 sm:p-2 rounded-md bg-white border border-gray-300 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
100100
>
101101
<ChevronLeftIcon className="w-4 h-4" />
102102
</button>
@@ -105,7 +105,7 @@ export default function Pagination({total = 0, perPage = 10, onChange = () => {}
105105
type="button"
106106
onClick={() => onChange(safePage - 1)}
107107
disabled={safePage === 1}
108-
className="p-2 rounded-md bg-white border border-gray-300 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
108+
className="p-1.5 sm:p-2 rounded-md bg-white border border-gray-300 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
109109
>
110110
<ChevronLeftIcon className="w-4 h-4" />
111111
</button>
@@ -116,7 +116,7 @@ export default function Pagination({total = 0, perPage = 10, onChange = () => {}
116116
type="button"
117117
onClick={() => onChange(safePage + 1)}
118118
disabled={safePage === pagesCount}
119-
className="p-2 rounded-md bg-white border border-gray-300 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
119+
className="p-1.5 sm:p-2 rounded-md bg-white border border-gray-300 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
120120
>
121121
<ChevronRightIcon className="w-4 h-4" />
122122
</button>
@@ -125,7 +125,7 @@ export default function Pagination({total = 0, perPage = 10, onChange = () => {}
125125
type="button"
126126
onClick={() => onChange(pagesCount)}
127127
disabled={safePage === pagesCount}
128-
className="p-2 rounded-md bg-white border border-gray-300 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
128+
className="p-1.5 sm:p-2 rounded-md bg-white border border-gray-300 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
129129
>
130130
<ChevronRightIcon className="w-4 h-4" />
131131
</button>
@@ -144,7 +144,7 @@ export default function Pagination({total = 0, perPage = 10, onChange = () => {}
144144
type="button"
145145
onClick={() => onChange(newPage)}
146146
disabled={newPage === 0}
147-
className="p-2 rounded-md bg-white border border-gray-300 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
147+
className="p-1.5 sm:p-2 rounded-md bg-white border border-gray-300 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
148148
>
149149
<ChevronRightIcon className="w-4 h-4" />
150150
</button>

src/components/Table/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function Table({
3434
<>
3535
<Cards columns={columns} rows={rows} />
3636
<div className="hidden md:block">
37-
<div className="bg-white mt-8 rounded-lg shadow-sm overflow-hidden">
37+
<div className="bg-white mt-8 rounded-lg shadow-sm overflow-x-auto">
3838
<table className="min-w-full">
3939
<TableHeader columns={columns} onSort={onSort} />
4040
<tbody>

0 commit comments

Comments
 (0)