From 3e632031f13eb9bbb0850a267e927eb7e85c2278 Mon Sep 17 00:00:00 2001 From: capdiem Date: Tue, 9 Apr 2024 15:25:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20refactor(Rating):=20move=20code?= =?UTF-8?q?=20to=20Masa.Blazor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Rating/BRating.razor | 12 ----- .../Components/Rating/BRating.razor.cs | 44 ------------------- .../Components/Rating/BRatingItem.razor | 14 ------ .../Components/Rating/BRatingItem.razor.cs | 14 ------ .../Components/Rating/IRating.cs | 11 ----- .../RatingAbstractProviderExtensions.cs | 11 ----- .../Components/Rating/RatingItem.cs | 19 -------- 7 files changed, 125 deletions(-) delete mode 100644 src/Component/BlazorComponent/Components/Rating/BRating.razor delete mode 100644 src/Component/BlazorComponent/Components/Rating/BRating.razor.cs delete mode 100644 src/Component/BlazorComponent/Components/Rating/BRatingItem.razor delete mode 100644 src/Component/BlazorComponent/Components/Rating/BRatingItem.razor.cs delete mode 100644 src/Component/BlazorComponent/Components/Rating/IRating.cs delete mode 100644 src/Component/BlazorComponent/Components/Rating/RatingAbstractProviderExtensions.cs delete mode 100644 src/Component/BlazorComponent/Components/Rating/RatingItem.cs diff --git a/src/Component/BlazorComponent/Components/Rating/BRating.razor b/src/Component/BlazorComponent/Components/Rating/BRating.razor deleted file mode 100644 index 4988293a3..000000000 --- a/src/Component/BlazorComponent/Components/Rating/BRating.razor +++ /dev/null @@ -1,12 +0,0 @@ -@namespace BlazorComponent -@inherits BDomComponentBase - - -
- @for (var i = 0; i < Length.ToInt32(); i++) - { - var index = i; - @RenderPart(typeof(BRatingItem<>), index, arg0Name: "ItemIndex") - } -
-
diff --git a/src/Component/BlazorComponent/Components/Rating/BRating.razor.cs b/src/Component/BlazorComponent/Components/Rating/BRating.razor.cs deleted file mode 100644 index b6fbe8327..000000000 --- a/src/Component/BlazorComponent/Components/Rating/BRating.razor.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace BlazorComponent -{ - public partial class BRating : BDomComponentBase - { - [Parameter] - public RenderFragment? ChildContent { get; set; } - - [Parameter] - public RenderFragment? ItemContent { get; set; } - - [Parameter] - [MasaApiParameter(5)] - public StringNumber Length { get; set; } = 5; - - [Parameter] - public bool Dark { get; set; } - - [Parameter] - public bool Light { get; set; } - - [CascadingParameter(Name = "IsDark")] - public bool CascadingIsDark { get; set; } - - public bool IsDark - { - get - { - if (Dark) - { - return true; - } - - if (Light) - { - return false; - } - - return CascadingIsDark; - } - } - } -} diff --git a/src/Component/BlazorComponent/Components/Rating/BRatingItem.razor b/src/Component/BlazorComponent/Components/Rating/BRatingItem.razor deleted file mode 100644 index 822a30acf..000000000 --- a/src/Component/BlazorComponent/Components/Rating/BRatingItem.razor +++ /dev/null @@ -1,14 +0,0 @@ -@namespace BlazorComponent -@typeparam TRating -@inherits ComponentPartBase - -@if (ItemContent != null) -{ - @ItemContent(Item) -} -else -{ - - @GetIconName(Item) - -} \ No newline at end of file diff --git a/src/Component/BlazorComponent/Components/Rating/BRatingItem.razor.cs b/src/Component/BlazorComponent/Components/Rating/BRatingItem.razor.cs deleted file mode 100644 index 4601302ff..000000000 --- a/src/Component/BlazorComponent/Components/Rating/BRatingItem.razor.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace BlazorComponent -{ - public partial class BRatingItem where TRating : IRating - { - [Parameter] - public int ItemIndex { get; set; } - - public RenderFragment? ItemContent => Component.ItemContent; - - public string GetIconName(RatingItem item) => Component.GetIconName(item); - - public RatingItem Item => Component.CreateProps(ItemIndex); - } -} diff --git a/src/Component/BlazorComponent/Components/Rating/IRating.cs b/src/Component/BlazorComponent/Components/Rating/IRating.cs deleted file mode 100644 index ac317c7fd..000000000 --- a/src/Component/BlazorComponent/Components/Rating/IRating.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace BlazorComponent -{ - public interface IRating : IHasProviderComponent - { - RenderFragment? ItemContent { get; } - - RatingItem CreateProps(int i); - - string GetIconName(RatingItem item); - } -} \ No newline at end of file diff --git a/src/Component/BlazorComponent/Components/Rating/RatingAbstractProviderExtensions.cs b/src/Component/BlazorComponent/Components/Rating/RatingAbstractProviderExtensions.cs deleted file mode 100644 index 9269dc8b5..000000000 --- a/src/Component/BlazorComponent/Components/Rating/RatingAbstractProviderExtensions.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace BlazorComponent -{ - public static class RatingAbstractProviderExtensions - { - public static ComponentAbstractProvider ApplyRatingDefault(this ComponentAbstractProvider abstractProvider) - { - return abstractProvider - .Apply(typeof(BRatingItem<>), typeof(BRatingItem)); - } - } -} diff --git a/src/Component/BlazorComponent/Components/Rating/RatingItem.cs b/src/Component/BlazorComponent/Components/Rating/RatingItem.cs deleted file mode 100644 index 46d73038f..000000000 --- a/src/Component/BlazorComponent/Components/Rating/RatingItem.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace BlazorComponent -{ - public class RatingItem - { - public int Index { get; set; } - - public double Value { get; set; } - - public bool IsFilled { get; set; } - - public bool? IsHalfFilled { get; set; } - - public bool IsHovered { get; set; } - - public bool? IsHalfHovered { get; set; } - - public Action? Click { get; set; } - } -}