Components/Daisy/ wraps all 69 components in daisyUI's llms.txt, grouped by daisyUI's categories (Actions, DataDisplay, Navigation, Feedback, DataInput, Layout, Mockup), with part components where daisyUI has repeating parts (DTab, DMenuItem, DTimelineItem, ...). - Each enum maps to whole literal class names in a switch, so Tailwind's scanner generates them. Nothing is concatenated. - Value-holding fields derive from DInputBase<TValue>, Blazor's InputBase, so @bind-Value and EditForm validation work. Invalid fields get the component's *-error class. - Open and active state lives in C# (@bind-IsOpen, @bind-Active) and is rendered with daisyUI's *-open modifiers. DDropdown adds an outside-click layer and Escape. No component uses JS interop. - The one exception is DCalendar, which wraps the Cally web component, vendored as wwwroot/vendor/cally.js (0.9.2, MIT). /styleguide (not linked) renders every component in all its colours, sizes and states, with a theme and hue picker that previews without saving. neo.css follows what the styleguide showed: - select keeps daisyUI's arrow; - skeleton-text isn't sunk; - the phone mockup and dock are raised; - active menu items and OTP digits are inset; - a joined accordion is raised as one block. The primary, secondary and accent colours are deeper, so they still read as text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
102 lines
3.1 KiB
Plaintext
102 lines
3.1 KiB
Plaintext
@inherits DInputBase<bool>
|
|
|
|
@* daisyUI Toggle: https://daisyui.com/components/toggle/ . With CheckedIcon/UncheckedIcon the toggle class moves to a
|
|
wrapper around the checkbox and the two icons (each must be a single element: daisyUI shows the wrapper's 2nd child
|
|
while unchecked and its 3rd while checked). daisyUI colors such a wrapper only through aria-checked, which a label
|
|
may not carry, so its color is a has-checked: variable instead. With LabelText all of it sits in a label.label. *@
|
|
@if (!HasIcons && LabelText is null)
|
|
{
|
|
@Checkbox(Cx("toggle", IsInvalid ? "toggle-error" : ColorClass, SizeClass, CssClass))
|
|
}
|
|
else if (!HasIcons)
|
|
{
|
|
<label class="label">
|
|
@Checkbox(Cx("toggle", IsInvalid ? "toggle-error" : ColorClass, SizeClass, CssClass))
|
|
@LabelText
|
|
</label>
|
|
}
|
|
else if (LabelText is null)
|
|
{
|
|
<label class="@WrapperClass">@IconParts</label>
|
|
}
|
|
else
|
|
{
|
|
<label class="label">
|
|
<span class="@WrapperClass">@IconParts</span>
|
|
@LabelText
|
|
</label>
|
|
}
|
|
|
|
@code {
|
|
[Parameter] public DColor Color { get; set; }
|
|
[Parameter] public DSize Size { get; set; }
|
|
[Parameter] public string LabelText { get; set; }
|
|
[Parameter] public RenderFragment CheckedIcon { get; set; }
|
|
[Parameter] public RenderFragment UncheckedIcon { get; set; }
|
|
|
|
bool HasIcons => CheckedIcon is not null || UncheckedIcon is not null;
|
|
|
|
string WrapperClass => Cx("toggle", IsInvalid ? "has-checked:[--input-color:var(--color-error)]" : WrapperColorClass, SizeClass, CssClass);
|
|
|
|
RenderFragment Checkbox(string cssClass) =>
|
|
@<input @attributes="InputAttributes" type="checkbox" class="@cssClass" name="@NameAttributeValue" checked="@CurrentValue"
|
|
@onchange="OnChange" aria-invalid="@(IsInvalid ? "true" : null)" />;
|
|
|
|
RenderFragment IconParts => @<text>
|
|
@Checkbox(null)
|
|
@if (UncheckedIcon is null)
|
|
{
|
|
<span></span>
|
|
}
|
|
else
|
|
{
|
|
@UncheckedIcon
|
|
}
|
|
@if (CheckedIcon is null)
|
|
{
|
|
<span></span>
|
|
}
|
|
else
|
|
{
|
|
@CheckedIcon
|
|
}
|
|
</text>;
|
|
|
|
string ColorClass => Color switch
|
|
{
|
|
DColor.Neutral => "toggle-neutral",
|
|
DColor.Primary => "toggle-primary",
|
|
DColor.Secondary => "toggle-secondary",
|
|
DColor.Accent => "toggle-accent",
|
|
DColor.Info => "toggle-info",
|
|
DColor.Success => "toggle-success",
|
|
DColor.Warning => "toggle-warning",
|
|
DColor.Error => "toggle-error",
|
|
_ => null
|
|
};
|
|
|
|
string WrapperColorClass => Color switch
|
|
{
|
|
DColor.Neutral => "has-checked:[--input-color:var(--color-neutral)]",
|
|
DColor.Primary => "has-checked:[--input-color:var(--color-primary)]",
|
|
DColor.Secondary => "has-checked:[--input-color:var(--color-secondary)]",
|
|
DColor.Accent => "has-checked:[--input-color:var(--color-accent)]",
|
|
DColor.Info => "has-checked:[--input-color:var(--color-info)]",
|
|
DColor.Success => "has-checked:[--input-color:var(--color-success)]",
|
|
DColor.Warning => "has-checked:[--input-color:var(--color-warning)]",
|
|
DColor.Error => "has-checked:[--input-color:var(--color-error)]",
|
|
_ => null
|
|
};
|
|
|
|
string SizeClass => Size switch
|
|
{
|
|
DSize.Xs => "toggle-xs",
|
|
DSize.Sm => "toggle-sm",
|
|
DSize.Lg => "toggle-lg",
|
|
DSize.Xl => "toggle-xl",
|
|
_ => null
|
|
};
|
|
|
|
void OnChange(ChangeEventArgs e) => CurrentValue = e.Value is true;
|
|
}
|