From f92d24e89c3f7abd3d8fff6ba681f94d3188e01f Mon Sep 17 00:00:00 2001 From: Evgeny Chaban Date: Mon, 2 Oct 2023 18:24:55 +0300 Subject: [PATCH 1/3] feat(sidebar): add sidebar indicator --- src/theme/css/chrome.css | 29 +++++++++++++++++++++-------- src/theme/css/variables.css | 2 ++ src/theme/index.hbs | 4 +++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/theme/css/chrome.css b/src/theme/css/chrome.css index 2314f7a1..5ff3c232 100644 --- a/src/theme/css/chrome.css +++ b/src/theme/css/chrome.css @@ -422,22 +422,35 @@ ul#searchresults span.teaser em { position: absolute; cursor: col-resize; width: 0; - right: 0; + right: calc(var(--sidebar-resize-indicator-width) * -1); top: 0; bottom: 0; + display: flex; + align-items: center; +} + +.sidebar-resize-handle .sidebar-resize-indicator { + width: 100%; + height: 12px; + background-color: var(--icons); + margin-inline-start: var(--sidebar-resize-indicator-space); +} + +[dir=rtl] .sidebar .sidebar-resize-handle { + left: calc(var(--sidebar-resize-indicator-width) * -1); + right: unset; } -[dir=rtl] .sidebar .sidebar-resize-handle { right: unset; left: 0; } .js .sidebar .sidebar-resize-handle { cursor: col-resize; - width: 5px; + width: calc(var(--sidebar-resize-indicator-width) - var(--sidebar-resize-indicator-space)); } /* sidebar-hidden */ #sidebar-toggle-anchor:not(:checked) ~ .sidebar { - transform: translateX(calc(0px - var(--sidebar-width))); + transform: translateX(calc(0px - var(--sidebar-width) - var(--sidebar-resize-indicator-width))); z-index: -1; } [dir=rtl] #sidebar-toggle-anchor:not(:checked) ~ .sidebar { - transform: translateX(var(--sidebar-width)); + transform: translateX(var(--sidebar-width) + var(--sidebar-resize-indicator-width)); } .sidebar::-webkit-scrollbar { background: var(--sidebar-bg); @@ -448,15 +461,15 @@ ul#searchresults span.teaser em { /* sidebar-visible */ #sidebar-toggle-anchor:checked ~ .page-wrapper { - transform: translateX(var(--sidebar-width)); + transform: translateX(var(--sidebar-width) + var(--sidebar-resize-indicator-width)); } [dir=rtl] #sidebar-toggle-anchor:checked ~ .page-wrapper { - transform: translateX(calc(0px - var(--sidebar-width))); + transform: translateX(calc(0px - var(--sidebar-width) - var(--sidebar-resize-indicator-width))); } @media only screen and (min-width: 620px) { #sidebar-toggle-anchor:checked ~ .page-wrapper { transform: none; - margin-inline-start: var(--sidebar-width); + margin-inline-start: calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width)); } [dir=rtl] #sidebar-toggle-anchor:checked ~ .page-wrapper { transform: none; diff --git a/src/theme/css/variables.css b/src/theme/css/variables.css index 10a75909..0da55e8c 100644 --- a/src/theme/css/variables.css +++ b/src/theme/css/variables.css @@ -3,6 +3,8 @@ :root { --sidebar-width: 300px; + --sidebar-resize-indicator-width: 8px; + --sidebar-resize-indicator-space: 2px; --page-padding: 15px; --content-max-width: 750px; --menu-bar-height: 50px; diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 2ee58c62..080b7851 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -112,7 +112,9 @@ - + From 8e8fd2717ed72739eb5b40601e311c022ba4c99e Mon Sep 17 00:00:00 2001 From: Evgeny Chaban Date: Wed, 4 Oct 2023 01:40:16 +0300 Subject: [PATCH 2/3] fix(style): use calc function --- src/theme/css/chrome.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/theme/css/chrome.css b/src/theme/css/chrome.css index 5ff3c232..ff4b3c06 100644 --- a/src/theme/css/chrome.css +++ b/src/theme/css/chrome.css @@ -450,7 +450,7 @@ ul#searchresults span.teaser em { z-index: -1; } [dir=rtl] #sidebar-toggle-anchor:not(:checked) ~ .sidebar { - transform: translateX(var(--sidebar-width) + var(--sidebar-resize-indicator-width)); + transform: translateX(calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width))); } .sidebar::-webkit-scrollbar { background: var(--sidebar-bg); @@ -461,7 +461,7 @@ ul#searchresults span.teaser em { /* sidebar-visible */ #sidebar-toggle-anchor:checked ~ .page-wrapper { - transform: translateX(var(--sidebar-width) + var(--sidebar-resize-indicator-width)); + transform: translateX(calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width))); } [dir=rtl] #sidebar-toggle-anchor:checked ~ .page-wrapper { transform: translateX(calc(0px - var(--sidebar-width) - var(--sidebar-resize-indicator-width))); From 80d3a86468c8f6b0be720e9fa7aaf629bd9e0f44 Mon Sep 17 00:00:00 2001 From: Evgeny Chaban Date: Wed, 4 Oct 2023 01:55:20 +0300 Subject: [PATCH 3/3] fix: hide resize indicator on devices with limited accuracy --- src/theme/css/chrome.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/theme/css/chrome.css b/src/theme/css/chrome.css index ff4b3c06..d3c09c8a 100644 --- a/src/theme/css/chrome.css +++ b/src/theme/css/chrome.css @@ -269,6 +269,11 @@ pre > .buttons button { /* On mobile, make it easier to tap buttons. */ padding: 0.3rem 1rem; } + + .sidebar-resize-indicator { + /* Hide resize indicator on devices with limited accuracy */ + display: none; + } } pre > code { padding: 1rem;