Skip to content

Commit

Permalink
Merge pull request #14 from neozhu/animation
Browse files Browse the repository at this point in the history
add animation
  • Loading branch information
neozhu authored Jul 28, 2024
2 parents 3aa9ab3 + 359c0af commit 6673e70
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 103 deletions.
2 changes: 1 addition & 1 deletion BlazorPocketApp.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
# 17
VisualStudioVersion = 17.10.34902.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sdk", "sdk", "{113EE8F0-D60C-44FE-AFEE-FB4CF48F0280}"
Expand Down
5 changes: 2 additions & 3 deletions src/BlazorPocket.WebAssembly/BlazorPocket.WebAssembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RuntimeFrameworkVersion>9.0.0-preview.5.24306.7</RuntimeFrameworkVersion>
<ImplicitUsings>enable</ImplicitUsings>
<RuntimeFrameworkVersion>9.0.0-preview.5.24306.7</RuntimeFrameworkVersion>
<Nullable>enable</Nullable>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MudBlazor" Version="7.1.1" />
<PackageReference Include="MudBlazor" Version="7.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0-preview.6.24328.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0-preview.6.24328.4" PrivateAssets="all" />
</ItemGroup>
Expand Down
109 changes: 109 additions & 0 deletions src/BlazorPocket.WebAssembly/Components/Carousel.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Class="mt-n4" Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Brian</MudText>
<MudText Typo="Typo.body2">EvoDynamic</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["Coming of an Angular project back to .NET, Blazor was the ideal choice and MudBlazor was the icing on the cake. . . not \"mud\" but a rich creamy sweet chocolate."]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Class="mt-n4" Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Developer Team</MudText>
<MudText Typo="Typo.body2">Wunderminds</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["Saving us from tons of tiny details and allowing us to deliver sharp looking modern web applications, MudBlazor is the king of open source UI frameworks that no one should miss when building apps with Blazor!"]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Wave Master</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["Comprehensive, ambitious, fresh and clean. Some really cool implementations. The development and improvement of components is really fast, and if a course correction is needed, they will do it. Garderoben, henon and all the other contributors are approachable. They are getting stuff done!"]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Class="mt-n4" Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Karakoulak Spyridon</MudText>
<MudText Typo="Typo.body2">Arhs Group</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["Best open source component library for Blazor out there and easy to understand!"]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Class="mt-n4" Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Hayden Ravenscroft</MudText>
<MudText Typo="Typo.body2">Mail Solutions UK Ltd</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["A comprehensive library. Takes the hassle out of designing for Blazor. Used in many ongoing projects at the Mail Solutions Group. The MudBlazor team has a real gem here."]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Class="mt-n4" Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Frederik</MudText>
<MudText Typo="Typo.body2">Xuntar</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["Very practical, convenient and user-friendly library that has massively helped us in developing our applications. Great community as well!"]
</MudCardContent>
</MudCard>
</div>

</div>
</div>
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
var result = await (new Swiper(JS)).Initialize(".swiper-container", false);
}
}
}
72 changes: 72 additions & 0 deletions src/BlazorPocket.WebAssembly/Components/CarouselReverse.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<div class="swiper-container-reverse">
<div class="swiper-wrapper">
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardContent Class="py-10 px-6 pb-6 mud-typography-body1">
@L["Tell me a fun fact about the Roman Empire"]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardContent Class="py-10 px-6 pb-6 mud-typography-body1">
@L["Write a text inviting my neighbors to a barbecue"]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">

<MudCardContent Class="py-10 px-6 pb-6 mud-typography-body1">
@L["Help me pick an outfit that will look good on camera"]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">

<MudCardContent Class="py-10 px-6 pb-6 mud-typography-body1">
@L["Write a message that goes with a kitten gif for a friend on a rough day"]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">

<MudCardContent Class="py-10 px-6 pb-6 mud-typography-body1">
@L["Quiz me on world capitals to enhance my geography skills"]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardContent Class="py-10 px-6 pb-6 mud-typography-body1">
@L["Make a sandwich using ingredients from my kitchen"]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardContent Class="py-10 px-6 pb-6 mud-typography-body1">
@L["Suggest fun activities to help me make friends in a new city"]
</MudCardContent>
</MudCard>
</div>
<div class="swiper-slide">
<MudCard Elevation="24">
<MudCardContent Class="py-10 px-6 pb-6 mud-typography-body1">
@L["Give me ideas about how to plan my New Years resolutions"]
</MudCardContent>
</MudCard>
</div>
</div>
</div>
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
var result = await (new Swiper(JS)).Initialize(".swiper-container-reverse", true);
}
}
}
107 changes: 8 additions & 99 deletions src/BlazorPocket.WebAssembly/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,105 +6,14 @@

