Skip to content

Commit 60be636

Browse files
authored
RangeSlider-Added DisableMin and DisableMax (#265)
* RangeSlider-Added DisableMin and DisableMax * Create global.json
1 parent 28cc7f0 commit 60be636

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

CodeBeam.MudBlazor.Extensions/Components/RangeSlider/MudRangeSlider.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131

3232
@if (Range)
3333
{
34-
<input class="mud-slider-input" aria-valuenow="@UpperValue" aria-valuemin="@_min" aria-valuemax="@_max" role="slider" @attributes="UserAttributes" type="range" min="@_min" max="@_max" step="@_step" disabled="@(Disabled || _userInvalidatedRange)"
34+
<input class="mud-slider-input" aria-valuenow="@UpperValue" aria-valuemin="@_min" aria-valuemax="@_max" role="slider" @attributes="UserAttributes" type="range" min="@_min" max="@_max" step="@_step" disabled="@(Disabled || _userInvalidatedRange || (Range && DisableMax))"
3535
@bind-value="@UpperText" @bind-value:event="@((Immediate ? "oninput" : "onchange"))" />
3636

3737
@SliderValueLabel(upperLeft, UpperValue?.ToString())
3838
}
3939

40-
<input class="mud-slider-input" aria-valuenow="@Value" aria-valuemin="@_min" aria-valuemax="@_max" role="slider" @attributes="UserAttributes" type="range" min="@_min" max="@_max" step="@_step" disabled="@(Disabled || _userInvalidatedRange)"
40+
<input class="mud-slider-input" aria-valuenow="@Value" aria-valuemin="@_min" aria-valuemax="@_max" role="slider" @attributes="UserAttributes" type="range" min="@_min" max="@_max" step="@_step" disabled="@(Disabled || _userInvalidatedRange || (Range && DisableMin))"
4141
@bind-value="@Text" @bind-value:event="@((Immediate ? "oninput" : "onchange"))" />
4242

4343
@SliderValueLabel(left, Value?.ToString())

CodeBeam.MudBlazor.Extensions/Components/RangeSlider/MudRangeSlider.razor.cs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,34 @@ public T? Step
9191
set => _step = Converter.Set(value);
9292
}
9393

94-
/// <summary>
95-
/// If true, the slider will be disabled.
96-
/// </summary>
97-
///
98-
[Parameter]
99-
[Category(CategoryTypes.Slider.Behavior)]
100-
public bool Disabled { get; set; } = false;
101-
102-
/// <summary>
103-
/// Child content of component.
104-
/// </summary>
105-
[Parameter]
94+
/// <summary>
95+
/// If true, the slider will be disabled.
96+
/// </summary>
97+
///
98+
[Parameter]
99+
[Category(CategoryTypes.Slider.Behavior)]
100+
public bool Disabled { get; set; } = false;
101+
102+
/// <summary>
103+
/// If true and <seealso cref="Range"/>, the slider's min value will be disabled.
104+
/// </summary>
105+
///
106+
[Parameter]
107+
[Category(CategoryTypes.Slider.Behavior)]
108+
public bool DisableMin { get; set; } = false;
109+
110+
/// <summary>
111+
/// If true and <seealso cref="Range"/>, the slider's max value will be disabled.
112+
/// </summary>
113+
///
114+
[Parameter]
115+
[Category(CategoryTypes.Slider.Behavior)]
116+
public bool DisableMax { get; set; } = false;
117+
118+
/// <summary>
119+
/// Child content of component.
120+
/// </summary>
121+
[Parameter]
106122
[Category(CategoryTypes.Slider.Behavior)]
107123
public RenderFragment? ChildContent { get; set; }
108124

ComponentViewer.Docs/Pages/Examples/RangeSliderExample1.razor

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<MudGrid>
66
<MudItem xs="12" sm="8">
77
<MudRangeSlider @bind-Value="@_value" @bind-UpperValue="@_upperValue" Size="Size.Large" Variant="Variant.Filled" ValueLabel="_valueLabel" Range="_range" TickMarks="_tickmarks"
8-
Min="_min" Max="_max" Step="_step" Display="_display" MinDistance="_minDistance">@_label</MudRangeSlider>
8+
Min="_min" Max="_max" Step="_step" Display="_display" MinDistance="_minDistance" DisableMin="_disableMin" DisableMax="_disableMax">@_label</MudRangeSlider>
99
</MudItem>
1010

1111
<MudItem xs="12" sm="4">
@@ -16,6 +16,8 @@
1616
<MudSwitchM3 @bind-Checked="_valueLabel" Label="ValueLabel" Color="Color.Secondary" />
1717
<MudSwitchM3 @bind-Checked="_range" Label="Range" Color="Color.Secondary" />
1818
<MudSwitchM3 @bind-Checked="_tickmarks" Label="Tickmarks" Color="Color.Secondary" />
19+
<MudSwitchM3 @bind-Checked="_disableMin" Label="DisableMin" Color="Color.Secondary" />
20+
<MudSwitchM3 @bind-Checked="_disableMax" Label="DisableMax" Color="Color.Secondary" />
1921
<MudSwitchM3 @bind-Checked="_display" Label="Display" Color="Color.Secondary" />
2022
<MudNumericField @bind-Value="_min" Label="Min" Variant="Variant.Outlined" Margin="Margin.Dense" />
2123
<MudNumericField @bind-Value="_max" Label="Max" Variant="Variant.Outlined" Margin="Margin.Dense" />
@@ -34,6 +36,8 @@
3436
bool _display = true;
3537
bool _range = true;
3638
bool _tickmarks = false;
39+
bool _disableMin = false;
40+
bool _disableMax = false;
3741
int _min = 0;
3842
int _max = 100;
3943
int _step = 1;

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"sdk": {
33
"version": "7.0.203"
44
}
5-
}
5+
}

0 commit comments

Comments
 (0)