Skip to content

Commit

Permalink
improved Editor UI
Browse files Browse the repository at this point in the history
  • Loading branch information
suxrobGM committed Aug 1, 2024
1 parent 067730b commit 23af91c
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/FormBuilder.DesignerApp/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<RadzenColumn class="d-flex" Size="3">
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Gap="0.5rem">
<RadzenSidebarToggle Click="@ToggleSidebar"/>
<RadzenText class="ms-2" Text="Blazor Form Builder" TextStyle="TextStyle.H5" />
<RadzenText class="rz-color-base-200" Text="Blazor Form Builder" TextStyle="TextStyle.H5"/>
</RadzenStack>
</RadzenColumn>
</RadzenRow>
Expand Down
2 changes: 1 addition & 1 deletion src/FormBuilder.DesignerApp/Pages/Renderer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<RadzenText TextStyle="TextStyle.H3">Renderer</RadzenText>

<RadzenStack Class="vh-100" Orientation="Orientation.Vertical" Gap="1rem">
<RadzenStack class="vh-100" Orientation="Orientation.Vertical" Gap="1rem">
<FormRenderer @ref="_formRendererRef" @bind-IsLoadingForm="_isLoading" />

<RadzenText TextStyle="TextStyle.Subtitle1">
Expand Down
2 changes: 1 addition & 1 deletion src/FormBuilder.DesignerApp/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<base href="/" />
<link rel="icon" type="image/png" href="favicon.png" />
<!-- <link href="_content/FormBuilder/css/app.css" rel="stylesheet" />-->
<link href="_content/Radzen.Blazor/css/standard-base.css" rel="stylesheet" /> <!-- Radzen CSS, specified explicitly for GitHub Pages -->
<link href="_content/Radzen.Blazor/css/material-base.css" rel="stylesheet" /> <!-- Radzen CSS, specified explicitly for GitHub Pages -->
<link href="_content/FormBuilder/css/bootstrap/bootstrap.min.css" rel="stylesheet" /> <!-- Bootstrap 5 CSS, specified explicitly for GitHub Pages -->
<link href="css/app.css" rel="stylesheet" />
<link href="FormBuilder.DesignerApp.styles.css" rel="stylesheet" />
Expand Down
16 changes: 8 additions & 8 deletions src/FormBuilder/Components/FieldPropertyEditor.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@if (Field is not null)
{
<RadzenStack Orientation="Orientation.Vertical">
<RadzenStack class="@ContainerClass" Orientation="Orientation.Vertical">
<RadzenFormField Text="ID">
<RadzenTextBox @bind-Value="Field.Name" Disabled="true"/>
</RadzenFormField>
Expand All @@ -24,14 +24,14 @@
<RadzenFormField Text="Hint" AllowFloatingLabel="false">
<RadzenTextBox @bind-Value="Field.Hint"/>
</RadzenFormField>
<div>
<RadzenCheckBox Name="ReadOnlyInput" @bind-Value="@ReadOnly"/>
<RadzenStack Orientation="Orientation.Horizontal" Gap="1rem" AlignItems="AlignItems.Center">
<RadzenLabel Text="Read only" Component="ReadOnlyInput"/>
</div>
<div>
<RadzenCheckBox Name="DisabledInput" @bind-Value="@Disabled"/>
<RadzenSwitch Name="ReadOnlyInput" @bind-Value="@ReadOnly"/>
</RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" Gap="1rem" AlignItems="AlignItems.Center">
<RadzenLabel Text="Disabled" Component="DisabledInput"/>
</div>
<RadzenSwitch Name="DisabledInput" @bind-Value="@Disabled"/>
</RadzenStack>

@if (Field is TextField textField)
{
Expand Down Expand Up @@ -84,6 +84,6 @@
}
}

<RadzenText Text="Validators" TextStyle="TextStyle.H6" />
<RadzenText Text="Validators" TextStyle="TextStyle.H6" TextAlign="TextAlign.Center" />
</RadzenStack>
}
7 changes: 6 additions & 1 deletion src/FormBuilder/Components/FieldPropertyEditor.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ public partial class FieldPropertyEditor : ComponentBase
/// </summary>
[Parameter]
public EventCallback<FieldPropertyChangedArgs> PropertyChanged { get; set; }

/// <summary>
/// The CSS class for the container element.
/// </summary>
[Parameter]
public string? ContainerClass { get; set; }

#endregion


#region Binding Properties

private string? Label
Expand Down
67 changes: 38 additions & 29 deletions src/FormBuilder/Components/FormEditor.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@using FormBuilder.Models

<RadzenRow Class="vh-100">
<RadzenRow class="vh-100">
<RadzenColumn Size="12" SizeMD="9" SizeLG="10">
<RadzenStack Orientation="Orientation.Vertical" Gap="1rem">
@if (_formDefinition.Id is not null)
Expand Down Expand Up @@ -47,34 +47,43 @@
</RadzenStack>
</RadzenColumn>

