Skip to content

Commit 93e5c8d

Browse files
committed
feat: Table title, search bar and button responsiveness
1 parent 8c1d446 commit 93e5c8d

File tree

2 files changed

+247
-24
lines changed

2 files changed

+247
-24
lines changed

src/components/MultiLevelTable.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -745,23 +745,25 @@ export const MultiLevelTable: React.FC<MultiLevelTableProps> = ({
745745
</div>
746746
</div>
747747
)}
748-
<table
749-
{...getTableProps()}
750-
className="main-table-container"
751-
style={{ borderColor: mergedTheme.table?.cell?.borderColor }}
752-
>
753-
<TableHeader
754-
headerGroups={headerGroups}
755-
theme={mergedTheme}
756-
sortable={sortable}
757-
ascendingIcon={ascendingIcon}
758-
descendingIcon={descendingIcon}
759-
selectable={selectable}
760-
isAllSelected={selectionState.isAllSelected}
761-
onSelectAll={onSelectAll}
762-
/>
763-
{renderTableBody()}
764-
</table>
748+
<div className="table-responsive-container">
749+
<table
750+
{...getTableProps()}
751+
className="main-table-container"
752+
style={{ borderColor: mergedTheme.table?.cell?.borderColor }}
753+
>
754+
<TableHeader
755+
headerGroups={headerGroups}
756+
theme={mergedTheme}
757+
sortable={sortable}
758+
ascendingIcon={ascendingIcon}
759+
descendingIcon={descendingIcon}
760+
selectable={selectable}
761+
isAllSelected={selectionState.isAllSelected}
762+
onSelectAll={onSelectAll}
763+
/>
764+
{renderTableBody()}
765+
</table>
766+
</div>
765767

766768
{renderPagination()}
767769
</div>

src/styles/MultiLevelTable.css

Lines changed: 228 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,57 @@
44
border-spacing: 0;
55
}
66

7+
/* Main container styling to prevent black space */
78
.table-wrapper {
9+
width: 100%;
10+
border-radius: 12px;
11+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
12+
/* Remove overflow-x from wrapper to prevent black space */
13+
margin: 0;
14+
padding: 0 ;
15+
/* Ensure proper height */
16+
height: auto;
17+
min-height: 0;
18+
/* Prevent any overflow issues */
19+
overflow: visible;
20+
}
21+
22+
/* Responsive table container */
23+
.table-responsive-container {
824
width: 100%;
925
overflow-x: auto;
1026
-webkit-overflow-scrolling: touch;
1127
border-radius: 12px;
12-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
28+
/* Show scrollbar */
29+
scrollbar-width: thin;
30+
scrollbar-color: #c1c1c1 #f1f1f1;
31+
/* Prevent extra space */
32+
margin: 0;
33+
padding: 0;
34+
/* Prevent vertical overflow */
35+
overflow-y: hidden;
36+
/* Ensure proper height */
37+
height: auto;
38+
min-height: 0;
39+
}
40+
41+
/* Custom scrollbar styling */
42+
.table-responsive-container::-webkit-scrollbar {
43+
height: 8px;
44+
}
45+
46+
.table-responsive-container::-webkit-scrollbar-track {
47+
background: #f1f1f1;
48+
border-radius: 4px;
49+
}
50+
51+
.table-responsive-container::-webkit-scrollbar-thumb {
52+
background: #c1c1c1;
53+
border-radius: 4px;
54+
}
55+
56+
.table-responsive-container::-webkit-scrollbar-thumb:hover {
57+
background: #a8a8a8;
1358
}
1459

1560
/* Ensure table container maintains proper spacing */
@@ -21,6 +66,17 @@
2166
padding: 0;
2267
}
2368

69+
/* Ensure no extra space from table elements */
70+
.main-table-container * {
71+
box-sizing: border-box;
72+
}
73+
74+
/* Ensure pagination doesn't create extra space */
75+
.table-wrapper > div:last-child {
76+
margin-bottom: 0;
77+
padding-bottom: 0;
78+
}
79+
2480
.main-table-container {
2581
width: 100%;
2682
border: 1px solid #d9d9d9;
@@ -30,6 +86,9 @@
3086
border-radius: 12px;
3187
overflow: hidden;
3288
table-layout: fixed;
89+
min-width: 900px; /* Ensure minimum width to prevent content trimming */
90+
margin: 0; /* Remove any margin */
91+
padding: 0; /* Remove any padding */
3392
}
3493

3594
/* Ensure table cells don't wrap content */
@@ -144,6 +203,10 @@
144203
vertical-align: middle;
145204
box-sizing: border-box;
146205
text-align: left;
206+
white-space: nowrap;
207+
overflow: hidden;
208+
text-overflow: ellipsis;
209+
min-width: 100px; /* Minimum width to prevent content trimming */
147210
}
148211

149212
.main-table-container tr:last-child td {
@@ -178,25 +241,29 @@
178241
align-items: center;
179242
padding: 1rem;
180243
gap: 1rem;
244+
flex-wrap: nowrap; /* Prevent wrapping on larger screens */
181245
}
182246

183247
.search-bar-left {
184248
display: flex;
185249
align-items: center;
186250
gap: 1rem;
187251
flex: 1;
252+
min-width: 0; /* Allow shrinking */
188253
}
189254

190255
.search-bar-right {
191256
display: flex;
192257
gap: 0.5rem;
193-
flex-shrink: 0;
258+
flex-shrink: 0; /* Prevent shrinking */
259+
align-items: center;
194260
}
195261

196262
.table-title-container {
197263
display: flex;
198264
flex-direction: column;
199265
gap: 0.25rem;
266+
flex-shrink: 0; /* Prevent title from shrinking */
200267
}
201268

