Skip to content

Commit

Permalink
Added ColorField
Browse files Browse the repository at this point in the history
  • Loading branch information
usercode committed Oct 23, 2022
1 parent 88480a2 commit 221b43e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static ContentFieldManager AddDefaults(this ContentFieldManager manager)
manager.Add<TextField>();
manager.Add<XHtmlField>();
manager.Add<XmlField>();
manager.Add<ColorField>();

return manager;
}
Expand Down
11 changes: 11 additions & 0 deletions src/DragonFly.Core/ContentItems/Models/Fields/Base/ColorField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) usercode
// https://github.com/usercode/DragonFly
// MIT License

namespace DragonFly;

[FieldOptions(typeof(ColorFieldOptions))]
public class ColorField : TextBaseField
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) usercode
// https://github.com/usercode/DragonFly
// MIT License

namespace DragonFly;

public class ColorFieldOptions : ContentFieldOptions
{
public ColorFieldOptions()
{

}

public override IContentField CreateContentField()
{
return new ColorField();
}
}
1 change: 1 addition & 0 deletions src/DragonFly.Razor/Modules/ContentModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ public override void Init(IDragonFlyApi api)
api.RegisterField<HtmlField, HtmlFieldView>();
api.RegisterField<XHtmlField, XHtmlFieldView>();
api.RegisterField<XmlField, XmlFieldView>();
api.RegisterField<ColorField, ColorFieldView>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@inherits FieldComponent<ColorField, ColorFieldOptions>

<div class="color-field">
<div class="input-group">
<span class="input-group-text">@Field.Value</span>
<BSInput InputType="InputType.Color" @bind-Value="Field.Value" />
<BSButton Color="BSColor.Light" title="Clear" OnClick="x => Field.Value = null"><i class="fas fa-times"></i></BSButton>
</div>
</div>

0 comments on commit 221b43e

Please sign in to comment.