blinc_layout/markdown/
config.rs1use blinc_core::Color;
4use blinc_theme::{ColorToken, ThemeState};
5
6#[derive(Clone, Debug)]
8pub struct MarkdownConfig {
9 pub h1_size: f32,
12 pub h2_size: f32,
14 pub h3_size: f32,
16 pub h4_size: f32,
18 pub h5_size: f32,
20 pub h6_size: f32,
22 pub body_size: f32,
24 pub code_size: f32,
26
27 pub text_color: Color,
30 pub text_secondary: Color,
32 pub link_color: Color,
34 pub code_bg: Color,
36 pub code_text: Color,
38 pub blockquote_border: Color,
40 pub blockquote_bg: Color,
42 pub hr_color: Color,
44
45 pub paragraph_spacing: f32,
48 pub heading_spacing: f32,
50 pub list_indent: f32,
52 pub list_item_spacing: f32,
54 pub blockquote_padding: f32,
56 pub code_padding: f32,
58 pub list_marker_width: f32,
60 pub list_marker_gap: f32,
62}
63
64impl Default for MarkdownConfig {
65 fn default() -> Self {
66 let theme = ThemeState::get();
67 Self {
68 h1_size: 32.0,
70 h2_size: 28.0,
71 h3_size: 24.0,
72 h4_size: 20.0,
73 h5_size: 18.0,
74 h6_size: 16.0,
75 body_size: 16.0,
76 code_size: 14.0,
77
78 text_color: theme.color(ColorToken::TextPrimary),
80 text_secondary: theme.color(ColorToken::TextSecondary),
81 link_color: theme.color(ColorToken::TextLink),
82 code_bg: theme.color(ColorToken::SurfaceOverlay),
83 code_text: theme.color(ColorToken::TextPrimary),
84 blockquote_border: theme.color(ColorToken::Border),
85 blockquote_bg: theme.color(ColorToken::SurfaceOverlay),
86 hr_color: theme.color(ColorToken::Border),
87
88 paragraph_spacing: 16.0,
90 heading_spacing: 24.0,
91 list_indent: 0.0,
92 list_item_spacing: 4.0,
93 blockquote_padding: 16.0,
94 code_padding: 12.0,
95 list_marker_width: 12.0,
96 list_marker_gap: 4.0,
97 }
98 }
99}
100
101impl MarkdownConfig {
102 pub fn new() -> Self {
104 Self::default()
105 }
106
107 pub fn light() -> Self {
110 let theme = ThemeState::get();
111 Self {
112 h1_size: 24.0,
114 h2_size: 20.0,
115 h3_size: 17.0,
116 h4_size: 15.0,
117 h5_size: 14.0,
118 h6_size: 13.0,
119 body_size: 14.0,
120 code_size: 13.0,
121
122 text_color: theme.color(ColorToken::TextPrimary),
124 text_secondary: theme.color(ColorToken::TextSecondary),
125 link_color: theme.color(ColorToken::TextLink),
126 code_bg: theme.color(ColorToken::SurfaceOverlay),
127 code_text: theme.color(ColorToken::TextPrimary),
128 blockquote_border: theme.color(ColorToken::Border),
129 blockquote_bg: theme.color(ColorToken::SurfaceOverlay),
130 hr_color: theme.color(ColorToken::Border),
131
132 paragraph_spacing: 6.0,
134 heading_spacing: 8.0,
135 list_indent: 0.0,
136 list_item_spacing: 4.0,
137 blockquote_padding: 8.0,
138 code_padding: 8.0,
139 list_marker_width: 12.0,
140 list_marker_gap: 4.0,
141 }
142 }
143
144 pub fn body_size(mut self, size: f32) -> Self {
146 self.body_size = size;
147 self
148 }
149
150 pub fn link_color(mut self, color: Color) -> Self {
152 self.link_color = color;
153 self
154 }
155
156 pub fn text_color(mut self, color: Color) -> Self {
158 self.text_color = color;
159 self
160 }
161
162 pub fn paragraph_spacing(mut self, spacing: f32) -> Self {
164 self.paragraph_spacing = spacing;
165 self
166 }
167
168 pub fn blockquote_bg(mut self, color: Color) -> Self {
170 self.blockquote_bg = color;
171 self
172 }
173
174 pub fn blockquote_border(mut self, color: Color) -> Self {
176 self.blockquote_border = color;
177 self
178 }
179}