use blinc_core::Color;
use blinc_theme::{ColorToken, ThemeState};
#[derive(Clone, Debug)]
pub struct MarkdownConfig {
pub h1_size: f32,
pub h2_size: f32,
pub h3_size: f32,
pub h4_size: f32,
pub h5_size: f32,
pub h6_size: f32,
pub body_size: f32,
pub code_size: f32,
pub text_color: Color,
pub text_secondary: Color,
pub link_color: Color,
pub code_bg: Color,
pub code_text: Color,
pub blockquote_border: Color,
pub blockquote_bg: Color,
pub hr_color: Color,
pub paragraph_spacing: f32,
pub heading_spacing: f32,
pub list_indent: f32,
pub list_item_spacing: f32,
pub blockquote_padding: f32,
pub code_padding: f32,
pub list_marker_width: f32,
pub list_marker_gap: f32,
}
impl Default for MarkdownConfig {
fn default() -> Self {
let theme = ThemeState::get();
Self {
h1_size: 32.0,
h2_size: 28.0,
h3_size: 24.0,
h4_size: 20.0,
h5_size: 18.0,
h6_size: 16.0,
body_size: 16.0,
code_size: 14.0,
text_color: theme.color(ColorToken::TextPrimary),
text_secondary: theme.color(ColorToken::TextSecondary),
link_color: theme.color(ColorToken::TextLink),
code_bg: theme.color(ColorToken::SurfaceOverlay),
code_text: theme.color(ColorToken::TextPrimary),
blockquote_border: theme.color(ColorToken::Border),
blockquote_bg: theme.color(ColorToken::SurfaceOverlay),
hr_color: theme.color(ColorToken::Border),
paragraph_spacing: 16.0,
heading_spacing: 24.0,
list_indent: 0.0,
list_item_spacing: 4.0,
blockquote_padding: 16.0,
code_padding: 12.0,
list_marker_width: 12.0,
list_marker_gap: 4.0,
}
}
}
impl MarkdownConfig {
pub fn new() -> Self {
Self::default()
}
pub fn light() -> Self {
let theme = ThemeState::get();
Self {
h1_size: 24.0,
h2_size: 20.0,
h3_size: 17.0,
h4_size: 15.0,
h5_size: 14.0,
h6_size: 13.0,
body_size: 14.0,
code_size: 13.0,
text_color: theme.color(ColorToken::TextPrimary),
text_secondary: theme.color(ColorToken::TextSecondary),
link_color: theme.color(ColorToken::TextLink),
code_bg: theme.color(ColorToken::SurfaceOverlay),
code_text: theme.color(ColorToken::TextPrimary),
blockquote_border: theme.color(ColorToken::Border),
blockquote_bg: theme.color(ColorToken::SurfaceOverlay),
hr_color: theme.color(ColorToken::Border),
paragraph_spacing: 6.0,
heading_spacing: 8.0,
list_indent: 0.0,
list_item_spacing: 4.0,
blockquote_padding: 8.0,
code_padding: 8.0,
list_marker_width: 12.0,
list_marker_gap: 4.0,
}
}
pub fn body_size(mut self, size: f32) -> Self {
self.body_size = size;
self
}
pub fn link_color(mut self, color: Color) -> Self {
self.link_color = color;
self
}
pub fn text_color(mut self, color: Color) -> Self {
self.text_color = color;
self
}
pub fn paragraph_spacing(mut self, spacing: f32) -> Self {
self.paragraph_spacing = spacing;
self
}
pub fn blockquote_bg(mut self, color: Color) -> Self {
self.blockquote_bg = color;
self
}
pub fn blockquote_border(mut self, color: Color) -> Self {
self.blockquote_border = color;
self
}
}