@L["Welcome to your new app."]

<div class="d-flex flex-column">
<div class="d-flex flex-column gap-3">
<MudText Typo="Typo.h3" Align="Align.Center" Class="mt-16 mb-8">“Never had such a good time making a site“</MudText>

<MudGrid Spacing="4">
<MudItem md="5">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Class="mt-n4" Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Brian</MudText>
<MudText Typo="Typo.body2">EvoDynamic</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["Coming of an Angular project back to .NET, Blazor was the ideal choice and MudBlazor was the icing on the cake. . . not \"mud\" but a rich creamy sweet chocolate."]
</MudCardContent>
</MudCard>
</MudItem>
<MudItem md="7">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Class="mt-n4" Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Developer Team</MudText>
<MudText Typo="Typo.body2">Wunderminds</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["Saving us from tons of tiny details and allowing us to deliver sharp looking modern web applications, MudBlazor is the king of open source UI frameworks that no one should miss when building apps with Blazor!"]
</MudCardContent>
</MudCard>
</MudItem>
<MudItem md="7">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Wave Master</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["Comprehensive, ambitious, fresh and clean. Some really cool implementations. The development and improvement of components is really fast, and if a course correction is needed, they will do it. Garderoben, henon and all the other contributors are approachable. They are getting stuff done!"]
</MudCardContent>
</MudCard>
</MudItem>
<MudItem md="5">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Class="mt-n4" Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Karakoulak Spyridon</MudText>
<MudText Typo="Typo.body2">Arhs Group</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["Best open source component library for Blazor out there and easy to understand!"]
</MudCardContent>
</MudCard>
</MudItem>
<MudItem md="6">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Class="mt-n4" Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Hayden Ravenscroft</MudText>
<MudText Typo="Typo.body2">Mail Solutions UK Ltd</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["A comprehensive library. Takes the hassle out of designing for Blazor. Used in many ongoing projects at the Mail Solutions Group. The MudBlazor team has a real gem here."]
</MudCardContent>
</MudCard>
</MudItem>
<MudItem md="6">
<MudCard Elevation="24">
<MudCardHeader Class="px-6 pt-6">
<CardHeaderAvatar>
<MudIcon Class="mt-n4" Icon="@Icons.Material.Rounded.FormatQuote" Size="Size.Large" />
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.subtitle2">Frederik</MudText>
<MudText Typo="Typo.body2">Xuntar</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pt-0 px-6 pb-6 mud-typography-body1">
@L["Very practical, convenient and user-friendly library that has massively helped us in developing our applications. Great community as well!"]
</MudCardContent>
</MudCard>
</MudItem>
</MudGrid>
<div >
<Carousel />
</div>
<div>
<CarouselReverse />
</div>

<div class="lp-fader"></div>
</div>
19 changes: 19 additions & 0 deletions src/BlazorPocket.WebAssembly/Services/JsInterop/Swiper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.JSInterop;

namespace BlazorPocket.WebAssembly.Services.JsInterop;

public sealed class Swiper
{
private readonly IJSRuntime _jsRuntime;

public Swiper(IJSRuntime jsRuntime)
{
_jsRuntime = jsRuntime;
}

public async Task<ValueTask> Initialize(string elment,bool reverse=false)
{
var jsmodule = await _jsRuntime.InvokeAsync<IJSObjectReference>("import", "/js/carousel.js");
return jsmodule.InvokeVoidAsync("initializeSwiper", elment, reverse);
}
}
2 changes: 2 additions & 0 deletions src/BlazorPocket.WebAssembly/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
@using Microsoft.Extensions.Localization
@using Mapster
@using PocketBaseClient.BlazorPocket.Models
@using BlazorPocket.WebAssembly.Services.JsInterop
@inject IJSRuntime JS
@inject NavigationManager Navigation
@inject ApplicationSettings AppSettings
@inject ISnackbar Snackbar
Expand Down
32 changes: 32 additions & 0 deletions src/BlazorPocket.WebAssembly/wwwroot/js/carousel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export function initializeSwiper(selector, direction) {


const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://cdn.jsdelivr.net/npm/[email protected]/swiper-bundle.min.css';
document.head.appendChild(link);

const script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/[email protected]/swiper-bundle.min.js';
script.onload = () => {
var swiper = new Swiper(selector, {
slidesPerView: 3,
spaceBetween: 30,
loop: true,
centeredSlides: true,
speed: 4000, // 动画速度
autoplay: {
delay: 0, // 自动滚动的时间间隔
disableOnInteraction: false, // 用户操作后是否禁用自动滚动
pauseOnMouseEnter: true,
reverseDirection: direction??false
}
});

};
document.body.appendChild(script);

console.log("initializeSwiper")
};


0 comments on commit 6673e70

Please sign in to comment.