Skip to content

Commit

Permalink
Added progress block
Browse files Browse the repository at this point in the history
  • Loading branch information
usercode committed Dec 15, 2022
1 parent 344598b commit 927f229
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static IDragonFlyBuilder AddBlockField(this IDragonFlyBuilder builder)
api.RegisterBlock<ReferenceBlock, ReferenceBlockView>();
api.RegisterBlock<ContainerBlock, ContainerBlockView>();
api.RegisterBlock<AlertBlock, AlertBlockView>();
api.RegisterBlock<ProgressBlock, ProgressBlockView>();
api.RegisterBlock<UnknownBlock, UnknownBlockView>();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="alert-block">
<div class="mb-3">
<EnumView TEnum="AlertType" @bind-EnumValue="@Block.AlertType" />
<EnumView TEnum="ColorType" @bind-EnumValue="@Block.ColorType" />
</div>
<BlocksView Blocks="Block.Blocks" />
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@inherits BlockComponent<ProgressBlock>

<div class="progess-block">
<div class="input-group">
<EnumView TEnum="ColorType" @bind-EnumValue="@Block.ColorType" />
<input class="form-control" type="number" @bind="@Block.Value" min="0" max="100" step="1" />
@*<div class="progress">
<div class="progress-bar bg-success" role="progressbar" style="width: @(Block.Value)%"></div>
</div>*@
</div>
</div>
1 change: 1 addition & 0 deletions src/DragonFly.BlockField/BlockFieldManagerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static void AddDefaults(this BlockFieldManager manager)
manager.Add<ReferenceBlock>();
manager.Add<ContainerBlock>();
manager.Add<AlertBlock>();
manager.Add<ProgressBlock>();

manager.Add<UnknownBlock>();
}
Expand Down
4 changes: 2 additions & 2 deletions src/DragonFly.BlockField/Blocks/AlertBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public class AlertBlock : Block, IChildBlocks
{
public AlertBlock()
{
AlertType = AlertType.Info;
ColorType = ColorType.Info;
Blocks = new List<Block>();
}

public override string CssIcon => "fa-solid fa-circle-info";

public IList<Block> Blocks { get; set; }

public AlertType AlertType { get; set; }
public ColorType ColorType { get; set; }

public IEnumerable<Block> GetBlocks()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace DragonFly.BlockField;

public enum AlertType
public enum ColorType
{
Primary,
Secondary,
Expand Down
17 changes: 17 additions & 0 deletions src/DragonFly.BlockField/Blocks/ProgressBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) usercode
// https://github.com/usercode/DragonFly
// MIT License

namespace DragonFly.BlockField;

/// <summary>
/// ProgressBlock
/// </summary>
public class ProgressBlock : Block
{
public override string CssIcon => "fa-solid fa-bars-progress";

public int? Value { get; set; }

public ColorType ColorType { get; set; }
}
18 changes: 9 additions & 9 deletions src/DragonFlyTemplate/Extensions/DragonFlyTypesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ namespace DragonFly.AspNetCore;

public static class DragonFlyTypesExtensions
{
public static string ToBootstrapCssClass(this AlertType alertType)
public static string ToBootstrapCssClass(this ColorType alertType)
{
return alertType switch
{
AlertType.Primary => "alert-primary",
AlertType.Secondary => "alert alert-secondary",
AlertType.Success => "alert-success",
AlertType.Danger => "alert-danger",
AlertType.Warning => "alert-warning",
AlertType.Info => "alert-info",
AlertType.Light => "alert-light",
AlertType.Dark => "alert-dark",
ColorType.Primary => "primary",
ColorType.Secondary => "secondary",
ColorType.Success => "success",
ColorType.Danger => "danger",
ColorType.Warning => "warning",
ColorType.Info => "info",
ColorType.Light => "light",
ColorType.Dark => "dark",
_ => string.Empty
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@if (Model.Blocks.Any())
{
<div class="block alert-block">
<div class="alert @Model.AlertType.ToBootstrapCssClass()">
<div class="alert alert-@Model.ColorType.ToBootstrapCssClass()">
@Html.DisplayFor(m => Model.Blocks)
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@model ProgressBlock

<div class="block progress-block">
<div class="progress">
<div class="progress-bar bg-@(Model.ColorType.ToBootstrapCssClass())" role="progressbar" style="width: @(Model.Value)%" aria-valuenow="@Model.Value" aria-valuemin="0" aria-valuemax="100">@(Model.Value)%</div>
</div>
</div>
4 changes: 4 additions & 0 deletions src/DragonFlyTemplate/assets/scss/type.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@ article {
top: 1rem;
font-size: 0.8rem;

}

.progress {
height: 1.5rem;
}
4 changes: 4 additions & 0 deletions src/DragonFlyTemplate/wwwroot/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ article .post-meta strong {
font-size: 0.8rem;
}

.progress {
height: 1.5rem;
}

img {
max-width: 100%;
max-height: 100%;
Expand Down
2 changes: 1 addition & 1 deletion src/DragonFlyTemplate/wwwroot/assets/css/style.min.css

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

0 comments on commit 927f229

Please sign in to comment.