Skip to content
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

Progress: Improve accessibility #9060

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/MudBlazor/Components/Progress/MudProgressCircular.razor
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
@namespace MudBlazor
@using MudBlazor.Extensions
@inherits MudComponentBase

<div @attributes="UserAttributes" class="@DivClassname" role="progressbar" style="@Style" aria-valuenow="@_valueState.Value">
<div role="progressbar"
aria-valuenow="@_valueState.Value.ToInvariantString()"
aria-valuemin="@Min.ToInvariantString()"
aria-valuemax="@Max.ToInvariantString()"
aria-live="@((Indeterminate ? null : "polite"))"
class="@Classname"
style="@Style"
@attributes="UserAttributes">
<svg class="mud-progress-circular-svg" viewBox="22 22 44 44">
@if (Indeterminate)
{
<circle class="@SvgClassname" cx="44" cy="44" r="20" fill="none" stroke-width="@StrokeWidth"></circle>
}
else
{
<circle class="@SvgClassname" cx="44" cy="44" r="20" fill="none" stroke-width="@StrokeWidth" style="stroke-dasharray: @_magicNumber; stroke-dashoffset: @_svgValue;"></circle>
<circle class="@SvgClassname" cx="44" cy="44" r="20" fill="none" stroke-width="@StrokeWidth" style="stroke-dasharray: @MagicNumber; stroke-dashoffset: @_svgValue;"></circle>
}
</svg>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public partial class MudProgressCircular : MudComponentBase
{
private int _svgValue;
private readonly ParameterState<double> _valueState;
private const int _magicNumber = 126; // weird, but required for the SVG to work
private const int MagicNumber = 126; // weird, but required for the SVG to work

protected string DivClassname =>
protected string Classname =>
new CssBuilder("mud-progress-circular")
.AddClass($"mud-{Color.ToDescriptionString()}-text")
.AddClass($"mud-progress-{Size.ToDescriptionString()}")
Expand Down Expand Up @@ -91,7 +91,7 @@ private int ToSvgValue(double value)
// calculate fraction, which is a value between 0 and 1
var fraction = (minValue - Min) / (Max - Min);
// now project into the range of the SVG value (126 .. 0)
return (int)Math.Round(_magicNumber - (_magicNumber * fraction));
return (int)Math.Round(MagicNumber - (MagicNumber * fraction));
}
}
}
12 changes: 10 additions & 2 deletions src/MudBlazor/Components/Progress/MudProgressLinear.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
@using MudBlazor.Extensions
@inherits MudComponentBase

<div @attributes="UserAttributes" class="@DivClassname" style="@Style" role="progressbar" aria-valuenow="@_valueState.Value.ToInvariantString()" aria-valuemin="@_minState.Value.ToInvariantString()" aria-valuemax="@_maxState.Value.ToInvariantString()">
<div role="progressbar"
aria-valuenow="@_valueState.Value.ToInvariantString()"
aria-valuemin="@_minState.Value.ToInvariantString()"
aria-valuemax="@_maxState.Value.ToInvariantString()"
aria-live="@((Indeterminate ? null : "polite"))"
class="@Classname"
style="@Style"
@attributes="UserAttributes">
<div class="mud-progress-linear-bars">
@if (Indeterminate)
{
Expand All @@ -20,7 +27,8 @@
<div class="mud-progress-linear-bar" style="@GetStyledBar1Transform()"></div>
}
</div>
@if(ChildContent is not null)

@if (ChildContent is not null)
{
<div class="mud-progress-linear-content">
@ChildContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class MudProgressLinear : MudComponentBase
private readonly ParameterState<double> _valueState;
private readonly ParameterState<double> _bufferValueState;

protected string DivClassname =>
protected string Classname =>
new CssBuilder("mud-progress-linear")
.AddClass("mud-progress-linear-rounded", Rounded)
.AddClass($"mud-progress-linear-striped", Striped)
Expand Down
Loading