From dc275b8ff6fea154056774c659810ba4115415c9 Mon Sep 17 00:00:00 2001 From: Imants Date: Thu, 23 Jul 2026 20:17:48 +0300 Subject: [PATCH 1/7] feat: adapt snippets shell for mobile --- src/css/common/_page-header.scss | 17 ++++++ src/css/common/_subnav.scss | 30 +++++++++- src/css/common/_theme.scss | 2 + src/css/common/_toolbar.scss | 59 ++++++++++++++++++- .../SnippetsTable/SnippetsTable.tsx | 35 ++++++----- src/js/components/common/Toolbar.tsx | 5 +- tests/e2e/code-snippets-mobile.spec.ts | 43 ++++++++++++++ 7 files changed, 171 insertions(+), 20 deletions(-) create mode 100644 tests/e2e/code-snippets-mobile.spec.ts diff --git a/src/css/common/_page-header.scss b/src/css/common/_page-header.scss index 81a8c10e0..d25a0ae71 100644 --- a/src/css/common/_page-header.scss +++ b/src/css/common/_page-header.scss @@ -43,3 +43,20 @@ text-decoration: underline; } } + +@media (width <= 480px) { + .snippets-page-header { + align-items: flex-start; + flex-direction: column; + gap: 16px; + margin-block: 17px 24px; + margin-inline: 8px; + + h1, + h2 { + font-size: 28px; + font-weight: 590; + letter-spacing: -0.56px; + } + } +} diff --git a/src/css/common/_subnav.scss b/src/css/common/_subnav.scss index 4b5ecf5fa..78842b8e9 100644 --- a/src/css/common/_subnav.scss +++ b/src/css/common/_subnav.scss @@ -11,7 +11,7 @@ // The toolbar band above already draws the 1px separator, so only a // bottom border here — a top border would double the line weight. - border-block-end: 1px solid #e2e2e4; + border-block-end: 1px solid theme.$border-light; min-block-size: 53px; // Bleed across the full admin content width, flush against the plugin @@ -88,7 +88,7 @@ color: #646970; text-decoration: none; box-sizing: border-box; - border-inline-end: 1px solid #e2e2e4; + border-inline-end: 1px solid theme.$border-light; // The text-only "All Snippets" tab uses a slightly wider gap between // its label and count than tabs that lead with a badge or icon. @@ -138,6 +138,14 @@ } +.snippet-type-nav-container { + position: relative; +} + +.snippet-type-nav-fade { + display: none; +} + // Card/table view toggle: a two-icon segmented pair of square tiles with // the active view filled in the accent colour. .snippet-view-toggle { @@ -240,3 +248,21 @@ margin-block-start: 20px; border-block-start: 1px solid theme.$control-border; } + +@media (width <= 480px) { + .snippet-type-nav-fade { + display: block; + position: absolute; + z-index: 1; + inset-block-start: -10px; + inset-inline-end: -12px; + inline-size: 66px; + block-size: 52px; + background: linear-gradient(90deg, rgb(255 255 255 / 0%), #fff); + pointer-events: none; + } + + .snippets-screen-meta-slot { + display: none; + } +} diff --git a/src/css/common/_theme.scss b/src/css/common/_theme.scss index a836dce51..3c266010e 100644 --- a/src/css/common/_theme.scss +++ b/src/css/common/_theme.scss @@ -12,6 +12,8 @@ $cloud-update: #ff9800; // Plugin admin control tokens, applied to native form controls on all plugin // screens regardless of WordPress version (see common/_wp-admin.scss). $accent-hover: #0a4b78; +$background-light: #f7f7f8; +$border-light: #e2e2e4; $control-border: #c3c4c7; $control-text: #2c3338; $control-height: 38px; diff --git a/src/css/common/_toolbar.scss b/src/css/common/_toolbar.scss index 2fe2b16d2..935e88953 100644 --- a/src/css/common/_toolbar.scss +++ b/src/css/common/_toolbar.scss @@ -66,7 +66,7 @@ $wpcontent-inline-start-indent: 20px; } .code-snippets-toolbar-lower { - border-block-end: 1px solid #e2e2e4; + border-block-end: 1px solid theme.$border-light; block-size: 60px; box-sizing: border-box; @@ -201,3 +201,60 @@ $wpcontent-inline-start-indent: 20px; .code-snippets-return-link { float: inline-end; } + +@media (width <= 480px) { + #wpbody { + padding-block-start: 143px; + } + + .code-snippets-toolbar { + block-size: 143px; + } + + .code-snippets-toolbar-upper nav { + display: none; + } + + .code-snippets-toolbar-lower { + block-size: 67px; + + nav { + overflow-x: auto; + scrollbar-width: none; + + &::-webkit-scrollbar { + display: none; + } + } + + ul { + min-inline-size: 100%; + } + + li { + flex: 1 0 92px; + } + + li a { + inline-size: 100%; + padding-block: 8px; + padding-inline: 12px; + gap: 4px; + border-block-end: 3px solid transparent; + font-size: 14px; + font-weight: 700; + + &.active-link { + border-block-end-color: theme.$accent; + } + } + + li:not(.toolbar-end-item) + li.toolbar-end-item { + margin-inline-start: 0; + } + + .cloud-library-item { + display: none; + } + } +} diff --git a/src/js/components/ManageMenu/SnippetsTable/SnippetsTable.tsx b/src/js/components/ManageMenu/SnippetsTable/SnippetsTable.tsx index e129d949b..dd80f92f5 100644 --- a/src/js/components/ManageMenu/SnippetsTable/SnippetsTable.tsx +++ b/src/js/components/ManageMenu/SnippetsTable/SnippetsTable.tsx @@ -123,24 +123,27 @@ const SnippetsTableInner = () => { return ( <> - +