Skip to content

Commit

Permalink
Demo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelMichels committed Apr 28, 2024
1 parent 0985f89 commit a94dd36
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 23 deletions.
4 changes: 1 addition & 3 deletions src/MichelMichels.ViesSharp.Demo/Components/App.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
@using MichelMichels.ViesSharp.Demo.Services;

@inject IThemeService themeService;

<!DOCTYPE html>
<html lang="en" data-bs-theme="@(themeService.IsDarkMode ? "dark" : "light")">
<html lang="en" data-bs-theme="dark">

<head>
<meta charset="utf-8" />
Expand Down
19 changes: 4 additions & 15 deletions src/MichelMichels.ViesSharp.Demo/Components/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<PageTitle>ViesSharp | Demo</PageTitle>

<header class="p-4 pb-3 d-flex align-items-center">
<header class="p-4 pb-3 d-flex align-items-center" data-bs-theme="dark">
<div class="me-auto">
<h1 class="m-0 fw-bold lh-1">Michel</h1>
<h1 class="m-0 fw-bold lh-1">Michels</h1>
Expand All @@ -27,10 +27,6 @@
<span>Profile</span>
</div>
</a>

<button class="btn btn-outline-secondary" @onclick="@ToggleDarkTheme">
<i class="@(themeService.IsDarkMode ? "bi-brightness-high" : "bi-moon-stars" )" />
</button>
</div>
</header>

Expand Down Expand Up @@ -102,13 +98,13 @@

@if(LastResponse is not null)
{
<div class="card">
<div class="card @(BackgroundClass) bg-opacity-25">
<div class="card-body">
<i class="@(LastResponse.IsValid ? "bi-check-circle-fill text-success" : "bi-x-circle-fill text-danger") d-block text-center mb-2" style="font-size: 4rem;"></i>

@if(LastResponse.IsValid) {
<h3>@LastResponse.Name</h3>
<p>@LastResponse.Address</p>
<h4 class="text-center">@LastResponse.Name</h4>
<p class="text-center">@LastResponse.Address</p>
} else {
<h3 class="text-center">This is not a valid VAT number.</h3>
}
Expand Down Expand Up @@ -223,11 +219,4 @@
{
return string.Join("", value.Where(x => char.IsDigit(x)));
}

public void ToggleDarkTheme()
{
themeService.ToggleMode();
//IsDarkMode = ThemeService.IsDarkMode;
StateHasChanged();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand Down
2 changes: 1 addition & 1 deletion src/MichelMichels.ViesSharp.Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

builder.Services
.AddSingleton<IViesSharpClient, ViesSharpClient>()
.AddSingleton<IThemeService, ThemeService>();
.AddScoped<IThemeService, ThemeService>();

// Add services to the container.
builder.Services
Expand Down
3 changes: 2 additions & 1 deletion src/MichelMichels.ViesSharp.Demo/Services/IThemeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

public interface IThemeService
{
public bool IsDarkMode { get; set; }
event Action? ModeChanged;

bool IsDarkMode { get; set; }
void ToggleMode();
}
6 changes: 5 additions & 1 deletion src/MichelMichels.ViesSharp.Demo/Services/ThemeService.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
namespace MichelMichels.ViesSharp.Demo.Services;

namespace MichelMichels.ViesSharp.Demo.Services;

public class ThemeService : IThemeService
{
public bool IsDarkMode { get; set; } = true;

public event Action? ModeChanged;

public void ToggleMode()
{
IsDarkMode = !IsDarkMode;
ModeChanged?.Invoke();
}
}
2 changes: 1 addition & 1 deletion src/MichelMichels.ViesSharp.Demo/wwwroot/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ body {
overflow-y: scroll;
}

h1, h2, h3 {
h1, h2, h3, h4, h5, h6 {
font-family: 'Montserrat', 'sans-serif';
}

Expand Down

0 comments on commit a94dd36

Please sign in to comment.