Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): stack the infrastructure cards below 1200px

Yudhi Armyndharis36ab1c153a26
diff --git a/dashboard/src/pages/Infrastructure.css b/dashboard/src/pages/Infrastructure.css
index da666e062..953878181 100644
--- a/dashboard/src/pages/Infrastructure.css
+++ b/dashboard/src/pages/Infrastructure.css
@@ -385,11 +385,15 @@
}
/* Responsive */
-@media (max-width: 900px) {
+/* Two columns of cards need 1035px of viewport with the sidebar open (1190px in German, whose labels are
+ wider); below that they stack. */
+@media (max-width: 1200px) {
.infrastructure-page .infra-sections {
grid-template-columns: 1fr;
}
+}
+@media (max-width: 900px) {
.infrastructure-page {
padding: 1rem;
}
diff --git a/dashboard/src/pages/Infrastructure.responsive.test.ts b/dashboard/src/pages/Infrastructure.responsive.test.ts
new file mode 100644
index 000000000..508387d37
--- /dev/null
+++ b/dashboard/src/pages/Infrastructure.responsive.test.ts
@@ -0,0 +1,18 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { decl, readRules } from '../test-helpers/css-rules.ts';
+
+// The two columns of cards need 1035px of viewport with the sidebar open (the widest card holds a form row that is
+// 378px wide at its narrowest) and 1190px in German, whose labels are wider. Down to 900px the page spilled past
+// the window (41px at 960px), and the right-hand card lost its edge and its badge. Below 1200px the cards stack.
+const rules = readRules(new URL('./Infrastructure.css', import.meta.url));
+
+test('the infrastructure cards stack before the columns overflow', () => {
+ const stacked = rules.filter(
+ r =>
+ r.selectors.includes('.infrastructure-page .infra-sections') && decl(r.body, 'grid-template-columns') === '1fr',
+ );
+ assert.equal(stacked.length, 1, 'expected one rule that stacks the cards');
+ const width = Number(/max-width: (\d+)px/.exec(stacked[0].media)?.[1]);
+ assert.ok(width >= 1200, `the cards stack at ${stacked[0].media || 'every width'}`);
+});