mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 13:37:35 +08:00
c9656ca227
* feat(module: image): add image * add image preview * add locale
57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public partial class SpaceItem : ComponentBase
|
|
{
|
|
[CascadingParameter]
|
|
public Space Parent { get; set; }
|
|
|
|
[Parameter]
|
|
public RenderFragment ChildContent { get; set; }
|
|
|
|
[Parameter] public ForwardRef RefBack { get; set; } = new ForwardRef();
|
|
|
|
private ElementReference _ref;
|
|
|
|
/// <summary>
|
|
/// Returned ElementRef reference for DOM element.
|
|
/// </summary>
|
|
public virtual ElementReference Ref
|
|
{
|
|
get => _ref;
|
|
set
|
|
{
|
|
_ref = value;
|
|
RefBack?.Set(value);
|
|
}
|
|
}
|
|
|
|
private static readonly Dictionary<string, string> _spaceSize = new()
|
|
{
|
|
["small"] = "8",
|
|
["middle"] = "16",
|
|
["large"] = "24"
|
|
};
|
|
|
|
private string _marginStyle = "";
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
base.OnParametersSet();
|
|
|
|
if (Parent == null)
|
|
return;
|
|
|
|
var size = Parent.Size;
|
|
var direction = Parent.Direction;
|
|
|
|
var marginSize = size.IsIn("small", "middle", "large") ? _spaceSize[size] : size;
|
|
|
|
_marginStyle = direction == "horizontal" ? $"margin-right:{(CssSizeLength)marginSize};" : $"margin-bottom:{(CssSizeLength)marginSize};";
|
|
}
|
|
}
|
|
}
|