Coder Social home page Coder Social logo

hassanhabib / prettyblazor Goto Github PK

View Code? Open in Web Editor NEW
104.0 12.0 20.0 68 KB

PrettyBlazor is a Blazor .NET library that enables Blazor developers to use control structures in their Blazor applications through markup without having to use obtrusive C# code to iterate or select particular fragments.

C# 98.56% HTML 1.44%
blazor blazor-webassembly blazor-server blazor-client blazor-component

prettyblazor's People

Contributors

adbir avatar baltermia avatar hassanhabib avatar imjane5 avatar shrihumrudha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prettyblazor's Issues

Merge the 2 readme files

I realized that there are two different readme-files in this project. After forking the repository and cloning it onto my windows machine I got the following git warning:

warning: the following paths have collided (e.g. case-sensitive paths
on a case-insensitive filesystem) and only one from the same
colliding group is in the working tree:

  'README.md'
  'readme.md'

The two files are not identical and have both been updated separately a few times. They should be merged into one file.

Consider adding an Index to your Iterator

We started down the path of doing things like you are doing, but came up with a slightly different approach for the Iterator and Iterations... Essentially, we tried to keep as much of the razor tags as close to C# as possible. This implementation breaks one thing I like better about yours... and that is you have direct access to the object in the loop. With the below method,, one must understand you have an Item as well as an Index.

public class ComponentContext<T> where T : ComponentBase
{
    public ComponentContext(T @component) => Component = @component;
    public T Component { get; set; }
}

public class ForEach<T> : ComponentBase
{
    [Parameter]
    public IEnumerable<T> Items { get; set; }
    [Parameter]
    public RenderFragment<ForEachContext<T>> ChildContent { get; set; }

    protected override void BuildRenderTree(RenderTreeBuilder builder)
    {
        var index = 0;
        foreach (var item in Items)
            builder?.AddContent(0, ChildContent(new ForEachContext<T>(this, item, index++)));
    }
}

public class ForEachContext<T> : ComponentContext<ForEach<T>>
{
    public ForEachContext(ForEach<T> component, T item, int index) : base(component)
    {
        Item = item;
        Index = index;
    }
    public T Item { get; }
    public int Index { get; }
}

Allow other enumerable types in the Iteration component

I've noticed that the Iteration component seems to be hardcoded to only take a List.

If an ICollection or IEnumerable is provided, for example, the error is also rather confusing.

Would it be possible to allow IEnumerable on the Items parameter? Or is there a specific reason why it has to be List?

Visual Studio 2022 does not see Condition as an if statement

During development, I check for null reference pointer exceptions, i.e. from my Fluxor states, using the PrettyBlazor package.
This is not picked up by Visual Studio.
This does not register:

<Condition Evaluation="UserState != null">
    <Match>
        @UserState.Value.User.FullName
    </Match>
</Condition>

This does:

@if(UserState != null)
{
    @UserState.Value.User.FullName
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.