feat: add Light and Inverted classes.

This commit is contained in:
Zhang Dian
2023-07-21 02:21:28 +08:00
parent 23b4611b5b
commit 905e0f6fc2
4 changed files with 350 additions and 137 deletions

View File

@@ -11,6 +11,7 @@
<!-- Set a very large corner radius to achieve pill look. -->
<Setter Property="u:Badge.CornerRadius" Value="100" />
<Setter Property="u:Badge.FontSize" Value="14" />
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeForeground}" />
<Setter Property="u:Badge.Background" Value="{DynamicResource BadgePrimaryBadgeBackground}" />
<Setter Property="u:Badge.ClipToBounds" Value="False" />
<Setter Property="u:Badge.HorizontalAlignment" Value="Center" />
@@ -18,6 +19,7 @@
<Setter Property="u:Badge.BorderThickness" Value="{DynamicResource BadgeBorderThickness}" />
<Setter Property="u:Badge.UseLayoutRounding" Value="False" />
<Setter Property="u:Badge.BorderBrush" Value="{DynamicResource BadgeBorderBrush}" />
<Setter Property="u:Badge.CornerPosition" Value="TopRight" />
<Setter Property="u:Badge.Template">
<ControlTemplate TargetType="{x:Type u:Badge}">
<Grid
@@ -54,7 +56,7 @@
Focusable="False"
IsTabStop="False"
TextElement.FontSize="{TemplateBinding FontSize}"
TextElement.Foreground="{DynamicResource BadgeForeground}">
TextElement.Foreground="{TemplateBinding Foreground}">
<ContentPresenter.Content>
<MultiBinding Converter="{StaticResource BadgeContentConverter}">
<Binding Path="BadgeContent" RelativeSource="{RelativeSource TemplatedParent}" />
@@ -133,5 +135,53 @@
<Style Selector="^.Success">
<Setter Property="u:Badge.Background" Value="{DynamicResource BadgeSuccessBadgeBackground}" />
</Style>
<Style Selector="^.Light">
<Style Selector="^.Primary">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeLightPrimaryBadgeForeground}" />
<Setter Property="u:Badge.Background" Value="{DynamicResource BadgeLightPrimaryBadgeBackground}" />
</Style>
<Style Selector="^.Secondary">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeLightSecondaryBadgeForeground}" />
<Setter Property="u:Badge.Background" Value="{DynamicResource BadgeLightSecondaryBadgeBackground}" />
</Style>
<Style Selector="^.Tertiary">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeLightTertiaryBadgeForeground}" />
<Setter Property="u:Badge.Background" Value="{DynamicResource BadgeLightTertiaryBadgeBackground}" />
</Style>
<Style Selector="^.Warning">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeLightWarningBadgeForeground}" />
<Setter Property="u:Badge.Background" Value="{DynamicResource BadgeLightWarningBadgeBackground}" />
</Style>
<Style Selector="^.Danger">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeLightDangerBadgeForeground}" />
<Setter Property="u:Badge.Background" Value="{DynamicResource BadgeLightDangerBadgeBackground}" />
</Style>
<Style Selector="^.Success">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeLightSuccessBadgeForeground}" />
<Setter Property="u:Badge.Background" Value="{DynamicResource BadgeLightSuccessBadgeBackground}" />
</Style>
</Style>
<Style Selector="^.Inverted">
<Setter Property="u:Badge.Background" Value="{DynamicResource BadgeInvertedBadgeBackground}" />
<Style Selector="^.Primary">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeInvertedPrimaryBadgeForeground}" />
</Style>
<Style Selector="^.Secondary">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeInvertedSecondaryBadgeForeground}" />
</Style>
<Style Selector="^.Tertiary">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeInvertedTertiaryBadgeForeground}" />
</Style>
<Style Selector="^.Warning">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeInvertedWarningBadgeForeground}" />
</Style>
<Style Selector="^.Danger">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeInvertedDangerBadgeForeground}" />
</Style>
<Style Selector="^.Success">
<Setter Property="u:Badge.Foreground" Value="{DynamicResource BadgeInvertedSuccessBadgeForeground}" />
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>
</ResourceDictionary>

View File

