Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): make the install dialog header a grid
Yudhi Armyndharis524f0c93db9f
diff --git a/dashboard/src/pages/Plugins.css b/dashboard/src/pages/Plugins.cssindex 67b258047..a9915ecc2 100644--- a/dashboard/src/pages/Plugins.css+++ b/dashboard/src/pages/Plugins.css@@ -838,35 +838,43 @@border-radius: 10px;}-/* When the tabs sit INSIDE the install modal header (between the title and the close button), drop- the standalone-row margins so they don't push the title up / leave a gap. On a narrow viewport they- take a row of their own under the title and the close button (flex-wrap on the header). */+/* Three-item header (title + tabs + close). On a narrow viewport the tabs take a row of their own under the+ title and the close button (flex-wrap on the header), without the standalone-row margins that would push+ the title up or leave a gap. */+.plugins-page .install-modal .modal-header {+ flex-wrap: wrap;+ row-gap: 0.75rem;+}+.plugins-page .install-modal .modal-header .install-tabs {margin: 0;order: 3;width: 100%;}-/* Where the header has room beside the longest title, pin the tabs to its true horizontal center with- absolute positioning: justify-content:space-between only centers them approximately because the- title (left) and close button (right) have different widths, leaving the pill visibly off-center. An- absolutely positioned box takes no part in wrapping, so below this width it would cover the title. */+/* From 700px the header is three tracks: the middle one as wide as the tabs, the outer two sharing the rest+ equally. That puts the tabs in the true horizontal center (justify-content:space-between only+ approximates it, as the title and the close button differ in width) and cuts a long title inside its own+ track, where absolute positioning let it run under the tabs. */@media (min-width: 700px) {+ .plugins-page .install-modal .modal-header {+ display: grid;+ grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);+ align-items: center;+ }+.plugins-page .install-modal .modal-header .install-tabs {order: 0;width: auto;- position: absolute;- left: 50%;- top: 50%;- transform: translate(-50%, -50%);+ /* Out of the row height, so a tall pill (a label that wraps) does not grow the header, and centered in+ the header's padding box (1.5rem above the row, 1rem below it) as the absolute positioning it+ replaces had it: 0.25rem above the center of the row. */+ margin-block: -3.25rem -2.75rem;}-}-/* Three-item header (title + tabs + close). Position:relative anchors the absolutely-centered pill. */-.plugins-page .install-modal .modal-header {- position: relative;- flex-wrap: wrap;- row-gap: 0.75rem;+ .plugins-page .install-modal .modal-header .btn-icon {+ justify-self: end;+ }}.plugins-page .install-modal .modal-header h2 {diff --git a/dashboard/src/pages/Plugins.responsive.test.ts b/dashboard/src/pages/Plugins.responsive.test.tsindex 0b227667b..623eb3495 100644--- a/dashboard/src/pages/Plugins.responsive.test.ts+++ b/dashboard/src/pages/Plugins.responsive.test.ts@@ -4,15 +4,37 @@ import { decl, readRules } from '../test-helpers/css-rules.ts';const rules = readRules(new URL('./Plugins.css', import.meta.url));-// The Upload/Catalog pill in the install modal header. Centred with absolute positioning it takes no part in-// flex-wrap, so on a phone it was drawn over the title ("Insta" and a tab). It is centred only where the header-// has room beside the longest translated title, and takes a row of its own below that.-const PILL = '.plugins-page .install-modal .modal-header .install-tabs';+// The Upload/Catalog pill in the install modal header. Centred with absolute positioning it took no part in+// flex-wrap, so on a phone it was drawn over the title ("Insta" and a tab), and it took no part in sizing the+// title either, so a long translated title (Telugu) ran under it at every width. From 700px the header is three+// tracks with the pill in the middle one, so the title is cut inside its own track; below that the pill takes a+// row of its own.+const HEADER = '.plugins-page .install-modal .modal-header';+const PILL = `${HEADER} .install-tabs`;-test('the install tabs are centred over the header only on wide screens', () => {- const centred = rules.filter(r => r.selectors.includes(PILL) && decl(r.body, 'position') === 'absolute');- assert.equal(centred.length, 1, 'expected one rule that pins the pill');- assert.equal(centred[0].media, '@media (min-width: 700px)');+test('from 700px the install header is a grid with the tabs in the middle track', () => {+ const grids = rules.filter(r => r.selectors.includes(HEADER) && decl(r.body, 'display') === 'grid');+ assert.equal(grids.length, 1, 'expected one rule that makes the header a grid');+ assert.equal(grids[0].media, '@media (min-width: 700px)');+ assert.equal(decl(grids[0].body, 'grid-template-columns'), 'minmax(0, 1fr) auto minmax(0, 1fr)');+});++test('the install tabs are not positioned out of the header', () => {+ for (const rule of rules.filter(r => r.selectors.includes(PILL))) {+ assert.equal(decl(rule.body, 'position'), undefined, `${rule.media || 'base'} positions the pill`);+ }+});++test('the close button stays in the end track and the title is cut inside its own', () => {+ const close = rules.filter(+ r => r.selectors.includes(`${HEADER} .btn-icon`) && decl(r.body, 'justify-self') === 'end',+ );+ assert.equal(close.length, 1, 'no rule keeps the close button at the end of the header');+ assert.equal(close[0].media, '@media (min-width: 700px)');+ const title = rules.find(r => !r.media && r.selectors.includes(`${HEADER} h2`));+ assert.ok(title, 'no title rule');+ assert.equal(decl(title.body, 'min-width'), '0');+ assert.equal(decl(title.body, 'text-overflow'), 'ellipsis');});test('below that the install tabs wrap to a row of their own', () => {