Skip to content

Commit fb7403e

Browse files
committed
optimized panel responsive to show better in mobile
1 parent c4f5662 commit fb7403e

File tree

7 files changed

+113
-7
lines changed

7 files changed

+113
-7
lines changed

app/Helpers/Helper.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ function lastCrump()
323323
echo '<li >
324324
<a>
325325
<i class="ri-folder-chart-line" ></i>
326-
' . __(ucfirst($routes[count($routes) - 1])) . '
326+
<span>' . __(ucfirst($routes[count($routes) - 1])) . '</span>
327327
</a>
328328
</li>';
329329
return;
@@ -337,7 +337,7 @@ function lastCrump()
337337
echo '<li >
338338
<a>
339339
<i class="ri-list-check" ></i>
340-
' . __(Str::plural(ucfirst($routes[count($routes) - 2]))) . '
340+
<span>' . __(Str::plural(ucfirst($routes[count($routes) - 2]))) . '</span>
341341
</a>
342342
</li>';
343343
} else {
@@ -349,7 +349,7 @@ function lastCrump()
349349
echo '<li>
350350
<a href="' . $link . '">
351351
<i class="ri-list-check" ></i>
352-
' . __(ucfirst(Str::plural($routes[count($routes) - 2]))) . '
352+
<span>' . __(ucfirst(Str::plural($routes[count($routes) - 2]))) . '</span>
353353
</a>
354354
</li>';
355355
switch ($route) {
@@ -386,7 +386,7 @@ function lastCrump()
386386
echo '<li>
387387
<a>
388388
<i class="' . $icon . '" ></i>
389-
' . $title . '
389+
<span> ' . $title . ' </span>
390390
</a>
391391
</li>';
392392
}

resources/js/app.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import './panel/setting-section-controller.js';
3030
import './panel/sotable-controller.js';
3131
import './panel/prototypes.js';
3232
import './panel/panel-window-loader.js';
33+
import './panel/responsive-control.js';
3334

3435
// chartjs.defaults.defaultFontFamily = "Vazir";
3536
// chartjs.defaults.defaultFontSize = 18;
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const responsiveControl = function () {
2+
let vpw = document.querySelector('body').clientWidth; // view port width
3+
4+
if (document.querySelectorAll('.table-list').length > 0) {
5+
if (vpw > 620) {
6+
document.querySelectorAll('.table-list span.th')?.forEach(function (el) {
7+
el.remove();
8+
})
9+
} else {
10+
if (document.querySelectorAll('.table-list span.th')?.length === 0) {
11+
12+
document.querySelectorAll('.table-list')?.forEach(function (table) {
13+
14+
console.log(table);
15+
// Get all the header cells
16+
const headers = Array.from(table.querySelectorAll('th')).map(th => th.textContent.trim());
17+
18+
// Get all the rows in the table, excluding the header row
19+
const rows = table.querySelectorAll('tr');
20+
21+
rows.forEach(function (row) {
22+
const cells = row.querySelectorAll('td');
23+
24+
cells.forEach(function (cell, index) {
25+
const headerText = headers[index]; // Get the corresponding header for this cell
26+
if (headerText.trim() != ''){
27+
cell.innerHTML = `<span class="th float-start"> ${headerText}: </span> ${cell.innerHTML}`; // Update the cell content
28+
}
29+
});
30+
});
31+
});
32+
33+
34+
}
35+
}
36+
}
37+
};
38+
window.addEventListener('resize', responsiveControl);
39+
window.addEventListener('load', responsiveControl)

resources/sass/panel/_breadcrumbs.scss

+25
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,28 @@ $pnl-brc-height: 50px;
6161
}
6262

6363
}
64+
65+
/*-500px width*/
66+
@media (max-width: 600px) {
67+
#panel-breadcrumb{
68+
display: block;
69+
li{
70+
text-align: end;
71+
}
72+
73+
span{
74+
display: none !important;
75+
}
76+
i{
77+
margin: 0;
78+
display: inline-block;
79+
}
80+
a{
81+
justify-content: end !important;
82+
padding-right: 0 !important;
83+
padding-left: 0 !important;
84+
}
85+
}
86+
87+
88+
}

resources/sass/panel/_common.scss

+38
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,41 @@ a.btn,a.action-btn,a.circle-btn{
338338
.btn-light,a.btn-light{
339339
color: black !important;
340340
}
341+
/* -620px width */
342+
@media (max-width: 620px) {
343+
.table-list {
344+
position: relative; /* Ensure this is the direct container */
345+
overflow: auto; /* Allow scrolling */
346+
}
347+
348+
tr, td, th {
349+
display: block;
350+
width: 100% !important;
351+
text-align: end;
352+
}
353+
td{
354+
display: flex;
355+
justify-content: space-between;
356+
align-items: center;
357+
}
358+
td:last-child{
359+
justify-content: center;
360+
}
361+
362+
div.float-start, div.float-end {
363+
float: none !important;
364+
}
365+
366+
.dropdown{
367+
min-width: 75%;
368+
.btn{
369+
width: 100%;
370+
}
371+
}
372+
373+
thead {
374+
display: none;
375+
}
376+
377+
378+
}

resources/views/admin/templates/panel-list-template.blade.php

-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ class="form-check form-switch mt-1 mx-2">
133133
@endforeach
134134
{{-- @yield('table-head')--}}
135135
<th>
136-
137136
</th>
138137
</tr>
139138
</thead>

resources/views/components/panel-breadcrumb.blade.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
<li>
44
<a href="{{url('/')}}" target="_blank">
55
<i class="ri-home-3-line"></i>
6-
{{config('app.name')}}
6+
<span>
7+
{{config('app.name')}}
8+
</span>
79
</a>
810
</li>
911
<li>
1012
<a href="{{route('admin.home')}}">
1113
<i class="ri-dashboard-3-line"></i>
12-
{{__("Dashboard")}}
14+
<span>
15+
{{__("Dashboard")}}
16+
</span>
1317
</a>
1418
</li>
1519
{{lastCrump()}}

0 commit comments

Comments
 (0)