Skip to content

Commit

Permalink
added working implementation of user specified class or style needing…
Browse files Browse the repository at this point in the history
… to be consumed by markup, typeahead as well as textareas.
  • Loading branch information
JByfordRew committed Jun 13, 2022
1 parent 2ace842 commit 32b74c2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/BlazorStyledTextArea/StyledTextArea.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@using BlazorTextarea
<div id="@id" class='textarea-container @(isEditing ? "blazor-styled-textarea-focus" : "blazor-styled-textarea")'>
@if (isEditing || hasSelection) {
<div class="just-content overlayed no-interaction">
<div class="just-content overlayed no-interaction @classAttributeValue" style="@styleAttributeValue">
@for (int i = 0; i < markupLines.Count; i++) {
<span @key="markupLines[i].Id">@GetMarkup(i)</span><br />
}
Expand Down Expand Up @@ -40,15 +40,15 @@
</Textarea>
}
@if (!isEditing && !hasSelection) {
<div class="just-content overlayed no-interaction">
<div class="just-content overlayed no-interaction @classAttributeValue" style="@styleAttributeValue">
@for (int i = 0; i < markupLines.Count; i++) {
<span @key="markupLines[i].Id">@GetMarkup(i)</span><br />
}
</div>
}
</div>
<div>
<div id='id-@this.id.ToString()-bsta-typeahead' style='line-height: initial; position: absolute; top: @((caretData.Top)+"px"); left: @((caretData.Left)+"px")'>
<div id='id-@this.id.ToString()-bsta-typeahead' class="@classAttributeValue" style='line-height: initial; position: absolute; top: @((caretData.Top)+"px"); left: @((caretData.Left)+"px"); @styleAttributeValue'>
@if (InlineTypeahead is not null)
{
@InlineTypeahead
Expand Down
15 changes: 14 additions & 1 deletion src/BlazorStyledTextArea/StyledTextArea.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace BlazorStyledTextArea;

public partial class StyledTextArea : ComponentBase
{
private string textareaClass => $"just-content overlayed hidden-text {HiddenCaretCssClass}";
private string textareaClass => $"just-content overlayed hidden-text {HiddenCaretCssClass} {classAttributeValue}";

private readonly Guid id = Guid.NewGuid();

Expand All @@ -18,6 +18,8 @@ public partial class StyledTextArea : ComponentBase

private string eventCallbackName = "";
private EventCallback<string> eventCallback;
private string classAttributeValue = "";
private string styleAttributeValue = "";

[Parameter(CaptureUnmatchedValues = true)]
public IDictionary<string, object>? AdditionalAttributes {
Expand All @@ -37,6 +39,17 @@ public IDictionary<string, object>? AdditionalAttributes {
}

additionalAttributes = value;

if (value.ContainsKey("class"))
{
classAttributeValue = (string)value["class"];
value.Remove("class");
}

if (value.ContainsKey("style"))
{
styleAttributeValue = (string)value["style"];
}
}
}

Expand Down

0 comments on commit 32b74c2

Please sign in to comment.