mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-03-29 19:11:38 +00:00
added class and style attrs to switch
This commit is contained in:
parent
ec357d7c4f
commit
a32a5354e9
@ -116,7 +116,9 @@
|
||||
UncheckedColor="@assistantSwitch.GetColor(assistantSwitch.UncheckedColor)"
|
||||
ThumbIcon="@assistantSwitch.GetIconSvg()"
|
||||
ThumbIconColor="@assistantSwitch.GetColor(assistantSwitch.IconColor)"
|
||||
Disabled="@assistantSwitch.Disabled">
|
||||
Disabled="@assistantSwitch.Disabled"
|
||||
Class="@assistantSwitch.Class"
|
||||
Style="@this.GetOptionalStyle(assistantSwitch.Style)">
|
||||
@(currentValue ? assistantSwitch.LabelOn : assistantSwitch.LabelOff)
|
||||
</MudSwitch>
|
||||
</MudField>
|
||||
|
||||
@ -11,7 +11,7 @@ Supported types (matching the Blazor UI components):
|
||||
|
||||
- `TEXT_AREA`: user input field based on `MudTextField`; requires `Name`, `Label`, and may include `HelperText`, `HelperTextOnFocus`, `Adornment`, `AdornmentIcon`, `AdornmentText`, `AdornmentColor`, `Counter`, `MaxLength`, `IsImmediate`, `UserPrompt`, `PrefillText`, `IsSingleLine`, `ReadOnly`, `Class`, `Style`.
|
||||
- `DROPDOWN`: selects between variants; `Props` must include `Name`, `Label`, `Default`, `Items`, and optionally `ValueType` plus `UserPrompt`.
|
||||
- `SWITCH`: boolean option; requires `Name`, `Label`, `Value`, and may include `Disabled`, `UserPrompt`, `LabelOn`, `LabelOff`, `LabelPlacement`, `Icon`, `IconColor`, `CheckedColor`, `UncheckedColor`.
|
||||
- `SWITCH`: boolean option; requires `Name`, `Label`, `Value`, and may include `Disabled`, `UserPrompt`, `LabelOn`, `LabelOff`, `LabelPlacement`, `Icon`, `IconColor`, `CheckedColor`, `UncheckedColor`, `Class`, `Style`.
|
||||
- `COLOR_PICKER`: color input based on `MudColorPicker`; requires `Name`, `Label`, and may include `Placeholder`, `ShowAlpha`, `ShowToolbar`, `ShowModeSwitch`, `PickerVariant`, `UserPrompt`, `Class`, `Style`.
|
||||
- `PROVIDER_SELECTION` / `PROFILE_SELECTION`: hooks into the shared provider/profile selectors.
|
||||
- `WEB_CONTENT_READER`: renders `ReadWebContent`; include `Name`, `UserPrompt`, `Preselect`, `PreselectContentCleanerAgent`.
|
||||
@ -173,7 +173,8 @@ Example:
|
||||
- `IconColor`: one of the MudBlazor `Color` enum names such as `Primary`, `Secondary`, `Warning`; omitted values default to `Inherit`.
|
||||
- `CheckedColor`: color used when the switch state is `true`; omitted values default to `Inherit`.
|
||||
- `UncheckedColor`: color used when the switch state is `false`; omitted values default to `Inherit`.
|
||||
|
||||
- `Class`, `Style`: forwarded to the rendered component for layout/styling.
|
||||
-
|
||||
Example:
|
||||
```lua
|
||||
{
|
||||
@ -190,7 +191,8 @@ Example:
|
||||
["Icon"] = "Icons.Material.Filled.Summarize",
|
||||
["IconColor"] = "Primary",
|
||||
["CheckedColor"] = "Success",
|
||||
["UncheckedColor"] = "Default"
|
||||
["UncheckedColor"] = "Default",
|
||||
["Class"] = "mb-6",
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -83,8 +83,8 @@ ASSISTANT = {
|
||||
["PrefillText"] = "<text to show in the field initially>",
|
||||
["IsSingleLine"] = false, -- if true, shows a text field instead of an area
|
||||
["ReadOnly"] = false, -- if true, deactivates user input (make sure to provide a PrefillText)
|
||||
["Class"] = "<MudBlazor or css classes>",
|
||||
["Style"] = "<css styles>",
|
||||
["Class"] = "<optional MudBlazor or css classes>",
|
||||
["Style"] = "<optional css styles>",
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -116,6 +116,8 @@ ASSISTANT = {
|
||||
["IconColor"] = "<Dark|Error|Info|Inherit|Primary|Secondary|Success|Surface|Tertiary|Transparent|Warning>", -- color of the thumb icon. Defaults to `Inherit`
|
||||
["CheckedColor"] = "<Dark|Error|Info|Inherit|Primary|Secondary|Success|Surface|Tertiary|Transparent|Warning>", -- color of the switch if state is true. Defaults to `Inherit`
|
||||
["UncheckedColor"] = "<Dark|Error|Info|Inherit|Primary|Secondary|Success|Surface|Tertiary|Transparent|Warning>", -- color of the switch if state is false. Defaults to `Inherit`
|
||||
["Class"] = "<optional MudBlazor or css classes>",
|
||||
["Style"] = "<optional css styles>",
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@ -79,6 +79,18 @@ internal sealed class AssistantSwitch : AssistantComponentBase
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.IconColor));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.IconColor), value);
|
||||
}
|
||||
|
||||
public string Class
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
|
||||
}
|
||||
|
||||
public string Style
|
||||
{
|
||||
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
|
||||
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
|
||||
}
|
||||
|
||||
public MudBlazor.Color GetColor(string colorString) => Enum.TryParse<Color>(colorString, out var color) ? color : MudBlazor.Color.Inherit;
|
||||
public Placement GetLabelPlacement() => Enum.TryParse<Placement>(this.LabelPlacement, out var placement) ? placement : Placement.Right;
|
||||
|
||||
@ -35,7 +35,10 @@ public static class ComponentPropSpecs
|
||||
),
|
||||
[AssistantComponentType.SWITCH] = new(
|
||||
required: ["Name", "Label", "Value"],
|
||||
optional: [ "LabelOn", "LabelOff", "LabelPlacement", "Icon", "IconColor", "UserPrompt", "CheckedColor", "UncheckedColor", "Disabled"]
|
||||
optional: [
|
||||
"LabelOn", "LabelOff", "LabelPlacement", "Icon", "IconColor", "UserPrompt",
|
||||
"CheckedColor", "UncheckedColor", "Disabled", "Class", "Style",
|
||||
]
|
||||
),
|
||||
[AssistantComponentType.HEADING] = new(
|
||||
required: ["Text", "Level"],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user