Skip to content

Commit 1dd5450

Browse files
Feat/update responsive UI (#31)
1 parent 8c1d446 commit 1dd5450

File tree

7 files changed

+315
-33
lines changed

7 files changed

+315
-33
lines changed

example/src/styles/componentStyles.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,6 @@ export const createComponentStyles = (colors: any, theme: ThemeProps = {}) => {
348348
alignItems: 'center',
349349
gap: '24px',
350350
position: 'absolute',
351-
left: '50%',
352-
transform: 'translateX(-50%)',
353351
},
354352
totalItems: {
355353
fontSize: '0.875rem',

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/components/Pagination.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ export const Pagination: React.FC<PaginationProps> = ({
105105
display: 'flex',
106106
alignItems: 'center',
107107
gap: '24px',
108-
position: 'absolute',
109-
left: '50%',
110-
transform: 'translateX(-50%)'
108+
position: 'absolute'
111109
}}>
112110
{/* Total Items Text */}
113111
<div style={{ ...componentStyles.pagination.totalItems, position: 'static' }}>

src/styles/MultiLevelTable.css

Lines changed: 236 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,59 @@
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+
/* Ensure horizontal scroll works properly */
40+
white-space: nowrap;
41+
}
42+
43+
/* Custom scrollbar styling */
44+
.table-responsive-container::-webkit-scrollbar {
45+
height: 8px;
46+
}
47+
48+
.table-responsive-container::-webkit-scrollbar-track {
49+
background: #f1f1f1;
50+
border-radius: 4px;
51+
}
52+
53+
.table-responsive-container::-webkit-scrollbar-thumb {
54+
background: #c1c1c1;
55+
border-radius: 4px;
56+
}
57+
58+
.table-responsive-container::-webkit-scrollbar-thumb:hover {
59+
background: #a8a8a8;
1360
}
1461

1562
/* Ensure table container maintains proper spacing */
@@ -21,6 +68,20 @@
2168
padding: 0;
2269
}
2370

71+
/* Ensure no extra space from table elements */
72+
.main-table-container * {
73+
box-sizing: border-box;
74+
}
75+
76+
/* Ensure pagination doesn't create extra space */
77+
.table-wrapper > div:last-child {
78+
margin-bottom: 0;
79+
padding-bottom: 0;
80+
/* Ensure pagination maintains its layout on smaller screens */
81+
min-width: 1200px; /* Match table minimum width */
82+
overflow-x: auto; /* Allow horizontal scroll if needed */
83+
}
84+
2485
.main-table-container {
2586
width: 100%;
2687
border: 1px solid #d9d9d9;
@@ -30,6 +91,9 @@
3091
border-radius: 12px;
3192
overflow: hidden;
3293
table-layout: fixed;
94+
min-width: 1200px; /* Increased minimum width to ensure all content fits properly */
95+
margin: 0; /* Remove any margin */
96+
padding: 0; /* Remove any padding */
3397
}
3498

3599
/* Ensure table cells don't wrap content */
@@ -38,6 +102,8 @@
38102
white-space: nowrap;
39103
overflow: hidden;
40104
text-overflow: ellipsis;
105+
/* Prevent content from being truncated */
106+
min-width: 0;
41107
}
42108

43109
/* Column width distribution - spread across full width with end spacing for actions */
@@ -144,6 +210,10 @@
144210
vertical-align: middle;
145211
box-sizing: border-box;
146212
text-align: left;
213+
white-space: nowrap;
214+
overflow: hidden;
215+
text-overflow: ellipsis;
216+
min-width: 120px; /* Increased minimum width to prevent content trimming */
147217
}
148218

149219
.main-table-container tr:last-child td {
@@ -178,25 +248,29 @@
178248
align-items: center;
179249
padding: 1rem;
180250
gap: 1rem;
251+
flex-wrap: nowrap; /* Prevent wrapping on larger screens */
181252
}
182253

183254
.search-bar-left {
184255
display: flex;
185256
align-items: center;
186257
gap: 1rem;
187258
flex: 1;
259+
min-width: 0; /* Allow shrinking */
188260
}
189261

190262
.search-bar-right {
191263
display: flex;
192264
gap: 0.5rem;
193-
flex-shrink: 0;
265+
flex-shrink: 0; /* Prevent shrinking */
266+
align-items: center;
194267
}
195268

196269
.table-title-container {
197270
display: flex;
198271
flex-direction: column;
199272
gap: 0.25rem;
273+
flex-shrink: 0; /* Prevent title from shrinking */
200274
}
201275

202276
.table-subtitle {
@@ -211,9 +285,10 @@
211285
position: relative;
212286
width: 100%;
213287
height: 48px;
214-
min-width: 0;
288+
min-width: 200px; /* Minimum width for search */
215289
max-width: 400px;
216290
flex: 1;
291+
min-width: 0; /* Allow shrinking below 200px when needed */
217292
}
218293

219294
.search-input-icon {
@@ -250,23 +325,177 @@
250325
opacity: 1;
251326
}
252327

253-
/* Responsive design with better breakpoints */
328+
/* Responsive design with comprehensive breakpoints */
254329
@media (max-width: 768px) {
330+
/* Tablet and smaller - Title on first line, search bar and buttons on second line */
255331
.search-bar-container {
256332
flex-direction: column;
257333
align-items: stretch;
334+
gap: 1rem;
258335
}
259336

260337
.search-bar-left {
261-
flex-direction: column;
262-
align-items: stretch;
338+
width: 100%;
263339
}
264340

341+
.search-bar-right {
342+
width: 100%;
343+
justify-content: space-between;
344+
gap: 1rem;
345+
}
346+
265347
.search-input-container {
266348
max-width: none;
349+
min-width: 200px;
350+
flex: 1;
351+
}
352+
353+
354+
/* Ensure table scrolls horizontally on mobile */
355+
.table-responsive-container {
356+
overflow-x: auto;
357+
min-width: 1200px; /* Match table minimum width */
358+
}
359+
360+
/* Ensure table headers and cells don't break */
361+
.main-table-container th,
362+
.main-table-container td {
363+
white-space: nowrap;
364+
overflow: hidden;
365+
text-overflow: ellipsis;
366+
min-width: 120px; /* Minimum width for mobile */
367+
}
368+
369+
/* Adjust column widths for mobile - maintain exact same proportions */
370+
.main-table-container th:nth-child(1),
371+
.main-table-container td:nth-child(1) {
372+
min-width: 264px; /* Resource Type - 22% of 1200px */
373+
}
374+
375+
.main-table-container th:nth-child(2),
376+
.main-table-container td:nth-child(2) {
377+
min-width: 216px; /* Name - 18% of 1200px */
378+
}
379+
380+
.main-table-container th:nth-child(3),
381+
.main-table-container td:nth-child(3) {
382+
min-width: 216px; /* Date & Time - 18% of 1200px */
383+
}
384+
385+
.main-table-container th:nth-child(4),
386+
.main-table-container td:nth-child(4) {
387+
min-width: 144px; /* Status - 12% of 1200px */
267388
}
268389

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

0 commit comments

Comments
 (0)