Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global input sizing #2485

Merged
merged 2 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions Demos/Blazorise.Demo/Layouts/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -293,97 +293,6 @@
</LayoutContent>
</Layout>
</Layout>

@code{
[Inject] protected ITextLocalizerService LocalizationService { get; set; }

protected override async Task OnInitializedAsync()
{
await SelectCulture( "en-US" );

await base.OnInitializedAsync();
}

Task SelectCulture( string name )
{
LocalizationService.ChangeLanguage( name );

return Task.CompletedTask;
}

void OnThemeEnabledChanged( bool value )
{
if ( Theme == null )
return;

Theme.Enabled = value;

Theme.ThemeHasChanged();
}

void OnGradientChanged( bool value )
{
if ( Theme == null )
return;

Theme.IsGradient = value;

//if ( Theme.GradientOptions == null )
// Theme.GradientOptions = new GradientOptions();

//Theme.GradientOptions.BlendPercentage = 80;

Theme.ThemeHasChanged();
}

void OnRoundedChanged( bool value )
{
if ( Theme == null )
return;

Theme.IsRounded = value;

Theme.ThemeHasChanged();
}

void OnThemeColorChanged( string value )
{
if ( Theme == null )
return;

if ( Theme.ColorOptions == null )
Theme.ColorOptions = new ThemeColorOptions();

if ( Theme.BackgroundOptions == null )
Theme.BackgroundOptions = new ThemeBackgroundOptions();

if ( Theme.TextColorOptions == null )
Theme.TextColorOptions = new ThemeTextColorOptions();

Theme.ColorOptions.Primary = value;
Theme.BackgroundOptions.Primary = value;
Theme.TextColorOptions.Primary = value;

if ( Theme.InputOptions == null )
Theme.InputOptions = new ThemeInputOptions();

//Theme.InputOptions.Color = value;
Theme.InputOptions.CheckColor = value;
Theme.InputOptions.SliderColor = value;

if ( Theme.SpinKitOptions == null )
Theme.SpinKitOptions = new ThemeSpinKitOptions();

Theme.SpinKitOptions.Color = value;

Theme.ThemeHasChanged();
}

private bool topbarVisible = false;
private bool uiElementsVisible = true;
private bool utilitiesVisible = false;

[CascadingParameter] protected Theme Theme { get; set; }

RenderFragment customIcon =@<img src="/brand-logo.png" style="width:32px; height: 32px" />;
}
100 changes: 100 additions & 0 deletions Demos/Blazorise.Demo/Layouts/MainLayout.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using System.Threading.Tasks;
using Blazorise.Localization;
using Microsoft.AspNetCore.Components;

