Skip to content

Commit

Permalink
feat: using Padding instead of Gap in Avatar.
Browse files Browse the repository at this point in the history
  • Loading branch information
zdpcdt committed Jan 17, 2025
1 parent 33bfd67 commit a366ca6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 43 deletions.
4 changes: 2 additions & 2 deletions demo/Ursa.Demo/Pages/AvatarDemo.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="8">
<u:Avatar Content="AS" />
<u:Avatar Content="Semi" Gap="4" />
<u:Avatar Content="Semi" Gap="10" />
<u:Avatar Content="Semi" Padding="4" />
<u:Avatar Content="Semi" Padding="10" />
</StackPanel>

</StackPanel>
Expand Down
15 changes: 6 additions & 9 deletions src/Ursa.Themes.Semi/Controls/Avatar.axaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa"
xmlns:converters="clr-namespace:Ursa.Converters;assembly=Ursa">
xmlns:u="https://irihi.tech/ursa">
<Design.PreviewWith>
<StackPanel Margin="20" Orientation="Horizontal" Spacing="8">
<u:Avatar Content="AS" />
<u:Avatar Content="Semi" Gap="4" />
<u:Avatar Content="Semi" Gap="10" />
<u:Avatar Content="Semi" Padding="4" />
<u:Avatar Content="Semi" Padding="10" />
</StackPanel>
</Design.PreviewWith>
<converters:DoubleToThicknessConverter x:Key="DoubleToThicknessConverter" />
<ControlTheme x:Key="{x:Type u:Avatar}" TargetType="{x:Type u:Avatar}">
<Setter Property="Foreground" Value="{DynamicResource AvatarForeground}" />
<Setter Property="Background" Value="{DynamicResource AvatarGreyBackground}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarMediumFontSize}" />
<Setter Property="FontWeight" Value="{DynamicResource AvatarFontWeight}" />
<Setter Property="Gap" Value="3" />
<Setter Property="Padding" Value="3" />
<Setter Property="Width" Value="{DynamicResource AvatarMediumWidth}" />
<Setter Property="Height" Value="{Binding $self.Width}" />
<Setter Property="Cursor" Value="Hand" />
Expand All @@ -32,10 +30,9 @@
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Background="{TemplateBinding Background}">
</Border>
Background="{TemplateBinding Background}" />
<Viewbox
Margin="{TemplateBinding Gap, Converter={StaticResource DoubleToThicknessConverter}}"
Margin="{TemplateBinding Padding}"
StretchDirection="DownOnly">
<ContentPresenter
Name="PART_ContentPresenter"
Expand Down
9 changes: 0 additions & 9 deletions src/Ursa/Controls/Avatar/Avatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,12 @@ namespace Ursa.Controls;

public class Avatar : Button
{
public static readonly StyledProperty<double> GapProperty = AvaloniaProperty.Register<Avatar, double>(
nameof(Gap));

public static readonly StyledProperty<IImage?> SourceProperty = AvaloniaProperty.Register<Avatar, IImage?>(
nameof(Source));

public static readonly StyledProperty<object?> HoverMaskProperty = AvaloniaProperty.Register<Avatar, object?>(
nameof(HoverMask));

public double Gap
{
get => GetValue(GapProperty);
set => SetValue(GapProperty, value);
}

[ExcludeFromCodeCoverage]
public IImage? Source
{
Expand Down
23 changes: 0 additions & 23 deletions src/Ursa/Converters/DoubleToThicknessConverter.cs

This file was deleted.

0 comments on commit a366ca6

Please sign in to comment.