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

@@ -8,135 +8,254 @@
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel
Margin="24"
HorizontalAlignment="Left"
ClipToBounds="False">
<StackPanel.Styles>
<Style Selector="u|Badge">
<Setter Property="Margin" Value="14" />
</Style>
<Style Selector="Border">
<Setter Property="Background" Value="Orange" />
</Style>
</StackPanel.Styles>
<TextBlock Text="Hello" />
<u:Badge
HorizontalAlignment="Center"
BadgeContent="500"
OverflowCount="100">
<Border Width="100" Height="50" />
</u:Badge>
<StackPanel Orientation="Horizontal">
<u:Badge BadgeContent="5" CornerPosition="TopLeft">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="5" CornerPosition="TopRight">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="5" CornerPosition="BottomLeft">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="5" CornerPosition="BottomRight">
<Border Width="100" Height="50" />
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<StackPanel
Margin="24"
HorizontalAlignment="Left"
ClipToBounds="False">
<StackPanel.Styles>
<Style Selector="u|Badge">
<Setter Property="Margin" Value="14" />
</Style>
<Style Selector="u|Badge > Border">
<Setter Property="Background" Value="Orange" />
<Setter Property="CornerRadius" Value="8" />
</Style>
</StackPanel.Styles>
<StackPanel Orientation="Horizontal">
<u:Badge
HorizontalAlignment="Center"
BadgeContent="500"
OverflowCount="100">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="SUCCEED!">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="Hello" />
<u:Badge BadgeContent="Hello" Dot="True" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<u:Badge BadgeContent="5" CornerPosition="TopLeft">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="5" CornerPosition="TopRight">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="5" CornerPosition="BottomLeft">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="5" CornerPosition="BottomRight">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
<StackPanel Orientation="Horizontal">
<u:Badge
BadgeContent="VIP"
CornerPosition="TopLeft"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="VIP"
CornerPosition="TopRight"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="VIP"
CornerPosition="BottomLeft"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="VIP"
CornerPosition="BottomRight"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
<u:Badge HorizontalAlignment="Stretch" BadgeContent="VIP">
<Border Height="50" />
</u:Badge>
<StackPanel Orientation="Horizontal">
<u:Badge BadgeContent="URSA" Classes="Primary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Secondary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Tertiary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Warning">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Danger">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Success">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
<StackPanel Orientation="Horizontal">
<u:Badge BadgeContent="URSA" Classes="Light Primary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Light Secondary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Light Tertiary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Light Warning">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Light Danger">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Light Success">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
<StackPanel Orientation="Horizontal">
<u:Badge BadgeContent="URSA" Classes="Inverted Primary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Inverted Secondary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Inverted Tertiary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Inverted Warning">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Inverted Danger">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Inverted Success">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
<StackPanel Orientation="Horizontal">
<u:Badge
BadgeContent="URSA"
Classes="Primary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Secondary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Tertiary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Warning"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Danger"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Success"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
<StackPanel Orientation="Horizontal">
<u:Badge
BadgeContent="URSA"
Classes="Light Primary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Light Secondary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Light Tertiary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Light Warning"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Light Danger"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Light Success"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
<Border Background="LightGray" CornerRadius="4">
<StackPanel Orientation="Horizontal">
<u:Badge
BadgeContent="URSA"
Classes="Inverted Primary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Inverted Primary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Inverted Secondary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Inverted Tertiary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Inverted Warning"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Inverted Danger"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
</Border>
</StackPanel>
<u:Badge BadgeContent="SUCCEED!">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge HorizontalAlignment="Stretch" BadgeContent="VIP">
<Border Height="50" />
</u:Badge>
<StackPanel Orientation="Horizontal">
<u:Badge
BadgeContent="VIP"
CornerPosition="TopLeft"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="VIP"
CornerPosition="TopRight"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="VIP"
CornerPosition="BottomLeft"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="VIP"
CornerPosition="BottomRight"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
<StackPanel Orientation="Horizontal">
<u:Badge BadgeContent="URSA" Classes="Primary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Secondary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Tertiary">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Warning">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Danger">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge BadgeContent="URSA" Classes="Success">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
<StackPanel Orientation="Horizontal">
<u:Badge
BadgeContent="URSA"
Classes="Primary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Secondary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Tertiary"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Warning"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Danger"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
<u:Badge
BadgeContent="URSA"
Classes="Success"
Dot="True">
<Border Width="100" Height="50" />
</u:Badge>
</StackPanel>
<StackPanel Orientation="Horizontal">
<u:Badge VerticalAlignment="Center" BadgeContent="Hello" />
<u:Badge
VerticalAlignment="Center"
BadgeContent="Hello"
Dot="True" />
</StackPanel>
</StackPanel>
</UserControl>
</ScrollViewer>
</UserControl>

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>