diff --git a/src/css/injected.scss b/src/css/injected.scss index b78f8ca9..e537442b 100644 --- a/src/css/injected.scss +++ b/src/css/injected.scss @@ -661,92 +661,241 @@ html.bsplus-custom-title-pending #title > :not(#bsplus-title-root), height: 28px !important; } -/* Icon Only Sidebar - compact mode. When submenu is open, all styles are disabled so it behaves as normal sidebar. */ -body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) { +/* Icons-only keeps the root rail visible while a full submenu opens beside it. */ +body.icon-only-sidebar { + --bsplus-icon-rail-space: 70px; + #menu { width: 70px !important; - transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); overflow: visible !important; } #menu > ul { + position: static !important; min-width: 0 !important; - overflow-x: visible !important; + overflow-x: hidden !important; + overflow-y: auto !important; } #content { - left: 70px !important; - transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1); + left: var(--bsplus-icon-rail-space) !important; + /* Reserve the panel before its reveal so it never covers page content. */ + transition: none !important; } - #menu .sub { - left: 70px !important; - transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1); - } - - #menu li > label span, - #menu section > label span { - display: none !important; - } - - #menu ul > li > svg { - display: none !important; - } - - #menu ul li, - #menu ul section { + /* Keep root hitboxes and icons in place; only nested lists drill away. */ + #menu#menu > ul > :is(li, section) { + width: 85% !important; min-width: 0 !important; - max-width: 100% !important; + max-width: 70px !important; + margin: 8px auto !important; padding: 8px !important; justify-content: center !important; box-sizing: border-box !important; - } + pointer-events: auto !important; + transform: none !important; + animation: none !important; + transition: background-color 150ms ease !important; - #menu li > label, - #menu section > label { - flex: 0 0 auto !important; - min-width: 0 !important; - justify-content: center !important; - overflow: visible !important; - } + > label { + position: relative; + font-size: 0 !important; + flex: 0 0 auto !important; + min-width: 0 !important; + justify-content: center !important; + overflow: visible !important; + transform: none !important; - #menu li > label > svg, - #menu section > label > svg { - margin: 0 auto !important; - flex-shrink: 0 !important; - } - - /* Engage: hide text nodes in labels via font-size trick, restore SVG size */ - #menu .logo-link li > label, - #menu .logo-link section > label { - font-size: 0 !important; - justify-content: center !important; - - svg { - width: 24px !important; - height: 24px !important; - font-size: initial !important; - flex-shrink: 0 !important; - margin: 0 auto !important; + span { + display: none !important; + } + > svg { + margin: 0 auto !important; + flex-shrink: 0 !important; + } + } + > svg { + display: none !important; } } - /* Engage: hide chevron arrows on hasChildren items */ - #menu .logo-link li > svg { - display: none !important; + #menu#menu > ul > .hasChildren { + position: static !important; + backdrop-filter: none !important; + contain: none !important; + } + + #menu#menu > ul > .hasChildren:is(.active, .bsplus-active) { + /* Preserve the outer hover inset; the inner edge meets the panel. */ + width: 92.5% !important; + margin-left: 7.5% !important; + margin-right: 0 !important; + border-radius: var(--bsplus-sidebar-radius, 12px) 0 0 + var(--bsplus-sidebar-radius, 12px) !important; + background: var(--background-primary) !important; + transition: none !important; + color: var(--text-primary) !important; + } + + #menu#menu > ul > .hasChildren:is(.active, .bsplus-active) > label { + /* Compensate for the extra inner fill, keeping the icon centered on the rail. */ + transform: translateX(-2.625px) !important; + } + + /* Keep the arc fixed; bleed its paint into the opaque panel to avoid a + fractional compositor gap at the rail edge when zoomed. */ + #menu#menu > ul > .hasChildren:is(.active, .bsplus-active) > label::after { + content: ""; + position: absolute; + pointer-events: none; + width: calc(var(--bsplus-sidebar-radius, 12px) + 1px); + right: calc((100% - 70px) / 2 - 1px); + top: calc(-8px - var(--bsplus-sidebar-radius, 12px)); + bottom: calc(-8px - var(--bsplus-sidebar-radius, 12px)); + background: + radial-gradient( + circle at 0 0, + transparent calc(var(--bsplus-sidebar-radius, 12px) - 0.5px), + var(--background-primary) var(--bsplus-sidebar-radius, 12px) + ) + top / 100% var(--bsplus-sidebar-radius, 12px) no-repeat, + radial-gradient( + circle at 0 100%, + transparent calc(var(--bsplus-sidebar-radius, 12px) - 0.5px), + var(--background-primary) var(--bsplus-sidebar-radius, 12px) + ) + bottom / 100% var(--bsplus-sidebar-radius, 12px) no-repeat, + linear-gradient(var(--background-primary), var(--background-primary)) + center / 100% calc(100% - 2 * var(--bsplus-sidebar-radius, 12px)) + no-repeat; + } + + #menu > ul > .hasChildren > .sub { + left: 70px !important; + right: auto !important; + top: 71px !important; + margin-top: 0 !important; + width: min( + var(--bsplus-sidebar-width, 270px), + calc(100vw - 70px) + ) !important; + background: var(--background-primary) !important; + color: var(--text-primary) !important; + border-right: 1px solid var(--border-color, rgba(128, 128, 128, 0.3)) !important; + visibility: hidden; + opacity: 1; + transform: translateX(-100%); + /* The matching clip keeps the visible edge at the rail during the slide. */ + clip-path: inset(0 0 0 100%); + transition: + transform 0.3s ease, + clip-path 0.3s ease, + visibility 0s 0.3s; + + .nav { + background: var(--background-primary) !important; + } + :is(.nav, .back, .backLabel, li, section, label, svg) { + color: var(--text-primary) !important; + } + svg:not([fill="none"]) { + fill: currentColor !important; + } + :is(li, section):hover { + background: color-mix( + in srgb, + var(--text-primary) 8%, + transparent + ) !important; + } + :is(li, section):is(.active, .bsplus-active):not(.hasChildren) { + background: color-mix( + in srgb, + var(--text-primary) 14%, + transparent + ) !important; + &::after { + background: var(--text-primary) !important; + box-shadow: 0 0 10px + color-mix(in srgb, var(--text-primary) 45%, transparent) !important; + } + } + .sub { + left: 0 !important; + right: auto !important; + width: 100% !important; + background: var(--background-primary) !important; + color: var(--text-primary) !important; + } + } + + #menu > ul > .hasChildren:is(.active, .bsplus-active) > .sub { + visibility: visible; + opacity: 1; + transform: none; + clip-path: inset(0); + transition-delay: 0s; + } + + /* Switching root folders retires the previous panel immediately. */ + #menu:has(> ul > .hasChildren:is(.active, .bsplus-active)) + > ul + > .hasChildren:not(:is(.active, .bsplus-active)) + > .sub { + visibility: hidden; + transition-delay: 0s; + } + + /* Full panel rows retain their preset shape with equal horizontal insets. */ + #menu#menu .sub :is(li.item, section.item) { + box-sizing: border-box !important; + } + #menu#menu:not(.bsplus-sidebar-style-strip) + .sub + > ul:not(.bsplus-drill-rows) + > :is(li.item, section.item) { + margin-inline: auto !important; + } + #menu#menu.bsplus-sidebar-style-strip .sub :is(li.item, section.item) { + width: 100% !important; + margin-inline: 0 !important; + } + + #menu.bsplus-icon-rail-switching > ul > .hasChildren > .sub { + transition: none !important; + } + + #menu#menu.bsplus-sidebar-style-neon .sub li.active:not(.hasChildren) { + box-shadow: + 0 0 0 1px color-mix(in srgb, var(--text-primary) 55%, transparent), + 0 0 14px color-mix(in srgb, var(--text-primary) 40%, transparent), + inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 12%, transparent) !important; + } + + #menu#menu.bsplus-sidebar-indicator-outline .sub li.active:not(.hasChildren) { + background: transparent !important; + box-shadow: + inset 0 0 0 2px color-mix(in srgb, var(--text-primary) 55%, transparent), + 0 0 0 1px color-mix(in srgb, var(--text-primary) 12%, transparent) !important; } - /* Engage: hide the name/details in #userActions */ #menu #userActions .details { display: none !important; } - /* Compact BetterSEQTA mark instead of the full wordmark. */ &.student #menu > ul::before { + width: 70px !important; background-size: 36px 36px !important; background-position: center center !important; } +} +body.icon-only-sidebar:has( + #menu > ul > .hasChildren:is(.active, .bsplus-active) + ) { + --bsplus-icon-rail-space: calc( + 70px + min(var(--bsplus-sidebar-width, 270px), calc(100vw - 70px)) + ); } [class*="notifications__items___"] { @@ -1260,15 +1409,16 @@ html.transparencyEffects transform: translatex(var(--bsplus-sidebar-width, 270px)); } - body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) { + body.icon-only-sidebar { #menu { -webkit-transform: translatex(-70px); transform: translatex(-70px); } - .menuShown #content { - -webkit-transform: translatex(70px); - transform: translatex(70px); - } + #content { left: 0 !important; } + } + body.icon-only-sidebar.menuShown #content { + -webkit-transform: translatex(var(--bsplus-icon-rail-space)) !important; + transform: translatex(var(--bsplus-icon-rail-space)) !important; } } diff --git a/src/css/injected/sidebar-animation.scss b/src/css/injected/sidebar-animation.scss index 9bbd4c50..5a986625 100644 --- a/src/css/injected/sidebar-animation.scss +++ b/src/css/injected/sidebar-animation.scss @@ -1,4 +1,5 @@ -#menu ul:has(li.hasChildren:is(.active, .bsplus-active)) +#menu + ul:has(li.hasChildren:is(.active, .bsplus-active)) li.hasChildren:is(.active, .bsplus-active) { box-shadow: inset 0px 0 var(--item-colour, transparent) !important; background: transparent !important; @@ -8,77 +9,61 @@ overflow-y: scroll !important; } -#menu > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::before, -#menu > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::after, -#menu > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::before, -#menu > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li::after, -#menu > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > label, -#menu > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > svg, -#menu > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > label, -#menu > ul ul:has(li.hasChildren:is(.active, .bsplus-active)) > li > svg { - /* !important beats theme animations (e.g. Beach palm-slide forwards). */ - transform: translateX(-320px) !important; +/* Move the complete row, including hover fill, arrow and subject stripe. + A transform on the folder itself would also move its absolute `.sub` panel. + Resting margins are measured before drilling so auto margins interpolate. */ +#menu#menu ul.bsplus-drill-rows > :is(li, section) { + margin-left: var(--bsplus-row-margin-left) !important; + transition: + margin-left 0.3s ease, + background-color 0.2s ease, + box-shadow 0.2s ease !important; animation: none !important; -} -#menu ul > li > label, -#menu ul > li > svg { - transition: transform 0.3s ease; -} - -/* Frontmost drill panel: rows move with `.sub` only — no separate enter animation. */ -#menu - li.hasChildren:is(.active, .bsplus-active):not( - :has(.sub li.hasChildren:is(.active, .bsplus-active)) - ) - > .sub - > ul - > li, -#menu - li.hasChildren:is(.active, .bsplus-active):not( - :has(.sub li.hasChildren:is(.active, .bsplus-active)) - ) - > .sub - > ul - > li > label, -#menu - li.hasChildren:is(.active, .bsplus-active):not( - :has(.sub li.hasChildren:is(.active, .bsplus-active)) - ) - > .sub - > ul - > li > svg, -#menu - li.hasChildren:is(.active, .bsplus-active):not( - :has(.sub li.hasChildren:is(.active, .bsplus-active)) - ) - > .sub - > ul - > li::before, -#menu - li.hasChildren:is(.active, .bsplus-active):not( - :has(.sub li.hasChildren:is(.active, .bsplus-active)) - ) - > .sub - > ul - > li::after { - animation: none !important; - transition: none !important; - transform: none !important; + &::before, + &::after { + transform: none !important; + animation: none !important; + } +} + +#menu#menu + ul.bsplus-drill-rows:has(> .hasChildren:is(.active, .bsplus-active)) + > :is(li, section) { + margin-left: calc( + var(--bsplus-row-margin-left) + var(--bsplus-slide-off, -320px) + ) !important; +} + +/* Incoming rows travel only with their native panel. */ +#menu .sub > ul:not(.bsplus-drill-rows) > li { + &, + > label, + > svg, + &::before, + &::after { + animation: none !important; + transform: none !important; + } } #menu .sub { - transition: transform 0.3s ease, left 0.4s cubic-bezier(0.4, 0, 0.2, 1); + transition: + transform 0.3s ease, + left 0.4s cubic-bezier(0.4, 0, 0.2, 1); } -#menu .sub ul:has(> li.hasChildren:is(.active, .bsplus-active)) +#menu + .sub + ul:has(> li.hasChildren:is(.active, .bsplus-active)) > li:not(:is(.active, .bsplus-active)) { pointer-events: none !important; } -#menu > ul:has(li.hasChildren:is(.active, .bsplus-active)) +#menu + > ul:has(li.hasChildren:is(.active, .bsplus-active)) > li:is(.active, .bsplus-active) { background: transparent !important; } @@ -99,59 +84,3 @@ #menu { --bsplus-slide-off: -320px; } - -/* Reverse slide when drilling back — label/svg motion is driven inline in JS - so text stays off-screen until `.active` clears. Pseudo-elements use CSS. */ -#menu.bsplus-sidebar-returning ul.bsplus-drill-return-target > li::before, -#menu.bsplus-sidebar-returning ul.bsplus-drill-return-target > li::after { - animation: bsplus-sidebar-return 0.3s cubic-bezier(0.4, 0, 0.2, 1) both !important; - transition: none !important; -} - -@keyframes bsplus-sidebar-return { - from { - transform: translateX(var(--bsplus-slide-off, -320px)); - } - to { - transform: translateX(0); - } -} - -/* Icon-only collapsed: submenu slides over narrow icons. */ -body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) - #menu - > ul:has(li.hasChildren:is(.active, .bsplus-active)) - > li::before, -body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) - #menu - > ul - ul:has(li.hasChildren:is(.active, .bsplus-active)) - > li::before, -body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) - #menu - > ul:has(li.hasChildren:is(.active, .bsplus-active)) - > li - > label, -body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) - #menu - > ul:has(li.hasChildren:is(.active, .bsplus-active)) - > li - > svg, -body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) - #menu - > ul - ul:has(li.hasChildren:is(.active, .bsplus-active)) - > li - > label, -body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) - #menu - > ul - ul:has(li.hasChildren:is(.active, .bsplus-active)) - > li - > svg { - transform: translateX(-70px); -} - -body.icon-only-sidebar #menu { - --bsplus-slide-off: -70px; -} diff --git a/src/css/injected/sidebar-position.scss b/src/css/injected/sidebar-position.scss index 5b385ccd..0471d9f8 100644 --- a/src/css/injected/sidebar-position.scss +++ b/src/css/injected/sidebar-position.scss @@ -33,13 +33,14 @@ body.bsplus-sidebar-right { max-width: none !important; } - &.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) { + &.icon-only-sidebar { #menu { width: 70px !important; } #content { - right: 70px !important; + right: var(--bsplus-icon-rail-space) !important; + transition: none !important; } #menu .sub { @@ -71,7 +72,11 @@ body.bsplus-sidebar-right { } } - #menu li:is(.active, .hasChildren.bsplus-active) > .sub > ul > .item:not(.hasChildren)::before { + #menu + li:is(.active, .hasChildren.bsplus-active) + > .sub + > ul + > .item:not(.hasChildren)::before { left: auto !important; right: 0 !important; border-radius: 0 8px 8px 0 !important; @@ -96,16 +101,21 @@ body.bsplus-sidebar-right { } &.menuShown #content { - transform: translateX(calc(-1 * var(--bsplus-sidebar-width, 270px))) !important; + transform: translateX( + calc(-1 * var(--bsplus-sidebar-width, 270px)) + ) !important; } - &.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) { + &.icon-only-sidebar { #menu { transform: translateX(70px) !important; } &.menuShown #content { - transform: translateX(-70px) !important; + right: 0 !important; + transform: translateX( + calc(-1 * var(--bsplus-icon-rail-space)) + ) !important; } } @@ -127,7 +137,55 @@ body.bsplus-sidebar-right { } &.icon-only-sidebar.menuShown #container #content #title { - transform: translateX(70px) !important; + transform: translateX(var(--bsplus-icon-rail-space)) !important; } } } + +body.icon-only-sidebar.bsplus-sidebar-right { + #menu#menu > ul > .hasChildren:is(.active, .bsplus-active) { + margin-left: 0 !important; + margin-right: 7.5% !important; + border-radius: 0 var(--bsplus-sidebar-radius, 12px) + var(--bsplus-sidebar-radius, 12px) 0 !important; + > label { + transform: translateX(2.625px) !important; + } + } + #menu#menu > ul > .hasChildren:is(.active, .bsplus-active) > label::after { + right: auto; + left: calc((100% - 70px) / 2 - 1px); + background: + radial-gradient( + circle at 100% 0, + transparent calc(var(--bsplus-sidebar-radius, 12px) - 0.5px), + var(--background-primary) var(--bsplus-sidebar-radius, 12px) + ) + top / 100% var(--bsplus-sidebar-radius, 12px) no-repeat, + radial-gradient( + circle at 100% 100%, + transparent calc(var(--bsplus-sidebar-radius, 12px) - 0.5px), + var(--background-primary) var(--bsplus-sidebar-radius, 12px) + ) + bottom / 100% var(--bsplus-sidebar-radius, 12px) no-repeat, + linear-gradient(var(--background-primary), var(--background-primary)) + center / 100% calc(100% - 2 * var(--bsplus-sidebar-radius, 12px)) + no-repeat; + } + #menu > ul > .hasChildren > .sub { + left: auto !important; + right: 70px !important; + border-right: none !important; + border-left: 1px solid var(--border-color, rgba(128, 128, 128, 0.3)) !important; + transform: translateX(100%); + clip-path: inset(0 100% 0 0); + } + #menu > ul > .hasChildren:is(.active, .bsplus-active) > .sub { + transform: none; + clip-path: inset(0); + } + #menu > ul > .hasChildren > .sub .sub { + left: 0 !important; + right: auto !important; + } +} diff --git a/src/css/injected/sidebar-styles.scss b/src/css/injected/sidebar-styles.scss index 729959c6..ead1d63c 100644 --- a/src/css/injected/sidebar-styles.scss +++ b/src/css/injected/sidebar-styles.scss @@ -92,20 +92,22 @@ $sidebar-motion: 0.4s cubic-bezier(0.4, 0, 0.2, 1); &.bsplus-sidebar-style-glass { /* Never put backdrop-filter on an open folder — it becomes a clip containing-block and hides `.sub` labels on Chromium/Edge. */ - #{$item}:not(:has(> .sub)) { - margin: 0 8px 8px !important; - background: rgba(255, 255, 255, 0.1) !important; - backdrop-filter: blur(10px); - -webkit-backdrop-filter: blur(10px); - box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); - } - #{$item}:has(> .sub) { - background: transparent !important; - backdrop-filter: none !important; - -webkit-backdrop-filter: none !important; - box-shadow: none !important; - overflow: visible !important; - contain: none !important; + #{$item} { + &:not(:has(> .sub)) { + margin: 0 8px 8px !important; + background: rgba(255, 255, 255, 0.1) !important; + backdrop-filter: blur(10px); + -webkit-backdrop-filter: blur(10px); + box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); + } + &:has(> .sub) { + background: transparent !important; + backdrop-filter: none !important; + -webkit-backdrop-filter: none !important; + box-shadow: none !important; + overflow: visible !important; + contain: none !important; + } } #{$active} { background: rgba(255, 255, 255, 0.2) !important; @@ -145,16 +147,17 @@ $sidebar-motion: 0.4s cubic-bezier(0.4, 0, 0.2, 1); } } - &.bsplus-sidebar-style-neon #{$active} { - background: rgba(255, 255, 255, 0.1) !important; - box-shadow: - 0 0 0 1px rgba(255, 255, 255, 0.55), - 0 0 14px rgba(255, 255, 255, 0.4), - 0 0 28px rgba(255, 255, 255, 0.22) !important; - } - - &.bsplus-sidebar-style-neon #{$item} { - margin: 0 8px 8px !important; + &.bsplus-sidebar-style-neon { + #{$active} { + background: rgba(255, 255, 255, 0.1) !important; + box-shadow: + 0 0 0 1px rgba(255, 255, 255, 0.55), + 0 0 14px rgba(255, 255, 255, 0.4), + 0 0 28px rgba(255, 255, 255, 0.22) !important; + } + #{$item} { + margin: 0 8px 8px !important; + } } /* —— Density (comfortable = no class / no overrides) —— */ @@ -206,42 +209,48 @@ $sidebar-motion: 0.4s cubic-bezier(0.4, 0, 0.2, 1); } /* —— Active indicator (fill = default, no class) —— */ - &.bsplus-sidebar-indicator-bar:not(.bsplus-sidebar-style-strip) #{$active} { - position: relative !important; - background: rgba(255, 255, 255, 0.1) !important; - box-shadow: none !important; - &::after { - @include accent-bar(0.45); + &.bsplus-sidebar-indicator-bar:not(.bsplus-sidebar-style-strip) { + #{$active} { + position: relative !important; + background: rgba(255, 255, 255, 0.1) !important; + box-shadow: none !important; + &::after { + @include accent-bar(0.45); + } } } - &.bsplus-sidebar-indicator-outline #{$active} { - background: transparent !important; - box-shadow: - inset 0 0 0 2px rgba(255, 255, 255, 0.55), - 0 0 0 1px rgba(255, 255, 255, 0.12) !important; + &.bsplus-sidebar-indicator-outline { + #{$active} { + background: transparent !important; + box-shadow: + inset 0 0 0 2px rgba(255, 255, 255, 0.55), + 0 0 0 1px rgba(255, 255, 255, 0.12) !important; + } } - &.bsplus-sidebar-indicator-underline:not(.bsplus-sidebar-style-strip) #{$active} { - position: relative !important; - background: transparent !important; - box-shadow: none !important; - &::after { - content: "" !important; - position: absolute !important; - left: 14px !important; - right: 14px !important; - bottom: 6px !important; - top: auto !important; - width: auto !important; - height: 3px !important; - border-radius: 999px !important; - background: #fff !important; - box-shadow: 0 0 8px rgba(255, 255, 255, 0.4) !important; - pointer-events: none !important; - z-index: 3 !important; - opacity: 1 !important; - display: block !important; + &.bsplus-sidebar-indicator-underline:not(.bsplus-sidebar-style-strip) { + #{$active} { + position: relative !important; + background: transparent !important; + box-shadow: none !important; + &::after { + content: "" !important; + position: absolute !important; + left: 14px !important; + right: 14px !important; + bottom: 6px !important; + top: auto !important; + width: auto !important; + height: 3px !important; + border-radius: 999px !important; + background: #fff !important; + box-shadow: 0 0 8px rgba(255, 255, 255, 0.4) !important; + pointer-events: none !important; + z-index: 3 !important; + opacity: 1 !important; + display: block !important; + } } } } diff --git a/src/seqta/ui/AddBetterSEQTAElements.ts b/src/seqta/ui/AddBetterSEQTAElements.ts index a71b51a0..5892138c 100644 --- a/src/seqta/ui/AddBetterSEQTAElements.ts +++ b/src/seqta/ui/AddBetterSEQTAElements.ts @@ -750,6 +750,10 @@ function updateSidebarAccessibility() { const visibleEntries = new Set( visibleList ? getDirectSidebarEntries(visibleList) : [], ); + if (document.body?.classList.contains("icon-only-sidebar")) { + const rootList = menu.querySelector(":scope > ul") as HTMLElement | null; + if (rootList) getDirectSidebarEntries(rootList).forEach((entry) => visibleEntries.add(entry)); + } const drillFolders = getDrillFolderChain(menu, visibleList); const menuEntries = menu.querySelectorAll("li.item, section.item, li, section"); diff --git a/src/seqta/ui/colors/Manager.ts b/src/seqta/ui/colors/Manager.ts index a0ba56b9..7fa8d155 100644 --- a/src/seqta/ui/colors/Manager.ts +++ b/src/seqta/ui/colors/Manager.ts @@ -104,7 +104,7 @@ function applyBetterseqtaLogoBackground(isDark: boolean) { background-image: url("${fullUrl}") !important; } /* Icon-only sidebar: wordmark → compact mark (theme-aware). */ - body.student.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active))) #menu > ul::before { + body.student.icon-only-sidebar #menu > ul::before { background-image: url("${iconUrl}") !important; } `; diff --git a/src/seqta/ui/sidebar/sidebarDrillReturn.ts b/src/seqta/ui/sidebar/sidebarDrillReturn.ts index aa2bc573..71dcaced 100644 --- a/src/seqta/ui/sidebar/sidebarDrillReturn.ts +++ b/src/seqta/ui/sidebar/sidebarDrillReturn.ts @@ -1,7 +1,7 @@ const MENU_RETURN_CLASS = "bsplus-sidebar-returning"; const LIST_RETURN_CLASS = "bsplus-drill-return-target"; const RETURN_MS = 300; -const RETURN_EASE = "cubic-bezier(0.4, 0, 0.2, 1)"; +const ROWS_CLASS = "bsplus-drill-rows"; /** Count open folder levels (0 = root list only). */ export function getSidebarDrillDepth( @@ -19,7 +19,9 @@ export function getSidebarDrillDepth( if (!activeFolder) break; depth += 1; - list = activeFolder.querySelector(":scope > .sub > ul") as HTMLElement | null; + list = activeFolder.querySelector( + ":scope > .sub > ul", + ) as HTMLElement | null; } return depth; @@ -42,37 +44,74 @@ function getSidebarListAtDepth( ":scope > li.hasChildren.active, :scope > section.hasChildren.active", ) as HTMLElement | null; if (!activeFolder) return list; - list = activeFolder.querySelector(":scope > .sub > ul") as HTMLElement | null; + list = activeFolder.querySelector( + ":scope > .sub > ul", + ) as HTMLElement | null; depth += 1; } return list; } -function getSlideOff(menu: HTMLElement): string { - const value = getComputedStyle(menu).getPropertyValue("--bsplus-slide-off").trim(); - return value || "-320px"; -} - function getReturnSlideNodes(list: HTMLElement): HTMLElement[] { return [ - ...list.querySelectorAll( - ":scope > li > label, :scope > li > svg, :scope > section > label, :scope > section > svg", - ), + ...list.querySelectorAll(":scope > li, :scope > section"), ]; } -function clearInlineReturnStyles(nodes: Iterable) { +function prepareRowSlide(list: HTMLElement) { + // The icons-only root rail remains visible next to the open panel. + if ( + document.body?.classList.contains("icon-only-sidebar") && + list.parentElement?.id === "menu" + ) + return; + if (list.classList.contains(ROWS_CLASS)) return; + const nodes = getReturnSlideNodes(list); + // Read all auto/preset margins before changing any row's layout. + const margins = nodes.map((node) => getComputedStyle(node).marginLeft); + nodes.forEach((node, index) => { + node.style.setProperty("--bsplus-row-margin-left", margins[index]); + node.style.setProperty("margin-left", margins[index], "important"); + }); + list.classList.add(ROWS_CLASS); + // Establish a concrete start before native state changes (or an observer + // prepares a programmatically opened folder after its class changed). + void list.offsetWidth; + nodes.forEach((node) => node.style.removeProperty("margin-left")); +} + +function clearRowSlide(nodes: Iterable) { for (const node of nodes) { - node.style.removeProperty("transition"); - node.style.removeProperty("transform"); + node.style.removeProperty("margin-left"); + node.style.removeProperty("--bsplus-row-margin-left"); + node.parentElement?.classList.remove(ROWS_CLASS); } } let returnTimer: ReturnType | null = null; -let lastAnimatedNodes: HTMLElement[] = []; let lastDrillDepth = 0; let menuObserver: MutationObserver | null = null; +let lastRootFolder: Element | null = null; +let swapFrame: number | null = null; + +function rootFolder(menu: HTMLElement) { + return menu.querySelector( + ":scope > ul > .hasChildren:is(.active, .bsplus-active)", + ); +} + +function swapRootPanel(menu: HTMLElement) { + if (!document.body?.classList.contains("icon-only-sidebar")) return; + if (swapFrame !== null) cancelAnimationFrame(swapFrame); + menu.classList.add("bsplus-icon-rail-switching"); + swapFrame = requestAnimationFrame(() => { + swapFrame = requestAnimationFrame(() => { + swapFrame = null; + menu.classList.remove("bsplus-icon-rail-switching"); + }); + }); +} let backCaptureAttached = false; function clearReturnClasses(menu: HTMLElement) { @@ -97,39 +136,24 @@ export function runSidebarDrillReturn( if (returnTimer) clearTimeout(returnTimer); clearReturnClasses(menu); - clearInlineReturnStyles(lastAnimatedNodes); - lastAnimatedNodes = nodes; - - const slideOff = getSlideOff(menu); - - // Hold the off-screen transform before SEQTA clears `.active` and drops `:has()`. - for (const node of nodes) { - node.style.transition = "none"; - node.style.transform = `translateX(${slideOff})`; - } + prepareRowSlide(list); menu.classList.add(MENU_RETURN_CLASS); list.classList.add(LIST_RETURN_CLASS); lastDrillDepth = depth; - requestAnimationFrame(() => { - requestAnimationFrame(() => { - for (const node of nodes) { - node.style.transition = `transform ${RETURN_MS}ms ${RETURN_EASE}`; - node.style.transform = "translateX(0)"; - } - }); - }); - returnTimer = setTimeout(() => { returnTimer = null; clearReturnClasses(menu); - clearInlineReturnStyles(nodes); - lastAnimatedNodes = []; + clearRowSlide(nodes); }, RETURN_MS + 50); } function onDrillDepthChange(menu: HTMLElement) { + const currentRoot = rootFolder(menu); + if (lastRootFolder && currentRoot && lastRootFolder !== currentRoot) + swapRootPanel(menu); + lastRootFolder = currentRoot; if (menu.classList.contains(MENU_RETURN_CLASS)) return; const depth = getSidebarDrillDepth(menu); @@ -137,16 +161,39 @@ function onDrillDepthChange(menu: HTMLElement) { runSidebarDrillReturn(menu, depth); return; } + if (depth > lastDrillDepth) { + const outgoing = getSidebarListAtDepth(menu, lastDrillDepth); + if (outgoing) prepareRowSlide(outgoing); + } lastDrillDepth = depth; } function onMenuClickCapture(event: MouseEvent) { const menu = document.getElementById("menu"); - if (!menu || menu.classList.contains(MENU_RETURN_CLASS)) return; + if (!menu) return; const target = event.target; if (!(target instanceof Element)) return; - if (!target.closest(".sub .back")) return; + if (!target.closest(".sub .back")) { + const folder = target.closest("li.hasChildren, section.hasChildren"); + if ( + folder && + !folder.classList.contains("active") && + folder.parentElement + ) { + if ( + folder.parentElement.parentElement === menu && + rootFolder(menu) && + rootFolder(menu) !== folder + ) + swapRootPanel(menu); + if (returnTimer) clearTimeout(returnTimer); + returnTimer = null; + clearReturnClasses(menu); + prepareRowSlide(folder.parentElement); + } + return; + } const depthBefore = getSidebarDrillDepth(menu); if (depthBefore > 0) { @@ -154,13 +201,18 @@ function onMenuClickCapture(event: MouseEvent) { } } -/** Drive the reverse slide when folder `.active` is cleared. */ +/** Keep row motion together when native folder state changes. */ export function installSidebarDrillReturn( menu: HTMLElement | null = document.getElementById("menu"), ) { if (!menu || menuObserver) return; lastDrillDepth = getSidebarDrillDepth(menu); + lastRootFolder = rootFolder(menu); + for (let depth = 0; depth < lastDrillDepth; depth++) { + const list = getSidebarListAtDepth(menu, depth); + if (list) prepareRowSlide(list); + } menuObserver = new MutationObserver(() => { onDrillDepthChange(menu); @@ -183,12 +235,19 @@ export function uninstallSidebarDrillReturn() { if (returnTimer) clearTimeout(returnTimer); returnTimer = null; lastDrillDepth = 0; + lastRootFolder = null; + if (swapFrame !== null) cancelAnimationFrame(swapFrame); + swapFrame = null; const menu = document.getElementById("menu"); if (menu) { + menu.classList.remove("bsplus-icon-rail-switching"); clearReturnClasses(menu); - clearInlineReturnStyles(lastAnimatedNodes); - lastAnimatedNodes = []; + clearRowSlide( + menu.querySelectorAll( + `ul.${ROWS_CLASS} > li, ul.${ROWS_CLASS} > section`, + ), + ); if (backCaptureAttached) { menu.removeEventListener("click", onMenuClickCapture, true); backCaptureAttached = false;