Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Razor syntax #16574

Closed
datdefboi opened this issue Oct 27, 2019 · 1 comment
Closed

New Razor syntax #16574

datdefboi opened this issue Oct 27, 2019 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@datdefboi
Copy link

datdefboi commented Oct 27, 2019

I think the "killer feature" of Blazor should be the following syntax of razor controllers.

// Component.razor
<Container>
    <Header Size="12">
          <Congratulation>Jack</Congratulation>
    </Header>
</Container>

@css { // simple css, injected immediately 
    background:red;
}

@css red { // named css, injected immediately 
    ...
}

//tags is a scoped components that automatically generates tag as described below
@tag Container:Div { // inherits predefined tag
     @css{
         ...
     }

     @code{
        ...
     }
}

@tag Header:H1 {
    @id someId
    
    @onclick Clicked

    @code{

        [Parameter]
        public int Size { get; set; }
    
        void Clicked()
        {

        }

    }

    @css {
        font-size:@Size;
    }
}

@component Congratulation { // that is a regular component
    <span>Dear, @content. Thanks!</span> // directly provides content

    @css {
        background:red;
    }
}

@component BtnBase {
    <btn @onclick="OnClick">@content</btn>

    @code {

        void OnClick()
        {
        }

    }

    @css btnStyle {
        ...
    }
    @css:hover { // elements's selector
        ...
    }
    
    @tag Badge { // scoped in BtnBase
        ...
    }
    
    @component BtnRed:BtnBase { // Scoped and inherited
        @style red; // includes named css
        @css {
            ... // this css merges with or replaces parent's css, 
        }
    }
}

@component BtnBlack:BtnBase { // just inherits
    @css {
        ... // this css merges with or replaces parent's css, 
    }
}

It solves most cases of frontend development and should be implemented in future releases.
The main idea of components id similarity to "components" in /Pages dir.
Tags just provides fast and scoped way to write

and their css or scss styling.
It seems that layout components are an obsolete way of providing @content slots (as it called in Vue).
Just provide an opportunity to use it everywhere.

@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Oct 28, 2019
@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @datdefboi.
This is not something we plan to do. We do plan to review and potentially improve CSS support / interaction in the future.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

2 participants