202269
.table-subtitle {
@@ -211,9 +278,10 @@
211278
position: relative;
212279
width: 100%;
213280
height: 48px;
214-
min-width: 0;
281+
min-width: 200px; /* Minimum width for search */
215282
max-width: 400px;
216283
flex: 1;
284+
min-width: 0; /* Allow shrinking below 200px when needed */
217285
}
218286

219287
.search-input-icon {
@@ -250,23 +318,176 @@
250318
opacity: 1;
251319
}
252320

253-
/* Responsive design with better breakpoints */
321+
/* Responsive design with comprehensive breakpoints */
254322
@media (max-width: 768px) {
323+
/* Tablet and smaller - Title on first line, search bar and buttons on second line */
255324
.search-bar-container {
256325
flex-direction: column;
257326
align-items: stretch;
327+
gap: 1rem;
258328
}
259329

260330
.search-bar-left {
261-
flex-direction: column;
262-
align-items: stretch;
331+
width: 100%;
263332
}
264333

334+
.search-bar-right {
335+
width: 100%;
336+
justify-content: space-between;
337+
gap: 1rem;
338+
}
339+
265340
.search-input-container {
266341
max-width: none;
342+
min-width: 200px;
343+
flex: 1;
344+
}
345+
346+
347+
/* Ensure table scrolls horizontally on mobile */
348+
.table-responsive-container {
349+
overflow-x: auto;
350+
min-width: 900px; /* Match table minimum width */
351+
}
352+
353+
/* Ensure table headers and cells don't break */
354+
.main-table-container th,
355+
.main-table-container td {
356+
white-space: nowrap;
357+
overflow: hidden;
358+
text-overflow: ellipsis;
359+
min-width: 120px; /* Minimum width for mobile */
360+
}
361+
362+
/* Adjust column widths for mobile */
363+
.main-table-container th:nth-child(1),
364+
.main-table-container td:nth-child(1) {
365+
min-width: 150px; /* Resource Type */
366+
}
367+
368+
.main-table-container th:nth-child(2),
369+
.main-table-container td:nth-child(2) {
370+
min-width: 120px; /* Name */
371+
}
372+
373+
.main-table-container th:nth-child(3),
374+
.main-table-container td:nth-child(3) {
375+
min-width: 140px; /* Date & Time */
376+
}
377+
378+
.main-table-container th:nth-child(4),
379+
.main-table-container td:nth-child(4) {
380+
min-width: 100px; /* Status */
381+
}
382+
383+
.main-table-container th:nth-child(5),
384+
.main-table-container td:nth-child(5) {
385+
min-width: 120px; /* Orchestration */
267386
}
268387

388+
.main-table-container th:nth-child(6),
389+
.main-table-container td:nth-child(6) {
390+
min-width: 100px; /* Actions */
391+
}
392+
}
393+
394+
/* Small mobile devices */
395+
@media (max-width: 480px) {
396+
.search-bar-container {
397+
padding: 0.75rem;
398+
gap: 0.75rem;
399+
}
400+
401+
.search-bar-left {
402+
width: 100%;
403+
}
404+
405+
.search-bar-right {
406+
width: 100%;
407+
justify-content: space-between;
408+
gap: 0.5rem;
409+
}
410+
411+
.search-input-container {
412+
height: 44px; /* Slightly smaller on very small screens */
413+
min-width: 120px; /* Further reduced minimum width for very small screens */
414+
flex: 1;
415+
}
416+
417+
.search-input {
418+
height: 44px;
419+
font-size: 13px;
420+
}
421+
}
422+
423+
/* ≤ 1024 px – turn the whole header into a 2‑row grid */
424+
@media (max-width: 1024px) {
425+
.search-bar-container {
426+
display: grid;
427+
grid-template-columns: 1fr auto; /* search grows, buttons = auto */
428+
grid-template-areas:
429+
"title title" /* row 1: title full‑width */
430+
"search buttons"; /* row 2: search + buttons */
431+
gap: 1rem;
432+
align-items: center;
433+
}
434+
435+
/* let the children of .search-bar-left take part in the grid */
436+
.search-bar-left {
437+
display: contents; /* no box of its own */
438+
}
439+
440+
/* name each piece */
441+
.table-title-container { grid-area: title; }
442+
.search-input-container { grid-area: search; }
443+
444+
/* push buttons to the right */
445+
.search-bar-right {
446+
grid-area: buttons;
447+
justify-self: end; /* align right edge */
448+
}
449+
}
450+
451+
/* Large desktop breakpoint */
452+
@media (min-width: 1025px) {
453+
.search-bar-container {
454+
flex-direction: row;
455+
align-items: center;
456+
}
457+
}
458+
459+
/* Tablet and smaller breakpoint */
460+
@media (max-width: 1024px) {
461+
.search-bar-container > * {
462+
margin-bottom: 0.5rem;
463+
}
464+
465+
.search-bar-left,
269466
.search-bar-right {
270-
justify-content: center;
467+
width: 100%;
468+
}
469+
}
470+
471+
@media (max-width: 768px) {
472+
.search-input-container {
473+
max-width: 350px;
474+
}
475+
}
476+
477+
/* Medium desktop breakpoint */
478+
@media (max-width: 1200px) and (min-width: 1025px) {
479+
.search-input-container {
480+
max-width: 350px; /* Slightly reduced for medium screens */
481+
}
482+
483+
.table-responsive-container {
484+
overflow-x: auto;
485+
}
486+
487+
.main-table-container th,
488+
.main-table-container td {
489+
white-space: nowrap;
490+
overflow: hidden;
491+
text-overflow: ellipsis;
271492
}
272493
}

0 commit comments

Comments
 (0)