51 lines
1.6 KiB
Plaintext
51 lines
1.6 KiB
Plaintext
@inherits DComponentBase
|
|||
|
|
|
||
|
|
@* daisyUI Tooltip: https://daisyui.com/components/tooltip/ . Shows on hover or keyboard focus of ChildContent: Tip
|
||
|
|
sets data-tip, or TipContent renders a tooltip-content part for markup. IsOpen keeps it shown (tooltip-open). *@
|
||
|
|
<div @attributes="AdditionalAttributes" class="@CssClass" data-tip="@Tip">
|
||
|
|
@if (TipContent is not null)
|
||
|
|
{
|
||
|
|
<div class="tooltip-content">@TipContent</div>
|
||
|
|
}
|
||
|
|
@ChildContent
|
||
|
|
</div>
|
||
|
|
|
||
|
|
@code {
|
||
|
|
[Parameter] public RenderFragment ChildContent { get; set; }
|
||
|
|
[Parameter] public string Tip { get; set; }
|
||
|
|
[Parameter] public RenderFragment TipContent { get; set; }
|
||
|
|
[Parameter] public DTooltipPlacement Placement { get; set; }
|
||
|
|
[Parameter] public DTooltipAlign Align { get; set; }
|
||
|
|
/// <summary>Neutral is the default look; daisyUI has no tooltip-neutral.</summary>
|
||
|
|
[Parameter] public DColor Color { get; set; }
|
||
|
|
[Parameter] public bool IsOpen { get; set; }
|
||
|
|
|
||
|
|
string CssClass => Cx("tooltip", PlacementClass, AlignClass, ColorClass, IsOpen ? "tooltip-open" : null, Class);
|
||
|
|
|
||
|
|
string PlacementClass => Placement switch
|
||
|
|
{
|
||
|
|
DTooltipPlacement.Bottom => "tooltip-bottom",
|
||
|
|
DTooltipPlacement.Left => "tooltip-left",
|
||
|
|
DTooltipPlacement.Right => "tooltip-right",
|
||
|
|
_ => null
|
||
|
|
};
|
||
|
|
|
||
|
|
string AlignClass => Align switch
|
||
|
|
{
|
||
|
|
DTooltipAlign.Start => "tooltip-start",
|
||
|
|
DTooltipAlign.End => "tooltip-end",
|
||
|
|
_ => null
|
||
|
|
};
|
||
|
|
|
||
|
|
string ColorClass => Color switch
|
||
|
|
{
|
||
|
|
DColor.Primary => "tooltip-primary",
|
||
|
|
DColor.Secondary => "tooltip-secondary",
|
||
|
|
DColor.Accent => "tooltip-accent",
|
||
|
|
DColor.Info => "tooltip-info",
|
||
|
|
DColor.Success => "tooltip-success",
|
||
|
|
DColor.Warning => "tooltip-warning",
|
||
|
|
DColor.Error => "tooltip-error",
|
||
|
|
_ => null
|
||
|
|
};
|
||
|
|
}
|