-
-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: interactively resizable side bar #2423
Comments
Here is a poor man solution mentioned in the discussion. Part 1. Markup. @inject IJSRuntime JS
@if (_showSlider)
{
<Slider TValue="int" Value="@_width1" Max="@_width2" ValueChanged="@SliderValueChanged" />
}
<Layout Sider="true">
<LayoutSider>
<LayoutSiderContent>
... Part 2. Code behind. Code for toggling bool _showSlider;
int _width1, _width2;
[CascadingParameter] protected Theme Theme { get; set; }
protected override async Task OnInitializedAsync()
{
_width2 = await JS.InvokeAsync<int>("getWindowWidth");
_width1 = int.Parse(Theme.BarOptions.VerticalWidth.Replace("px", ""));
}
async Task SliderValueChanged(int value)
{
var coeff = (double)value / _width2;
_width2 = await JS.InvokeAsync<int>("getWindowWidth");
_width1 = Math.Max(300, (int)(_width2 * coeff));
Theme.BarOptions.VerticalWidth = $"{_width1}px";
Theme.ThemeHasChanged();
} Part 3. JavaScript, e.g. in <script>
function getWindowWidth() {
return window.innerWidth;
}
</script> |
Our UX designer has also requested this feature. To have a resizable sidebar and to also have it resize automatically when resizing the window. Like having a percentage size + explicit max-size instead of having 1 fixed values / breakpoints |
I can schedule it for 1.2 and we'll see how it goes. |
@stsrki Fantastic news, looking forward to it! |
good news @stsrki for now I will use a css formula to calculate the width |
Feature: interactively resizable side bar
ref:
Is your feature request related to a problem? Please describe.
Kind of a usability problem and poor user experience in some cases.
We use
TreeView
in the side bar (left panel) and render selected item pagesin the main area (right panel). It's a popular UI layout pattern used in apps
like "file explorers", "hierarchical content browsers", etc.
Depending on the tree item text lengths and the depth of expanded items the
fixed width of the side bar (either default or custom but still fixed) may be
insufficient for comfortable viewing and navigating through the tree items.
And I can imagine use cases without
TreeView
but with dynamic content of theside bar. The comfortable width may be difficult to predict and set beforehand.
Describe the solution you'd like
The natural solution would be ability to resize the side bar by dragging the
right edge of the bar horizontally, some sort of optional vertical splitter
dividing the application side bar and main areas.
The text was updated successfully, but these errors were encountered: