[CounterBadge] Add ShowWhen, Dot, and VerticalPosition. #1786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To make the counterbadge more versatile, some rework has been done. Previously when the
Count
value was 0, the whole component would not get rendered. This made it hard to use the component because you needed aif..else
construct to render the component that the FluentCounterBadge wraps. In most cases that lead to repeated rendering logic.With the changes made, the
FluentCounterBadge
will always render its container andChildContent
. The rendering of the actual badge is still dependant on theCount'. By default the badge will not be shown if the
Count` is zero.New parameters:
ShowWhen
: aFunc<int,bool>
which can be used to specify the condition that determines if the badge is shown. This replacesShowZero
which has now been obsoleted. Default value isCount => Count > 0
. To get theShowZero
functionality, you could specifyShowWhen="@(Count => Count >= 0)"
Dot
(bool
, default false). When set to true, a dot is rendered instead of a full badge.Count
is ignored in this case.BadgeContent
VerticalPosition
(int, default 60) This just replaces theBottomPosition
parameter (which has been obsoleted) to better align with theHorizontalPosition
parameter name.BadgeContent
has been obsoleted and is replaced byBadgeTemplate
to be more aligned with how we use this in other parts of the library.BadgeTemplate
is now a real template and makes theCount
available for use throught the@context
parameter.Tests have been veriefied and updated.