Skip to content

Commit

Permalink
v2.7.1 #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Peugnet committed Feb 15, 2025
1 parent 507fdf8 commit c17717a
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 93 deletions.
44 changes: 16 additions & 28 deletions BlazorCalendar/AnnualView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
@inherits CalendarBase

@{
string labelMonth = "";
string labelDay = "";
string? CSSbackground = null;
string taskContent = "";
string? taskColor = null;
string? taskComment = null;
string? classPin = null;
string? classPointer = null;
string labelMonth = string.Empty;
string labelDay = string.Empty;
string? CSSbackground;
string taskContent = string.Empty;
string? taskColor;
string? taskComment;
string? classPin;
string? classPointer;
int tasksCounter;
bool draggable = false;
string? ondragover = null;
string? disabled = null;
string? ondragover;
string? disabled;
string? isHidden = DisplayedView == DisplayedView.Annual ? null : "hidden-element";
bool NotbeDraggeble = false;
string borderStyle = "";
string borderStyle = string.Empty;
}
<div class="frame">

Expand All @@ -43,8 +43,8 @@
if (j.Month != m.Month)
{
j = default;
labelDay = "";
taskContent = "";
labelDay = string.Empty;
taskContent = string.Empty;
taskColor = null;
taskComment = null;
classPin = null;
Expand All @@ -58,31 +58,19 @@
else
{
disabled = null;
int d = (int)j.DayOfWeek;
if (d == 6)
{
CSSbackground = $"background:{SaturdayColor}";
}
else if (d == 0)
{
CSSbackground = $"background:{SundayColor}";
}
else
{
CSSbackground = $"background:{WeekDaysColor}";
}
CSSbackground = GetBackground(j);

string jour = j.ToString("ddd").Substring(0, 1).ToUpper();
labelDay = $"{jour} {j.Day.ToString()}";

taskContent = "";
taskContent = string.Empty;
taskColor = null;
taskComment = null;
classPin = null;
classPointer = null;
tasksCounter = 0;
ondragover = "event.preventDefault();";
borderStyle = "";
borderStyle = string.Empty;
if ( TasksList is not null )
{
for (var k = 0; k < TasksList.Length; k++)
Expand Down
5 changes: 2 additions & 3 deletions BlazorCalendar/AnnualView.razor.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace BlazorCalendar;

using BlazorCalendar.Models;
using BlazorCalendar.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

namespace BlazorCalendar;

partial class AnnualView : CalendarBase
{
Expand Down
22 changes: 22 additions & 0 deletions BlazorCalendar/Base/CalendarBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,26 @@ public abstract class CalendarBase : ComponentBase
/// </summary>
[Parameter]
public string SundayColor { get; set; } = "#DBE7F8";

/// <summary>
/// Allows the user to change the sunday background color
/// </summary>
[Parameter]
public string DisabledDayColor { get; set; } = "#DBE7F8";

public string GetBackground(DateTime day)
{
int d = (int)day.DayOfWeek;

if (d == 6)
{
return $"background:{SaturdayColor}";
}
else if (d == 0)
{
return $"background:{SundayColor}";
}

return $"background:{WeekDaysColor}";
}
}
6 changes: 3 additions & 3 deletions BlazorCalendar/BlazorCalendar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<RepositoryType>git</RepositoryType>
<PackageTags>blazor, calendar, schedule, component</PackageTags>
<PackageReleaseNotes>https://github.com/tossnet/Blazor-Calendar#release-notes</PackageReleaseNotes>
<Version>2.7.0</Version>
<Version>2.7.1</Version>
<Authors>Christophe Peugnet</Authors>
<DebugType>embedded</DebugType>
</PropertyGroup>
Expand All @@ -31,11 +31,11 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.13" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
File renamed without changes.
18 changes: 10 additions & 8 deletions BlazorCalendar/MonthlyView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@{
FirstDate = new DateTime(FirstDate.Year, FirstDate.Month, 1);
int firstDayWeek = (int)FirstDate.DayOfWeek;

StateCase State = StateCase.Before;
DateTime LastDay = new DateTime(FirstDate.Year, FirstDate.Month, 1).AddMonths(1);
DateTime DayCounter = FirstDate;
Expand Down Expand Up @@ -39,9 +40,9 @@

@for ( var i = 0; i < 40; i++ )
{
if ( State == StateCase.Before )
if (State == StateCase.Before)
{
if ( firstDayWeek == Dates.GetNumOfDay(i) ) // Cell is first day?
if (firstDayWeek == Dates.GetNumOfDay(i)) // Cell is first day?
{
State = StateCase.InMonth; // Start filling days
var dayClick = DayCounter;
Expand All @@ -64,9 +65,9 @@
</div>
}
}
if ( State == StateCase.InMonth )
if (State == StateCase.InMonth)
{
if ( DayCounter >= LastDay ) // Stop at last day
if (DayCounter >= LastDay) // Stop at last day
{
State = StateCase.After;
// Again empty cells from here on
Expand All @@ -93,10 +94,11 @@
DayCounter = DayCounter.AddDays(1);
}
}
if ( State == StateCase.After )
if (State == StateCase.After)
{
<div class="monthly-day monthly-day--disabled cursor-bottom"
@onclick="() => HandleClickOutsideCurrentMonthClick(1)"></div>
@onclick="() => HandleClickOutsideCurrentMonthClick(1)">
</div>
}
}

Expand All @@ -110,7 +112,7 @@
}

string? classPosition;
string taskContent = "";
string taskContent = string.Empty;
string? taskComment = null;
bool onmMultiLine = false;
bool draggable = false;
Expand Down Expand Up @@ -226,7 +228,7 @@
y = (Start.Day + OffsetCell - 1) / 7 + 2;
s = (int)(End.Date - Start.Date).TotalDays + 1;

borderClass = "";
borderClass = string.Empty;
}

} while ( onmMultiLine );
Expand Down
15 changes: 0 additions & 15 deletions BlazorCalendar/MonthlyView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,4 @@ private async Task HandleDayOnDrop(DateTime day)
TaskDragged = null;
}

