Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SettingContainer Warning/Error styles to replace InfoBar #16876

Merged
merged 1 commit into from
Mar 18, 2024
Merged
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
182 changes: 182 additions & 0 deletions src/cascadia/TerminalSettingsEditor/SettingContainerStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@
Color="{StaticResource CardStrokeColorDefault}" />
<StaticResource x:Key="ExpanderHeaderBorderBrush"
ResourceKey="CardStrokeColorDefaultBrush" />

<StaticResource x:Key="SettingContainerErrorSeverityBackgroundBrush"
ResourceKey="SystemFillColorCriticalBackgroundBrush" />
<StaticResource x:Key="SettingContainerWarningSeverityBackgroundBrush"
ResourceKey="SystemFillColorCautionBackgroundBrush" />

<StaticResource x:Key="SettingContainerErrorSeverityIconBackground"
ResourceKey="SystemFillColorCriticalBrush" />
<StaticResource x:Key="SettingContainerWarningSeverityIconBackground"
ResourceKey="SystemFillColorCautionBrush" />

<StaticResource x:Key="SettingContainerErrorSeverityIconForeground"
ResourceKey="TextFillColorInverseBrush" />
<StaticResource x:Key="SettingContainerWarningSeverityIconForeground"
ResourceKey="TextFillColorInverseBrush" />

<StaticResource x:Key="SettingContainerTitleForeground"
ResourceKey="TextFillColorPrimaryBrush" />
<StaticResource x:Key="SettingContainerMessageForeground"
ResourceKey="TextFillColorPrimaryBrush" />

</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<Style x:Key="SecondaryTextBlockStyle"
Expand All @@ -32,6 +53,26 @@
Color="{ThemeResource SystemColorWindowTextColor}" />
<StaticResource x:Key="ExpanderHeaderBorderBrush"
ResourceKey="SystemColorButtonTextColorBrush" />

<StaticResource x:Key="SettingContainerErrorSeverityBackgroundBrush"
ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SettingContainerWarningSeverityBackgroundBrush"
ResourceKey="SystemColorWindowColorBrush" />

<StaticResource x:Key="SettingContainerErrorSeverityIconBackground"
ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="SettingContainerWarningSeverityIconBackground"
ResourceKey="SystemColorHighlightColorBrush" />

<StaticResource x:Key="SettingContainerErrorSeverityIconForeground"
ResourceKey="SystemColorHighlightTextColorBrush" />
<StaticResource x:Key="SettingContainerWarningSeverityIconForeground"
ResourceKey="SystemColorHighlightTextColorBrush" />

<StaticResource x:Key="SettingContainerTitleForeground"
ResourceKey="SystemColorWindowTextColorBrush" />
<StaticResource x:Key="SettingContainerMessageForeground"
ResourceKey="SystemColorWindowTextColorBrush" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<Style x:Key="SecondaryTextBlockStyle"
Expand All @@ -45,9 +86,38 @@
Color="{StaticResource CardStrokeColorDefault}" />
<StaticResource x:Key="ExpanderHeaderBorderBrush"
ResourceKey="CardStrokeColorDefaultBrush" />

<StaticResource x:Key="SettingContainerErrorSeverityBackgroundBrush"
ResourceKey="SystemFillColorCriticalBackgroundBrush" />
<StaticResource x:Key="SettingContainerWarningSeverityBackgroundBrush"
ResourceKey="SystemFillColorCautionBackgroundBrush" />

<StaticResource x:Key="SettingContainerErrorSeverityIconBackground"
ResourceKey="SystemFillColorCriticalBrush" />
<StaticResource x:Key="SettingContainerWarningSeverityIconBackground"
ResourceKey="SystemFillColorCautionBrush" />

<StaticResource x:Key="SettingContainerErrorSeverityIconForeground"
ResourceKey="TextFillColorInverseBrush" />
<StaticResource x:Key="SettingContainerWarningSeverityIconForeground"
ResourceKey="TextFillColorInverseBrush" />

<StaticResource x:Key="SettingContainerTitleForeground"
ResourceKey="TextFillColorPrimaryBrush" />
<StaticResource x:Key="SettingContainerMessageForeground"
ResourceKey="TextFillColorPrimaryBrush" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<FontWeight x:Key="SettingContainerTitleFontWeight">SemiBold</FontWeight>

<x:String x:Key="SettingContainerIconBackgroundGlyph">&#xF136;</x:String>
<x:String x:Key="SettingContainerErrorIconGlyph">&#xF13D;</x:String>
<x:String x:Key="SettingContainerWarningIconGlyph">&#xF13C;</x:String>

<Thickness x:Key="SettingContainerIconMargin">0,4,8,4</Thickness>
<x:Double x:Key="SettingContainerIconFontSize">16</x:Double>

