jsakamoto / BlazingStory

The clone of "Storybook" for Blazor, a frontend workshop for building UI components and pages in isolation.
https://jsakamoto.github.io/BlazingStory/
Mozilla Public License 2.0
296 stars 14 forks source link

Passing more than just text to a renderfragment #46

Open NathanVG opened 3 months ago

NathanVG commented 3 months ago

I'm trying to create a story for my custom button. Normally I can pass an icon to the button and it will render correctly as such:

<ExampleButton><PlusCircleIcon class="mr-2 h-4 w-4 text-current" /> Add New</ExampleButton>

However all I get is the text "Add New" when I do this in blazing story, the span etc is stripped as well:

<Stories>
    <Story Name="With Icon">
        <Arguments>
            <Arg For="_ => _.ChildContent" Value="_ButtonContentWithIcon" />
            <Arg For="_=>_.ButtonStyle" Value="ExampleButtonStyle.Primary" />
            <Arg For="_ => _.isLoading" Value="false" />
        </Arguments>
        <Template>
            <div class="flex items-center justify-center p-4">
                <ExampleButton@attributes="context.Args"></ExampleButton>
            </div>
        </Template>
    </Story>
</Stories>

@code
{
    private RenderFragment _ButtonContentWithIcon = @<span class="text-red-500"><PlusCircleIcon class="mr-2 h-4 w-4 text-current" /> Add new</span>;
}

How can I do this correctly?

NathanVG commented 3 months ago

I just read in the docs that this is a limitation of blazing story at the moment. This is a shame as this is a core functionality of Blazor and one I use a lot in my component library,

Are there any plans to fix this or is it just not possible?

WimVdSElia commented 3 months ago

I just create a pull request to fix this: Pull Request If have some suggestion to make it better or question please shot