Code Monkey home page Code Monkey logo

blazor-book's Introduction

blazor-book

A Storybook like UI for hosting Blazor components

Installation

The BlazorBook nuget package needs to be added to your Blazor WASM/Server app and your Razor Class library project containing your individual stories.

Install-Package BlazorBook -ProjectName MyProject

Setup

In the startup of your Blazor WASM/Server app:

app.RegisterAllStories(Assembly.Load("<<Assembly name containing stories>>"));

  • In _Imports.razor

Add @using BlazorBook.Components

  • In App.razor

    1. Add <BlazorBook.Resources /> to the top
    2. Add an AdditionalAssemblies prop on the component as follows:
<Router
  AppAssembly="@typeof(App).Assembly"
  AdditionalAssemblies="new[] { typeof(BlazorBook.UI).Assembly }"
>
  ...
</Router>

The stories will be registered and the UI available on the path /blazorbook

Stories

Create a Razor Class Library to contain your stories. This should also have the BlazorBook nuget package as a dependency.

For example a story can be as follows:

HelloWorld.razor

@inherits BlazorBook.StoryComponent
@attribute [DisplayName("Story name")]

<div>Hello @(world)!</div>

@code {
    string world = "World!";
}

blazor-book's People

Contributors

aeagle avatar thedayismyenemy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

blazor-book's Issues

Published to NuGet

Hi,

I can't seem to find this package on any NuGet package repository. Has this been published yet?

Kind regards,
Charl

Next release?

Sorry But I couldnt figure out where the best place to send a message was.

I am after a grouping function in this library similar to what the original StoryBook has. I was going to just FORK the repo and add it myself but I noticed that exists in /DEV already.

I was wondering why that hasnt been merged yet?

When opening the blazorbook location : "there is nothing

Looks like a very interesting project.
When I open the blazorbook location, I get the above error (which is simply the "notfound" found route of my router component in the main app).

I installed your nuget in both the webassembly project and the razor class lib (i named it "StoryBook").
I added the "StoryBook" assembly as referenced assembly
and added following line in program.cs

builder.RegisterAllStories(Assembly.Load("StoryBook"));

What am I missing?

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.