Skip to content

Commit

Permalink
Merge pull request #128 from Blazorade/fix/112-shadow
Browse files Browse the repository at this point in the history
ShadowSize enum -> Shadow struct
  • Loading branch information
MikaBerglund authored Mar 7, 2020
2 parents 213ad27 + f723317 commit b73e7fa
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 60 deletions.
4 changes: 2 additions & 2 deletions Blazorade.Bootstrap.Components.Showroom/Alerts.razor
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</Alert>

@code { private Alert DismissibleAlert; }
<Alert Color="NamedColor.Light" IsDismissible="true" FadeOnDismiss="true" @ref="this.DismissibleAlert" Shadow="ShadowSize.Small">
<Alert Color="NamedColor.Light" IsDismissible="true" FadeOnDismiss="true" @ref="this.DismissibleAlert" Shadow="Shadow.Small">
<HeadingTemplate>Custom Dismissal</HeadingTemplate>
<ChildContent>
This alert can be dismissed from outside of the component, by clicking on the button below.
Expand Down Expand Up @@ -78,7 +78,7 @@
This is a simple alert that defines the heading text as a parameter on the Alert component, and not as a template parameter as the alert above does.
</Alert>

<Alert Color="NamedColor.White" Shadow="ShadowSize.Regular" Heading="Alert with Stretched Link">
<Alert Color="NamedColor.White" Shadow="Shadow.Regular" Heading="Alert with Stretched Link">
<Paragraph Margin="Spacing.S0" IsStretchedLinkContainer="true">
This entire text will be clickable, because <AlertLink IsStretched="true" href="https://github.com/MikaBerglund/Blazor-Bootstrap" target="_blank">this link</AlertLink> is a stretched link. The heading will not be clickable, because this paragraph is set as container for the stretched link.
</Paragraph>
Expand Down
2 changes: 1 addition & 1 deletion Blazorade.Bootstrap.Components.Showroom/Breadcrumbs.razor
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<ItemTemplate>
@if (!string.IsNullOrEmpty(context.Url))
{
<Button Color="NamedColor.Light" Shadow="ShadowSize.Regular" Link="@context.Url" IsLink="true">@context.Text</Button>
<Button Color="NamedColor.Light" Shadow="Shadow.Regular" Link="@context.Url" IsLink="true">@context.Text</Button>
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Blazorade.Bootstrap.Components.Showroom/Navbars.razor
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<Paragraph MarginTop="Spacing.S2">
You can also have the brand section of the <code>Navbar</code> component collapse with the navbar itself.
</Paragraph>
<Navbar BrandText="@this.Brand" CollapseBrand="true" ColorScheme="NavbarColor.Light" BackgroundColor="NamedColor.Light" ExpandAt="this.Breakpoint" Shadow="ShadowSize.Regular">
<Navbar BrandText="@this.Brand" CollapseBrand="true" ColorScheme="NavbarColor.Light" BackgroundColor="NamedColor.Light" ExpandAt="this.Breakpoint" Shadow="Shadow.Regular">
<NavbarNav>
<NavItem Text="Item 1" />
<NavItem Text="Item 2" />
Expand Down
23 changes: 18 additions & 5 deletions Blazorade.Bootstrap.Components/Blazorade.Bootstrap.Components.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 2 additions & 19 deletions Blazorade.Bootstrap.Components/BootstrapComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected BootstrapComponentBase()
/// Specifies a shadow for the component. Shadows are used to make certain elements stand out.
/// </summary>
[Parameter]
public ShadowSize? Shadow { get; set; }
public Shadow? Shadow { get; set; }

/// <summary>
/// Specifies whether the component is a container for streteched links. If the component contains
Expand Down Expand Up @@ -286,24 +286,7 @@ protected async override Task OnParametersSetAsync()

if (this.Shadow.HasValue)
{
switch (this.Shadow.Value)
{
case ShadowSize.None:
this.AddClasses(ClassNames.Shadows.None);
break;

case ShadowSize.Small:
this.AddClasses(ClassNames.Shadows.Small);
break;

case ShadowSize.Regular:
this.AddClasses(ClassNames.Shadows.Regular);
break;

case ShadowSize.Large:
this.AddClasses(ClassNames.Shadows.Large);
break;
}
this.AddClasses(this.Shadow.Value.Value);
}

#endregion
Expand Down
98 changes: 98 additions & 0 deletions Blazorade.Bootstrap.Components/Utilities/Shadow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Blazorade.Bootstrap.Components.Utilities
{
/// <summary>
/// Defines different shadow sizes for components.
/// </summary>
public struct Shadow
{

internal const string NoneValue = ClassNames.Shadows.None;

internal const string SmallValue = ClassNames.Shadows.Small;

internal const string RegularValue = ClassNames.Shadows.Regular;

internal const string LargeValue = ClassNames.Shadows.Large;



/// <summary>
/// No shadow. Default.
/// </summary>
public static Shadow None
{
get { return new Shadow(NoneValue); }
}

/// <summary>
/// A small shadow.
/// </summary>
public static Shadow Small
{
get { return new Shadow(SmallValue); }
}

/// <summary>
/// Regular shadow.
/// </summary>
public static Shadow Regular
{
get { return new Shadow(RegularValue); }
}

/// <summary>
/// Large shadow.
/// </summary>
public static Shadow Large
{
get { return new Shadow(LargeValue); }
}


internal Shadow(string s)
{
this.Value = s;
}


/// <summary>
/// Converts the given string to <see cref="Shadow"/>.
/// </summary>
public static implicit operator Shadow(string s)
{
switch ($"{s}".ToLower())
{
case "sm":
case "small":
return Shadow.Small;

case "r":
case "reg":
case "regular":
return Shadow.Regular;

case "lg":
case "l":
case "large":
return Shadow.Large;

default:
return Shadow.None;
}
}

/// <summary>
/// The value.
/// </summary>
/// <remarks>
/// The value equals the class name to add to an element for different sizes of shadows.
/// </remarks>
public string Value { get; private set; }

}

}
32 changes: 0 additions & 32 deletions Blazorade.Bootstrap.Components/Utilities/ShadowSize.cs

This file was deleted.

0 comments on commit b73e7fa

Please sign in to comment.