Skip to content

Commit

Permalink
Upgrade packages
Browse files Browse the repository at this point in the history
- ApexCharts
- CommunityToolkit
- MAUI
- MudBlazor (most impactful)
- EF Core
- Xunit
  • Loading branch information
danielchalmers committed May 10, 2024
1 parent c65c71d commit 803ce44
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 75 deletions.
53 changes: 40 additions & 13 deletions JournalApp.Tests/DataPointViewTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,22 @@

point.ScaleIndex.Should().Be(null);
cut.FindAll(".mud-toggle-item").Count.Should().Be(4);
cut.FindAll(".mud-toggle-item-selected-border").Count.Should().Be(0);
cut.FindAll(".mud-toggle-item-selected").Count.Should().Be(0);

cut.FindAll(".mud-toggle-item")[1].Click();
cut.FindAll(".mud-toggle-item")[1].ClassList.Should().Contain("mud-toggle-item-selected-border");
cut.FindAll(".mud-toggle-item")[1].ClassList.Should().Contain("mud-toggle-item-selected");
point.ScaleIndex.Should().Be(1);

cut.FindAll(".mud-toggle-item")[2].Click();
cut.FindAll(".mud-toggle-item")[2].ClassList.Should().Contain("mud-toggle-item-selected-border");
cut.FindAll(".mud-toggle-item")[2].ClassList.Should().Contain("mud-toggle-item-selected");
point.ScaleIndex.Should().Be(3);

cut.FindAll(".mud-toggle-item")[3].Click();
cut.FindAll(".mud-toggle-item")[3].ClassList.Should().Contain("mud-toggle-item-selected-border");
cut.FindAll(".mud-toggle-item")[3].ClassList.Should().Contain("mud-toggle-item-selected");
point.ScaleIndex.Should().Be(5);

cut.FindAll(".mud-toggle-item")[3].Click();
cut.FindAll(".mud-toggle-item")[3].ClassList.Should().NotContain("mud-toggle-item-selected-border");
cut.FindAll(".mud-toggle-item")[3].ClassList.Should().NotContain("mud-toggle-item-selected");
point.ScaleIndex.Should().Be(null);
}

Expand Down Expand Up @@ -239,26 +239,26 @@
// Initial state.
point.Bool.Should().Be(null);
cut.FindAll(".mud-toggle-item").Count.Should().Be(2);
cut.FindAll(".mud-toggle-item-selected-border").Count.Should().Be(0);
cut.FindAll(".mud-toggle-item-selected").Count.Should().Be(0);

// A changed dose should get reset to default when clicking No.
point.MedicationDose--;

cut.FindAll(".mud-toggle-item")[0].Click();
cut.FindAll(".mud-toggle-item")[0].ClassList.Should().Contain("mud-toggle-item-selected-border");
cut.FindAll(".mud-toggle-item")[0].ClassList.Should().Contain("mud-toggle-item-selected");
point.Bool.Should().Be(false);

point.MedicationDose.Should().Be(point.Category.MedicationDose);

cut.FindAll(".mud-toggle-item")[1].Click();
cut.FindAll(".mud-toggle-item")[1].ClassList.Should().Contain("mud-toggle-item-selected-border");
cut.FindAll(".mud-toggle-item")[1].ClassList.Should().Contain("mud-toggle-item-selected");
point.Bool.Should().Be(true);

// A changed dose should get reset to default when unselecting.
point.MedicationDose--;

cut.FindAll(".mud-toggle-item")[1].Click();
cut.FindAll(".mud-toggle-item")[1].ClassList.Should().NotContain("mud-toggle-item-selected-border");
cut.FindAll(".mud-toggle-item")[1].ClassList.Should().NotContain("mud-toggle-item-selected");
point.Bool.Should().Be(null);

point.MedicationDose.Should().Be(point.Category.MedicationDose);
Expand All @@ -271,6 +271,7 @@
{
Guid = Guid.NewGuid(),
Type = PointType.Medication,
MedicationUnit = "oz",
MedicationDose = 11,
};

Expand All @@ -290,7 +291,7 @@

// Initial state.
point.Bool.Should().Be(null);
cut.FindAll(".mud-toggle-item-selected-border").Count.Should().Be(0);
cut.FindAll(".mud-toggle-item-selected").Count.Should().Be(0);

