core: use typography roles for text styling
This commit is contained in:
@@ -20,7 +20,9 @@ use gpui_native_core::button::{Button, ButtonVariant};
|
||||
use gpui_native_core::checkbox::Checkbox;
|
||||
use gpui_native_core::common::Sizable as _;
|
||||
use gpui_native_core::scrollbar::{Scrollbar, ScrollbarVisibility};
|
||||
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, CODE_OVERSCROLL_MAX, Size};
|
||||
use gpui_native_theme::{
|
||||
ActiveTheme as _, BORDER_WIDTH, CODE_OVERSCROLL_MAX, Size, TextRole, Typeset as _,
|
||||
};
|
||||
use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd};
|
||||
|
||||
use std::borrow::Borrow as _;
|
||||
@@ -32,8 +34,6 @@ use std::sync::Arc;
|
||||
use crate::highlight::{HighlightedCode, Language, highlight, plain};
|
||||
use crate::utils::code_line;
|
||||
|
||||
/// Heading scale steps relative to the root font size, H1 first.
|
||||
const HEADING_SCALES: [f32; 6] = [1.9, 1.5, 1.25, 1.1, 1.0, 0.95];
|
||||
/// The bottom padding between sibling blocks, in root font sizes.
|
||||
const BLOCK_GAP: f32 = 0.75;
|
||||
/// The tighter bottom padding between list items, in root font sizes.
|
||||
@@ -1497,7 +1497,12 @@ fn heading_row(
|
||||
cx: &App,
|
||||
) -> AnyElement {
|
||||
let theme = cx.theme();
|
||||
let scale = HEADING_SCALES[(level.level() - 1).min(HEADING_SCALES.len() - 1)];
|
||||
let role = match level {
|
||||
MarkdownHeading::H1 => TextRole::Title,
|
||||
MarkdownHeading::H2 => TextRole::Title2,
|
||||
MarkdownHeading::H3 => TextRole::Title3,
|
||||
MarkdownHeading::H4 | MarkdownHeading::H5 | MarkdownHeading::H6 => TextRole::Headline,
|
||||
};
|
||||
|
||||
indented_frame(
|
||||
indent,
|
||||
@@ -1508,9 +1513,7 @@ fn heading_row(
|
||||
ctx.block_id,
|
||||
cx,
|
||||
)
|
||||
.text_size(theme.root_font_size * scale)
|
||||
.line_height(relative(1.3))
|
||||
.font_weight(FontWeight::SEMIBOLD)
|
||||
.typeset(role, cx)
|
||||
.child(text_child(spans, ctx.block_id, ctx.piece_context(0), cx)),
|
||||
cx,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user