Skip to content

Commit

Permalink
Revert "Implements EventsConfig"
Browse files Browse the repository at this point in the history
This reverts commit 8aa2a11.
  • Loading branch information
wesProg23 committed Jun 14, 2023
1 parent 30291ce commit 536904a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 73 deletions.
67 changes: 6 additions & 61 deletions src/MudBlazor/Components/Container/MudContainer.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@namespace MudBlazor
@using MudBlazor.Extensions;
@using MudBlazor.Utilities
@inherits MudComponentBase

@RenderParent()
<div @attributes="UserAttributes" class="@Classname" style="@Style">
@ChildContent
</div>

@code {

Expand All @@ -17,77 +18,21 @@
/// <summary>
/// Set the max-width to match the min-width of the current breakpoint. This is useful if you'd prefer to design for a fixed set of sizes instead of trying to accommodate a fully fluid viewport. It's fluid by default.
/// </summary>
[Parameter]
[Parameter]
[Category(CategoryTypes.Container.Behavior)]
public bool Fixed { get; set; } = false;

/// <summary>
/// Determine the max-width of the container. The container width grows with the size of the screen. Set to false to disable maxWidth.
/// </summary>
[Parameter]
[Parameter]
[Category(CategoryTypes.Container.Behavior)]
public MaxWidth MaxWidth { get; set; } = MaxWidth.Large;

/// <summary>
/// Child content of component.
/// </summary>
[Parameter]
[Category(CategoryTypes.Container.Behavior)]
[ Category(CategoryTypes.Container.Behavior)]
public RenderFragment ChildContent { get; set; }

[Parameter]
public Dictionary<string, DirectiveAttribute[]> EventsConfig { get; set; } = new();

private Dictionary<string, object> _UserAttributes = new();


private RenderFragment RenderParent()
{
RenderFragment parent = builder =>
{
builder.OpenElement(1, "div");
_UserAttributes = UserAttributes ?? new Dictionary<string, object>();
if (!_UserAttributes.ContainsKey("class"))
{
_UserAttributes.Add("class", Classname);
}
else
{
_UserAttributes["class"] = Classname;
}

if (!_UserAttributes.ContainsKey("style"))
{
_UserAttributes.Add("style", Style);
}
else
{
_UserAttributes["style"] = Style;
}

foreach (var (k, v) in _UserAttributes)
{
builder.AddAttribute(1, k, v);
}

foreach (var config in EventsConfig)
{
foreach (var eventDirective in config.Value)
{
if (eventDirective == DirectiveAttribute.preventDefault)
{
builder.AddEventPreventDefaultAttribute(1, config.Key, true);
}
else if (eventDirective == DirectiveAttribute.stopPropagation)
{
builder.AddEventStopPropagationAttribute(1, config.Key, true);
}
}
}
builder.AddContent(1, ChildContent);
builder.CloseElement();
};

return parent;
}
}
12 changes: 0 additions & 12 deletions src/MudBlazor/Enums/DirectiveAttribute.cs

This file was deleted.

0 comments on commit 536904a

Please sign in to comment.