// Change dose to empty via dialog.
cut.Find(".mud-link").Click();
Expand All @@ -300,7 +301,7 @@

// Empty dose resets to default and selects No.
point.MedicationDose.Should().Be(point.Category.MedicationDose);
cut.FindAll(".mud-toggle-item")[0].ClassList.Should().Contain("mud-toggle-item-selected-border");
cut.FindAll(".mud-toggle-item")[0].ClassList.Should().Contain("mud-toggle-item-selected");

// Change dose via dialog.
cut.Find(".mud-link").Click();
Expand All @@ -310,7 +311,7 @@

// Submitting dose is the same as Yes.
point.MedicationDose.Should().Be(99);
cut.FindAll(".mud-toggle-item")[1].ClassList.Should().Contain("mud-toggle-item-selected-border");
cut.FindAll(".mud-toggle-item")[1].ClassList.Should().Contain("mud-toggle-item-selected");

// Cancel dialog.
cut.Find(".mud-link").Click();
Expand All @@ -320,7 +321,32 @@

// Same as before
point.MedicationDose.Should().Be(99);
cut.FindAll(".mud-toggle-item")[1].ClassList.Should().Contain("mud-toggle-item-selected-border");
cut.FindAll(".mud-toggle-item")[1].ClassList.Should().Contain("mud-toggle-item-selected");
}

[Fact]
public void MedicationEditDoseDisabledWithNoUnit()
{
var category = new DataPointCategory
{
Guid = Guid.NewGuid(),
Type = PointType.Medication,
MedicationDose = 11,
};

var day = Day.Create(new(2024, 01, 01));
var point = DataPoint.Create(day, category);

var layout = Render(
@<MainLayout>
<Body>
<DataPointView Point="point" />
</Body>
</MainLayout>);

var cut = layout.FindComponent<DataPointView>();

cut.Find(".mud-link").ClassList.Should().Contain("mud-link-disabled");
}

[Fact]
Expand All @@ -330,6 +356,7 @@
{
Guid = Guid.NewGuid(),
Type = PointType.Medication,
MedicationUnit = "oz",
MedicationDose = 11,
};

Expand Down
4 changes: 2 additions & 2 deletions JournalApp.Tests/JournalApp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8" PrivateAssets="all">
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

Expand Down
10 changes: 5 additions & 5 deletions JournalApp/Components/DataPointView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ChildContent>
@foreach (var mood in DataPoint.Moods)
{
<MudMenuItem OnAction="@(() => Point.Mood = mood)">
<MudMenuItem OnClick="@(() => Point.Mood = mood)">
<MudText Typo="Typo.h4">@mood</MudText>
</MudMenuItem>
}
Expand All @@ -27,7 +27,7 @@ else if (Point.Type == PointType.Sleep)
<div class="d-flex align-center flex-grow-1" style="gap: 0.5em">
<MudText Class="sleep-hours" Typo="Typo.caption">@((Point.SleepHours ?? 0).ToString("00.0"))</MudText>
<MudIconButton Class="less-sleep" Icon="@Icons.Material.Filled.Remove" Title="Less sleep" OnClick="DecrementSleep" Disabled="@(Point.SleepHours <= 0)" Size="Size.Small" />
<MudSlider @bind-Value="Point.SleepHours" Variant="Variant.Filled" Min="0" Max="24" Step="0.5m" Size="Size.Large" Immediate />
<MudSlider T="decimal" @bind-NullableValue="Point.SleepHours" Variant="Variant.Filled" Min="0" Max="24" Step="0.5m" Size="Size.Large" />
<MudIconButton Class="more-sleep" Icon="@Icons.Material.Filled.Add" Title="More sleep" OnClick="IncrementSleep" Disabled="@(Point.SleepHours >= 24)" Size="Size.Small" />
</div>
}
Expand Down Expand Up @@ -73,10 +73,10 @@ else if (Point.Type == PointType.Note)
<div class="d-flex flex-column flex-grow-1">
@if (!string.IsNullOrWhiteSpace(Point.Text))
{
<MudTextField @bind-Value="Point.Text" Class="text-field-small"
<MudTextField @bind-Value="Point.Text"
Placeholder="@(Point.IsTimestampedNote ? "What's on your mind?" : null)"
Label="@(NoteLabel)"
Immediate ReadOnly DisableUnderLine
Label="@(NoteLabel)" Typo="Typo.body2"
Immediate ReadOnly Underline="false"
AutoGrow Lines="1" MaxLines="10" />
}
Expand Down
3 changes: 1 addition & 2 deletions JournalApp/Components/EditCategoryDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

