Skip to content
Merged
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
13 changes: 7 additions & 6 deletions src/Clever.TokenMap.App/Views/ShareCardPreviewView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,20 @@
<Grid Margin="0,24,0,18"
RowDefinitions="Auto,*,Auto">
<StackPanel Spacing="10">
<StackPanel Name="ShareTopSectionWithProjectName"
Spacing="10"
IsVisible="{Binding ShowProjectName}">
<Grid Name="ShareTopSectionWithProjectName"
RowDefinitions="38,10,Auto"
IsVisible="{Binding ShowProjectName}">
<TextBlock Name="ShareProjectTitleText"
MaxWidth="248"
VerticalAlignment="Center"
FontSize="30"
FontWeight="SemiBold"
Foreground="{DynamicResource TokenMapShareCardPrimaryTextBrush}"
Text="{Binding DisplayProjectName}"
TextTrimming="CharacterEllipsis" />

<StackPanel Spacing="4">
<StackPanel Grid.Row="2"
Spacing="4">
<Grid Name="ShareTokenValueHost"
Width="236"
HorizontalAlignment="Left">
Expand All @@ -65,7 +67,7 @@
Foreground="{DynamicResource TokenMapShareCardSecondaryTextBrush}"
Text="tokens" />
</StackPanel>
</StackPanel>
</Grid>

<StackPanel Name="ShareTopSectionWithoutProjectName"
Spacing="4"
Expand Down Expand Up @@ -170,7 +172,6 @@
Grid.Column="2"
Width="12"
Height="12"
Margin="0,2,0,0"
Stretch="Uniform"
VerticalAlignment="Center"
Fill="{DynamicResource TokenMapShareCardFooterIconBrush}"
Expand Down
1 change: 1 addition & 0 deletions src/Clever.TokenMap.App/Views/ShareSnapshotModalView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
IsChecked="{Binding IncludeProjectName}" />

<TextBox Name="ProjectNameTextBox"
Classes="share-project-name"
Width="320"
VerticalAlignment="Center"
Watermark="Project name"
Expand Down
7 changes: 6 additions & 1 deletion src/Clever.TokenMap.App/Views/Styles/MainWindowStyles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,12 @@
<Style Selector="CheckBox">
<Setter Property="Foreground" Value="{DynamicResource TokenMapTextBrush}" />
</Style>

<Style Selector="TextBox.share-project-name">
<Setter Property="MinHeight" Value="36" />
<Setter Property="Padding" Value="10,0" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="LineHeight" Value="18" />
</Style>
<Style Selector="Border.segmented-toggle-panel">
<Setter Property="Background" Value="{DynamicResource TokenMapSurfaceBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource TokenMapBorderBrush}" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Headless.XUnit;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Styling;
using Avalonia.VisualTree;
using Clever.TokenMap.Core.Enums;
using Clever.TokenMap.Core.Models;
using Clever.TokenMap.Tests.Headless.Support;
Expand Down Expand Up @@ -150,6 +152,79 @@ public async Task ShareSnapshotModal_ResolvesLightThemeBrushes_WhenApplicationTh
}
}

[AvaloniaFact]
public async Task ShareSnapshotModal_ProjectTitle_KeepsVisibleGapAboveTokenValue()
{
var demoRootPath = GetTestFolderPath("Demo");
var window = new AppMainWindow();
var viewModel = CreateMainWindowViewModel(selectedFolderPath: demoRootPath);
window.DataContext = viewModel;

try
{
window.Show();
await viewModel.Toolbar.OpenFolderCommand.ExecuteAsync(null);
viewModel.OpenShareSnapshotCommand.Execute(null);
window.UpdateLayout();

var titleBounds = GetRenderedBounds<TextBlock, Border>(window, "ShareProjectTitleText", "ShareCardRoot");
var tokenBounds = GetRenderedBounds<TextBlock, Border>(window, "ShareTokenValueText", "ShareCardRoot");
var gap = tokenBounds.Top - titleBounds.Bottom;

Assert.True(
gap >= 8,
$"Expected share card title and token value to keep a visible vertical gap, got {gap:F2}px.");
}
finally
{
window.Close();
}
}

[AvaloniaFact]
public async Task ShareSnapshotModal_ProjectNameTextBox_UsesCenteredSingleLineLayout()
{
var demoRootPath = GetTestFolderPath("Demo");
var window = new AppMainWindow();
var viewModel = CreateMainWindowViewModel(selectedFolderPath: demoRootPath);
window.DataContext = viewModel;

try
{
window.Show();
await viewModel.Toolbar.OpenFolderCommand.ExecuteAsync(null);
viewModel.OpenShareSnapshotCommand.Execute(null);
window.UpdateLayout();

var projectNameTextBox = FindNamedDescendant<TextBox>(window, "ProjectNameTextBox");

Assert.NotNull(projectNameTextBox);
Assert.Equal(VerticalAlignment.Center, projectNameTextBox.VerticalContentAlignment);
Assert.Equal(new Thickness(10, 0), projectNameTextBox.Padding);

var textPresenter = projectNameTextBox
.GetVisualDescendants()
.OfType<Control>()
.FirstOrDefault(control => control.GetType().Name == "TextPresenter");

Assert.NotNull(textPresenter);

var presenterTransform = textPresenter.TransformToVisual(projectNameTextBox);
Assert.NotNull(presenterTransform);

var presenterBounds = new Rect(textPresenter.Bounds.Size).TransformToAABB(presenterTransform.Value);
var textBoxCenterY = projectNameTextBox.Bounds.Height / 2d;

Assert.True(
Math.Abs(presenterBounds.Center.Y - textBoxCenterY) <= 2,
$"Expected share project name text presenter to stay vertically centered, got presenterCenterY={presenterBounds.Center.Y:F2}, textBoxCenterY={textBoxCenterY:F2}.");
}
finally
{
window.Close();
}
}

[AvaloniaFact]
public async Task ShareSnapshotModal_FooterElements_StayWithinFooterRow()
{
Expand Down Expand Up @@ -206,6 +281,9 @@ public async Task ShareSnapshotModal_FooterElements_StayWithinFooterRow()
Assert.True(
iconBounds.Right <= textBounds.X + 0.5,
$"Expected share footer icon to stay before the repository text, got icon={iconBounds}, text={textBounds}.");
Assert.True(
Math.Abs(iconBounds.Center.Y - textBounds.Center.Y) <= 1.5,
$"Expected share footer icon and repository text to stay vertically centered together, got icon={iconBounds}, text={textBounds}.");
}
finally
{
Expand Down