Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds custom icon implementation #213

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions samples/BlazorServer/BlazorServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Content Remove="wwwroot\blazoredIcon.svg" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="wwwroot\blazoredIcon.svg" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Blazored.Toast\Blazored.Toast.csproj" />
</ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion samples/BlazorServer/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
<button class="btn btn-info" @onclick="@(() => toastService.ShowInfo("Click to refresh the page", options => options.OnClick = () => NavigationManager.NavigateTo("/", true)))">
Info Toast with custom action on click
</button>
<button class="btn btn-info" @onclick="@(() => toastService.ShowInfo("Custom icon", options => {options.IconType=Blazored.Toast.Configuration.IconType.Custom; options.Icon=customIconHtml;} ))">
Custom icon
</button>
</div>
<div class="mt-2">
<button class="btn btn-info" @onclick="@(() => toastService.ShowInfo("When you hover over me, I will pause the timeout progress and resume it once you move away", settings => {settings.Timeout = 15; settings.PauseProgressOnHover = true; }))">Pause progress on hover</button>
<button class="btn btn-success" @onclick="@(() => toastService.ShowSuccess("When you hover over me, I will stop the timeout progress and close after an extended timeout of 1 second", settings => {settings.Timeout = 15; settings.PauseProgressOnHover = true; settings.ExtendedTimeout = 1;}))">Pause progress on hover with extended timeout</button>
</div>

<hr />


Expand All @@ -25,6 +29,7 @@
<button class="btn btn-primary" @onclick="@(() => toastService.ShowToast<MyToastComponent>(settings => { settings.Timeout = 5; settings.ShowProgressBar = false; }))">Custom Toast</button>
<button class="btn btn-secondary" @onclick="@(() => toastService.ShowToast<MyToastComponent>(_toastParameters, settings => { settings.Timeout = 5; settings.ShowProgressBar = false; }))">Custom Toast with parameters</button>
<hr />
dasdasd


<h1>Blazored Toasts - Remove Toasts</h1>
Expand All @@ -45,13 +50,15 @@
{
private ToastParameters _toastParameters;

private string customIconHtml => $"<img style=\"width:40px\" src=\"blazoredIcon.svg\"/>";

protected override void OnInitialized()
{
_toastParameters = new ToastParameters();
_toastParameters.Add(nameof(MyToastComponent.Title), "I'm a custom toast component with parameters");
_toastParameters.Add(nameof(MyToastComponent.ToastParam), "I'm a parameter");
}

private void OnShowHtml()
{
RenderFragment message =@<text>I'm an <em>INFO</em> message with some <strong>bold</strong> text</text>
Expand Down
852 changes: 852 additions & 0 deletions samples/BlazorServer/wwwroot/blazoredIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions samples/BlazorWebAssembly/BlazorWebAssembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<Content Remove="wwwroot\blazoredIcon.svg" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="wwwroot\blazoredIcon.svg" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.1" PrivateAssets="all" />
Expand Down
5 changes: 5 additions & 0 deletions samples/BlazorWebAssembly/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<button class="btn btn-info" @onclick="@(() => ToastService.ShowInfo("Click to refresh the page", settings => settings.OnClick = () => NavigationManager.NavigateTo("/", true)))">
Info Toast with custom action on click
</button>
<button class="btn btn-info" @onclick="@(() => ToastService.ShowInfo("Custom icon", options => {options.IconType=Blazored.Toast.Configuration.IconType.Custom; options.Icon=customIconHtml;} ))">
Custom icon
</button>
<div class="mt-2">
<button class="btn btn-info" @onclick="@(() => ToastService.ShowInfo("When you hover over me, I will pause the timeout progress and resume it once you move away", settings => {settings.Timeout = 15; settings.PauseProgressOnHover = true; }))">Pause progress on hover</button>
<button class="btn btn-success" @onclick="@(() => ToastService.ShowSuccess("When you hover over me, I will stop the timeout progress and close after an extended timeout of 1 second", settings => {settings.Timeout = 15; settings.PauseProgressOnHover = true; settings.ExtendedTimeout = 1;}))">Pause progress on hover with extended timeout</button>
Expand Down Expand Up @@ -54,6 +57,8 @@
{
private ToastParameters _toastParameters = default!;

private string customIconHtml => $"<img style=\"width:40px\" src=\"blazoredIcon.svg\"/>";

protected override void OnInitialized()
{
_toastParameters = new ToastParameters()
Expand Down
Loading