@if (Group == null)
{
<MudSelect Label="Type" @bind-Value="Type" Disabled="@(Category != null)" TransformOrigin="Origin.CenterCenter" Immedi
ate>
<MudSelect Label="Type" @bind-Value="Type" Disabled="@(Category != null)" TransformOrigin="Origin.CenterCenter" Immediate>
<MudSelectItem Value="PointType.Bool">Yes or no</MudSelectItem>
<MudSelectItem Value="PointType.LowToHigh">Low to high</MudSelectItem>
<MudSelectItem Value="PointType.MildToSevere">Mild to severe</MudSelectItem>
Expand Down
2 changes: 1 addition & 1 deletion JournalApp/Components/EditNoteDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</TitleContent>

<DialogContent>
<MudTextField @bind-Value="Text" Class="text-field-small" Placeholder="@Placeholder" Lines="10" AutoGrow DisableUnderLine Immediate />
<MudTextField @bind-Value="Text" Typo="Typo.body2" Placeholder="@Placeholder" Lines="10" AutoGrow Underline="false" Immediate />
</DialogContent>
</MudDialog>

Expand Down
12 changes: 6 additions & 6 deletions JournalApp/JournalApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Blazor-ApexCharts" Version="3.1.0" />
<PackageReference Include="CommunityToolkit.Maui" Version="7.0.1" />
<PackageReference Include="Blazor-ApexCharts" Version="3.3.0" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="MudBlazor" Version="6.18.0" />
<PackageReference Include="MudBlazor" Version="7.0.0-preview.2" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="All" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion JournalApp/Pages/Calendar/ColorPickerDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<MudDialog Class="color-picker" DefaultFocus="DefaultFocus.Element" OnBackdropClick="Submit">
<DialogContent>
<MudColorPicker Label="Primary" PickerVariant="PickerVariant.Static" @bind-Value="SelectedColor" DisableToolbar DisableAlpha />
<MudColorPicker Label="Primary" PickerVariant="PickerVariant.Static" @bind-Value="SelectedColor" ShowToolbar="false" ShowAlpha="false" />
</DialogContent>
</MudDialog>

Expand Down
26 changes: 13 additions & 13 deletions JournalApp/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@

<div class="page-title">
<div class="page-header">
<MudButton OnClick="OnTitleClicked" DisableRipple Variant="Variant.Text">
<MudButton OnClick="OnTitleClicked" Ripple="false" Variant="Variant.Text">
<MudText Typo="Typo.h6">🙂 @ThisAssembly.AssemblyTitle</MudText>
</MudButton>

<MudSpacer />

<MudMenu Icon="@Icons.Material.Filled.MoreVert" title="More" AnchorOrigin="Origin.BottomRight" TransformOrigin="Origin.BottomLeft">
<MudMenuItem Icon="@Icons.Material.Filled.Category" OnAction="ManageCategories" AutoClose="false">Categories</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Medication" OnAction="ManageMedications" AutoClose="false">Medications</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Comment" OnAction="NewNote">New note</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.ShowChart" OnAction="OpenTrends" AutoClose="false">Trends</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Article" OnAction="OpenWorksheets" AutoClose="false">Worksheets</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Category" OnClick="ManageCategories" AutoClose="false">Categories</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Medication" OnClick="ManageMedications" AutoClose="false">Medications</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Comment" OnClick="NewNote">New note</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.ShowChart" OnClick="OpenTrends" AutoClose="false">Trends</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Article" OnClick="OpenWorksheets" AutoClose="false">Worksheets</MudMenuItem>

@if (PreferenceService.SafetyPlan != null)
{
<MudMenuItem Icon="@Icons.Material.Filled.HealthAndSafety" OnAction="OpenSafetyPlan">Safety Plan</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.HealthAndSafety" OnClick="OpenSafetyPlan">Safety Plan</MudMenuItem>
}

<MudDivider />

<MudMenuItem Icon="@Icons.Material.Filled.Campaign" OnAction="OpenFeedback">Feedback</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Share" OnAction="OpenShare">Share</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Settings" OnAction="OpenSettings" AutoClose="false">Settings</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Campaign" OnClick="OpenFeedback">Feedback</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Share" OnClick="OpenShare">Share</MudMenuItem>
<MudMenuItem Icon="@Icons.Material.Filled.Settings" OnClick="OpenSettings" AutoClose="false">Settings</MudMenuItem>
</MudMenu>
</div>

Expand Down Expand Up @@ -103,15 +103,15 @@
<div class="data-point-group-footer">
@if (group.Key == null)
{
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Category" OnClick="ManageCategories" FullWidth>Choose categories</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Surface" StartIcon="@Icons.Material.Filled.Category" OnClick="ManageCategories" FullWidth>Choose categories</MudButton>
}
else if (group.Key == "Medications")
{
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Medication" OnClick="ManageMedications" FullWidth>Choose medications</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Surface" StartIcon="@Icons.Material.Filled.Medication" OnClick="ManageMedications" FullWidth>Choose medications</MudButton>
}
else if (group.Key == "Notes")
{
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Comment" OnClick="NewNote" FullWidth>New note</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Surface" StartIcon="@Icons.Material.Filled.Comment" OnClick="NewNote" FullWidth>New note</MudButton>
}
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion JournalApp/Pages/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

<MudThemeProvider Theme="_theme" IsDarkMode="PreferenceService.IsDarkMode" DefaultScrollbar />

<MudPopoverProvider />

<MudDialogProvider MaxWidth="MaxWidth.Small"
FullWidth="true"
NoHeader="false"
Expand All @@ -26,7 +28,7 @@

MudTheme _theme = new()
{
Palette = new PaletteLight()
PaletteLight = new PaletteLight()
{
Primary = "#776be7",
PrimaryLighten = "#978dec",
Expand Down
4 changes: 2 additions & 2 deletions JournalApp/Pages/SafetyPlanning/SafetyPlanItem.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div class="@($"safety-plan-item safety-plan-item-{MarkupUtil.ToClassName(Title)}")">
<MudText Typo="Typo.h5">@Title</MudText>
<MudText Typo="Typo.caption">@Subtitle</MudText>
<MudTextField Class="text-field-small" T="string" @bind-Text="Text" Placeholder="@Placeholder"
Variant="Variant.Outlined" Immediate DisableUnderLine
<MudTextField T="string" @bind-Text="Text" Placeholder="@Placeholder"
Typo="Typo.body2" Variant="Variant.Outlined" Immediate Underline="false"
AutoGrow Lines="3" MaxLines="10" />
</div>

Expand Down
4 changes: 2 additions & 2 deletions JournalApp/Pages/SettingsPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
@* TODO: Replace with separate page so we can change state of inline fields and have it updated properly in settings *@
<div class="d-flex justify-center">
<MudProgressCircular Color="Color.Primary" Style="height:33vw;width:33vw;margin-top:10vh;" Indeterminate="true" />
<MudProgressCircular Color="Color.Primary" Style="height:33vw;width:33vw;margin-top:10vh;" Indeterminate />
</div>
}
else
Expand Down Expand Up @@ -62,7 +62,7 @@ else
<div class="settings-group">
<MudText Typo="Typo.h4">Credits</MudText>

<MudTextField T="string" Text="@CreditsText" Class="text-field-small" ReadOnly DisableUnderLine
<MudTextField T="string" Text="@CreditsText" Typo="Typo.body2" ReadOnly Underline="false"
AutoGrow MaxLines="_creditsExpanded ? 0 : 5" FullWidth />

<MudLink OnClick="() => _creditsExpanded = true">Expand credits</MudLink>
Expand Down
4 changes: 2 additions & 2 deletions JournalApp/Pages/Trends/TrendCategoryView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
{
foreach (var point in points.Where(x => !string.IsNullOrEmpty(x.Text)))
{
<MudTextField Value="point.Text" Class="text-field-small"
<MudTextField Value="point.Text" Typo="Typo.body2"
Label="@GetNoteLabel(point, day)"
ReadOnly DisableUnderLine AutoGrow />
ReadOnly Underline="false" AutoGrow />
}
}
</div>
Expand Down
Loading

0 comments on commit 803ce44

Please sign in to comment.