Skip to content

Commit 68e05be

Browse files
authored
Merge pull request #12 from NeverMorewd/fix/design-tokens-audit
fix: replace hardcoded magic numbers with design tokens (closes #9)
2 parents beeb9e6 + 15b37b5 commit 68e05be

35 files changed

+115
-103
lines changed

src/Pipboy.Avalonia/PipboyTheme.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using Avalonia.Controls;
23
using Avalonia.Markup.Xaml;
34
using Avalonia.Media;
45
using Avalonia.Styling;
@@ -103,14 +104,25 @@ public PipboyTheme(IServiceProvider? serviceProvider = null)
103104
Resources["PipboyScanBeamColor"] = Color.FromArgb(40, p.Primary.R, p.Primary.G, p.Primary.B);
104105

105106
// Font design tokens
106-
Resources["PipboyFontFamily"] = new FontFamily("Consolas,Courier New,monospace");
107-
Resources["PipboyFontSize"] = 13.0;
108-
Resources["PipboyFontSizeSmall"] = 11.0;
109-
Resources["PipboyFontSizeLarge"] = 16.0;
107+
Resources["PipboyFontFamily"] = new FontFamily("Consolas,Courier New,monospace");
108+
Resources["PipboyFontSize"] = 13.0;
109+
Resources["PipboyFontSizeXSmall"] = 10.0;
110+
Resources["PipboyFontSizeSmall"] = 11.0;
111+
Resources["PipboyFontSizeLarge"] = 16.0;
110112

111113
// Spacing / sizing design tokens
112114
Resources["PipboyControlHeight"] = 30.0;
113115
Resources["PipboyTreeViewItemIndent"] = 16.0;
116+
Resources["PipboyPickerRowHeight"] = new GridLength(29);
117+
Resources["PipboyPickerItemHeight"] = 40.0;
118+
Resources["PipboyPopupMaxHeight"] = 200.0;
119+
120+
// Opacity design tokens
121+
Resources["PipboyDisabledOpacity"] = 0.45;
122+
Resources["PipboyDimOpacity"] = 0.7;
123+
124+
// Stroke design tokens
125+
Resources["PipboyIconStrokeThickness"] = 1.5;
114126

115127
// Load compiled AXAML styles — AvaloniaXamlLoader.Load uses the compiled (NativeAOT-safe)
116128
// version generated from PipboyTheme.axaml; the StyleInclude chain inside that AXAML file

src/Pipboy.Avalonia/Styles/Controls/AutoCompleteBox.axaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<!-- Dropdown suggestions popup -->
2929
<Popup
3030
Name="PART_Popup"
31-
MaxHeight="200"
31+
MaxHeight="{DynamicResource PipboyPopupMaxHeight}"
3232
IsLightDismissEnabled="True"
3333
IsOpen="False"
3434
Placement="BottomEdgeAlignedLeft"
@@ -40,7 +40,7 @@
4040
CornerRadius="0">
4141
<ListBox
4242
Name="PART_SelectingItemsControl"
43-
MaxHeight="200"
43+
MaxHeight="{DynamicResource PipboyPopupMaxHeight}"
4444
Background="Transparent"
4545
BorderThickness="0"
4646
ScrollViewer.VerticalScrollBarVisibility="Auto" />
@@ -52,7 +52,7 @@
5252
</Setter>
5353

5454
<Style Selector="^:disabled">
55-
<Setter Property="Opacity" Value="0.45" />
55+
<Setter Property="Opacity" Value="{DynamicResource PipboyDisabledOpacity}" />
5656
</Style>
5757
</ControlTheme>
5858

src/Pipboy.Avalonia/Styles/Controls/BracketHighlight.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
</Style>
102102

103103
<Style Selector="^:disabled">
104-
<Setter Property="Opacity" Value="0.45" />
104+
<Setter Property="Opacity" Value="{DynamicResource PipboyDisabledOpacity}" />
105105
</Style>
106106
</ControlTheme>
107107

src/Pipboy.Avalonia/Styles/Controls/Button.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<Setter Property="BorderBrush" Value="{DynamicResource PipboyPrimaryBrush}" />
4343
</Style>
4444
<Style Selector="^:disabled">
45-
<Setter Property="Opacity" Value="0.45" />
45+
<Setter Property="Opacity" Value="{DynamicResource PipboyDisabledOpacity}" />
4646
</Style>
4747
<Style Selector="^:focus-visible /template/ Border#PART_Border">
4848
<Setter Property="BorderBrush" Value="{DynamicResource PipboyBorderFocusBrush}" />

src/Pipboy.Avalonia/Styles/Controls/CheckBox.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<Setter Property="BorderThickness" Value="2" />
7777
</Style>
7878
<Style Selector="^:disabled">
79-
<Setter Property="Opacity" Value="0.45" />
79+
<Setter Property="Opacity" Value="{DynamicResource PipboyDisabledOpacity}" />
8080
</Style>
8181
</ControlTheme>
8282

src/Pipboy.Avalonia/Styles/Controls/ComboBox.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
VerticalAlignment="Center"
8484
Data="M 4 6 L 8 10 L 12 6"
8585
Stroke="{DynamicResource PipboyTextDimBrush}"
86-
StrokeThickness="1.5" />
86+
StrokeThickness="{DynamicResource PipboyIconStrokeThickness}" />
8787
</Border>
8888
</Grid>
8989
</Border>
@@ -118,7 +118,7 @@
118118
<Setter Property="BorderBrush" Value="{DynamicResource PipboyBorderFocusBrush}" />
119119
</Style>
120120
<Style Selector="^:disabled">
121-
<Setter Property="Opacity" Value="0.45" />
121+
<Setter Property="Opacity" Value="{DynamicResource PipboyDisabledOpacity}" />
122122
</Style>
123123
</ControlTheme>
124124

0 commit comments

Comments
 (0)