<Style x:Key="StackPanelInExpanderStyle"
TargetType="StackPanel">
<Setter Property="VerticalAlignment" Value="Center" />
Expand Down Expand Up @@ -99,6 +169,7 @@
<Setter Property="TextWrapping" Value="WrapWholeWords" />
</Style>

<!-- A setting container for a setting that has no additional options -->
<Style TargetType="local:SettingContainer">
<Setter Property="Margin" Value="0,4,0,0" />
<Setter Property="IsTabStop" Value="False" />
Expand Down Expand Up @@ -136,6 +207,7 @@
</Setter>
</Style>

<!-- A setting container which can expand -->
<Style x:Key="ExpanderSettingContainerStyle"
TargetType="local:SettingContainer">
<Setter Property="MaxWidth" Value="1000" />
Expand Down Expand Up @@ -185,4 +257,114 @@
</Setter>
</Style>

<!-- A setting container that displays a warning with an icon -->
<Style x:Key="SettingContainerWarningStyle"
TargetType="local:SettingContainer">
<Setter Property="Margin" Value="0,4,0,0" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="MaxWidth" Value="1000" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:SettingContainer">
<Grid AutomationProperties.Name="{TemplateBinding Header}"
Background="{ThemeResource SettingContainerWarningSeverityBackgroundBrush}"
Style="{StaticResource NonExpanderGrid}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Style="{StaticResource StackPanelInExpanderStyle}">
<StackPanel Orientation="Horizontal">
<Grid>
<TextBlock x:Name="IconBackground"
Grid.Column="0"
Margin="{StaticResource SettingContainerIconMargin}"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="{StaticResource SettingContainerIconFontSize}"
Foreground="{ThemeResource SettingContainerWarningSeverityIconBackground}"
Text="{StaticResource SettingContainerIconBackgroundGlyph}" />

<TextBlock x:Name="StandardIcon"
Grid.Column="0"
Margin="{StaticResource SettingContainerIconMargin}"
VerticalAlignment="Center"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="{StaticResource SettingContainerIconFontSize}"
Foreground="{ThemeResource SettingContainerWarningSeverityIconForeground}"
Text="{StaticResource SettingContainerWarningIconGlyph}" />
</Grid>
<TextBlock VerticalAlignment="Center"
FontWeight="{StaticResource SettingContainerTitleFontWeight}"
Foreground="{ThemeResource SettingContainerTitleForeground}"
Style="{StaticResource SettingsPageItemHeaderStyle}"
Text="{TemplateBinding Header}" />
</StackPanel>
<TextBlock x:Name="HelpTextBlock"
Foreground="{ThemeResource SettingContainerMessageForeground}"
Style="{StaticResource SettingsPageItemDescriptionStyle}"
Text="{TemplateBinding HelpText}" />
</StackPanel>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<!-- A setting container that displays an error with an icon -->
<Style x:Key="SettingContainerErrorStyle"
TargetType="local:SettingContainer">
<Setter Property="Margin" Value="0,4,0,0" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="MaxWidth" Value="1000" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:SettingContainer">
<Grid AutomationProperties.Name="{TemplateBinding Header}"
Background="{ThemeResource SettingContainerErrorSeverityBackgroundBrush}"
Style="{StaticResource NonExpanderGrid}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Style="{StaticResource StackPanelInExpanderStyle}">
<StackPanel Orientation="Horizontal">
<Grid>
<TextBlock x:Name="IconBackground"
Grid.Column="0"
Margin="{StaticResource SettingContainerIconMargin}"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="{StaticResource SettingContainerIconFontSize}"
Foreground="{ThemeResource SettingContainerErrorSeverityIconBackground}"
Text="{StaticResource SettingContainerIconBackgroundGlyph}" />

<TextBlock x:Name="StandardIcon"
Grid.Column="0"
Margin="{StaticResource SettingContainerIconMargin}"
VerticalAlignment="Center"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="{StaticResource SettingContainerIconFontSize}"
Foreground="{ThemeResource SettingContainerErrorSeverityIconForeground}"
Text="{StaticResource SettingContainerErrorIconGlyph}" />
</Grid>
<TextBlock VerticalAlignment="Center"
FontWeight="{StaticResource SettingContainerTitleFontWeight}"
Foreground="{ThemeResource SettingContainerTitleForeground}"
Style="{StaticResource SettingsPageItemHeaderStyle}"
Text="{TemplateBinding Header}" />
</StackPanel>
<TextBlock x:Name="HelpTextBlock"
Foreground="{ThemeResource SettingContainerMessageForeground}"
Style="{StaticResource SettingsPageItemDescriptionStyle}"
Text="{TemplateBinding HelpText}" />
</StackPanel>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</ResourceDictionary>
Loading