Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): stack the template columns before they overflow
Yudhi Armyndharis3b797620ebbb
diff --git a/dashboard/src/pages/Templates.css b/dashboard/src/pages/Templates.cssindex e139051ff..dace30582 100644--- a/dashboard/src/pages/Templates.css+++ b/dashboard/src/pages/Templates.css@@ -419,7 +419,8 @@color: var(--error-text);}-@media (max-width: 1280px) {+/* Three columns need 1286px of viewport with the sidebar open. */+@media (max-width: 1290px) {.templates-page .templates-workspace {grid-template-columns: 280px minmax(380px, 1fr);}@@ -441,16 +442,8 @@}}-@media (max-width: 900px) {- .templates-page {- padding: 1rem;- }-- .templates-page .templates-session-select {- min-width: 0;- width: 100%;- }-+/* Stacked below 1000px: two columns need 984px of viewport with the sidebar open. */+@media (max-width: 1000px) {.templates-page .templates-workspace {display: flex;flex-direction: column;@@ -474,6 +467,17 @@}}+@media (max-width: 900px) {+ .templates-page {+ padding: 1rem;+ }++ .templates-page .templates-session-select {+ min-width: 0;+ width: 100%;+ }+}+@media (max-width: 640px) {.templates-page .templates-library-header,.templates-page .template-editor-header,diff --git a/dashboard/src/pages/Templates.responsive.test.ts b/dashboard/src/pages/Templates.responsive.test.tsnew file mode 100644index 000000000..f9274fb28--- /dev/null+++ b/dashboard/src/pages/Templates.responsive.test.ts@@ -0,0 +1,24 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { decl, readRules } from '../test-helpers/css-rules.ts';++// The workspace is clipped by its own rounded frame, so a column that does not fit lost its right edge. Its minimum+// tracks (280 + 380px, or 260 + 420 + 280px) plus the two border pixels and the 324px that the sidebar and the page+// padding take need 984px of viewport for two columns and 1286px for three.+const rules = readRules(new URL('./Templates.css', import.meta.url));+const WORKSPACE = '.templates-page .templates-workspace';+const widthOf = (media: string): number => Number(/max-width: (\d+)px/.exec(media)?.[1]);++test('the template columns stack before two of them overflow', () => {+ const stacked = rules.filter(r => r.selectors.includes(WORKSPACE) && decl(r.body, 'flex-direction') === 'column');+ assert.equal(stacked.length, 1, 'expected one rule that stacks the workspace');+ assert.ok(widthOf(stacked[0].media) >= 1000, `the workspace stacks at ${stacked[0].media || 'every width'}`);+});++test('the workspace keeps two columns until three of them fit', () => {+ const two = rules.filter(+ r => r.selectors.includes(WORKSPACE) && decl(r.body, 'grid-template-columns')?.startsWith('280px'),+ );+ assert.equal(two.length, 1, 'expected one rule for the two-column workspace');+ assert.ok(widthOf(two[0].media) >= 1286, `two columns apply at ${two[0].media || 'every width'}`);+});