namespace Blazorise.Demo.Layouts
{
public partial class MainLayout
{
private bool topbarVisible = false;
private bool uiElementsVisible = true;
private bool utilitiesVisible = false;

protected override async Task OnInitializedAsync()
{
await SelectCulture( "en-US" );

await base.OnInitializedAsync();
}

Task SelectCulture( string name )
{
LocalizationService.ChangeLanguage( name );

return Task.CompletedTask;
}

void OnThemeEnabledChanged( bool value )
{
if ( Theme == null )
return;

Theme.Enabled = value;

Theme.ThemeHasChanged();
}

void OnGradientChanged( bool value )
{
if ( Theme == null )
return;

Theme.IsGradient = value;

//if ( Theme.GradientOptions == null )
// Theme.GradientOptions = new GradientOptions();

//Theme.GradientOptions.BlendPercentage = 80;

Theme.ThemeHasChanged();
}

void OnRoundedChanged( bool value )
{
if ( Theme == null )
return;

Theme.IsRounded = value;

Theme.ThemeHasChanged();
}

void OnThemeColorChanged( string value )
{
if ( Theme == null )
return;

if ( Theme.ColorOptions == null )
Theme.ColorOptions = new ThemeColorOptions();

if ( Theme.BackgroundOptions == null )
Theme.BackgroundOptions = new ThemeBackgroundOptions();

if ( Theme.TextColorOptions == null )
Theme.TextColorOptions = new ThemeTextColorOptions();

Theme.ColorOptions.Primary = value;
Theme.BackgroundOptions.Primary = value;
Theme.TextColorOptions.Primary = value;

if ( Theme.InputOptions == null )
Theme.InputOptions = new ThemeInputOptions();

//Theme.InputOptions.Color = value;
Theme.InputOptions.CheckColor = value;
Theme.InputOptions.SliderColor = value;

if ( Theme.SpinKitOptions == null )
Theme.SpinKitOptions = new ThemeSpinKitOptions();

Theme.SpinKitOptions.Color = value;

Theme.ThemeHasChanged();
}

[Inject] protected ITextLocalizerService LocalizationService { get; set; }

[CascadingParameter] protected Theme Theme { get; set; }
}
}
21 changes: 21 additions & 0 deletions Demos/Blazorise.Demo/Pages/Tests/ThemingPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@page "/tests/theming"
<Row>
<Column>
<Card Margin="Margin.Is4.OnY">
<CardHeader>
<CardTitle>Buttons and Input sizes</CardTitle>
</CardHeader>
<CardBody>
<CardText>Define the global size for button and input components.</CardText>
</CardBody>
<CardBody>
<Select TValue="Size?" SelectedValue="@selectedSize" SelectedValueChanged="@OnThemeInputSizeChanged">
<SelectItem TValue="Size?" Value="@(null)"></SelectItem>
<SelectItem TValue="Size?" Value="Size.Small">Small</SelectItem>
<SelectItem TValue="Size?" Value="Size.None">Default</SelectItem>
<SelectItem TValue="Size?" Value="Size.Large">Large</SelectItem>
</Select>
</CardBody>
</Card>
</Column>
</Row>
47 changes: 47 additions & 0 deletions Demos/Blazorise.Demo/Pages/Tests/ThemingPage.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;

namespace Blazorise.Demo.Pages.Tests
{
public partial class ThemingPage
{
private Size? selectedSize;

void OnThemeInputSizeChanged( Size? size )
{
selectedSize = size;

if ( Theme == null )
return;

if ( Theme.ButtonOptions == null )
Theme.ButtonOptions = new ThemeButtonOptions();

if ( Theme.DropdownOptions == null )
Theme.DropdownOptions = new ThemeDropdownOptions();

if ( Theme.InputOptions == null )
Theme.InputOptions = new ThemeInputOptions();

if ( Theme.PaginationOptions == null )
Theme.PaginationOptions = new ThemePaginationOptions();

if ( Theme.ProgressOptions == null )
Theme.ProgressOptions = new ThemeProgressOptions();

Theme.ButtonOptions.Size = size;
Theme.DropdownOptions.Size = size;
Theme.InputOptions.Size = size;
Theme.PaginationOptions.Size = size;
Theme.ProgressOptions.Size = size;

Theme.ThemeHasChanged();
}

[CascadingParameter] protected Theme Theme { get; set; }
}
}
6 changes: 6 additions & 0 deletions Source/Blazorise.AntDesign/AntDesignClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public class AntDesignClassProvider : ClassProvider

public override string ColorEdit() => "ant-input";

public override string ColorEditSize( Size size ) => $"ant-input-{ToSize( size )}";

#endregion

#region Check
Expand All @@ -105,6 +107,8 @@ public class AntDesignClassProvider : ClassProvider
public override string RadioGroup( bool buttons, Orientation orientation )
=> "ant-radio-group ant-radio-group-outline" + ( orientation == Orientation.Horizontal ? "" : " ant-radio-group-vertical" );

public override string RadioGroupSize( bool buttons, Orientation orientation, Size size ) => $"ant-btn-group-{ToSize( size )}";

public override string RadioGroupValidation( ValidationStatus validationStatus ) => ToValidationStatus( validationStatus );

