docs: fix error in for silder demo pages

This commit is contained in:
ElderJames 2020-05-13 13:45:49 +08:00
parent 671fff979c
commit 994aed2a7a
11 changed files with 55 additions and 38 deletions

View File

@ -237,3 +237,9 @@ dotnet_diagnostic.CA2227.severity = none
# CA1303: 请不要将文本作为本地化参数传递
dotnet_diagnostic.CA1303.severity = none
# CA2208: 正确实例化参数异常
dotnet_diagnostic.CA2208.severity = none
# CA1819: 属性不应返回数组
dotnet_diagnostic.CA1819.severity = none

View File

@ -67,7 +67,6 @@ namespace AntBlazor
.If($"{PrefixCls}-vertical", () => DotPosition == AntCarouselDotPosition.Left || DotPosition == AntCarouselDotPosition.Right);
}
protected async override Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
@ -102,7 +101,6 @@ namespace AntBlazor
private int Activate(int index, string transition = " transition: -webkit-transform 500ms ease 0s;")
{
if (Effect == AntCarouselEffect.ScrollX)
{
_trackStyle = $"width: {_totalWidth}px; opacity: 1; transform: translate3d(-{_slickWidth * (index + 1)}px, 0px, 0px);{transition}";

View File

@ -3,9 +3,9 @@ using System.Globalization;
namespace AntBlazor
{
public class DateHelper
public static class DateHelper
{
private static Calendar calendar = CultureInfo.InvariantCulture.Calendar;
private static readonly Calendar _calendar = CultureInfo.InvariantCulture.Calendar;
public static bool IsSameDate(DateTime date, DateTime compareDate)
{
@ -26,18 +26,18 @@ namespace AntBlazor
public static bool IsSameDay(DateTime date, DateTime compareDate)
{
return IsSameYear(date, compareDate)
&& calendar.GetDayOfYear(date) == calendar.GetDayOfYear(compareDate);
&& _calendar.GetDayOfYear(date) == _calendar.GetDayOfYear(compareDate);
}
public static bool IsSameWeak(DateTime date, DateTime compareDate)
{
return IsSameYear(date, compareDate)
return IsSameYear(date, compareDate)
&& GetWeekOfYear(date) == GetWeekOfYear(compareDate);
}
public static bool IsSameQuarter(DateTime date, DateTime compareDate)
{
return IsSameYear(date, compareDate)
return IsSameYear(date, compareDate)
&& GetDayOfQuarter(date) == GetDayOfQuarter(compareDate);
}
@ -51,7 +51,7 @@ namespace AntBlazor
public static int GetWeekOfYear(DateTime date)
{
return calendar.GetWeekOfYear(date, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
return _calendar.GetWeekOfYear(date, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
}
}
}

View File

@ -4,7 +4,7 @@ using System.Text;
namespace AntBlazor
{
public class AntDatePickerSize
public static class AntDatePickerSize
{
public const string Large = "40px";
public const string Default = "32px";

View File

@ -26,7 +26,7 @@ namespace AntBlazor
public bool IsButton { get; set; } = false;
[Parameter]
public AntDropdownTrigger[] Trigger { get; set; } = new AntDropdownTrigger[] { AntDropdownTrigger.Hover };
public AntDropdownTrigger[] Trigger { get; set; } = { AntDropdownTrigger.Hover };
[Parameter]
public string OverlayClassName { get; set; }
@ -64,7 +64,6 @@ namespace AntBlazor
private RenderFragment _leftButton;
private RenderFragment _rightButton;
[Inject]
private DomEventService DomEventService { get; set; }

View File

@ -9,7 +9,7 @@ namespace AntBlazor
{
public partial class AntList : AntDomComponentBase
{
public string _prefixName = "ant-list";
private string _prefixName = "ant-list";
[Parameter] public RenderFragment ChildContent { get; set; }

View File

@ -45,6 +45,11 @@ namespace AntBlazor
public void SelectItem(AntMenuItem item)
{
if (item == null)
{
return;
}
foreach (AntMenuItem menuitem in MenuItems.Where(x => x != item))
{
menuitem.Deselect();
@ -61,6 +66,11 @@ namespace AntBlazor
public void SelectSubmenu(AntSubMenu menu)
{
if (menu == null)
{
return;
}
if (Accordion)
{
foreach (AntSubMenu item in Submenus.Where(x => x != menu && x != menu.Parent))
@ -138,12 +148,14 @@ namespace AntBlazor
}
}
public void Dispose()
protected override void Dispose(bool disposing)
{
if (Parent != null)
{
Parent.OnCollapsed -= Update;
}
base.Dispose(disposing);
}
}
}

View File

@ -1,12 +1,13 @@
using Ardalis.SmartEnum;
using System.Globalization;
using Ardalis.SmartEnum;
namespace AntBlazor
{
public sealed class AntMenuMode : SmartEnum<AntMenuMode>
{
public static readonly AntMenuMode Vertical = new AntMenuMode(nameof(Vertical).ToLower(), 1);
public static readonly AntMenuMode Horizontal = new AntMenuMode(nameof(Horizontal).ToLower(), 2);
public static readonly AntMenuMode Inline = new AntMenuMode(nameof(Inline).ToLower(), 3);
public static readonly AntMenuMode Vertical = new AntMenuMode(nameof(Vertical).ToLower(CultureInfo.CurrentCulture), 1);
public static readonly AntMenuMode Horizontal = new AntMenuMode(nameof(Horizontal).ToLower(CultureInfo.CurrentCulture), 2);
public static readonly AntMenuMode Inline = new AntMenuMode(nameof(Inline).ToLower(CultureInfo.CurrentCulture), 3);
private AntMenuMode(string name, int value) : base(name, value)
{

View File

@ -1,11 +1,12 @@
using Ardalis.SmartEnum;
using System.Globalization;
using Ardalis.SmartEnum;
namespace AntBlazor
{
public sealed class AntMenuTheme : SmartEnum<AntMenuTheme>
{
public static readonly AntMenuTheme Light = new AntMenuTheme(nameof(Light).ToLowerInvariant(), 1);
public static readonly AntMenuTheme Dark = new AntMenuTheme(nameof(Dark).ToLowerInvariant(), 2);
public static readonly AntMenuTheme Light = new AntMenuTheme(nameof(Light).ToLower(CultureInfo.CurrentCulture), 1);
public static readonly AntMenuTheme Dark = new AntMenuTheme(nameof(Dark).ToLower(CultureInfo.CurrentCulture), 2);
private AntMenuTheme(string name, int value) : base(name, value)
{

View File

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Components.Web;
using OneOf;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
@ -272,7 +273,7 @@ namespace AntBlazor
public Action<double> OnChange { get; set; }
/// <summary>
/// Set Tooltip display position. Ref <seealso cref="Tooltip"/>
/// Set Tooltip display position. Ref Tooltip
/// </summary>
[Parameter]
public string TooltipPlacement { get; set; }
@ -335,7 +336,7 @@ namespace AntBlazor
throw new ArgumentOutOfRangeException(nameof(Step), "Must greater than 0.");
}
if (Step != null && ((Max - Min) / Step) % 1 != 0)
if (Step != null && (Max - Min) / Step % 1 != 0)
{
throw new ArgumentOutOfRangeException(nameof(Step), $"Must be divided by ({Max} - {Min}).");
}
@ -367,13 +368,12 @@ namespace AntBlazor
}
}
private async Task CalculateValueAsync(double clickClient, bool right = true)
private async Task CalculateValueAsync(double clickClient)
{
_sliderDom = await JsInvokeAsync<DomRect>(JSInteropConstants.getBoundingClientRect, _slider);
double sliderOffset = (double)(Vertical ? _sliderDom.top : _sliderDom.left);
double sliderLength = (double)(Vertical ? _sliderDom.height : _sliderDom.width);
double handleNewPosition = 0;
double handleNewPosition;
if (_right)
{
if (_rightHandleDom == null)
@ -460,15 +460,15 @@ namespace AntBlazor
private void SetStyle()
{
_rightHandleStyle = string.Format(RightHandleStyleFormat, (RightValue / Max).ToString("p"));
_rightHandleStyle = string.Format(CultureInfo.CurrentCulture, RightHandleStyleFormat, (RightValue / Max).ToString("p", CultureInfo.CurrentCulture));
if (Range)
{
_trackStyle = string.Format(TrackStyleFormat, (LeftValue / Max).ToString("p"), ((RightValue - LeftValue) / Max).ToString("p"));
_leftHandleStyle = string.Format(LeftHandleStyleFormat, (LeftValue / Max).ToString("p"));
_trackStyle = string.Format(CultureInfo.CurrentCulture, TrackStyleFormat, (LeftValue / Max).ToString("p", CultureInfo.CurrentCulture), ((RightValue - LeftValue) / Max).ToString("p", CultureInfo.CurrentCulture));
_leftHandleStyle = string.Format(CultureInfo.CurrentCulture, LeftHandleStyleFormat, (LeftValue / Max).ToString("p", CultureInfo.CurrentCulture));
}
else
{
_trackStyle = string.Format(TrackStyleFormat, "0%", (RightValue / Max).ToString("p"));
_trackStyle = string.Format(CultureInfo.CurrentCulture, TrackStyleFormat, "0%", (RightValue / Max).ToString("p", CultureInfo.CurrentCulture));
}
StateHasChanged();
@ -476,7 +476,7 @@ namespace AntBlazor
private string SetMarkPosition(double key)
{
return (key / Max).ToString("p");
return (key / Max).ToString("p", CultureInfo.CurrentCulture);
}
private string IsActiveMark(double key)
@ -507,4 +507,4 @@ namespace AntBlazor
}
}
}
}
}

View File

@ -9,9 +9,9 @@
<Title>Basic</Title>
<Description>Basic slider. When <code>range</code> is <code>true</code>, display as dual thumb mode. When <code>disable</code> is <code>true</code>, the slider will not be interactable.</Description>
<Demo>
<AntSlider DefaultValue="30" _disabled="@_disabled" />
<AntSlider DefaultValue="new double[] { 20, 50 }" _disabled="@_disabled" />
_disabled: <AntSwitch size="small" checked="@_disabled" OnChange="(e)=>OnSwitch(e)" />
<AntSlider DefaultValue="30" Disabled="@_disabled" />
<AntSlider DefaultValue="new double[] { 20, 50 }" Disabled="@_disabled" />
_disabled: <AntSwitch Size="small" Checked="@_disabled" OnChange="(e)=>OnSwitch(e)" />
</Demo>
</DemoCard>
@ -45,9 +45,9 @@
<Description>You can add an icon beside the slider to make it meaningful.</Description>
<Demo>
<div>
<AntIcon Style="display: inline-block" type="Frown" theme="outline" />
<AntIcon Style="display: inline-block" Type="Frown" Theme="outline" />
<AntSlider Style="display: inline-block; width: 300px;" Min="0" Max="20" DefaultValue="0" />
<AntIcon Style="display: inline-block" type="Smile" theme="outline" />
<AntIcon Style="display: inline-block" Type="Smile" Theme="outline" />
</div>
</Demo>
</DemoCard>
@ -107,7 +107,7 @@
<div>
<AntSlider Reverse="@_reversed" DefaultValue="30" />
<AntSlider Reverse="@_reversed" DefaultValue="new double[] { 20, 50 }" />
_reversed: <AntSwitch size="small" checked="@_reversed" OnChange="(e)=>OnSwitchReverse(e)" />
_reversed: <AntSwitch Size="small" Checked="@_reversed" OnChange="(e)=>OnSwitchReverse(e)" />
</div>
</Demo>
</DemoCard>
@ -119,7 +119,7 @@
<div>
<AntSlider Reverse="@_reversed" Value="30" />
@*<AntSlider Reverse="@_reversed" Value="[20, 50]" />*@
_reversed: <AntSwitch size="small" checked="@_reversed" OnChange="(e)=>OnSwitchReverse(e)" />
_reversed: <AntSwitch Size="small" Checked="@_reversed" OnChange="(e)=>OnSwitchReverse(e)" />
</div>
</Demo>
</DemoCard>