Skip to content

Commit

Permalink
[Lists] Change Option<TType>.Text to string? (#2063)
Browse files Browse the repository at this point in the history
* In Option<TType> change the type of `Text` to string?  If it is TType it only adds value for TType of string otherwise it makes no sense if Text is some Ojbect.

* Update the demo apps to use Text as a string.

* Use string literal instead of ToString.

* Now we can remove redundant .ToString

---------

Co-authored-by: Vincent Baaij <[email protected]>
  • Loading branch information
StevenTCramer and vnbaaij authored May 16, 2024
1 parent 88f055f commit a43b7c3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

<FluentCombobox Items=@intOptions
TOption="Option<int>"
OptionText="@(i => i.Text.ToString())"
OptionValue="@(i => i.Value.ToString())"
OptionText="@(i => i.Text)"
OptionValue="@(i => i.Value.ToString())"
OptionDisabled="@(i => i.Disabled)"
@bind-SelectedOption="@selectedIntOption"
@bind-Value="@intValue" />
Expand All @@ -48,9 +48,9 @@

List<Option<int>> intOptions = new()
{
{ new Option<int> { Value = 1, Text = 1, Disabled = true } },
{ new Option<int> { Value = 2, Text = 2 } },
{ new Option<int> { Value = 3, Text = 3 } }
{ new Option<int> { Value = 1, Text = "1", Disabled = true } },
{ new Option<int> { Value = 2, Text = "2" } },
{ new Option<int> { Value = 3, Text = "3" } }

};
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<FluentListbox Items=@intOptions
TOption="Option<int>"
OptionText="@(i => i.Text.ToString())"
OptionText="@(i => i.Text)"
OptionValue="@(i => i.Value.ToString())"
OptionDisabled="@(i => i.Disabled)"
@bind-SelectedOption="@selectedIntOption"
Expand All @@ -43,9 +43,9 @@

List<Option<int>> intOptions = new()
{
{ new Option<int> { Value = 1, Text = 1, Disabled = true } },
{ new Option<int> { Value = 2, Text = 2 } },
{ new Option<int> { Value = 3, Text = 3 } }
{ new Option<int> { Value = 1, Text = "1", Disabled = true } },
{ new Option<int> { Value = 2, Text = "2" } },
{ new Option<int> { Value = 3, Text = "3" } }

};
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<p><em>Note that the second option in the list is automatically highlighted but it has <strong>NOT</strong> been selected. It's just the first item in the list available for selection</em></p>
<FluentSelect Items=@intOptions
TOption="Option<int>"
OptionText="@(i => i.Text.ToString())"
OptionText="@(i => i.Text)"
OptionValue="@(i => i.Value.ToString())"
OptionDisabled="@(i => i.Disabled)"
@bind-SelectedOption="@selectedIntOption"
Expand Down Expand Up @@ -81,9 +81,9 @@

List<Option<int>> intOptions = new()
{
{ new Option<int> { Value = 1, Text = 1, Disabled = true, Icon = (new Icons.Regular.Size24.NumberCircle1(), Color.Neutral, "start" ) } },
{ new Option<int> { Value = 2, Text = 2, Icon = (new Icons.Regular.Size24.NumberCircle2(), Color.Neutral, "end" ) } },
{ new Option<int> { Value = 3, Text = 3, Icon = (new Icons.Regular.Size24.NumberCircle3(), Color.Neutral, "start" ) } }
{ new Option<int> { Value = 1, Text = "1", Disabled = true, Icon = (new Icons.Regular.Size24.NumberCircle1(), Color.Neutral, "start" ) } },
{ new Option<int> { Value = 2, Text = "2", Icon = (new Icons.Regular.Size24.NumberCircle2(), Color.Neutral, "end" ) } },
{ new Option<int> { Value = 3, Text = "3", Icon = (new Icons.Regular.Size24.NumberCircle3(), Color.Neutral, "start" ) } }

};
}
2 changes: 1 addition & 1 deletion src/Core/Components/List/Option.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class Option<TType> : IOptionIcon
{
public TType? Value { get; set; }

public TType? Text { get; set; }
public string? Text { get; set; }

public (Icon Value, Color? Color, string? Slot)? Icon { get; set; }

Expand Down

0 comments on commit a43b7c3

Please sign in to comment.