#endregion
Expand Down Expand Up @@ -143,6 +147,8 @@ public override string RadioGroup( bool buttons, Orientation orientation )

public override string FileEdit() => null;

public override string FileEditSize( Size size ) => null;

public override string FileEditValidation( ValidationStatus validationStatus ) => ToValidationStatus( validationStatus );

#endregion
Expand Down
4 changes: 2 additions & 2 deletions Source/Blazorise.AntDesign/Select.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ string ContainerClassNames
{
var sb = new StringBuilder( "ant-select ant-select-show-arrow" );

if ( Size != Size.None )
sb.Append( $" ant-select-{ClassProvider.ToSize( Size )}" );
if ( ThemeSize != Blazorise.Size.None )
sb.Append( $" ant-select-{ClassProvider.ToSize( ThemeSize )}" );

if ( Multiple )
sb.Append( " ant-select-multiple" );
Expand Down
8 changes: 8 additions & 0 deletions Source/Blazorise.Bootstrap/BootstrapClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public class BootstrapClassProvider : ClassProvider

public override string ColorEdit() => "form-control";

public override string ColorEditSize( Size size ) => $"form-control-{ToSize( size )}";

#endregion

#region Check
Expand All @@ -106,6 +108,10 @@ public override string RadioGroup( bool buttons, Orientation orientation ) => bu
? orientation == Orientation.Horizontal ? "btn-group btn-group-toggle" : "btn-group-vertical btn-group-toggle"
: null;

public override string RadioGroupSize( bool buttons, Orientation orientation, Size size ) => buttons
? orientation == Orientation.Horizontal ? $"btn-group-{ToSize( size )}" : $"btn-group-vertical-{ToSize( size )}"
: null;

public override string RadioGroupValidation( ValidationStatus validationStatus ) => ToValidationStatus( validationStatus );

#endregion
Expand Down Expand Up @@ -146,6 +152,8 @@ public override string RadioInline( bool inline ) => inline

public override string FileEdit() => UseCustomInputStyles ? "custom-file-input" : "form-control-file";

public override string FileEditSize( Size size ) => $"{FileEdit()}-{ToSize( size )}";

public override string FileEditValidation( ValidationStatus validationStatus ) => ToValidationStatus( validationStatus );

#endregion
Expand Down
6 changes: 6 additions & 0 deletions Source/Blazorise.Bulma/BulmaClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public class BulmaClassProvider : ClassProvider

public override string ColorEdit() => "input";

public override string ColorEditSize( Size size ) => $"is-{ToSize( size )}";

#endregion

#region Check
Expand All @@ -105,6 +107,8 @@ public class BulmaClassProvider : ClassProvider
public override string RadioGroup( bool buttons, Orientation orientation )
=> $"{( buttons ? "buttons has-addons" : "control" )}{( orientation == Orientation.Horizontal ? null : " are-vertical" )}";

public override string RadioGroupSize( bool buttons, Orientation orientation, Size size ) => $"are-{ToSize( size )}";

public override string RadioGroupValidation( ValidationStatus validationStatus ) => ToValidationStatus( validationStatus );

#endregion
Expand Down Expand Up @@ -143,6 +147,8 @@ public override string RadioGroup( bool buttons, Orientation orientation )

public override string FileEdit() => "file-input";

public override string FileEditSize( Size size ) => $"is-{ToSize( size )}";

public override string FileEditValidation( ValidationStatus validationStatus ) => ToValidationStatus( validationStatus );

#endregion
Expand Down
2 changes: 1 addition & 1 deletion Source/Blazorise.Bulma/Pagination.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@inherits Blazorise.Pagination
<nav class=@("pagination " + ClassProvider.PaginationSize(Size))>
<nav class=@("pagination " + ClassProvider.PaginationSize(ThemeSize))>
<ul id="@ElementId" class="@ClassNames" style="@StyleNames" @attributes="@Attributes">
@ChildContent
</ul>
Expand Down
Loading