Skip to content

Commit

Permalink
rendseq (#1286)
Browse files Browse the repository at this point in the history
* 2024-03-15 EoD

* 2024-03-18 BoD

* Commit 'safe' files

* Commit 'safe' files #2

* 2024-03-19 EoD

* 2024-03-19 Completed rendseq updates
  • Loading branch information
MarkStega authored Mar 19, 2024
1 parent eecc417 commit 2b1e083
Show file tree
Hide file tree
Showing 30 changed files with 2,152 additions and 2,421 deletions.
27 changes: 16 additions & 11 deletions Material.Blazor.MD3/Components/Button/MBButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public sealed class MBButton : ComponentFoundation
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
var attributesToSplat = AttributesToSplat().ToArray();
var buttonID = "Button-" + Guid.NewGuid().ToString();
var rendSeq = 0;

BuildRenderTreeWorker(
Expand All @@ -40,7 +39,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
attributesToSplat,
@class,
style,
buttonID,
id,
AppliedDisabled,
ButtonStyle,
IconDescriptor,
Expand Down Expand Up @@ -80,26 +79,28 @@ public static void BuildRenderTreeWorker(
_ => throw new System.Exception("Unknown ButtonStyle")
};

builder.OpenElement(rendSeq++, componentName);
builder.OpenElement(rendSeq, componentName);
{
builder.AddAttribute(rendSeq++, "class", classString);
builder.AddAttribute(rendSeq++, "style", styleString);
builder.AddAttribute(rendSeq++, "id", idString);
builder.AddAttribute(rendSeq + 1, "class", classString);
builder.AddAttribute(rendSeq + 2, "style", styleString);
builder.AddAttribute(rendSeq + 3, "id", idString);
if (attributesToSplat.Any())
{
builder.AddMultipleAttributes(rendSeq++, attributesToSplat);
builder.AddMultipleAttributes(rendSeq + 4, attributesToSplat);
}

if (appliedDisabled)
{
builder.AddAttribute(rendSeq++, "disabled");
rendSeq = 100;
builder.AddAttribute(rendSeq + 5, "disabled");
}

if (iconIsTrailing)
{
builder.AddAttribute(rendSeq++, "trailing-icon");
builder.AddAttribute(rendSeq + 6, "trailing-icon");
}

rendSeq += 10;
if (iconDescriptor is not null)
{
MBIcon.BuildRenderTreeWorker(
Expand All @@ -114,20 +115,24 @@ public static void BuildRenderTreeWorker(
"icon");
}

rendSeq += 10;
if (!string.IsNullOrWhiteSpace(formId))
{
builder.AddAttribute(rendSeq++, "form", formId);
builder.AddAttribute(rendSeq, "form", formId);
}

rendSeq += 10;
if (!string.IsNullOrWhiteSpace(buttonValue))
{
builder.AddAttribute(rendSeq++, "value", buttonValue);
builder.AddAttribute(rendSeq, "value", buttonValue);
}

rendSeq += 10;
if (!string.IsNullOrWhiteSpace(label))
{
builder.AddContent(rendSeq++, label);
}
rendSeq += 10;
}
builder.CloseElement();

Expand Down
32 changes: 16 additions & 16 deletions Material.Blazor.MD3/Components/Checkbox/MBCheckbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ public sealed class MBCheckbox : InputComponent<bool>
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
var attributesToSplat = AttributesToSplat().ToArray();
var rendSeq = 0;
builder.OpenElement(rendSeq++, "div");

builder.OpenElement(0, "div");
{
builder.OpenElement(rendSeq++, "div");
builder.OpenElement(1, "div");
{
builder.AddAttribute(rendSeq++, "class", @class);
builder.AddAttribute(rendSeq++, "style", checkboxStyle + style);
builder.AddAttribute(rendSeq++, "id", id);
builder.AddAttribute(2, "class", @class);
builder.AddAttribute(3, "style", checkboxStyle + style);
builder.AddAttribute(4, "id", id);
if (attributesToSplat.Any())
{
builder.AddMultipleAttributes(rendSeq++, attributesToSplat);
builder.AddMultipleAttributes(5, attributesToSplat);
}

if (!string.IsNullOrWhiteSpace(LeadingLabelPLUS))
Expand All @@ -66,28 +66,28 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
"<span class=\"mdc-typography--body1\" style=\"margin-right: 1em;\">"
+ LeadingLabelPLUS
+ "</Span>";
builder.AddMarkupContent(rendSeq++, "\r\n");
builder.AddMarkupContent(rendSeq++, labelSpan);
builder.AddMarkupContent(6, "\r\n");
builder.AddMarkupContent(7, labelSpan);
}

builder.OpenElement(rendSeq++, "md-checkbox");
builder.OpenElement(8, "md-checkbox");
{
if (AppliedDisabled || IsDisabled)
{
builder.AddAttribute(rendSeq++, "disabled");
builder.AddAttribute(9, "disabled");
}

if (Value)
{
builder.AddAttribute(rendSeq++, "checked");
builder.AddAttribute(10, "checked");
}

if (IsIndeterminate)
{
builder.AddAttribute(rendSeq++, "indeterminate");
builder.AddAttribute(11, "indeterminate");
}

builder.AddAttribute(rendSeq++, "onclick", EventCallback.Factory.Create<MouseEventArgs>(this, OnClickInternal));
builder.AddAttribute(12, "onclick", EventCallback.Factory.Create<MouseEventArgs>(this, OnClickInternal));
}
builder.CloseElement();

Expand All @@ -97,8 +97,8 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
"<span class=\"mdc-typography--body1\" style=\"margin-left: 1em;\">"
+ TrailingLabelPLUS
+ "</Span>";
builder.AddMarkupContent(rendSeq++, "\r\n");
builder.AddMarkupContent(rendSeq++, labelSpan);
builder.AddMarkupContent(13, "\r\n");
builder.AddMarkupContent(14, labelSpan);
}
}
builder.CloseElement();
Expand Down
30 changes: 16 additions & 14 deletions Material.Blazor.MD3/Components/ChipSet/MBChipSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ public sealed class MBChipSet : ComponentFoundation
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
var attributesToSplat = AttributesToSplat().ToArray();
var rendSeq = 0;

builder.OpenElement(rendSeq++, "md-chip-set");
builder.OpenElement(0, "md-chip-set");
{
builder.AddAttribute(rendSeq++, "class", @class);
builder.AddAttribute(rendSeq++, "style", style);
builder.AddAttribute(rendSeq++, "id", id);
builder.AddAttribute(1, "class", @class);
builder.AddAttribute(2, "style", style);
builder.AddAttribute(3, "id", id);
if (attributesToSplat.Any())
{
builder.AddMultipleAttributes(rendSeq++, attributesToSplat);
builder.AddMultipleAttributes(4, attributesToSplat);
}

var rendSeq = 10;
if (ChipsetItems is not null)
{
foreach (var chip in ChipsetItems)
Expand All @@ -52,30 +52,30 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
_ => throw new System.Exception("Unknown ChipType")
};

builder.OpenElement(rendSeq++, componentName);
builder.OpenElement(rendSeq, componentName);
{
if (!string.IsNullOrWhiteSpace(chip.Label))
{
builder.AddAttribute(rendSeq++, "label", chip.Label);
builder.AddAttribute(rendSeq + 1, "label", chip.Label);
}

if (AppliedDisabled || chip.IsDisabled)
{
builder.AddAttribute(rendSeq++, "disabled");
builder.AddAttribute(rendSeq + 2, "disabled");
}

if (chip.IsElevated)
{
builder.AddAttribute(rendSeq++, "elevated");
builder.AddAttribute(rendSeq + 3, "elevated");
}

if (!string.IsNullOrWhiteSpace(chip.Link))
{
builder.AddAttribute(rendSeq++, "href", chip.Link);
builder.AddAttribute(rendSeq + 4, "href", chip.Link);

if (!string.IsNullOrWhiteSpace(chip.LinkTarget))
{
builder.AddAttribute(rendSeq++, "target", chip.LinkTarget);
builder.AddAttribute(rendSeq + 5, "target", chip.LinkTarget);
}
}

Expand All @@ -84,14 +84,15 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
// Only for filter & input chips
if (componentName.Equals("md-filter-chip"))
{
builder.AddAttribute(rendSeq++, "removable");
builder.AddAttribute(rendSeq + 6, "removable");
}
else if (componentName.Equals("md-input-chip"))
{
builder.AddAttribute(rendSeq++, "remove-only");
builder.AddAttribute(rendSeq + 7, "remove-only");
}
}

rendSeq += 10;
if (chip.Icon is not null)
{
MBIcon.BuildRenderTreeWorker(
Expand All @@ -107,6 +108,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
}
}
builder.CloseElement();
rendSeq += 100;
}
}
}
Expand Down
35 changes: 18 additions & 17 deletions Material.Blazor.MD3/Components/Dialog/MBDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ public class MBDialog : ComponentFoundation
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
var attributesToSplat = AttributesToSplat().ToArray();
var rendSeq = 0;

