Skip to content

Commit b4d1391

Browse files
committed
replace hard svg tag to mudicon component
1 parent e80ebd7 commit b4d1391

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

src/Components/MudStaticRadio.razor

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@
1818
id="@($"static-radio-{_elementId}")"
1919
checked="@IsChecked" />
2020

21-
<svg class="mud-icon-root mud-svg-icon mud-icon-size-medium"
22-
focusable="false"
23-
viewBox="0 0 24 24"
24-
aria-hidden="true"
25-
role="img"
26-
id="@($"radio-svg-{_elementId}")">
27-
@(new MarkupString(IsChecked ? Icons.Material.Filled.RadioButtonChecked : Icons.Material.Filled.RadioButtonUnchecked))
28-
</svg>
21+
<MudIcon Size="Size"
22+
Color="HasErrors ? Color.Error : Color"
23+
Icon="@(IsChecked ? CheckedIcon : UncheckedIcon)"
24+
id="@($"radio-svg-{_elementId}")" />
2925
</span>
3026

3127
<p class="mud-typography mud-typography-body1">
@@ -40,8 +36,8 @@
4036
const radio = document.getElementById('static-radio-@_elementId');
4137
const svg = document.getElementById('radio-svg-@_elementId');
4238
43-
const checkedIcon = '@(Icons.Material.Filled.RadioButtonChecked)';
44-
const uncheckedIcon = '@(Icons.Material.Filled.RadioButtonUnchecked)';
39+
const checkedIcon = '@(CheckedIcon)';
40+
const uncheckedIcon = '@(UncheckedIcon)';
4541
4642
if (radio && svg) {
4743
const handleChange = () => {
@@ -65,9 +61,6 @@
6561

6662
private bool IsChecked => ParentGroup is not null && EqualityComparer<T>.Default.Equals(ParentGroup.Value, Value);
6763

68-
private const string UnChecked = "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z";
69-
private const string Checked = "M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z";
70-
7164
private readonly string _elementId = Guid.NewGuid().ToString()[..8];
7265

7366
protected override void OnInitialized()
@@ -77,8 +70,6 @@
7770
throw new InvalidOperationException($"{nameof(MudStaticRadio<T>)} must be used inside a {nameof(MudStaticRadioGroup<T>)}");
7871
}
7972

80-
var test = Icons.Material.Filled.RadioButtonChecked;
81-
8273
base.OnInitialized();
8374
}
8475

0 commit comments

Comments
 (0)