private string GetBackground(DateTime day)
{
int d = (int)day.DayOfWeek;

if (d == 6)
{
return $"background:{SaturdayColor}";
}
else if (d == 0)
{
return $"background:{SundayColor}";
}

return $"background:{WeekDaysColor}";
}
}
7 changes: 3 additions & 4 deletions BlazorCalendar/MonthlyView.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
}

.monthly-day--disabled {
color: rgba(#98a0a6, 0.6);
background-color: #ffffff;
/*color: rgba(#98a0a6, 0.6);
background-color: #ffffff;*/
background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23f4f6f7' fill-opacity='1' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E");
}

Expand All @@ -98,7 +98,6 @@
height: 2vh;
}


@media (max-width: 767.98px) {
.monthly-task {
padding: 0px 8px 0px 4px;
Expand Down Expand Up @@ -131,4 +130,4 @@
color: darkblue;
align-self: end;
margin-left: 10px;
}
}
18 changes: 7 additions & 11 deletions BlazorCalendar/WeekView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
@inherits CalendarBase

@{
DateTime FirstDateWeek = new DateTime(FirstDate.Year, FirstDate.Month, FirstDate.Day).AddDays(-(Dates.GetNumOfDay((int)FirstDate.Date.DayOfWeek) - 2));
DateTime firstDateWeek = FirstDate.AddDays(-(int)(FirstDate.DayOfWeek - System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek + 7) % 7);

string[] dayNames = CultureInfo.CurrentCulture.DateTimeFormat.AbbreviatedDayNames;
string? isHidden = DisplayedView == DisplayedView.Weekly ? null : "hidden-element";
string? CSSbackground = null;
string? taskColor = null;
string? classPin = null;
string? classPointer = null;
string borderStyle = "";
string? CSSbackground;
string? taskColor;
string? classPin;
string? classPointer;

// The sorting must be done each time we redraw in case the user moves the spots
if (TasksList is not null)
Expand All @@ -28,13 +28,12 @@
@for (var i = 0; i < 7; i++)
{
int d = Dates.GetNumOfDay(i);
DateTime day = FirstDateWeek.AddDays(i);
DateTime day = firstDateWeek.AddDays(i);

<div class="day-column" style="grid-column-start: @(i+1)">

<div class="day-header header-name noselect" style="@HeaderStyle">
@dayNames[d] @day.ToString("dd.MM")

</div>

<div class="hours">
Expand Down Expand Up @@ -62,7 +61,6 @@
{
Tasks t = TasksList[k];


if (t.DateEnd > hours && t.DateStart <= hours)
{
column++;
Expand All @@ -89,7 +87,5 @@
</div>

</div>

}

</div>
23 changes: 3 additions & 20 deletions BlazorCalendar/WeekView.razor.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace BlazorCalendar;

using BlazorCalendar.Models;
using BlazorCalendar.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

namespace BlazorCalendar;

partial class WeekView : CalendarBase
{
[CascadingParameter(Name = "SelectedView")]
Expand Down Expand Up @@ -86,22 +86,6 @@ private async Task HandleDayOnDrop(DateTime day)
TaskDragged = null;
}

private string GetBackground(DateTime day)
{
int d = (int)day.DayOfWeek;

if (d == 6)
{
return $"background:{SaturdayColor}";
}
else if (d == 0)
{
return $"background:{SundayColor}";
}

return $"background:{WeekDaysColor}";
}

private async Task ClickDayInternal(MouseEventArgs e, DateTime day)
{
if (!DayClick.HasDelegate)
Expand Down Expand Up @@ -137,5 +121,4 @@ private async Task ClickTaskInternal(MouseEventArgs e, int taskID, DateTime day)

await TaskClick.InvokeAsync(clickTaskParameter);
}

}
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ https://github.com/tossnet/Blazor-Calendar/wiki

## <a name="ReleaseNotes"></a>Release Notes

<details open="open"><summary>Version 2.7.0</summary>
<details open="open"><summary>Version 2.7.1</summary>

>- In the Weekview, the component did not correctly display the first day of the week according to Culture [Issue #24](https://github.com/tossnet/Blazor-Calendar/issues/24)
</details>
<details><summary>Version 2.7.0</summary>

>- Add .NET9 and remove .NET6.0
</details>
Expand Down
4 changes: 4 additions & 0 deletions samples/BlazorServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using System.Globalization;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();

CultureInfo.DefaultThreadCurrentCulture = CultureInfo.GetCultureInfo("en-US");
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US");

var app = builder.Build();

// Configure the HTTP request pipeline.
Expand Down
1 change: 1 addition & 0 deletions samples/BlazorWebAssembly/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BlazorWebAssembly;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using System.Globalization;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
Expand Down

0 comments on commit c17717a

Please sign in to comment.