Blazor Slide Show Presenter

 

This is a simple project that shows how to create a slide show presenter in Blazor.   Most of the work is done in the CSS.  Applying some Blazor goodness to it elevates the application.

Creating a static slide show presentation is fairly straightforward.  You can create the meat of the presentation in HTML within the Blazor page.  Nothing to fancy about that.  

To make things more interesting, we will show how to handle dynamic content in the presentation.  This will allow you to load the content on startup that could be pulled from any other source, API, Database, etc.

You step between pages using the arrow keys, ↑ ↓.


HTML / CSS

As I stated HTML and CSS are the heart of the display.  You can see this on the index page.

HTML

        <section>
            <h1>title 1</h1>
        </section>

CSS
        html {
            scroll-snap-type: y mandatory;
        }

        section {
            block-size: 100vh;
            scroll-snap-align: center;
            scroll-snap-stop: always;
            display: grid;
            place-items: center;
         }


Blazor Style

Now we will add some Blazor handling of the content to make it dynamic.  You can pull any HTML content from any source and add it to a collection string.  You will need to make sure you escape any needed quotes.

Once you have your collection of content, you just need to display it as HTML.  To do this, you use the string "MarkupSting".  You can see this on the BlazorStyle page

        @((MarkupString)data)


To put this all together, we will need to enumerate the collection building the page to be displayed.

        @foreach (var data in content)
        {
            <section>
                @((MarkupString)data)
            </section>    
        }

You will need to load the content collection on the page OnInitializedAsync:

        @code {
            private List<string> content = new List<string>();

            protected override async Task OnInitializedAsync()
            {
                content.Add("<p class='markup'>This is a <em>markup string</em>.</p>");
                content.Add("<img src='https://source.unsplash.com/random'");
                content.Add("<iframe width=\"560\" height=\"315\"       src=\"https://www.youtube.com/embed/UjoFECrCxBI\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>");
            }
        }

As you can see, you can add any HTML content that you would like.


Summary

Even though the project is fairly straightforward, you can easily add additional features to make it much more powerful.  Some cool features could add additional keystrokes to step through the slides, automatically walk the slides, and jump to the beginning once it has ended. 

You could connect it to an API or database where a marketing team manages the content.



[source code]

Comments

Popular posts from this blog

Yes, Blazor Server can scale!

Blazor - Cool Blur Loading Page

Blazor new and improved Search Box