Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ο»Ώο»Ώ<div style="height: 400px">
<FluentStack Orientation="Orientation.Vertical">

<FluentSelect Items="@Sources"
TOption="LootieFile"
@bind-Value="Source"
Placeholder="Select a Lottie Animation"
Style="margin-bottom: 20px;"
OptionText="@(e => e.Name)"
OptionValue="@(e => e.Url)" />


<FluentStack VerticalAlignment="VerticalAlignment.Center"
HorizontalAlignment="HorizontalAlignment.Center">
<FluentCxLottiePlayer Source="@Source?.Url"
Width="300px"
Height="300px"
Loop="true"
Autoplay="true" />
</FluentStack>
</FluentStack>
</div>

@code {
private record LootieFile(string Name, string Url);

private static readonly List<LootieFile> Sources = [
new("Trophy", "https://assets10.lottiefiles.com/packages/lf20_touohxv0.json"),
new("Book1", "https://lottie.host/6918cb79-0097-427d-9e33-763c70a8090e/fdfBQynp6I.json"),
new("Book2", "https://lottie.host/3204b079-1565-4c21-8965-fbe96b9d09ab/c4azoY9oBc.json")
];

private LootieFile? Source{ get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ο»Ώο»Ώ<div style="height: 400px">
<FluentStack VerticalAlignment="VerticalAlignment.Center" HorizontalAlignment="HorizontalAlignment.Center">
<FluentCxLottiePlayer Source="https://assets2.lottiefiles.com/packages/lf20_touohxv0.json"
Width="300px"
Height="300px"
Loop="true">
<LottieControls />
</FluentCxLottiePlayer>
</FluentStack>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: Lottie Player
icon: Play
route: /LottiePlayer
---

# Lottie Player

The <code>FluentCxLottiePlayer</code> component allows you to easily integrate Lottie animations into your Blazor applications.
The component supports various customization options, including setting the animation source, dimensions, playback controls, and interactivity features.
The <code>FluentCxLottieProvider</code> is required to use the <code>FluentCxLottie</code> component and should be added once in your application, typically in the MainLayout.
There are 3 renderers available: <code>Svg</code>, <code>Canvas</code> and <code>Html</code>. By default, the <code>Svg</code> renderer is used.

## Examples

{{ LottiePlayerDefault }}

{{ LottiePlayerWithControls }}



## API Lottie Player

{{ API Type=LottiePlayer }}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@

</FluentLayout>

<FluentCxLootiePlayerProvider />
<!-- FluentUI Service Providers -->
<FluentProviders />


Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ο»Ώ@namespace FluentUI.Blazor.Community.Components
@inherits FluentComponentBase

<HeadContent>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.13.0/lottie.min.js"></script>
</HeadContent>

@code {
public FluentCxLootiePlayerProvider(LibraryConfiguration libraryConfiguration)
: base(libraryConfiguration)
{
}

[Inject]
private LottieState State { get; set; } = default!;

/// <inheritdoc />
protected override void OnInitialized()
{
base.OnInitialized();
State.Register();
}

/// <inheritdoc />
public override ValueTask DisposeAsync()
{
State.Unregister();

return base.DisposeAsync();
}
}
13 changes: 13 additions & 0 deletions src/Core/Components/LottiePlayer/FluentCxLottiePlayer.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ο»Ώ@namespace FluentUI.Blazor.Community.Components
@inherits FluentComponentBase

<CascadingValue Value="this">
<div id="lottie-container">
<div id="@Id"
style="@InternalStyle"
class="@InternalCss">
</div>

@ChildContent
</div>
</CascadingValue>
Loading