builder.OpenElement(rendSeq++, "md-dialog");
builder.OpenElement(0, "md-dialog");
{
builder.AddAttribute(rendSeq++, "class", @class);
builder.AddAttribute(rendSeq++, "style", style);
builder.AddAttribute(rendSeq++, "id", DialogId);
builder.AddAttribute(1, "class", @class);
builder.AddAttribute(2, "style", style);
builder.AddAttribute(3, "id", DialogId);
if (attributesToSplat.Any())
{
builder.AddMultipleAttributes(rendSeq++, attributesToSplat);
builder.AddMultipleAttributes(4, attributesToSplat);
}

if (IconDescriptor is not null)
{
var rendSeq = 10;
MBIcon.BuildRenderTreeWorker(
builder,
ref rendSeq,
Expand All @@ -90,12 +90,12 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)

if (!string.IsNullOrWhiteSpace(Headline) || CustomHeader is not null)
{
builder.OpenElement(rendSeq++, "div");
builder.OpenElement(200, "div");
{
builder.AddAttribute(rendSeq++, "slot", "headline");
builder.AddAttribute(201, "slot", "headline");
if (CustomHeader is not null)
{
builder.AddContent(rendSeq++, CustomHeader);
builder.AddContent(202, CustomHeader);

if (!string.IsNullOrWhiteSpace(Headline))
{
Expand All @@ -104,33 +104,34 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
}
else
{
builder.AddContent(rendSeq++, Headline);
builder.AddContent(203, Headline);
}
}
builder.CloseElement();
}

if (Body is not null)
{
builder.OpenElement(rendSeq++, "form");
builder.OpenElement(300, "form");
{
builder.AddAttribute(rendSeq++, "id", FormId);
builder.AddAttribute(rendSeq++, "slot", "content");
builder.AddAttribute(rendSeq++, "method", "dialog");
builder.AddAttribute(301, "id", FormId);
builder.AddAttribute(302, "slot", "content");
builder.AddAttribute(303, "method", "dialog");

builder.AddContent(rendSeq++, Body);
builder.AddContent(304, Body);
}
builder.CloseElement();
}

if (ButtonItems is not null)
{
builder.OpenElement(rendSeq++, "div");
builder.OpenElement(305, "div");
{
builder.AddAttribute(rendSeq++, "slot", "actions");
builder.AddAttribute(306, "slot", "actions");

foreach (var button in ButtonItems)
{
var rendSeq = 400;
MBButton.BuildRenderTreeWorker(
builder,
ref rendSeq,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public sealed class MBFloatingActionButton : ComponentFoundation
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
var attributesToSplat = AttributesToSplat().ToArray();
var rendSeq = 0;

var componentName = CascadingDefaults.AppliedFloatingActionButtonStyle(FloatingActionButtonStyle) switch
{
Expand All @@ -77,46 +76,47 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
_ => throw new System.Exception("Unknown FloatingActionButtonStyle")
};

builder.OpenElement(rendSeq++, componentName);
builder.OpenElement(0, componentName);
{
if (AppliedDisabled)
{
builder.AddAttribute(rendSeq++, "disabled");
builder.AddAttribute(1, "disabled");
}

if (IsLowered)
{
builder.AddAttribute(rendSeq++, "lowered");
builder.AddAttribute(2, "lowered");
}

builder.AddAttribute(rendSeq++, "class", @class);
builder.AddAttribute(rendSeq++, "style", style);
builder.AddAttribute(rendSeq++, "id", id);
builder.AddAttribute(3, "class", @class);
builder.AddAttribute(4, "style", style);
builder.AddAttribute(5, "id", id);
if ((attributesToSplat is not null) && attributesToSplat.Any())
{
builder.AddMultipleAttributes(rendSeq++, attributesToSplat);
builder.AddMultipleAttributes(6, attributesToSplat);
}

if (!string.IsNullOrWhiteSpace(variant))
{
builder.AddAttribute(rendSeq++, "variant", variant);
builder.AddAttribute(7, "variant", variant);
}

if (!string.IsNullOrWhiteSpace(Label))
{
builder.AddAttribute(rendSeq++, "label", Label);
builder.AddAttribute(8, "label", Label);
}

var size = CascadingDefaults.AppliedFloatingActionButtonSize(FloatingActionButtonSize);
if (size == MBFloatingActionButtonSize.Small)
{
builder.AddAttribute(rendSeq++, "size", "small");
builder.AddAttribute(9, "size", "small");
}
else if (size == MBFloatingActionButtonSize.Large)
{
builder.AddAttribute(rendSeq++, "size", "large");
builder.AddAttribute(9, "size", "large");
}

var rendSeq = 10;
if (IconDescriptor is not null)
{
MBIcon.BuildRenderTreeWorker(
Expand Down
Loading

0 comments on commit 2b1e083

Please sign in to comment.