@@ -1,11 +1,33 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<SolidColorBrush x:Key="BadgeBorderBrush" Opacity="0.08" Color="White" />
<SolidColorBrush x:Key="BadgeForeground" Color="White" />
<SolidColorBrush x:Key="BadgeForeground" Color="#1C1F23" />
<!-- Solid -->
<SolidColorBrush x:Key="BadgePrimaryBadgeBackground" Color="#FF54A9FF" />
<SolidColorBrush x:Key="BadgeSecondaryBadgeBackground" Color="#FF40B4F3" />
<SolidColorBrush x:Key="BadgeTertiaryBadgeBackground" Color="#FF888D92" />
<SolidColorBrush x:Key="BadgeWarningBadgeBackground" Color="#FFFFAE43" />
<SolidColorBrush x:Key="BadgeDangerBadgeBackground" Color="#FFFC725A" />
<SolidColorBrush x:Key="BadgeSuccessBadgeBackground" Color="#FF5DC264" />
</ResourceDictionary>
<!-- Light -->
<SolidColorBrush x:Key="BadgeLightPrimaryBadgeForeground" Color="#FF54A9FF" />
<SolidColorBrush x:Key="BadgeLightPrimaryBadgeBackground" Color="#FF003D8F" />
<SolidColorBrush x:Key="BadgeLightSecondaryBadgeForeground" Color="#FF40B4F3" />
<SolidColorBrush x:Key="BadgeLightSecondaryBadgeBackground" Color="#FF004B83" />
<SolidColorBrush x:Key="BadgeLightTertiaryBadgeForeground" Color="#FF888D92" />
<SolidColorBrush x:Key="BadgeLightTertiaryBadgeBackground" Color="#FF2E3238" />
<SolidColorBrush x:Key="BadgeLightWarningBadgeForeground" Color="#FFFFAE43" />
<SolidColorBrush x:Key="BadgeLightWarningBadgeBackground" Color="#FF7E3100" />
<SolidColorBrush x:Key="BadgeLightDangerBadgeForeground" Color="#FFFC725A" />
<SolidColorBrush x:Key="BadgeLightDangerBadgeBackground" Color="#FF8E0805" />
<SolidColorBrush x:Key="BadgeLightSuccessBadgeForeground" Color="#FF5DC264" />
<SolidColorBrush x:Key="BadgeLightSuccessBadgeBackground" Color="#FF1B5924" />
<!-- Inverted -->
<SolidColorBrush x:Key="BadgeInvertedBadgeBackground" Color="#1C1F23" />
<SolidColorBrush x:Key="BadgeInvertedPrimaryBadgeForeground" Color="#FF54A9FF" />
<SolidColorBrush x:Key="BadgeInvertedSecondaryBadgeForeground" Color="#FF40B4F3" />
<SolidColorBrush x:Key="BadgeInvertedTertiaryBadgeForeground" Color="#FF888D92" />
<SolidColorBrush x:Key="BadgeInvertedWarningBadgeForeground" Color="#FFFFAE43" />
<SolidColorBrush x:Key="BadgeInvertedDangerBadgeForeground" Color="#FFFC725A" />
<SolidColorBrush x:Key="BadgeInvertedSuccessBadgeForeground" Color="#FF5DC264" />
</ResourceDictionary>

View File

@@ -1,11 +1,33 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<SolidColorBrush x:Key="BadgeBorderBrush" Opacity="0.08" Color="#1C1F23" />
<SolidColorBrush x:Key="BadgeForeground" Color="White" />
<!-- Solid -->
<SolidColorBrush x:Key="BadgePrimaryBadgeBackground" Color="#0077F0" />
<SolidColorBrush x:Key="BadgeSecondaryBadgeBackground" Color="#0095EE" />
<SolidColorBrush x:Key="BadgeTertiaryBadgeBackground" Color="#6B7075" />
<SolidColorBrush x:Key="BadgeWarningBadgeBackground" Color="#FC8800" />
<SolidColorBrush x:Key="BadgeDangerBadgeBackground" Color="#F93920" />
<SolidColorBrush x:Key="BadgeSuccessBadgeBackground" Color="#3BB346" />
</ResourceDictionary>
<!-- Light -->
<SolidColorBrush x:Key="BadgeLightPrimaryBadgeForeground" Color="#0077FA" />
<SolidColorBrush x:Key="BadgeLightPrimaryBadgeBackground" Color="#D4ECFF" />
<SolidColorBrush x:Key="BadgeLightSecondaryBadgeForeground" Color="#0095EE" />
<SolidColorBrush x:Key="BadgeLightSecondaryBadgeBackground" Color="#CEEEFC" />
<SolidColorBrush x:Key="BadgeLightTertiaryBadgeForeground" Color="#6B7075" />
<SolidColorBrush x:Key="BadgeLightTertiaryBadgeBackground" Color="#E6E8EA" />
<SolidColorBrush x:Key="BadgeLightWarningBadgeForeground" Color="#FC8800" />
<SolidColorBrush x:Key="BadgeLightWarningBadgeBackground" Color="#FFEFD0" />
<SolidColorBrush x:Key="BadgeLightDangerBadgeForeground" Color="#F93920" />
<SolidColorBrush x:Key="BadgeLightDangerBadgeBackground" Color="#FEE0D5" />
<SolidColorBrush x:Key="BadgeLightSuccessBadgeForeground" Color="#3BB346" />
<SolidColorBrush x:Key="BadgeLightSuccessBadgeBackground" Color="#D0F0D1" />
<!-- Inverted -->
<SolidColorBrush x:Key="BadgeInvertedBadgeBackground" Color="White" />
<SolidColorBrush x:Key="BadgeInvertedPrimaryBadgeForeground" Color="#0077F0" />
<SolidColorBrush x:Key="BadgeInvertedSecondaryBadgeForeground" Color="#0095EE" />
<SolidColorBrush x:Key="BadgeInvertedTertiaryBadgeForeground" Color="#6B7075" />
<SolidColorBrush x:Key="BadgeInvertedWarningBadgeForeground" Color="#FC8800" />
<SolidColorBrush x:Key="BadgeInvertedDangerBadgeForeground" Color="#F93920" />
<SolidColorBrush x:Key="BadgeInvertedSuccessBadgeForeground" Color="#3BB346" />
</ResourceDictionary>