<RadzenColumn Class="border bg-light px-1" Size="12" SizeMD="3" SizeLG="2">
<RadzenStack Class="pt-2" Orientation="Orientation.Vertical">
<RadzenText TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">Fields</RadzenText>
<Dragable Data="() => AddField(FieldType.Text)" Zone="FieldsZone">
<RadzenButton Class="w-100" Text="Text Field" Click="() => AddField(FieldType.Text)"/>
</Dragable>
<Dragable Data="() => AddField(FieldType.NumericInt)" Zone="FieldsZone">
<RadzenButton Class="w-100" Text="Integer Field" Click="() => AddField(FieldType.NumericInt)"/>
</Dragable>
<Dragable Data="() => AddField(FieldType.NumericDecimal)" Zone="FieldsZone">
<RadzenButton Class="w-100" Text="Decimal Field" Click="() => AddField(FieldType.NumericDecimal)"/>
</Dragable>
<Dragable Data="() => AddField(FieldType.Date)" Zone="FieldsZone">
<RadzenButton Class="w-100" Text="Date Field" Click="() => AddField(FieldType.Date)"/>
</Dragable>
<Dragable Data="() => AddField(FieldType.Select)" Zone="FieldsZone">
<RadzenButton Class="w-100" Text="Select Field" Click="() => AddField(FieldType.Select)"/>
</Dragable>
<hr/>
</RadzenStack>
<RadzenStack Orientation="Orientation.Vertical" Gap="1rem">
<RadzenText TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">Properties</RadzenText>
<FieldPropertyEditor
@bind-Field="SelectedField"
PropertyChanged="(e) => HandleFieldPropertyChanged(e)">
</FieldPropertyEditor>
<hr/>
<RadzenButton Text="Save Form" Click="SaveFormAsync" Disabled="IsLoading"/>
<RadzenColumn class="border rz-background-color-base-100" Size="12" SizeMD="3" SizeLG="2">
<RadzenStack Orientation="Orientation.Vertical" Gap="0.5rem">
<RadzenPanelMenu>
<RadzenPanelMenuItem Text="Fields" Icon="payment">
<Dragable Data="() => AddField(FieldType.Text)" Zone="FieldsZone">
<RadzenPanelMenuItem Text="Text Field" Icon="input" Click="() => AddField(FieldType.Text)"/>
</Dragable>
<Dragable Data="() => AddField(FieldType.NumericInt)" Zone="FieldsZone">
<RadzenPanelMenuItem Text="Integer Field" Icon="pin" Click="() => AddField(FieldType.NumericInt)"/>
</Dragable>
<Dragable Data="() => AddField(FieldType.NumericDecimal)" Zone="FieldsZone">
<RadzenPanelMenuItem Text="Decimal Field" Icon="pin" Click="() => AddField(FieldType.NumericDecimal)"/>
</Dragable>
<Dragable Data="() => AddField(FieldType.Date)" Zone="FieldsZone">
<RadzenPanelMenuItem Text="Date Field" Icon="calendar_month" Click="() => AddField(FieldType.Date)"/>
</Dragable>
<Dragable Data="() => AddField(FieldType.Select)" Zone="FieldsZone">
<RadzenPanelMenuItem Text="Select Field" Icon="list_alt" Click="() => AddField(FieldType.Select)"/>
</Dragable>
</RadzenPanelMenuItem>
</RadzenPanelMenu>

@if (SelectedField is not null)
{
<RadzenText TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">Properties</RadzenText>
<FieldPropertyEditor
ContainerClass="px-1"
@bind-Field="SelectedField"
PropertyChanged="(e) => HandleFieldPropertyChanged(e)">
</FieldPropertyEditor>
}

@if (_formDefinition.Fields.Count > 0)
{
<RadzenButton Text="Save Form" Click="SaveFormAsync" Disabled="IsLoading"/>
}

<RadzenButton Text="Load Form" Click="OpenLoadFormDialogAsync" Disabled="IsLoading"/>
</RadzenStack>
</RadzenColumn>
Expand Down
2 changes: 1 addition & 1 deletion src/FormBuilder/Components/FormField.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@using FormBuilder.Models

<RadzenFormField Class="w-100" Text="@Field.Label" AllowFloatingLabel="true">
<RadzenFormField class="w-100" Text="@Field.Label" AllowFloatingLabel="true">
<Start>@Prepend</Start>
<ChildContent>
@switch (Field)
Expand Down
6 changes: 3 additions & 3 deletions src/FormBuilder/Components/NumericFieldPropertyEditor.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<RadzenFormField Text="Step">
<RadzenNumeric TValue="decimal" />
</RadzenFormField>
<div>
<RadzenCheckBox TValue="bool" Name="ShowUpDownInput" Value="Field.ShowUpDown" ValueChanged="OnShowUpDownChanged"/>
<RadzenStack Orientation="Orientation.Horizontal" Gap="1rem" AlignItems="AlignItems.Center">
<RadzenLabel Component="ShowUpDownInput" Text="Show Up Down" />
</div>
<RadzenSwitch TValue="bool" Name="ShowUpDownInput" Value="Field.ShowUpDown" ValueChanged="OnShowUpDownChanged"/>
</RadzenStack>

<RadzenFormField Text="Format">
<RadzenTextBox Value="@Field.Format" ValueChanged="OnFormatChanged"/>
Expand Down
2 changes: 1 addition & 1 deletion src/FormBuilder/Services/FormService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace FormBuilder.Services;

internal class FormService
public class FormService
{
private readonly HttpClient _httpClient;
private readonly JsonSerializerOptions _jsonSerializerDefaultOptions;
Expand Down
2 changes: 1 addition & 1 deletion src/FormBuilder/wwwroot/css/app.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@import "/_content/Radzen.Blazor/css/standard-base.css";
@import "/_content/Radzen.Blazor/css/material-base.css";
@import "/_content/FormBuilder/css/bootstrap/bootstrap.min.css";

0 comments on commit 23af91c

Please sign in to comment.