Skip to content

Commit f5751bb

Browse files
authored
Splitter Enhancements (#75)
1 parent 32deea3 commit f5751bb

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

CodeBeam.MudExtensions/Components/Splitter/MudSplitter.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@inherits MudComponentBase
33

44
<div class="@Classname" style="@Style">
5-
<MudSlider @ref="_slider" Class="@SliderClassname" T="double" Min="0" Max="100" Step="0.1" ValueChanged="UpdateDimensions" />
5+
<MudSlider @ref="_slider" Class="@SliderClassname" Style="overflow: hidden; z-index: 6" T="double" Min="0" Max="100" Step="@Sensitivity" ValueChanged="UpdateDimensions" Disabled="DisableSlide"/>
66

77
<div class="@ContentClassname" style="@StyleContent">
88
@StartContent

CodeBeam.MudExtensions/Components/Splitter/MudSplitter.razor.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public partial class MudSplitter : MudComponentBase
2525
.AddClass(Class)
2626
.Build();
2727

28-
protected string ContentClassname => new CssBuilder($"mud-splitter-content mud-splitter-content-{_styleGuid} d-flex ma-2")
28+
protected string ContentClassname => new CssBuilder($"mud-splitter-content mud-splitter-content-{_styleGuid} d-flex")
29+
.AddClass("ma-2", !DisableMargin)
2930
.AddClass(ClassContent)
3031
.Build();
3132

@@ -81,6 +82,24 @@ public string Height
8182
[Parameter]
8283
public string StyleBar { get; set; }
8384

85+
/// <summary>
86+
/// The slide sensitivity that should between 0.01 and 10. Smaller values increase the smooth but reduce performance. Default is 0.1
87+
/// </summary>
88+
[Parameter]
89+
public double Sensitivity { get; set; } = 0.1d;
90+
91+
/// <summary>
92+
/// If true, user cannot interact with splitter bar.
93+
/// </summary>
94+
[Parameter]
95+
public bool DisableSlide { get; set; }
96+
97+
/// <summary>
98+
/// Disables the default margin.
99+
/// </summary>
100+
[Parameter]
101+
public bool DisableMargin { get; set; }
102+
84103
///// <summary>
85104
///// If true, splitter bar goes vertical.
86105
///// </summary>

ComponentViewer.Docs/Pages/Examples/SplitterExample1.razor

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<MudGrid>
55
<MudItem xs="12" sm="8">
6-
<MudSplitter @ref="_splitter" Height="@_height" Color="_color" Bordered="_bordered" DimensionChanged="DimensionChanged">
6+
<MudSplitter @ref="_splitter" Height="@_height" Color="_color" Bordered="_bordered" DimensionChanged="DimensionChanged" DisableSlide="_disableSlide" DisableMargin="_disableMargin" Sensitivity="_sensitivity" Overlap="true">
77
<StartContent>
88
<MudText>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</MudText>
99
</StartContent>
@@ -23,8 +23,11 @@
2323
<MudSelectItem Value="col">@col.ToDescriptionString()</MudSelectItem>
2424
}
2525
</MudSelect>
26-
<MudSwitch @bind-Checked="_bordered" Color="Color.Primary" Label="Border" />
26+
<MudSwitchM3 @bind-Checked="_bordered" Color="Color.Primary" Label="Border" />
27+
<MudSwitchM3 @bind-Checked="_disableSlide" Color="Color.Primary" Label="Disable" />
28+
<MudSwitchM3 @bind-Checked="_disableMargin" Color="Color.Primary" Label="Disable Margin" />
2729
<MudDivider />
30+
<MudNumericField @bind-Value="_sensitivity" Variant="Variant.Outlined" Min="0.01" Max="10" Step="0.1" Label="Sensitivity" />
2831
<MudNumericField @bind-Value="_percentage" Variant="Variant.Outlined" Label="Start Content Percentage" />
2932
<MudButton OnClick="@(() => _splitter.SetDimensions(_percentage))">Set Dimension (@_percentage)</MudButton>
3033
</MudStack>
@@ -37,6 +40,9 @@
3740
Color _color;
3841
double _percentage = 50;
3942
bool _bordered = false;
43+
bool _disableSlide = false;
44+
bool _disableMargin = false;
45+
double _sensitivity = 0.1d;
4046

4147
private void DimensionChanged()
4248
{

0 commit comments

Comments
 (0)