Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): show the sessions table as cards up to 1200px

Yudhi Armyndharisb2472df171bf
diff --git a/dashboard/src/pages/Dashboard.css b/dashboard/src/pages/Dashboard.css
index 6edde54f6..5bd5e345b 100644
--- a/dashboard/src/pages/Dashboard.css
+++ b/dashboard/src/pages/Dashboard.css
@@ -296,34 +296,9 @@
.dashboard .stats-grid {
grid-template-columns: repeat(2, 1fr);
}
-}
-
-@media (max-width: 768px) {
- .dashboard {
- padding: 1rem;
- }
-
- .dashboard .stats-grid {
- grid-template-columns: 1fr;
- gap: 1rem;
- }
-
- .dashboard .stat-value {
- font-size: 1.5rem;
- }
-
- .dashboard .sessions-section {
- padding: 1rem;
- }
-
- .dashboard .section-header {
- flex-direction: column;
- align-items: flex-start;
- gap: 0.5rem;
- margin-bottom: 1rem;
- }
- /* Convert table to card layout on mobile */
+ /* Convert table to card layout wherever its fixed columns do not fit: they need about 1150px of
+ viewport with the sidebar open. */
.dashboard .sessions-table .table-header {
display: none;
}
@@ -371,6 +346,32 @@
}
}
+@media (max-width: 768px) {
+ .dashboard {
+ padding: 1rem;
+ }
+
+ .dashboard .stats-grid {
+ grid-template-columns: 1fr;
+ gap: 1rem;
+ }
+
+ .dashboard .stat-value {
+ font-size: 1.5rem;
+ }
+
+ .dashboard .sessions-section {
+ padding: 1rem;
+ }
+
+ .dashboard .section-header {
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 0.5rem;
+ margin-bottom: 1rem;
+ }
+}
+
@media (max-width: 480px) {
.dashboard {
padding: 0.75rem;
diff --git a/dashboard/src/pages/Dashboard.responsive.test.ts b/dashboard/src/pages/Dashboard.responsive.test.ts
new file mode 100644
index 000000000..bb965cf16
--- /dev/null
+++ b/dashboard/src/pages/Dashboard.responsive.test.ts
@@ -0,0 +1,23 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { decl, readRules } from '../test-helpers/css-rules.ts';
+
+// The sessions table has fixed 140, 200, 140 and 180 px tracks, so with the 260 px sidebar open the last column
+// ran out of the card and the page from 769px up to about 1135px, and the flexible one was squeezed to a sliver
+// up to about 1240px. It turns into cards, as it does on a phone, wherever those tracks do not fit.
+const rules = readRules(new URL('./Dashboard.css', import.meta.url));
+const ROW = '.dashboard .sessions-table .table-row';
+
+test('the sessions table turns into cards at 1200px and below', () => {
+ const cards = rules.filter(r => r.selectors.includes(ROW) && decl(r.body, 'display') === 'flex');
+ assert.equal(cards.length, 1, 'expected one rule that turns a table row into a card');
+ assert.equal(cards[0].media, '@media (max-width: 1200px)');
+});
+
+test('the table header goes away together with the columns', () => {
+ const hidden = rules.filter(
+ r => r.selectors.includes('.dashboard .sessions-table .table-header') && decl(r.body, 'display') === 'none',
+ );
+ assert.equal(hidden.length, 1);
+ assert.equal(hidden[0].media, '@media (max-width: 1200px)');
+});