Skip to content

Commit 8509121

Browse files
committed
Adding per heading foreground
1 parent 35c2da7 commit 8509121

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

components/MarkdownTextBlock/samples/MarkdownTextBlockExampleSample.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using CommunityToolkit.WinUI.Controls;
6+
using Microsoft.UI;
67
using System.Diagnostics;
78

89
namespace MarkdownTextBlockExperiment.Samples;
@@ -600,7 +601,12 @@ public string Text
600601
public MarkdownTextBlockExampleSample()
601602
{
602603
this.InitializeComponent();
603-
_config = new MarkdownConfig();
604+
605+
var themes = new MarkdownThemes
606+
{
607+
608+
};
609+
_config = new MarkdownConfig { Themes = themes };
604610
_text = _markdown;
605611
MarkdownTextBlock.OnLinkClicked += MarkdownTextBlock_OnLinkClicked;
606612
}

components/MarkdownTextBlock/src/MarkdownThemes.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ public sealed class MarkdownThemes : DependencyObject
3434

3535
public double H6FontSize { get; set; } = 12;
3636

37-
public Brush HeadingForeground { get; set; } = Extensions.GetAccentColorBrush();
37+
public Brush H1Foreground { get; set; } = (Brush)Application.Current.Resources["TextFillColorPrimaryBrush"];
38+
public Brush H2Foreground { get; set; } = (Brush)Application.Current.Resources["TextFillColorPrimaryBrush"];
39+
public Brush H3Foreground { get; set; } = (Brush)Application.Current.Resources["TextFillColorPrimaryBrush"];
40+
public Brush H4Foreground { get; set; } = (Brush)Application.Current.Resources["TextFillColorPrimaryBrush"];
41+
public Brush H5Foreground { get; set; } = (Brush)Application.Current.Resources["TextFillColorPrimaryBrush"];
42+
public Brush H6Foreground { get; set; } = (Brush)Application.Current.Resources["TextFillColorPrimaryBrush"];
3843

39-
public FontWeight H1FontWeight { get; set; } = FontWeights.Bold;
44+
public FontWeight H1FontWeight { get; set; } = FontWeights.SemiBold;
4045

4146
public FontWeight H2FontWeight { get; set; } = FontWeights.Normal;
4247

@@ -48,10 +53,10 @@ public sealed class MarkdownThemes : DependencyObject
4853

4954
public FontWeight H6FontWeight { get; set; } = FontWeights.Normal;
5055

51-
public Thickness H1Margin { get; set; } = new(left: 0, top: 14, right: 0, bottom: 0);
52-
public Thickness H2Margin { get; set; } = new(left: 0, top: 14, right: 0, bottom: 0);
53-
public Thickness H3Margin { get; set; } = new(left: 0, top: 14, right: 0, bottom: 0);
54-
public Thickness H4Margin { get; set; } = new(left: 0, top: 14, right: 0, bottom: 0);
56+
public Thickness H1Margin { get; set; } = new(left: 0, top: 16, right: 0, bottom: 0);
57+
public Thickness H2Margin { get; set; } = new(left: 0, top: 16, right: 0, bottom: 0);
58+
public Thickness H3Margin { get; set; } = new(left: 0, top: 16, right: 0, bottom: 0);
59+
public Thickness H4Margin { get; set; } = new(left: 0, top: 16, right: 0, bottom: 0);
5560
public Thickness H5Margin { get; set; } = new(left: 0, top: 8, right: 0, bottom: 0);
5661
public Thickness H6Margin { get; set; } = new(left: 0, top: 8, right: 0, bottom: 0);
5762

components/MarkdownTextBlock/src/TextElements/MyHeading.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,15 @@ private void SetHProperties(int level)
6060
5 => _config.Themes.H5FontSize,
6161
_ => _config.Themes.H6FontSize,
6262
};
63-
_paragraph.Foreground = _config.Themes.HeadingForeground;
63+
_paragraph.Foreground = level switch
64+
{
65+
1 => _config.Themes.H1Foreground,
66+
2 => _config.Themes.H2Foreground,
67+
3 => _config.Themes.H3Foreground,
68+
4 => _config.Themes.H4Foreground,
69+
5 => _config.Themes.H5Foreground,
70+
_ => _config.Themes.H6Foreground,
71+
};
6472
_paragraph.FontWeight = level switch
6573
{
6674
1 => _config.Themes.H1FontWeight,

0 commit comments

Comments
 (0)