diff --git a/src/BootstrapBlazor/Components/Layout/Layout.razor b/src/BootstrapBlazor/Components/Layout/Layout.razor index eacaaaa0b23..c0beaaddaca 100644 --- a/src/BootstrapBlazor/Components/Layout/Layout.razor +++ b/src/BootstrapBlazor/Components/Layout/Layout.razor @@ -2,9 +2,9 @@ @inherits BootstrapModuleComponentBase @attribute [BootstrapModuleAutoLoader(JSObjectReference = true)] - - @if (_init) - { +@if (_init) +{ + @if (IsAuthenticated) {
@@ -60,8 +60,8 @@ { @RenderMain } - } - + +} @code { RenderFragment RenderHeader => collapse => diff --git a/src/BootstrapBlazor/Components/Layout/Layout.razor.scss b/src/BootstrapBlazor/Components/Layout/Layout.razor.scss index 2872c7bcd8b..f3ba3749e23 100644 --- a/src/BootstrapBlazor/Components/Layout/Layout.razor.scss +++ b/src/BootstrapBlazor/Components/Layout/Layout.razor.scss @@ -84,7 +84,6 @@ } .has-sidebar { - /*left-right*/ position: relative; flex: 1; @@ -267,7 +266,6 @@ position: relative; width: var(--bb-layout-sidebar-width); transform: translateX(0); - transition: width .3s linear; flex-shrink: 0; .layout-menu { @@ -275,6 +273,10 @@ } } + &:not(.drag) .layout-side { + transition: width .3s linear; + } + &.has-sidebar { .layout-side { &.is-fixed-header { diff --git a/src/BootstrapBlazor/Components/Layout/LayoutSplitebar.razor.js b/src/BootstrapBlazor/Components/Layout/LayoutSplitebar.razor.js index 035061cec3d..84f5bd89170 100644 --- a/src/BootstrapBlazor/Components/Layout/LayoutSplitebar.razor.js +++ b/src/BootstrapBlazor/Components/Layout/LayoutSplitebar.razor.js @@ -6,16 +6,21 @@ export function init(id) { return; } - const min = parseFloat(el.getAttribute("data-bb-min") ?? "0"); - const max = parseFloat(el.getAttribute("data-bb-max") ?? "0"); + const min = parseFloat(el.getAttribute("data-bb-min") ?? "-1"); + const max = parseFloat(el.getAttribute("data-bb-max") ?? "-1"); const selector = el.getAttribute("data-bb-selector") ?? ".layout"; const section = document.querySelector(selector); + if (section === null) { + log.warning(`LayoutSplitebar: selector ${selector} not found`); + return; + } + const bar = el.querySelector(".layout-splitebar-body"); let originX = 0; let width = 0; Drag.drag(bar, e => { - bar.classList.add('drag') + section.classList.add('drag') width = parseInt(getComputedStyle(section).getPropertyValue('--bb-layout-sidebar-width')) originX = e.clientX || e.touches[0].clientX }, @@ -23,12 +28,16 @@ export function init(id) { const eventX = e.clientX || (e.touches.length > 0 && e.touches[0].clientX) const moveX = eventX - originX const newWidth = width + moveX - if (newWidth >= min && newWidth <= max) { - section.style.setProperty('--bb-layout-sidebar-width', `${newWidth}px`) + if (min > -1 && newWidth < min) { + newWidth = min + } + if (max > -1 && newWidth > max) { + newWidth = max } + section.style.setProperty('--bb-layout-sidebar-width', `${newWidth}px`) }, e => { - bar.classList.remove('drag') + section.classList.remove('drag') } ) } diff --git a/src/BootstrapBlazor/Components/Layout/LayoutSplitebar.razor.scss b/src/BootstrapBlazor/Components/Layout/LayoutSplitebar.razor.scss index 35f2e1ea2de..b834f110aa7 100644 --- a/src/BootstrapBlazor/Components/Layout/LayoutSplitebar.razor.scss +++ b/src/BootstrapBlazor/Components/Layout/LayoutSplitebar.razor.scss @@ -8,23 +8,35 @@ display: none; .layout-splitebar-body { + --bb-splitebar-body-hover-bg: #{$bb-splitebar-body-hover-bg}; + --bb-splitebar-body-drag-hover-bg: #{$bb-splitebar-body-drag-hover-bg}; position: absolute; inset: 0px -2px; cursor: col-resize; background-color: transparent; border-radius: 4px; + transition: background .3s linear; &:hover { - background-color: var(--bb-sidebar-body-hover-bg); + background-color: var(--bb-splitebar-body-hover-bg); } + } +} - &.drag, - &.drag:hover { - background-color: var(--bb-sidebar-body-drag-hover-bg); +.drag { + .layout-splitebar { + .layout-splitebar-body:hover { + background-color: var(--bb-splitebar-body-drag-hover-bg); } } } +.is-collapsed { + .layout-splitebar-body { + display: none; + } +} + @media(min-width: 768px) { .layout-splitebar { display: block; diff --git a/src/BootstrapBlazor/wwwroot/scss/theme/bootstrapblazor.scss b/src/BootstrapBlazor/wwwroot/scss/theme/bootstrapblazor.scss index fbfb33dbe0b..f52ebcf2aa1 100644 --- a/src/BootstrapBlazor/wwwroot/scss/theme/bootstrapblazor.scss +++ b/src/BootstrapBlazor/wwwroot/scss/theme/bootstrapblazor.scss @@ -346,6 +346,10 @@ $bb-layout-menu-item-hover-bg: #409eff; $bb-layout-logo-border-color: #d5d5d5; $bb-layout-logo-bg: #0e77e3; +// LayoutSplitebar +$bb-splitebar-body-hover-bg: rgba(175, 184, 193, 0.2); +$bb-splitebar-body-drag-hover-bg: rgb(9, 105, 218); + // Light $bb-light-bg: radial-gradient(circle, #fff, #aaa, #333); $bb-light-danger-start-color: #e17777;