feat: add size classes

This commit is contained in:
rabbitism
2023-06-28 04:10:02 +08:00
parent b7edc5550b
commit f086b51683
6 changed files with 22 additions and 5 deletions

View File

@@ -15,5 +15,8 @@
<StackPanel Margin="20" Spacing="20">
<u:ButtonGroup Classes="Primary Solid" ItemsSource="{Binding Items}" />
<u:ButtonGroup Classes="Primary" ItemsSource="{Binding Items}" />
<u:ButtonGroup Classes="Primary Borderless" ItemsSource="{Binding Items}" />
<u:ButtonGroup Classes="Primary Large" ItemsSource="{Binding Items}" />
<u:ButtonGroup Classes="Primary Small" ItemsSource="{Binding Items}" />
</StackPanel>
</UserControl>

View File

@@ -40,6 +40,7 @@
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="{DynamicResource ButtonGroupDefaultPadding}" />
<Setter Property="FontWeight" Value="{DynamicResource ButtonGroupDefaultFontWeight}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Button.Template">
@@ -53,12 +54,12 @@
DockPanel.Dock="Right"
Fill="{DynamicResource ButtonGroupSeparatorForeground}" />
<Border
Padding="8"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"

View File

@@ -21,6 +21,12 @@
<Style Selector="u|ButtonGroup.Borderless">
<Setter Property="Background" Value="Transparent" />
</Style>
<Style Selector="u|ButtonGroup.Large Button">
<Setter Property="Padding" Value="{DynamicResource ButtonGroupLargePadding}" />
</Style>
<Style Selector="u|ButtonGroup.Small Button">
<Setter Property="Padding" Value="{DynamicResource ButtonGroupSmallPadding}" />
</Style>
<Style Selector="u|ButtonGroup Button:pointerover">
<Setter Property="Background" Value="{DynamicResource ButtonGroupDefaultPointeroverBackground}" />
</Style>

View File

@@ -1,10 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<x:Double x:Key="ButtonGroupDefaultFontSize">14</x:Double>
<FontWeight x:Key="ButtonGroupDefaultFontWeight">600</FontWeight>
<CornerRadius x:Key="ButtonGroupCornerRadius">3</CornerRadius>
<SolidColorBrush x:Key="ButtonGroupSeparatorForeground" Opacity="0.08" Color="#FF1C1F23" />
<!-- Light -->
<SolidColorBrush x:Key="ButtonGroupDefaultPrimaryForeground" Color="#0077FA" />

View File

@@ -0,0 +1,10 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<x:Double x:Key="ButtonGroupDefaultFontSize">14</x:Double>
<FontWeight x:Key="ButtonGroupDefaultFontWeight">600</FontWeight>
<CornerRadius x:Key="ButtonGroupCornerRadius">3</CornerRadius>
<Thickness x:Key="ButtonGroupDefaultPadding">12 6</Thickness>
<Thickness x:Key="ButtonGroupLargePadding">16 10</Thickness>
<Thickness x:Key="ButtonGroupSmallPadding">6 2</Thickness>
</ResourceDictionary>

View File

@@ -3,6 +3,7 @@
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="Badge.axaml" />
<MergeResourceInclude Source="Banner.axaml" />
<MergeResourceInclude Source="ButtonGroup.axaml" />
<MergeResourceInclude Source="Divider.axaml" />
<MergeResourceInclude Source="IPv4Box.axaml" />
<MergeResourceInclude Source="NavigationMenu.axaml" />